Skip to content

Interface and application programming

Restarting programming

To be clear, I’m not a programmer. Last time I programmed was at university, over 20 years ago. Back then I did learn C and OpenGL to make a bolder-dash type game, but I hardly remember any of it.

This week I planned to write an application that interfaces a user to the ESP32, as that’s what I plan to use in my final project. In orde to program for the ESP32 you can use

  • Espressif IDF (IoT Development Framework), as I did last week
  • Arduino IDE
  • Micropython
  • JavaScript
  • LUA
  • … and others

This week I am following a tutorial which recommends using the Arduino IDE, so I set arduino up to be able to interface my ESP32, according to these instructions.

Essentially, I added this URL to the Additional Boards Manager in the Arduino IDE preferences

https://dl.espressif.com/dl/package_esp32_index.json

Then in th Boards Manager, added the ESP32 library, then selected my devboard DOIT ESP32 DEVKIT V1 from the pulldown menu and the port it is connected to (in my case, /dev/cu.SLAB_USBtoUART)

I then opened a simple WiFiScan example program and uploaded it to confirm proper function, pressing the boot button on the board when Arduino starts looking for the board, otherwise the flash will fail. Then I tested the program with the serial monitor, where it printed the available WiFi networks.

Tuning LEDs On and Off over wifi on ESP32

So I ran Rui Santos’ arduino code from the tutorial I followed, and it worked quite well. To be clear it’s not my code, I have no merit at all in this result, but studying the code and explanations in the tutorial I understand how it works and what it does. All I did was change a bit of CSS to change the way the buttons look.

2022

This year I followed another Random Nerd tutorial to control a servo motor using a slider in a website hosted on my esp32 development board.

I searched my Micro Servo SG90’s datasheet to figure out which cable’s corresponded to VCC, GND and PWM signal, and looked at the pinout of my Bardino to figure out where to connect those cables to.

! Connection Schematic

I was worried that the 3.3V of my Barduino wasn’t enough to power the servo, but it seems it does work. I then went to the Arduino IDE and installed the SERVOESP32 library from Jarek Paral. Once installed, I opened the simpleServo example, which just rotates the servo’s shaft between 0º and 180º, back and forth. That allowed me to determine that the 3.3V actually was enough for this motor.

I then carried on with the tutorial, that has code that allows my board to connect to my home Wifi Network, host a website with a slider that allows to control the rotation of the servo.

interface

Once uploaded, it worked well

Files

SimpleServo Arduino Sketch

My final Arduino Sketch

Checklist

Learning outcomes

  • Interpret and implement design and programming protocols to create a Graphic User Interface (GUI).

Have you?

  • Linked to the group assignment page
  • Documented your process
  • Explained the UI that you made and how you did it
  • Outlined problems and how you fixed them
  • Included original code (or a screenshot of the app code if that’s not possible)
  • Included a ‘hero shot/video’ of your application running with your board

Group Assignment

Link to the group assignment part.


Last update: June 30, 2022