Compiling from Scratch
UC2-ESP Firmware for the openUC2 UC2e electronics
This repository provides the latest (V2
) firmware that controls external hardware like Motors, LEDs, Lasers and other customized elements using an ESP32 and an adapter board. It is inspired by the UC2-REST firmware, but features a much more structured way of the code by dividing modules into separated classes. A ModuleController
ensures a proper initializiation of individual modules at runtime, which makes the entire code very modular and follows the overall UC2 principle.
Similar to the legacy UC2-REST Firmware, the microcontroller can communicate using the wired serial and the wireless WiFi protocol. Both rely on a more-less similar REST API
that uses endpoints to address an act, get, set
command. For example, the information about the state of the ESP can be retrieved by issuing the code:
{"task":"/state_get"}
A list of all commands that can be sent via HTTP requests and serial commands (e.g. by using the Arduino IDE-contained Serial monitor at 115200 BAUD) can be found in the RestApi.md-file.
Setting up the build/develpment environment
In order to build the code, you have to follow the following steps:
- Install Visual Studio Code + the Extension called "Platform.io" => Restart Visual studio code to load PIO
- Clone the repository including all the submodules:
git clone --recurse-submodules https://github.com/youseetoo/uc2-esp32
- Open the main folder in the Visual Studio Code
- Adjust the settings in the file
platformio.ini
-file (mostly the port) 4.1. Go to Platformio Home and navigate to Devices 4.2 Copy the Device port (if connected) and insert that into theplatformio.ini
, e.g.upload_port = /dev/cu.SLAB_USBtoUART
orCOM3
for windows - Hit the
PlatformIO upload
button; The following task will be run:platformio run --target upload
; The code is getting compiled and saved into./.pio/build/
5.1 The code will be uploaded. If everything goes right the terminal says: `Leaving... Hard resetting via RTS pin...`` - open the PlatformIO serial monitor (remember to also change the port in the
platform.io
accordingly) and check the ESP32's output (eventually hit the reset button) - In case you have any problems: File an issue :-)
In order to test several commands, you can find a useful list of json
files in this file: json_api_BD.txt
V1: Source-code, Compiling and Binaries (Deprecated)
The current version of the firmware can be found here: https://github.com/openUC2/UC2-REST/tree/master/ESP32
Additional information on how to install and compile the board can be found in the README
Precompiled binaries that can be installed through ImSwitch (more information coming soon) or the esptool.py
can be found here https://github.com/openUC2/UC2-REST/tree/master/ESP32/build
V1: Install necessary software for UC2 rest (flash and interact) (Deprecated)
Here you learn how to install the necessary software (Arduino IDE, drivers, ESP-IDF, Arduino libraries) that are necessary for the system to be working. Everything is explained in the video below.
Additional information about the UC2 electronics and UC2-REST are provided here: https://github.com/openUC2/UC2-REST
Download and install the software:
To simplify life, we host a dropbox folder containing all the necessary drivers and Software pieces for this workshop. It will run on a Windows 10 64 Bit system:
List of relevant files
for the UC2-REST
- Arduino IDE:
arduino-1.8.18-windows.exe
- ESP32 USB driver:
CH341SER.exe
- UC2 Rest firmware:
UC2-REST.zip
Alternative GitHub links that provide you with the latest version of the software:
- https://github.com/openUC2/UC2-REST (=> firmware under ESP32/main; compile and flash on your ESP32 board)
- https://github.com/beniroquai/BenesArduinoLibraries (=> all libraries necessary to compile the software)
- https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all (=> CH340 drivers for the ESP32 board)
Steps to install the software
- Download all relevant files from the Dropbox folder above
- Install the Arduino IDE (including all drivers if you are asked during the installation)
- Install the CH340 USB Serial driver https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all
- Extract
BenesArduinoLibraries-master.zip
to/User/$USER$/Documents/Aduino/libraries
- Open the Arduino IDE and add the ESP32 board configuration. For this you need to add the following URL to the settings tag:
https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
. For additional information please have a look in this tutorial - Once done, open the Board manager and add the
ESP32
version 2.0.3 - Unzip the folder
UC2-REST
and open the file/ESP32/main/main.ino
- Select the board, the port and hit the compile and upload button
- IMPORTANT when setting up the build + upload, make sure you add this setting for the partition scheme (and potentially all others if not already set as default):
The system accepts different hardware configurations (pins, devices, etc.). All of this is defined in the pindef_XXXX.h
. Please have a look in the UC2-REST repository for additional information: https://github.com/openUC2/UC2-REST