Week 13 Networking and Communication

Wired

I tried to do an I2C connection to an E-ink display/Accelerometer in my earlier week of Embedded Programming. I hate figuring out ESP32 quirks so much. So far in this class, I figured out how to debug and program interrupts/I2C and now the bluetooth. Easiest one of them all being bluetooth

I made a speaker/lights sculpture for my embedded programming week. I want to use it at home(hopefully with a better speaker replacement in the future). I wanted to connect to the ESP32 with my phone so I can play music (Unfortunately I need to get an SD card reader and maybe store the files on it and use the phone to select a song to play).

Connecting to Bluetooth on ESP32

I wanted to utilize the bluetooth speaker on the ESP32 since my sculpture from earlier uses ESP32 - Easiest Bluetooth Solution I could find and also seems like the main purpose of using esp32 is the ease of Wifi/Bluetooth Capabilities. I could have done a web server/wifi version but didn't think it's the best option for having a general purpose bluetooth speaker.

Because I am still waiting for Audio Amplifier breakout board I designed to arrive from pcb fab (oo my first pcb boards!!) I decided to use the bluetooth capability to get my motor to turn on and off. This will be useful later for my final project -maybe. There is no reason to have a wireless communication option in my final project.

Okay - connecting ESP32 bluetooth is pretty straightforward. We have to find the BLE server sarted in arduino. Note if you use "Classic" bluetooth connection typically used in Arduino IDE's your iphone will not recognize. I wanted a app to connect to the motors so getting my iphone to recognzie the bluetooth device was important to me

Before proceeding I had to generate a uuid for my esp32 module. I used uuidgen on terminal - B5FEB6E8-9652-4945-A4D5-2561E8CBD368

I primarily used this tutorial to understnad how I can do this - https://www.robkerr.com/ble-peripheral-ios-development-part1/ . I don't write many ios apps so I am excited to try this out.

A BLE device in my case my ESP32 board needs to create service objects (to receive requests to turn the motors on and off etc), respond to them + advertise the services available (in my case to my ios app).

Look at the app screen! I am very proud of myself. The last time I made an iOS app I was on the newest versions of swift/objective-c. So much has changed.

I ran the BLE code for Arduino to let my ESP32 connect to my Phone and perform some services

Also you have to remember to add the following settings to your info.plist in the iOS app for the target to run and connect to bluetooth

Established the connection between bluetooth on ESP32 and my iOS app

And I made the program - Blink an LED and turn the motor in one direction. And the other motor in one direction. I didn't have the enable pins set so the off motor button is basically moving the motor in the opposite direction. You can see it in action down here

IMG_4434.mp4