简体   繁体   English

Python + Xbee-解释模拟样本的二进制数据

[英]Python + Xbee - interpreting binary data for analog samples

I've been working on a project with Digi Xbee Series 2 (ZigBee) modules. 我一直在从事使用Digi Xbee Series 2(ZigBee)模块的项目。 I have a python script which receives the data on my coordinator device and saves it into a database. 我有一个python脚本,可在协调器设备上接收数据并将其保存到数据库中。 This script has been looking for and parsing the "samples" key in the returned data. 该脚本一直在寻找并解析返回数据中的“样本”键。

I've since bought a Digi XBee L/T/H sensor ( http://www.digi.com/wiki/developer/index.php/XBee_Sensors ) and have found that this returns the data using the "rf_data" key. 从那以后,我购买了Digi XBee L / T / H传感器( http://www.digi.com/wiki/developer/index.php/XBee_Sensors ),发现它使用“ rf_data”键返回了数据。 This appears to be binary. 这似乎是二进制的。 I'm failing to be able to process it and read the actual values from it. 我无法处理它并从中读取实际值。

Can anyone tell me if I can re-program the sensor to send the "samples" key, or how to read/convert the binary data? 谁能告诉我是否可以重新编程传感器以发送“样本”键,或者如何读取/转换二进制数据?

I've been trying to do it like this: 我一直在尝试这样做:

h=struct.unpack('f',response['rf_data'][0:4])[0]

But I'm out of my depth knowing exactly what I'm doing ;-) 但是我不知道自己在做什么;-)

Thanks in advance for any help you can give.... 在此先感谢您提供的任何帮助。

It's returning an I/O sample, as described in this Digi knowledge base article . 如本Digi知识库文章所述,它正在返回一个I / O示例。

The page you linked to includes formulas for converting the ADC readings into temperature, humidity and light readings. 链接到的页面包含用于将ADC读数转换为温度,湿度和光读数的公式。

Section 3.2 of the python-xbee documentation seems to imply that I/O samples are parsed as of version 2.1. python-xbee文档的 3.2节似乎暗示从2.1版开始对I / O样本进行解析。 Make sure you're using that version, and see if you can access adc-1 through adc-3 of the I/O sample, and convert the readings to light, temperature and humidity values. 确保使用的是该版本,并查看是否可以访问I / O样本的adc-1adc-3 ,并将读数转换为光,温度和湿度值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM