With your model trained and exported to a C array you're ready to implement it on your Feather Huzzah 32. We'll need to update the software on our ESP32, but the hardware can stay the same. In fact, it is best to leave the thermocouple in the freezer since moving it may affect the results of the machine learning model.
Code
Clone this repo to your computer, or you can download the directory for this project here.
Once you have downloaded the project files, you'll need to create a config.h file and fill in your Adafruit IO and WiFi credentials.
-
In the AIFreezerMonitor folder create a new text file called config.h
Note: You can also copy the config.h file you created for the data collection code.
-
Copy and paste the code below into that that file and save:
/************************ Adafruit IO Config *******************************/ // visit io.adafruit.com if you need to create an account, // or if you need your Adafruit IO key. #define IO_USERNAME "your-username" #define IO_KEY "your-key" /******************************* WIFI **************************************/ #define WIFI_SSID "your-ssid" #define WIFI_PASS "your-password" #include "AdafruitIO_WiFi.h" AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
3. Find your Adafruit IO credentials in the top right corner of the Adafruit IO webpage.
4. Copy and paste them in here between the quotes:
#define IO_USERNAME "your_username" #define IO_KEY "your_key"
Remember to treat your key like a password
5. Next you will need to add the WiFi SSID, or network name, and the password. Note: The code doesn't support WiFi networks that use a captive portal.
#define WIFI_SSID "your_ssid" #define WIFI_PASS "your_pass"
6. Move the model_data.h file you created earlier into the AIFreezerMonitor directory
Flashing your board
-
Follow the first section of this guide to add the ESP32 extension to the Arduino IDE.
-
Install the libraries listed below using Arduino Library Manager. If you haven't used the library manager before, here is a helpful guide.
- Adafruit IO Arduino
- Adafruit MCP9600
- TensorFlowLite_ESP32
Note: If you're prompted to install other dependencies for these libraries, select Install All
3. With FreezerTempAlert.ino open in the Arduino IDE select Tools > Board > ESP32 Arduino > Adafruit ESP32 Feather
4. Select the active COM Port in Tools > Port
5. Press the Upload button
Installing
If you moved the thermocouple to upload the new code, do your best to re-install it in the same place. If the thermocouple is moved too far away from the training position, the ML model may mistake normal operation as an anomaly.
Your IFTTT warning should still be working the same as before, so you don't need to change anything there.
Page last edited March 08, 2024
Text editor powered by tinymce.