Active1 year, 11 months ago
I plan to have several Arduino boards connected to XBee series 2 radios in the same network performing the same operation. They are to transmit data to another board that will upload all of the data at once using a cellular connection. I would like to uniquely identify each board in some way. I realize I can hardcode a serial number into the EEPROM memory of the Arduino board. However that will not scale very well for what I am trying to do. Is there a way to read the XBee's serial number using Arduino code, so that I can transmit it along with my data?
dda
Arduino Serial Read Number Line![]()
![]()
5,53422 gold badges2020 silver badges3333 bronze badges
Mike C.Mike C.
1 Answer
Reading numbers from serial on an Arduino is needed surprisingly commonly. Exactly what is happening might be kind of hard to figure out. Serial communication is digital, which means all data is transmitted in 1's and 0's. Typically, serial communication is done using ASCII letters. This means that, to send a number to the Arduino, the data sent is not the binary version of the number in base 2 (as an integer), but instead a sequence of characters for each digit in base 10 (which is.
You can retrieve the serial number using the AT commands
ATSH and ATSL (serial number high/low). You can do that by going into command mode, sending those sequences followed by a return, and parsing the responses.
RECOMMENDED:users who upgrade in the first year of Windows 10’s release. Free icons for windows 7.
To get into command mode, you need to wait 1 second without sending anything, send the escape sequence
+++ , and then wait another second. The XBee module should respond with OKr indicating that it's ready to receive commands.
Arduino Serial Read Write
Send
ATSHr and you should get a hex string representing the top four bytes of the serial number. Repeat with ATSLr for the bottom four bytes.
And know that if you use a destination address of tomlogic
0 , the XBee module will automatically send data to the coordinator on your network. If the coordinator is running in API mode, it can retrieve the sender's 64-bit MAC address from the frame header of the received data.
Arduino Serial Read Integer ArraytomlogicArduino Serial Read Line
8,88533 gold badges2626 silver badges5555 bronze badges
Arduino Read Serial ExampleNot the answer you're looking for? Browse other questions tagged arduinoxbee or ask your own question.Comments are closed.
|