【问题标题】:Xbee pro series 2b und TGS 2602 -receiving value are wrong and doesn´t changeXbee pro 系列 2b 和 TGS 2602 - 接收值错误且不会改变
【发布时间】:2014-06-13 14:52:18
【问题描述】:

我有一个 arduino uno、xbee pro series 2 b 和一个 voc 传感器:tgs 2602。 我想通过 xbee 将传感器的电阻值从 arduino 发送到串行监视器。 tgs2602--> xbee - xbee-->xbee 盾牌-->arduino uno

我将我的第一个 xbee 配置为 AT Modus 中的路由器,采样率为 1000 毫秒,并在 API 中配置我的协调器。 我使用的草图如下所示:

//Remote XBee:AT, Base XBee:API
float voc;
void setup(){
Serial.begin(9600);
};

void loop(){

if(Serial.available() >=21){ //Makesure the frame is all there
if (Serial.read()== 0x7E){ //7E is the start byte
for (int i = 1; i<18; i++) { //Skip ahead to the analog data
 byte discardByte = Serial.read();

}
int analogMSB = Serial.read(); // Read the first analog byte data
int analogLSB = Serial.read(); //Read the second byte
int analogReading = analogLSB + (analogMSB * 256);

float volt = analogReading/1023.0 * 5 ;    // Rechne die von ADC ausgegebenen Werten in Volt um
float Rs1 = 10*(5-volt)/volt;        //Rechne den Widerstandswert


Serial.println(Rs1);
}
}
}

我在 youtube 的示例中使用了这段代码。

我在串行监视器中收到的数据是 5105。即使我触摸传感器,这个值也不会改变。

为什么? 我是不是做错了什么。

我需要你的帮助。

谢谢

【问题讨论】:

  • 您可能想要查看框架类型并确保它是正确的。除了模拟读数外,XBee 还会向您发送状态帧。也许转储整个帧以确保它正确并且您正在正确解析它,和/或转储读取的 LSB 和 MSB 值。
  • 嗨,tomlogic,我做到了! “discardByte = 0 18 146 0 125 51 162 0 64 173 23 24 85 236 1 1 0”。
  • 146 = 0x92,所以这是一个数据样本。 analogMSBanalogLSB 是什么?它们有什么不同吗?传感器是否连接到第一个模拟输入 (A0)?
  • 嗨 tomlogic,analogMSB = 2,analogLSB=0,它们没有变化。传感器连接到第二个模拟输入。 (抱歉回复晚了)
  • 嗨,我正在使用 xbee 稳压分线板,我想知道问题是否出在电压上。

标签: arduino xbee


【解决方案1】:

确保您为模拟输入正确配置了所有内容。 Digi 在configuring an analog input with a potentiometer 上有一个很好的教程。按照这些步骤进行操作,然后逐步进行更改,直到您在 Arduino 上读取传感器。

例如,一旦您在 XBee 和 PC 上使用了电位计,请将其连接到 Arduino 并确保读数正确。然后用你的传感器更换电位器,看看读数是否仍然正确。

【讨论】:

  • 我在没有 xbee 的情况下使用了传感器,它的效果很好。但是使用 xbee 我得到了这个错误的值。也许是电压,我会尝试使用更多的电阻并分压。我遵循的教程在 youtube 中来自 tunnelsup(从远程 xbee 读取模拟数据)
猜你喜欢
  • 1970-01-01
  • 2016-07-16
  • 1970-01-01
  • 2016-05-09
  • 2017-11-29
  • 1970-01-01
  • 1970-01-01
  • 2021-05-14
  • 1970-01-01
相关资源
最近更新 更多