Xbee-Python and the BBBW (BeagleBone Black Wireless)…

Did you ever want to use another radio band to control your LED from a distance w/ an Xbee by way of push button?

Categories: Beginner

Hello,

First we need to get XCTU at
https://www.digi.com/products/embedded-systems/digi-xbee/digi-xbee-tools/xctu.

Once we have this software, we can plug in our Wireless Connectivity Kit Xbees to their host boards.

Once connected correctly, plug in your USB cables to two separate USB ports on your host computer (desktop environment).

Use your XCTU software to update your radio modules in this way:

1. Open your XCTU software by clicking on it or in any way you deem necessary, i.e. as long as it is open and ready to use.

2. Then, use the radio icon w/ the addition symbol on it to add your two Xbee radio modules.

Here:

Top left is where the addition symbol is on the module icon.

Next…you will see a dialog pop up.

Here is what it looks like w/ the updated version of the XCTU software I am using:

Here is where you can see your listed radio modules.

The "Add radio device" prompt pops up and you can now add your device. As you can tell, I have one radio at COM6 listed. Right now, my other radio is not plugged in. You can plug both in at the same time or wait and plug them in separately.

Just be sure to remember, if you are plugging in two at the same time, which belongs to what port.

Now, highlight by clicking on your COM port, mine is COM6, and click the Finish button on the dialog.

This will bring you to another screen where you can alter your radio module AT attributes.

Now, on the READtheDOCS page online at
https://xbplib.readthedocs.io/en/latest/getting_started_with_xbee_python_library.html,
we are going to listen to their guidance and start by installing their library, using their source to read changes in states, and also we are going to change our radio configurations on XCTU by their guidance.

So, on the listed hyperlink, they say use this command to get the xbee-python library for your BeagleBone Black Wireless!

pip3 install digi-xbee

If you do not have pip3 on your system, please use this command: sudo apt install python3-pip.

Now, we can configure our Xbee modules:

from readthedocs page online!

Supposedly, Python can override the configuration. So, if you are familiar w/ Xbee and XCTU, this Python library can be used to override some aspects to the XCTU software while configuration takes place. Nice!

Here is a sample of a set up from the XCTU software that I made up from the above photo.

XCTU software and setting configuration up...

So, as you can tell, I have darkened some listings in my config. file.

This is to protect me from you. You will have your own addresses for your Xbee modules. Keep them safe. Do not share them. Ethical hacking is a thing but not everyone shows the same etiquette.

So, now we need to add the source to our BBBW or allocate it from the
github.com
repo. for the xbee-python library.

use this command to get the library from the repo.

git clone https://github.com/digidotcom/xbee-python

So, now that we have the xbee-python library on the board and can use it b/c we used pip3 earlier to install the library into our files/directories where they can be used, we now have to venture forth to find what we want in the source.

I found this on their repo:

https://github.com/digidotcom/xbee-python/blob/master/examples/io/RemoteDIOSample/RemoteDIOSample.py

This is awesome and nice! They are giving us starter scripts to test hardware and source. Nice!

So, now that we have made everything available to us, we need to power down the BeagleBone Black Wireless w/ sudo poweroff, plug in the Xbee_A module into the USB port on the BBBW, and then plug the BBBW back into the host desktop.

Also, plug in your other Xbee_B into the host desktop or another computer in your area.

The further, the better. You can actually test the capabilities of these powerful, yet small, devices. They should be able to communicate through walls at some distance and the direct-line-of-sight is quite the length w/ Xbee protocols.

So, w/ everything ready, we now need to alter our source from the
RemoteDIOSample.py
file in the
github.com
repo.

Oh and one thing to note, the LED on the Xbee Wireless Connectivity Kit needs to be attached to the USB of the BBBW and not the other way around. So, attach the GroveLED to the Wireless Connectivity Board, make sure your Xbee is attached still, and then plug the USB into your BBBW, and finally make sure the BBBW is plugged into the development desktop via USB.

Okay…phew.

Now, here is the code in a photo. Well, part of the source. This is the source we are going to change.

from their repo. online at Github.com...

Okay:

Line 21: PORT = "/dev/ttyUSB0" <--- This is b/c of what Linux uses for USB hosts


Line 25: REMOTE_NODE_ID = "Xbee_B"

Line 27: IOLINE_IN = IOLine.DIO2_AD2 <--- This is the button on the other/REMOTE Xbee Module

Line 28: IOLINE_OUT = IOLine.DIO4_AD4 <--- This is the LED on the Xbee attached to the BBBW

So, now…we have changed the source, saved our source, and now we can use this command to run and execute the source we just altered.

python3 RemoteDIOSample.py

This should list some sentences on your console from the print functions in the source.

It will print the IOLine input and the value of this input, plus you will be able to see your LED turn on and off while this takes place. LEDs and buttons!

If you are having trouble following this rambling, please just leave a message.

Seth

P.S. Have fun w/ your new way of Xbee module source production w/ python3!

Comments are not currently available for this post.