Hello.
I send 6 analog and 2 digital inputs from one arduino micro to my computer via xbeeS1 with last firmware and an xbee explorer USB. Everythig's ok exept for some values of sample.
The problem is:
When s1 (value of sensor 1 on analog arduino input) matches 125(0x07D) or 381 (0x17D) or 637 (0x27D) or 893 (0x37D), the transmitted value of payload[2] (s2 MSB) jump to 0x93 or 0x94 in XCTU (or it should be a 10 bits Value<1023).
s2 input is grounded.
Here is My Arduino squetch for Arduino Micro (equal to leonardo):
#include <XBee.h>
/*
Sends a TX16 request with the value of 6 analog input and 2 digital and checks the status response for success
Note: In my testing it took about 15 seconds for the XBee to start reporting success, so I've added a startup delay
*/
XBee xbee = XBee();
unsigned long start = millis();
// allocate 16 bytes for to hold a 10-bit analog reading
uint8_t payload[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// with Series 1 you can use either 16-bit or 64-bit addressing
// 16-bit addressing: Enter address of remote XBee, typically the coordinator
Tx16Request tx = Tx16Request(0x10, payload, sizeof(payload));
TxStatusResponse txStatus = TxStatusResponse();
unsigned int s1 = 0; // value read from the pot
unsigned int s2 = 0;
unsigned int s3 = 0;
unsigned int s4 = 0;
unsigned int s5 = 0;
unsigned int s6 = 0;
unsigned int d1 = 0;
unsigned int d2 = 0;
void setup() {
Serial1.begin(57600);
xbee.setSerial(Serial1);
Serial.begin (9600);
}
void loop() {
// start transmitting after a startup delay. Note: this will rollover to 0 eventually so not best way to handle
if (millis() - start > 15000) {
// break down 10-bit reading into two bytes and place in payload
s1 = analogRead(0);
Serial.print ("s1: ");//debug
Serial.print (s1);//debug
s2 = analogRead(1);//debug
Serial.print (" s2: ");//debug
Serial.print (s2);//debug
s3 = analogRead(2);
s4 = analogRead(3);
s5 = analogRead(4);
s6 = analogRead(5);
d1 = digitalRead(7);
d2 = digitalRead(8);
payload[0] = (s1 >> 8) & 0xff;
payload[1] = s1 & 0xff;
payload[2] = (s2 >> 8) & 0xff;
payload[3] = s2 & 0xff;
payload[4] = (s3 >> 8) & 0xff;
payload[5] = s3 & 0xff;
payload[6] = (s4 >> 8) & 0xff;
payload[7] = s4 & 0xff;
payload[8] = (s5 >> 8) & 0xff;
payload[9] = s5 & 0xff;
payload[10] = (s6 >> 8) & 0xff;
payload[11] = s6 & 0xff;
payload[12] = (d1 >> 8) & 0xff;
payload[13] = d1 & 0xff;
payload[14] = (d2 >> 8) & 0xff;
payload[15] = d2 & 0xff;
Serial.print (" payload S1 MSB: ");//debug
Serial.print (payload[0]);//debug
Serial.print (" payload S1 LSB: ");//debug
Serial.print (payload[1]);//debug
Serial.print (" payload S2 MSB: ");//debug
Serial.print (payload[2]);//debug
Serial.print (" payload S2 LSB: ");//debug
Serial.println (payload[3]);//debug
xbee.send(tx);
delay(10);
}
}
Here is the arduino serial monitor:
s1: 124 s2: 0 payload S1 MSB: 0 payload S1 LSB: 124 payload S2 MSB: 0 payload S2 LSB: 0
s1: 125 s2: 0 payload S1 MSB: 0 payload S1 LSB: 125 payload S2 MSB: 0 payload S2 LSB: 0
But here is what's received on my Macbook Air by xbee/xbee explorer
When s1 is 124 (0x27A), the value of s2 is good:
When s1 is 125 (0x27D), s2 is corrupted.
Same behavior for other inputs:
When s2 reach 125, s3 MSB jump to 0x93, when s3 reach 125, s4 MSB jump to 0x93. etc...
For other values, the behavior is normal exept that I never get value of 126 (0x07E) in XCTU.
Could you help me please?