Week 12 - Networking

This week I am interested in trying to take on bluetooth communication so that I can implement it in the final project. I decided to use the CC2541 (2.4 GHz Bluetooth) HM-11. In the end, I want two of the same bluetooth boards to communicate with one another.

To focus on the challening problem, which is just general communication, I decided to not spend any time trying to re-design Neil's blutooth board and just used the board he already posted.

Next, I connected it to my FTDI and ran either coolTerms or miniterm.py (the one that Neil was using in the example to comunicate via the FTDI cable). Based on running, they both have their postives/negatives. Since miniterm.py can just be ran fromt the terminal, I baseically made that my ideal method for FTDI communicaiton. Having these work assumes your comuputer can recognize when the FTDI cable on your device. I have an OSX Mojave / HighSierra and explain how to get it working in a previous weeks tutorial.

Here's a screen shot of coolTerms doing the same communication as Neil did in miniterm.py

Next, I tried doing the same thing in miniterm.py. However, was having issues communicating with the device. A key point when watching Neil's videos, is that he is copying and pasting the commands into miniterm.py. If you don't do this, it send each of the char independently and since all the commands are strings, the device will not communicate back. Once, using the same method as Neil, I was able to communicate with the bluetooth device in a similar fashion to Neil. As always, I spent about an hour trying to figure out this very subtle problem.

Alright, so in Neil's example, he uses a mysterious phone app that was able to pair and communicated with the bluetooth device. Took some time to find a app that does this, but for any one else have this problem, the app I ended up using is called nRF connect. This is the same app that Neil uses, so you can watch the video as a reference on how to use it.

So, now that we are able to get the device to communicate with the phone, I wanted the device to be able to communicate with another board that also has a bluetooth communication chip.

Unfortunately this is where Neil's demo ends and now you have to enter the world of internet searches and trying to scrap together how to pair two devices together. Of course there was no tutorial that was able to provide me with the proper information on what commands I need to use to pair the device with another bluetooth device.

After a long time of inputing a lot of random commands in miniterm.py from what I thought was the specification sheet of the HM-11 bluetooth chip, I ended up finding a real specfication sheet from the chinese manufacturing company. The company was identified by entering the command AT+HELP?, which gave me a website to the actual company.

AT+RENEW (resets to default settings. Just in case you already messed with the settings)

AT+IMME1 (make it so that the decivice does not automatically pair with devices)

AT+ROLE1 (defines that the device as a master - aka can connect to devices)

AT+DISC? (this searches for device - if you can't find your other device, then the device is either not powered, or is not set to slave mode. With the other device, make sure to type in AT+ROLE0)

This is found in Neil's video, but in case you didn't catch it, you can determine the MAC address by entering the following command:

AT+ADDR?

After searching for devices, you should be able to see a divice with the address of that device. If you see it, then you should be able to connect. If not, then the device is either not in slave mode or powered on, or some other error I haven't encountered.

Assuming you were able to see the other device, below is the command to connect to the device.

AT+CO0[insert MAC addresss here]

Be sure to remove the brackets, and insert the MAC address of the device you are trying to connect to. A lot of tutorials used AT+CON[MAC addr], but this didnt work for me, and in the manufacutures documents, it says to use AT+CO0 if the MAC address is static, which it is.

After entering this command, you should recieve: CONN

CONN

This indicates that you have succefully connected to the device.

Below is a demo of one bluetooth board, connected to the computer via FTDI, communicating with a bluetooth board connected to an attiny44. When I press any key other than 1 will cause the board to flash once; however, if I press a 1, then the board should double flash. See video below.



Just getting to this step has taken a very long time. I have also tried having the boards input all these commands and connect to eachother. I was able to get these devices to communicate, but communication would only last for a few seconds and then no longer work. Based on when I program the attiny44 to communicate, I get the character that I programmed to send, but other weird characters too. So, I'm thinking theres a timing issue with my board that is not outputting correctly.