First test of passing data from XBee to Arduino to Node.js to client


Today I successfully mapped data from three different XBee modules onto a web page hosted on a local server. This is a very big accomplishment for me since it is truly a proof of concept for the entire Sonome project.

Just a few days ago I finally hooked up the receiver XBee to the Arduino so that I could see the packets coming in through the serial monitor. Today I took that one step further, by incorporating that Arduino code into the du.ino code used to connect the Arduino to the Node.js server.

I don't have an XBee shield so I had to wire the pins myself. It's very easy though; as indicated in the code, Arduino digital pins 8 and 9 connect to the XBee DOUT and DIN pins, respectively.

AltSoftSerial allows you an additional serial port simulated through software, and is necessary since both the XBee and Arduino use serial communication. In my testing I found that the hardware serial baud rate must be significantly higher than the XBee rate in order to minimize mixed-up packets. I found this using only 3 XBees, but it will become even more critical when all 16 are blasting away simultaneously.

I then had to incorporate the code above into the du.ino stock code. There was some sort of conflict with the Servo library used by du.ino, so I removed all servo-related code; I don't need to control servos for this project.

As you can probably see from the code, I am printing an array of 16 bytes to the serial port - one byte for each sensor. This is what gets passed through to Node.js, and is how a client knows which value is which. The indices correspond to the transmitter XBee addresses so I can correctly map their locations.

I'm in very good shape now to finish the project on time. I need to connect the microphones to the XBees, and start testing ranges and levels in the real space.

No comments:

Post a Comment

Speak now...