A project to control a peanut, coffee & cocoa roaster with an ESP32
All logic depends on the data given by the Thermocouple & DHT22 sensors, and the selected mode in the 4 Position Rotary Switch. It's intention is to control 3 motors, which will turn on or off based on the temperature that it reaches.
When the temperature reaches 140ºC, 170ºC or 180ºC (depending on the mode) it feeds a relay that controls the first motor, and also starts a timer that can be 12, 20 or 33 minutes which also depends on the mode.
There will be two push buttons, one will add +1min to the time (and start the timer if there isn't one already), and the other will reduce -1min to the time.
When the timer stops, a buzzer starts making noise and also feeds the other 2 relays that controls the second & third motor.
Motors can only be stopped manually by either the security button or through the web interface. If Motor 2 or Motor 3 are stopped via the web interface, they will stop any action taken after the timer stops.
Position | Name | Temperature | Time |
---|---|---|---|
0 | Off | 0ºC | 0m |
1 | Peanut | 180ºC | 20m |
2 | Cocoa | 140ºC | 33m |
3 | Coffee | 170ºC | 12m |
The default state of the switch does not set a timer. Timer response can also be turned off by setting the state of the switch to the position 0 (i.e. the default state.)
The project structure is as follows:
Resource | Description |
---|---|
src/ | The main.cpp file with the code to be uploaded to esp32 |
data/ | Static files written directly to the SPI flash file storage (SPIFFS) |
lib/ | All additional libraries. Core libraries are installed via PlatformIO or written in lib_deps using the platformio.ini file |
server/ | Express server for debugging |
env‑template.h | Environment variables template file used to get the credentials for WiFi & VPN |
platformio.ini | PlatformIO project configuration file |
Use env vars to store your credentials and build the firmware locally.
1 - Run the command: mv src/env-template.h src/env.h
2 - Edit the values
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "PASSWORD"
- ESP32-DEVKIT-V1: ESP32 Microcontroller
- I²C 16x2 LCD Display
- Type K thermocouple: Thermoelectrical thermometer
- MAX6675: Type K thermocouple digital converter
- DHT22: Humidity sensor
- 4 Position Rotary Switch: Mode selector
- Passive Buzzer
- Motor (x3)
- Push button (x2): Time adder/substractor
- Relay (x3)
- 7805 / 7812: Voltage regulators
- Capacitors
- Resistors
The ESP32 also act as a server for controlling the motor states, showing the temperature and humidity with gauges, and showing the remaining time in the timer. The server uses SSE to update the values on the web.
The web interface can read all values, and can only write to the motor states and timer values.
OTA updates are available thanks to ElegantOTA.
Resource | Description |
---|---|
/events | Event Source with readings , timer & states events |
/data | GET - Request to update the temperature & humidity readings, timer remaining time and motors states on the web interface |
/motors | POST - Request to control the state of the motors throught the web interface |
/time | POST - Request to increase or reduce the timer by 60 seconds |
/reset | POST - Request to perform a remote software reset of the ESP32 |
/update | Firmware & Filesystem OTA updates |
TODO: Upload circuit, PCB design, 3D design, Gerber files & ESP32 pinout