I'm working on a project where I would like to send the output from the Advancer Technologies EMG sensor (from Sparkfun) to an Arduino Uno wirelessly. Since the output is analog and only going one direction, I think the Series 1 should be able to handle it.
My question is: is this feasible? Or will I need an Arduino to transmit the EMG Sensor output via XBee?
Thanks PaulS! I'll only need one input, so I should be fine.
Any chance you can point me in the right direction of how to read in the analog XBee input?
I think it should be the same as if the sensor is connected directly to the Arduino. If that's the case, could I use SoftwareSerial to read in the analog input from the XBee and output those values to the serial monitor?
PaulS:
When you configure the XBee to measure analog or digital pins, you need to also configure it to use API (not AT) mode.
This makes the XBee send a fixed content packet that is easy to parse.
If you don't have Rob Faludi's book, Building Wireless Sensor Networks, get it.
I downloaded Rob Faludi's book and it definitely helped explain API packets. I have the two XBees talking with each other with one set to API=2 and one in AT with DI0 set to ADC (I successfully followed this tutorial to send AT commands from the API XBee to an LED on the AT XBee). As a basic example, I found some code sending values from a pot on a remote XBee to an arduino to control brightness of an LED.
The problem I'm running in to is I only get two values - 0 when the knob is turned all the way to one side, and 3.3 when I start turning it the opposite direction.
I don't think the code is the problem, but just in case:
#include <SoftwareSerial.h>
int const LEDPIN = 11;
SoftwareSerial XBee(2, 3);
void setup(){
// Start up our serial port, we configured our XBEE devices for 9600 bps.
Serial.begin(9600);
XBee.begin(9600);
pinMode(LEDPIN,OUTPUT);
// while the serial stream is not open, do nothing:
while (!Serial) ;
}
void loop(){
if (XBee.available() >= 20) { // Wait until we have a mouthful of data
if (XBee.read() == 126) { // Start delimiter of a frame
// Skip over the bytes in the API frame we don't care about
for (int i = 0; i < 10; i++) {
XBee.read();
}
// The next two bytes are the high and low bytes of the sensor reading
int analogHigh = XBee.read();
int analogLow = XBee.read();
float analogValue = (analogLow + (analogHigh * 256))*3.3/1023;
// Scale the brightness to the Arduino PWM range
int brightness = map(analogValue, 0, 1023, 0, 255);
// Light the LED
analogWrite(LEDPIN, brightness);
Serial.println(analogValue);
}
}
}
And I attached a picture of how I have things wired on the remote XBee (I'm using the SparkFun Shield for the Arduino).
Please let me know if I should move this topic to a different forum.