feat: capteur_balance #35
@ -3,7 +3,9 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Ultrasonic.h>
|
||||
|
||||
#include "API.h"
|
||||
#include "Balance.h"
|
||||
|
||||
class Program{
|
||||
public:
|
||||
@ -28,6 +30,13 @@ private:
|
||||
*/
|
||||
Ultrasonic *ultrasonic;
|
||||
|
||||
/**
|
||||
* @brief capteur poid pour le niveau de remplissage de la poubelle
|
||||
*
|
||||
*/
|
||||
Balance *balance;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Réference de l'API pour les calls
|
||||
*
|
||||
|
@ -4,18 +4,30 @@ int distance;
|
||||
|
||||
|
||||
Program::Program(){
|
||||
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);
|
||||
Serial1.begin(MONITOR_SPEED);
|
||||
this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO);
|
||||
this->balance = new Balance(POID_DOUT,POID_SCK);
|
||||
///////INITIALISATION OK//////
|
||||
|
||||
this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
||||
|
||||
Serial.begin(MONITOR_SPEED);
|
||||
this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO);
|
||||
Serial.print("start calibr : ");
|
||||
this->balance->initCalibration();
|
||||
Serial.println("OK");
|
||||
|
||||
this->balance->setCalibrationFact(1077);
|
||||
}
|
||||
|
||||
void Program::loop(){
|
||||
distance = this->ultrasonic->read();
|
||||
|
||||
this->api->sendValue(JSONVar::stringify(distance), TRASHCAN_ONE, "W", false);
|
||||
|
||||
//this->api->sendValue(JSONVar::stringify(distance), TRASHCAN_ONE, "W", false); //TODO: faire estimation poubelle plenne
|
||||
this->api->sendValue(this->balance->getValue(), TRASHCAN_TWO, ,false)
|
||||
Serial.print("Distance in CM: ");
|
||||
Serial.println(distance);
|
||||
delay(10000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user