Tanja ∈ Fab Academy 2018

Week 13: Embedded Networking and Communications

Spezial thanks in this week to Aleksandra Konopek, my colegue for her tips and support in this week. Thanks for tipps in this week to Florian Papproth our Instuctor and thanks to Marcel for lending me his bluetooth devices in this week.

Communication of Bluetooth Devices



In this week we had to design and build a communication network between at least two processors. As I would like to build a wireless network for my final project the airing assistant, I tested in this week also wireless devices. First I tested 433 MHz devices and then I controlled the bluetooth low energy device an controlled it first with an Android App.


The main feature is the master-slave-connection. There is also I2C as wired kind of network and WiFi, radio and bluetooth as wireless kind of network.

Module HC-08 BLE Bluetooth 4.0 CC2541 and Serial Bluetooth Android App

Here you can see HC-08 BLE Bluetooth 4.0 CC2541 6 pin wireless module (for Arduino Android IOS) selled by Magi Deal.




FTDI cable is very important for the serial connection, because of the TXD (Transmit) and RXD (receive).


FTDI Cable


FTDI cable pin wiring
Image: Wiring BLE HC-08 with Fritzing

I would like to control one red LED using my mobile phone (Master). For the bluetooth communication between my android mobile phone and ATmega328p board (Slave) I used following Arduino IDE scatch.



Below you can see the wired ATmega328p with Bluetooth BLE 4.0 HC-08 Module and LED.



Preparing my mobile phone for BL communication (App - Bluetooth):

- Installing Bluetooth serial App (Linkt to Google Play Stor see below in Downloads)
- activation Bluetooth on mobile phone
- scanning for other bluetooth singnals or devices
- powering BL device via connection to the ATmega 328p
- selecting the device and connecting it to mobile phone
- using the App for switching on or off of LED. For this I just tiped the "1" into the command window of the "M1" button. Instantly the LED switched on. Opposit I did with "0" to switch off.


Video: Communication between Andriod mobile phone and ATmega 328p prozessor using Bluetooth LE module HC-08 CC2541 and Serial Bluetooth App.



Two Modules HC-05 BLE Bluetooth 4.0 Comunicating

I planed to use the Bluetooth module to communicate between two prozessors and needed to change some setting of the modules or to sett the connection adress. As the programming of the Bluetooth LE module HC-08 CC2541 due to mising "Reset" button was not possible, I purchased another two Bluetooth devices. Anyway it was possible to query the adress and Software version of this module.



Unlike the HC-06, the HC-05 module can be used not only as a slave, but also as a master and can thus independently connect to one HC-06 module, another HC-05 module in slave mode or one connect other device with SPP profile.
The adapter board is also equipped with a red LED button and a voltage converter, so that the module can be operated at 3.6 ... 6V.


New devices (BLE HC-05) were simple to programm using AT-mode. AT mode was accessible using "Reset" button which had to be pressed while connecting the VCC (+5V) to HC-05 module. After that it is possible to make some settings in the Serial Monitor of the Arduino IDE. For this see images below.



1. Open a new sketch in Arduino IDE
2. Upload the empty sketch on your Board, which you use for programming the BLE Modul.
3. After uploading wire the RXD pin of the Bluetooth Modul with the RXD and TXD pin with TX of your board.Otherwise you become an error message.
4. Open the IDE Serial Monitor and type AT in the Comand window. You should get the response "OK". If not you should try again or change the baudrate.
5. In the comand line you can query and adjust different settings of the Bluetooth Module:

- Name: AT+NAME?
- Baudrate: AT+UART?
- Mode (slave or master): AT+ROLE?
- Possible connection(to one or any Module): AT+CODE?
- Address: AT+ADDR?
- Is there allready connection to another module: AT+BIND?
Master module adjustement:

- Set name (if needed): AT+NAME= ******
- Set baudrate (if needed): AT+UART=******
- Set mode for master module first: AT+ROLE=1
- Set connection to only one certain slave module: AT+CODE=0 (or if you need more than one slave than write "1" instead of "0")
- Set connection to slave module: AT+BIND=****,**,****** (instead of colons you shoud insert commas) as you can see below

Slave module adjustement:

- Set name (if needed): AT+NAME= ******
- Set baudrate (if needed): AT+UART=******
- Set mode for slave module first: AT+ROLE=0
- Set connection to only one certain master module: AT+CODE=0
- Set connection to master module: AT+BIND=****,**,****** (instead of colons you shoud insert commas) as you can see below





6. Now you should switch the connection between RXD and TXD and connect the RXD of the Bluetooth module with TX of your board. The TXD pin of the Bluetooth module you should now connect to RX of your board.
7. Starting communication:

- disconnect the VCC (+5V) pins of both modules and reconect those
- now the red status LEDs of both modules start blinking rapidly
- after a few seconds the modules will connect and red LEDs start blinking synchronous
8. Now you can upload corresponding sketches for each MCU you would like to connect.

Here you can see how I made the wiring of the boards and Bluetooth modules using Fritzing App. On the master board I uses a simple push button including an green LED to trigger the event. On the slave MCU I only used one red LED for show the status of the connection.



Following image shows the Arduino skaches used for each prozessor (master and slave) and also the Serial Monitor of Arduino IDE where are to see few outputs of the Master Module.
Left skech is for master MCU and the right for the slave MCU.




Below you can see the wiring with my FabKit board and one Arduino as my second board does not work yet.



Following movie shows the communication between two boards with each one HC-05 BLE 4.0 module.




This video tutorial was very usefull for me to understand and test the Bluetooth connection.


Downloads


Wiring Boards and Bluetooth Modules download
Sketch for Bluetooth communication Master Board download
Sketch for Bluetooth communication Slave Board download
Serial Bluettoth App at Google Play download
Arduino IDE sketch for Bluetooth communication using mobile phone Serial Bluetooth App download




433 MHz RF Devices



Some other trials with RF Devices (433 MHz) worked out using Arduino UNO but using my board did not work yet. The problem was that the pin designation in the library of modules is programmed according to the pin designation on an arduino board. I have tried to change those settings in the Radiohead library but it did not work.





In the tutorials it is recomended to use an antenna for bouth modules for geting better connection. But I find out that on short distances it works without antennas.

For simple test of those modules I used the sketch of the folowing tutorial :












Radio Head Library Download

Tutorial for RF 433 MHz Modules

Groupassignement