#include "DHTesp.h"
#include "LiquidCrystal.h"
#include "cmodel.h"
#include <tflm_esp32.h>
// put tinyml after model is a requirement of the library
#include <eloquent_tinyml.h>
// this is trial-and-error process
// when developing a new model, start with a high value
// (e.g. 10000), then decrease until the model stops
// working as expected
#define ARENA_SIZE 2000
Eloquent::TF::Sequential<TF_NUM_OPS, ARENA_SIZE> tf;
const int DHT_PIN = 2;
DHTesp dhtSensor;
const int rs = 12, en = 11, d4 = 10, d5 = 9, d6 = 8, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int columns = 16;
const int rows = 2;
String temp, humi;
void setup() {
Serial.begin(115200);
delay(3000);
lcd.begin(columns,rows);
lcd.print("Hello ^.^");
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
while (!tf.begin(cmodel).isOk())
Serial.println(tf.exception.toString());
}
void lcdWrite(LiquidCrystal lcd, String msg, String msg2=""){
lcd.clear();
// return cursor to top left
lcd.home();
lcd.print(msg);
if( msg2 != "" ){
lcd.setCursor(0,1);
lcd.print(msg2);
}
}
void loop() {
TempAndHumidity data = dhtSensor.getTempAndHumidity();
temp = "Temp: " + String(data.temperature, 2) + " C";
humi = "Humidity: " + String(data.humidity, 1) + "%";
float x0[2] = ( data.temperature, data.humidity)
while (!tf.predict(x0).isOk())
Serial.println(tf.exception.toString());
Serial.println(tf.classification);
Serial.println(temp);
Serial.println(humi);
lcdWrite(lcd, temp, humi);
Serial.println("---");
delay(1000);
// put your main code here, to run repeatedly:
}