Xbee Wireless Help


#1

Hello,
I am fairly new to Arduino and I am attempting to make a wireless circuit using the Xbee Wireless Series 1, Xbee explorer and the Lilypad Xbee, but I do not know where to start with code. To start with, I just want to be able to turn a LED on with a sensor wirelessly. If anyone has some in which I can use for this sort of thing that would be great. This is only for a proof that it is possible to make it work, it will, in the end, need code for matrix LED grids, other lights, and many sensors too.

I would also like to be able to power a set of 5 LED Grids of a battery connected to the Lilypad Xbee and would like to know what type of batteries should be used. Is a 9V okay?

Thanks Heaps


#2

G’day Tom,

I’m assuming you are using the Xbee Explorer USB or Xbee Explorer Dongle, though you might be using the Xbee Explorer Serial. Let me know.

To turn a LED on using XBee:

  • attach the LED to one of the LilyPad XBee output pins, along with a series resistor, and a return to ground,
  • use the XBee configuration programs to pair the two XBee modules,
  • insert one of the modules into the LilyPad,
  • give suitable power to the LilyPad,
  • write code on your computer to send an I/O command to the XBee on the Explorer.

As a result, the XBee will send the command over wireless to the other XBee and the LED will turn on.

The code can be in any language in which you can access the USB device. Python might be a good language to try. This will prove it is possible to flash a LED over wireless.

To turn on a LED in response to sensor input;

  • read the sensor input somehow (is it on the LilyPad or on the computer?),
  • make a decision in code,
  • send an appropriate I/O command to the XBee on the Explorer.

Moving on to your matrix LED grid; I’m not sure how that would work. The XBee on the LilyPad doesn’t have enough flexibility to directly drive matrix LED grids, unless you interpose a microcontroller between the LilyPad and the grids. The XBee Explorer Regulated can accept an Arduino Pro Mini board, and that can drive grids, either directly or using SPI or I2C to a matrix driver module.

A standard 9V battery might work with the LilyPad XBee; amazingly I can’t find a maximum voltage specification for the regulator on the LilyPad. You may have better luck.

You can calculate how long it will run for by taking the capacity of the battery (in milliamp hours), and dividing by total current draw. The current draw will be 50mA for the XBee, about 20mA for the Arduino Pro Mini, and 20mA per LED row in the matrix, worst case with all LEDs at full brightness.

Wikipedia says typical 9V alkaline capacity is 550 mAH, so about two hours for a ten row matrix.


#3

Thanks so much,
Yeah it is the Xbee Explorer USB


#4

Hey quozl,

What would you recommend to me for coding this sort of thing? Currently, I have been using the Arduino App. Is this app okay or do I need an app such as XCTU which is apparently needed for pairing the Xbee’s?
Thanks


#5

Arduino is a great app for coding for Arduino boards and some other boards. Only some XBees are programmable. Exactly which ones do you have?

I may be wrong, but in my brief reading X-CTU is mostly for changing the configuration of an XBee rather than writing a program for it. It might be old documentation I’m reading.

XBee expert community seems focused around http://www.digi.com/xbee/ in case you’d like to dig into what is there.


#6

I have the
Sparkfun Xbee Explorer USB WRL-11812
Lilypad Xbee DEV-12921
and two of the Xbee Module Series 1 for the antennas to wirelessly connect the two

Yeah, I read that X-CTU is to configure them to link to each other, but are you saying that they don’t need that?

Okay I’ll have a look into the Xbee Community too thanks


#7

The question is where will your program run; the program that will make decisions; will it run on your computer, an Arduino, or the XBee. Only some XBee modules can run a program. Look at this old table https://cdn-shop.adafruit.com/datasheets/chart_xbee_rf_features.pdf for the second-last column. N/A means it can’t hold a program. I don’t know how much will fit into the XBee program flash without knowing the exact XBee module, but if “Series 1” means “S1” hardware on this table, it isn’t capable of holding a program.

So you will have to use some other place to hold the program; what do you choose?

No, I’m not saying X-CTU is not needed for configuring.


#8

I was hoping the program would run on the Xbee Explorer USB

Yes, it is the S1. Sorry I didn’t get what you meant.

So can you please lead me in a direction of what I can get that will hold the program?


#9

No, a program would not run on the XBee Explorer USB, as it doesn’t have a microcontroller on it. The big chip is a USB-to-serial converter FT231X. You could plug in an S2B or S2C XBee and a program might run on that.

There’s no single S1, but all the S1 in that table are not programmable. To use an S1 to drive a matrix of LEDs you’ll need to add a microcontroller to do it. Some of the choices seem to be;

I’d need to know which S1 you have before recommending the best microcontroller.

Can you tell me a little more about the function you want the pair of XBees to be involved in? e.g. remote sensing of a flower pot water level with a local display of a smiley face on the matrix grid. :grin:


#10

Bike indicator lights
Flex sensors on both breaks which activate the rear 10x8 Matrix LED grid on jersey
Photoresistor which activates two warning lights 8x8 Matrix, Rear LED bike light and lasers, and a front white LED headlight for the bike.
Two Lilypad buttons or similar on the handlebar, which activate the left and right indicator 8x8 Matrix grids

I want the sensors to run into the main board and the LED Matrix Grids to run wirelessly from the second Arduino.

