Engduino Bluetooth For Android

The Engduino

The Engduino

As part of the ENGS101P module, we were tasked with creating a Coding Curriculum using TouchDevelop. In order to make it engaging to younger students, we were given a scenario where the students needed to create a “pot hole sensor” using a phone running TouchDevelop and an Engduino. My task was to work out how to get the Bluetooth connection to communicate with an Engduino with a Bluetooth module installed.

In order for TouchDevelop to be able to use the Bluetooth radio on the phone, it needed to be exported via Cordova to generate a (more) native application. However I had multiple problems in attempting to achieve this. I worked with fellow Student Computer Scientist Robert Soultanaev to work out where the problem was.

We knew that the problem was not hardware. We deduced this by downloading native Android applications that showed serial communication via Bluetooth, and could see that the Engduino was able to process commands, and send back data. Thus we knew that the issue must be caused either by the Cordova plugin that was being used, or by the TouchDevelop library that wraps the Cordova Plugin.

We got in touch with a Microsoft employee we knew as Peli, and we were able to assist him in fixing his implementation of the TouchDevelop wrapper library for the Cordova plugin. Whilst this was happening, Robert took the extra step of contacting the developer behind the Cordova plugin itself, who provided a very useful insight into how the plugin worked. He even suggested potential reasons why the plugin was not working for us, which Robert passed onto Peli.

After the TouchDevelop library was fixed, we we able to get the Engduino to communicate with the Android app freely. Now, we faced a different issue, how to get data back. We noticed that we were successful in getting the Engduino to send data over the serial, but for some reason, the application wouldn’t report the data. I then discovered that the reason was a difference in delimiter.

cordova bluetoothserial -> subscribe("}{", action)

Peli’s sample application assumed that the delimiter was the new line character, when experimentation with the native Bluetooth terminals showed me that this wasn’t the case. Once I changed the delimiter, the information was clearly shown, and the strings were ready for parsing.

I am happy with how this project turned out. It gave me an insight into how Bluetooth serial communications worked and serial communications in general. It also gave me an opportunity to use Cordova to be able to export to multiple platforms with a single code base.