41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
#include "Program.h"
|
|
|
|
int distance;
|
|
|
|
|
|
Program::Program()
|
|
// Serial
|
|
Serial.begin(MONITOR_SPEED); // motitor pour debug
|
|
Serial1.begin(MONITOR_SPEED); // port serie pour l'esp
|
|
|
|
///////INITIALISATION OBJ//////
|
|
this->api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
|
this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO);
|
|
this->balance = new Balance(POID_DOUT,POID_SCK);
|
|
this->dht = new DHT(DHTPIN, DHTTYPE);
|
|
///////INITIALISATION OK//////
|
|
|
|
Serial.print("start calibr : ");
|
|
this->balance->initCalibration();
|
|
this->balance->setCalibrationFact(1077);
|
|
Serial.println("OK");
|
|
|
|
//this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
|
dht->begin();
|
|
}
|
|
|
|
void Program::loop(){
|
|
distance = this->ultrasonic->read();
|
|
|
|
|
|
//TODO: envoyer les infos des capteur par la suite
|
|
|
|
Serial.println("Temperature = " + String(dht->readTemperature())+" °C");
|
|
Serial.println("Humidite = " + String(dht->readHumidity())+" %");
|
|
|
|
//this->api->sendValue(JSONVar::stringify(distance), TRASHCAN_ONE, "W", false); //TODO: faire estimation poubelle plenne
|
|
//this->api->sendValue(this->balance->getValue(), TRASHCAN_TWO, ,false); //TODO: faire estimation poubelle plenne
|
|
Serial.print("Distance in CM: ");
|
|
Serial.println(distance);
|
|
delay(1000);
|
|
} |