#include "DHT.h"
#include "LiquidCrystal.h"
#include "EloquentTinyML.h"
#include <eloquent_tinyml.h>
#include "model.h"
DHT dht(12,DHT22);
Eloquent::TinyML::TensorFlow::TensorFlow<1, 1, 2*1024> tf;
LiquidCrystal lcd(23,22,21,19,18,17);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
dht.begin();
lcd.begin(24, 2);
tf.begin(modelData);
if (!tf.isOk()) {
Serial.print("ERROR: ");
Serial.println(tf.getErrorMessage());
while (true) delay(1000);
}
}
void loop() {
// put your main code here, to run repeatedly:
delay(300);
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor");
lcd.print("Failed to read from DHT sensor");
} else {
lcd.clear();
Serial.print("Temp:");
Serial.print(temperature);
Serial.print(" C ");
Serial.print(" Humi:");
Serial.print(humidity);
float input[] = {temperature, humidity};
float prediction = tf.predict(input);
Serial.print(" Prediction:");
Serial.print(prediction);
Serial.print(" %\n");
if(prediction < 0.5){
lcd.print("Normal");
}
else{
lcd.print("Extreme");
}
}
}