The front headlight and rear bike light and laser I want to be connected to the main board.

Well this is what I was hoping to do


#11

Okay, I see. I’m a rural cyclist, kangaroos ignore my indications. :grin: The XBee RF link would carry commands to change the 10x8 matrix LED grid on jersey. A progressive build sequence could be;

Jersey controller

  • fit the grid to a jersey controller board, like an Arduino or Feather, with a battery,
  • write a script that will light the grid in response to serial data from a computer, and test,
  • replace the “computer attached to controller” with “computer attached to XBee, XBee attached to controller”, and test,

Handlebar controller

  • fit the other components to another controller board, like an Arduino or Feather, with another battery,
  • write a script that will light the other components in response to flex sensor inputs, and so on, and test with computer attached, making sure that the same serial data required by the jersey is sent by the handle bar unit,

Integration

  • replace the “computer attached controller” with “XBee attached controller”.

Sounds like fun.


#12

What type of Xbee’s, Arduino or Feather, Battery, and controllers do you recommend?
I wanted to try and make it as small as I could…


#13

It isn’t really practical to be that exact; hobby engineering is more of an approximation and progression, based on what you are already familiar with. You began with XBee, so I’ve focused on that, but there are other ways to solve it.

If it were me, I’ve not deployed XBee yet; but I’m already familiar with bare radio modules, the Arduino and Feather range, the RFM series of packet radios mounted on controller boards, and ESP8266 and ESP32 modules with built-in WiFi radios. But I wouldn’t know which one to try without first knowing the electrical interface requirements of the LED matrix. I know you’ve selected 10x8, but I don’t know which 10x8, whether it is already assembled or something you have to assemble, and what it has for an interface. Everything ends up being related.

(I’m presuming this is a one-off. If it were for mass production of more than 1000 units, I’d go for 8051 microcontrollers and custom circuit boards. Non-recurring engineering cost of about a man-month, but the cost per unit would be kept really low.)


#14

So I’m feeling a little overwhelmed at the moment so just to clarify I’m going to say what I want to be able to do as simple as I can.
So forget what I have already, I want to be able to make a system which allows me to:
When a button at the front of the bike is pressed, it is connected to a board at the front of the bike, which wirelessly sends a signal to a board on the user’s jersey, which then turns on the LED.
So in order to do this what sort of boards, shields, antennas, batteries etc do you say I would need? I don’t mind if I have to buy all new pieces.

I want to get a proof of concept first, which is just sending a basic message to turn on a LED, as this will help me to understand where to go. I also want the boards to be able to be programmable so I don’t have to keep them plugged into a computer. After I have been able to get the first stage, I will be looking at expanding it further to work with 10x8 and 8x8 LED Flexible Matrix Grids.

Thanks


#15

I would use a pair of Adafruit Feather 32u4 with RFM69 433 MHz packet radio modules, a pair of 500 mAh lithium ion polymer batteries, and some micro-USB cables for programming and charging.

The Feathers are reasonably small, can be battery powered, have a built-in LED for first stage, and a reset button.

Use the Arduino IDE to program them. A starting program could be to just transmit a command to the other device to blink the LED. You’d press reset on one, and the LED on the other would blink.


#16

Thank you.
Also will these work with the sensors (Flex, buttons, and Photoresistor) and the several Matrix Grids I will later need?
Am I able to get in touch if I am in need of some help later?


#17

It depends on each sensor and matrix grid, and some overall limits, but in general, yes. Those types of components will work individually with the Feather 32u4. Get each component working by itself to your satisfaction, then gradually build up to have everything. When you hit a limit, figure out whether to relax your requirements, or add components to overcome the limit.


#18

Adafruit Feather 32u4 with RFM69 433 MHz packet radio or the Adafruit Feather 32u4 RFM69HCW Packet Radio - 868 / 915 MHz one? And can you please tell me the difference? Thanks


#19

Difference is in the radio frequency used.

Either should be fine, but it depends on the regulations in your country and local area.

Tell me your country, nearest city, distance to city centre, and approximate bearing. If it is one that I know, I’ll be able to answer. Otherwise the most likely answer is to use 433 MHz.

For Australia, the regulations can be found at the ACMA web site. They specify maximum power, frequency, duration, and a few other things. See The Radiocommunications (Low Interference Potential Devices) Class Licence 2015 (the LIPD Class Licence).

Please, be careful. Read through the regulations, especially those that relate to the frequency you’ll be using, and take precautions to avoid interfering with other users of that frequency.

The 433 MHz frequency is used for many many things. You will have outside interference affecting your design, and you have to make sure you don’t cause interference. Best way to do that is (a) restrain power, (b) transmit very briefly, © have some way to prove the data you received from the handlebars is genuine, (d) repeat the transmissions until you get a valid acknowledgement from the other unit.

You may be required to lower the transmit power in software to stay within regulations. The distance you are transmitting; worst case from the handle bars through a human body to the back of a jersey, doesn’t need any significant power.

There are places you cannot use 433 MHz, and the license goes into detail.

The 915 MHz frequency isn’t available in Australia under LIPD. You might need a separate license to use that module.


#20

Oh okay
Port Macquarie, NSW, Australia

So I’m guessing the lower frequency 433 MHz will probably be the best for what I need it for?