Shop OBEX P1 Docs P2 Docs Learn Events
Need help with Basic stamp 2 and XBee series 2 — Parallax Forums

Need help with Basic stamp 2 and XBee series 2

ad9409ad9409 Posts: 8
edited 2013-12-07 10:31 in BASIC Stamp
I'm working on a project using a temperature sensor (LM34) to output voltage (temperature/data) to a transmitter (XBee series 2) and on the other end, a receiver (also XBee series 2) will receive the data and it will go through the basic stamp 2. Then I want to display the temperature on a LCD. This seems fairly simple but after researching about the coding for BS2, I can't seem to figure out where to start.

I know you have to set an input and output pin for the BS2. I'm not too sure where to go from there.

I need a little help getting started on the code to retrieve the data from the XBee (receiver) and display onto a LCD screen.

Many thanks in advance!!!

Comments

  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-12-04 20:15
    Baby steps. First, are your XBee's communicating? Are you able to get any test messages displayed on your LCD? I would first make sure you are able to do these tasks and then advance from there. I find it easier this way as opposed to trying to make it all work at once. Using the temp sensor demo program, try to get the output to display on the LCD and so on.
  • ad9409ad9409 Posts: 8
    edited 2013-12-05 08:04
    My XBees are communicating and we tested the LCD screen with the basic stamp and it works. My problem is getting started on the code to retrieve the data from the receiving XBee
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-12-05 08:46
    In the BASIC Stamp Manual there are examples for sending data back and forth between two BASIC Stamp Modules. These examples, while intended for a wired connection work just the same over the XBee connection. You need only set your I/O pins correctly for the DIN/DOUT connections. Remember that your TX from the BASIC Stamp Module will go to the DIN on the XBee Module.
  • stamptrolstamptrol Posts: 1,731
    edited 2013-12-05 09:53
    So, continuing with Andy's and Chris' advice (ie baby steps), heres how I'd proceed: You mention getting one Stamp to retrieve the data from the other. In the beginning, it is much easier to let one Stamp continuously push data out. Cuts down the number of things that have to be right during testing.

    On the Stamp with the temperature sensor, get your code to successfully read the temperature and display it with DEBUG on the local Stamp.

    When thats working, modify the code so the data is sent to your chosen SEROUT pin. You will use a baud rate the same as that set on the XBEE. Do you have the connection adapters for the XBEE or are you connecting direct to the XBEE circuit board? The adapter board makes it easier to use the 5 volt signals from the Stamp. Use X-CTU to change parameters on the XBEE's.

    Now, your data is being sent out into the ether.

    Power up the receiving XBEE and you should see data activity on the Rx led on the XBEE/adapter.

    On the receiving Stamp, write a simple SERIN loop that will grab any data on the pin of your choice. Display it on the LCD or use DEBUG on the laptop.

    No, it probably won't all fall into place the first time. Work from the known and tested towards the unknown, one step at a time.

    Cheers,
  • ad9409ad9409 Posts: 8
    edited 2013-12-05 17:50
    Sorry if I wasn't clear enough, but I will only use one BS2 and it would be on the receiving end. The temperature sensor is connected to ADC0831 and that is connected to the XBee directly and this is a separate circuit. That circuit will then go to a receiver XBee and the receiver XBee is connected to the BS2.

    Your advice is helpful. I'm slowly getting the hang of it. If there is anything to add feel free.

    Once again, thank you for your help!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-12-06 13:02
    Okay, now I see...the problem with this setup is that the ADC0831 is a synchronous serial device, not asynchronous serial, which is how the XBee modules communicate. There is no way for the ADC0831 and the XBee module to interact without a microcontroller. If the temperature sensor (or ADC) just sent out asynchronous serial data it would work, but unfortunately that's not how they work.
  • FranklinFranklin Posts: 4,747
    edited 2013-12-06 14:30
    Don't the xbees have analog pins (I know the series 1's do) If so just hook your vout to one of them and program the xbee to send the value to the stamp. You might have to figure out the actual packet structure but it should be possible.
  • ad9409ad9409 Posts: 8
    edited 2013-12-06 14:41
    Okay, now I see...the problem with this setup is that the ADC0831 is a synchronous serial device, not asynchronous serial, which is how the XBee modules communicate. There is no way for the ADC0831 and the XBee module to interact without a microcontroller. If the temperature sensor (or ADC) just sent out asynchronous serial data it would work, but unfortunately that's not how they work.

    Would it be possible to attach the ADC0831 at the receiving end, connected from the XBee's output to the basic stamp input, instead of connecting the ADC0831 after the temperature sensor in the transmitter?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-12-06 16:28
    Franklin is correct. You can have one XBee module connected to an analog source and sending that data back to the other XBee module. In this configuration you would not need the ADC0831.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-12-07 10:31
    Read about the analog and digital i/o capabilities in the XBee series 2 (ZB) manual.

    The analog input range of the XBee ZB is 0V to 1.2V with 10 bit resolution, and that is just about perfect for the LM34 in ambient temperatures.

    Both the remote end point and the coordinator have to be programmed with the API version of the firmware. The remote can be set up to transmit the voltage reading either periodically or on a request from the coordinator.
Sign In or Register to comment.