Our local instructor this week was Juha-Pekka Mäkelä. He did an overview of our possibilities for the network and communication. Then, he said something like: as we are in Oulu (you know, 5G, 6G...) it would make sense to go wireless. And I thought he was right. I borrowed from him some XBee modules. XBee is a radio communication module from Digi. If I have the time, I also want to test one of the serial bus communications
To Do
What would it do? I want to switch on/off the LED at board from week 7, Electronics design when one of the hall effect sensor at board from week 11, Input devices detect the magnet is very close to it. This will allow to switch off the LEDs of the thermometer when the wardrobe doors are closed, for the final project- Understanding XBee modules
- Wireless communication between boards
- Try one serial bus
The "Doing"
Understanding XBee modules
- PAN Id: identification of the network. Every component of a networks shares this
- My address: own address of 16 bit, assigned by coordinator. The value for the coordinator is 0
- Destination address: determines which node(s) in the network will receive the data you send (it is in DL (low) and DH (high)).
- each node's address can be found in the reverse of the board
- If you want to broadcast, use DL =FFFF
- Operation channel
Wireless communication between boards
To configure the network, you need to download XCTU. First time you open the application, you get the following: You need to have all the modules connected to the computer. Then, as it says, you need to click on
Add devices
or Discover radio modules connected to your PC
. When pressing discovering, you will need to select the COM ports where your XBees are plugged.
It will also allow you to change some settings. I just leave them as they are:
When ready, it will then show the results. Choose the boards to add them to the network you want to form
By selecting one of the modules you can see its properties.
Then, I connect each of my boards to each of the Xbee modules. Xbee module is connected to computer through its usb adapter board. Then, I connect the Xbee usb adapter board to my own board FTDI pins. The pins are labeled in the Xbee board: I get Vcc and ground to my Vcc and ground, and then the out and in pins (labeled DIN DOUT) to my board in (receiving, labeled TX by Neil) and out (transmitting, labeled RX by Neil) pins.
From the XCTU console it is possible to check what is sent/received by each of the Xbee modules as shown below. But I have to say I struggled with this for a while. I could not make it send anything through the wireless interface. Therefore, I decided to try with the serial bus communication (see next section) to test if I could make it work (and also to be able to have the assignment fulfilled on time). And I managed to make it work. It was a good idea to switch to the serial bus communication because the code of the microcontroller (see next section) in both cases (wireless and serial) is almost the same. So when implementing the serial, I noticed I had commented the code for initializing the output pins of the microcontroller on the sending board.... Those silly things that make you get crazy... So after having the serial bus working, I tested again with wireless and it worked.
Serial bus
The parts of the code for the actual sending/reading are shown bellow. I have connected the two boards using one 4 pin header in the hall/effect board that was put there for that purpose and the FTDI connector from the other board. I have done two tests: first, sending from the hall-effect with the address of the the other board and second, with another address. The code was working as expected.
Resources
- XBee datasheet
- Pages from Juha-Pekka Mäkelä and Antti Mäntyniemi
- Neil´s code from here and there
Once done
Summary
- I have managed to build a wireless communication network with 2 Xbee modules with addressing
- I have managed to build a serial communication network with 2 modules with addressing
Difficulties
- Main issues came from me: At some point I commented the code t needed for the initialization of the registers, so the code was not working; and it took a while to notice that code was commented. Once I put it back, everything went smoothly
Learnings
- Double check all the code, even those parts you think were working properly previously
Files
- main.c file for sender ( hall effect board)
- main.c file for receiver ( led board)