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
  1. Understanding XBee modules
  2. Wireless communication between boards
  3. Try one serial bus

The "Doing"

Understanding XBee modules

XBee is a radio communication module. To build a network of Xbees, you need to configure at least one of them as coordinator, and then the rest as routers and/or end devices. For network communication, we need different values
  • 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

I want to communicate between two boards as described here. For that, I will connect each of those boards to an Xbee module. So, lets start communicating 2 boards and ...lets see!

To configure the network, you need to download XCTU. First time you open the application, you get the following: 3d object design
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. 3d object design
It will also allow you to change some settings. I just leave them as they are: 3d object design
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. 3d object design
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

In the wireless communication, the Xbee network handles the id of the different nodes. The addressing is handle my the Xbee modules. So I started the serial bus communication task by adding to the sending microcontroller code some id and to the receiver microcontroller code some checking for the id. And then it would be ok. I use the code from Neil for sending/receiving data
The parts of the code for the actual sending/reading are shown bellow.
3d object design
Getting information in LED board. Direction set at the bit 7 received: if 1, then read instruction (at bit 0 received)
3d object design
Sending information from Hall Effect board
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.
3d object design
The 2 boards connected with a bus
3d object design
The Led from the receiver is on

Resources

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