Skip to content

14. Networking and Communications

This week we evaluate networking with Bus and address, and made an demo of bluetooth remote control by smartphone. Juha Pekka Mäkelä is an instructor who taught and guide how to use those devices and tools in Fablab Oulu.

1. Group work

Group work had done with Antti and Mona in Fablab Oulu Protopaja, using previous week made ATtiny412 of our each products and tested the bus and addresses. The report is here.

2. Individual work

Individual work, I decided to make the bluetooth connectivity with ESP32 and mobile phone. The same function is needed for my final project, to control the motor and servo by phone.

1. MIT App Inventor

MIT App Inventor is made by MIT, an online platform which provides the mobile App developing tool with GUI environment, similar with Android studio and the coding of Scratch. It supports only Android phones and Apple phone cannot work at this moment.

2. Installation

Installation of tools is followed this instruction, installed mobile App on the phone, and connected the phone to programming App of laptop via Wifi connection using QR code.

First open the programming webpage of App Inventor.
After defined the name of project, the designer view is shown with smartphone view.

Looks very similar GUI as Android studio etc, this can put the components into the phone screen and build the App view. Each component has attributes, properties can be modified.

Design is easy by drag and drop from left hand side toolbox to mobile phone screen. If you want to make the alighnment well layout, use Layout -> HorizontalArrangement produce one more window, it can be hold the GUI tools horizontally alighned.

Put the simple buttons to control Bluetooth connection and LED control ON/OFF buttons.

Changed the view of blocks, this is similar operation as Scratch coding blocks.
Here put the coding block of bluetooth and buttons. The function is connecting Bluetooth and send the signal of “1” (LED ON) and “0” (LED OFF) on the Bluetooth serial connection.

After setup done on PC, you can connect with phone and the phone can run this code and verify the functions. Connect ->USB.

And if you want completely download to your phone, you can make an application file by Build. It can be download by QR code by phone, or download to PC the apk file for Android phone.

3. ESP32 setup

As the main board of Bluetooth receiver side, previous input devices week made ESP32 is used.
Here is the hardware setup of ESP32,
- GPIO #23 is connected internal LED port

ESP32 coding, I used the library “SerialToSerialBT” from ESP32 dev Module regarding Bluetooth connectivity. And set the LED function using digitalWrite for GPIO #23 when received the Bluetooth serial “1” or “0”. Also set up the debug purpose serial print and can confirm the signal of Bluetooth connection.

4. Demo

Here is the demo, using MIT App Inventor on smartphone (android), Bluetooth wireless connectivity and ESP32 of my mainboard.

Reflections

  • Good to know how to use MIT App Inventor by this opportunity. This can use for both Apple and Android phones, very scalable with nicely GUI environment.
  • There was one problem that Bluetooth serial connection. The example code of ESP32 package that used both Serial() and SerialBT() getting the data from Serial() by exchanging data between Bluetooth and serial. However it couldn’t get the data, changed simply just used only SerialBT() then it worked!

Files

MIT App Inventor file
ESP32 Arduino file


Last update: June 18, 2021