10 years, 2 months ago.

xbee analog to serial

Hi,

I am trying send an analog signal from 1 xbee to another and then have it feed to an mbed 1768 serially in order to then display the values on the mbed websockets. The transmitting xbee is connected and configured as in the following link:

http://examples.digi.com/sensors/802-15-4-analog-input-with-a-potentiometer/3/

and the receiving is configured as follows:

ATRE

ATID 3001

ATMY 2

The code I have been trying is as follows:

include the mbed library with this snippet

#include "mbed.h"
#include "EthernetInterface.h"
#include "Websocket.h"
 
Serial xbee1(p9, p10);
DigitalOut rst1(p11);
 
int main() 
{
    char package[10];
    int analog=0;
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
 
    Websocket ws("ws://sockets.mbed.org:443/ws/ECG/wo");
    ws.connect();
 
    ws.send("Connected");
     
    while (1) 
    {
        
        if(xbee1.readable()) 
        {
        ws.send("xbee read");    
        analog = xbee1.getc();  //read xbee
        ws.send("xbee get"); 
        sprintf (package, "%d", analog);
        ws.send(package);
        }
    }
}

Now it displays the connected on http://sockets.mbed.org/ECG/viewer, but thats it, hence I can assume it either is not reading anything from the xbee since it is configured wrong or I am using the wrong code above to get a value from the serial input. If anyone could point out where I went wrong it would be appreciated.

Thanks in advance, Johann

I have since removed a wire to the reset which I am not sure why it was there in the first place and the only wires connected to the receiver are the 3.3v, GND, TX and RX. Now the websocket does display numbers but they are in a repeating pattern like 126, 1, 0, 131, 10, 0 and varying the pot does not seem to make a difference. Any ideas what could be going on?

posted by Johann Hur 18 Feb 2014
Be the first to answer this question.