From 4cafc40d614e5ee1bd7afdd6a85f5bc7835bf96c Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 10:40:02 +0200 Subject: [PATCH 01/35] =?UTF-8?q?feat:=20cr=C3=A9ation=20classe=20abstrait?= =?UTF-8?q?e=20capteur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IOT/lib/Capteur/include/Capteur.h | 65 +++++++++++++++++++++++++++++++ IOT/lib/Capteur/src/Capteur.cpp | 17 ++++++++ 2 files changed, 82 insertions(+) create mode 100644 IOT/lib/Capteur/include/Capteur.h create mode 100644 IOT/lib/Capteur/src/Capteur.cpp diff --git a/IOT/lib/Capteur/include/Capteur.h b/IOT/lib/Capteur/include/Capteur.h new file mode 100644 index 0000000..b1a9333 --- /dev/null +++ b/IOT/lib/Capteur/include/Capteur.h @@ -0,0 +1,65 @@ +#ifndef CAPTEUR_H +#define CAPTEUR_H + +#include + +class Capteur{ +public: + + +/** + * @brief Construct a new Capteur object + * + * @param[in] type type de mesure lue (T/H, W, D,...) + * @param[in] fullVal valeur a la quel la poubelle est considéré comme pleine + */ +Capteur(String type, String fullVal); + +/** + * @brief tar le capteur si il a besoins d'être tarré + * + * @param[in] val *opt* si le capteur a besoins d'une valeur de ref pour être tarré + * @return true si la tarre a bien réussi (ou si il n'a pas besoins de tarre) + * @return false erreur durrant la tar + */ +virtual bool tar(int val = 0); + +/** + * @brief lit la valeur du capteur + * + * @return String retour la valeur avec l'unité + */ +virtual String read() = 0; + +/** + * @brief revoie la valeur full + * + * @return true la poubelle est pleine + * @return false la poubelle n'est pas pleine + */ +bool isFull(); + +protected: + +/** + * @brief la poubelle est pleinne + * est mis a jours par read() + */ +bool full; + +/** + * @brief type de mesure lue (T/H, W, D,...) + * + */ +String type; + +/** + * @brief valeur a la quel la poubelle est considéré comme pleine + * + */ +String fullVall; + +}; + + +#endif // CAPTEUR_H diff --git a/IOT/lib/Capteur/src/Capteur.cpp b/IOT/lib/Capteur/src/Capteur.cpp new file mode 100644 index 0000000..0bb35d3 --- /dev/null +++ b/IOT/lib/Capteur/src/Capteur.cpp @@ -0,0 +1,17 @@ +#include "../include/Capteur.h" + + + +Capteur::Capteur(String type, String fullVall){ + this->type = type; + this->fullVall = fullVall; +} + +bool Capteur::tar(int val){ + return true; +} + + +bool Capteur::isFull(){ + return this->full; +} \ No newline at end of file -- 2.47.1 From 5b7f0f3d3e6add8805ed925f3d77a801a2187baf Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 10:45:12 +0200 Subject: [PATCH 02/35] refacto: main --- IOT/src/Program.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 710d302..bf73cd5 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -1,19 +1,21 @@ #include "Program.h" -int distance; - Program::Program(){ - this->api = new API(USER_NAME, USER_PASSWORD, API_HOST); + ////////SERIALS////// Serial1.begin(MONITOR_SPEED); + Serial.begin(MONITOR_SPEED); + + ////////API/////// + this->api = new API(USER_NAME, USER_PASSWORD, API_HOST); this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1); - Serial.begin(MONITOR_SPEED); + //////CAPTEUR///// this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO); } void Program::loop(){ - distance = this->ultrasonic->read(); + int distance = this->ultrasonic->read(); this->api->sendValue(JSONVar::stringify(distance), TRASHCAN_ONE, "W", false); Serial.print("Distance in CM: "); -- 2.47.1 From e8b420f3f755aecdff3e9a1c9444633c7fc47e78 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 11:07:18 +0200 Subject: [PATCH 03/35] fix: typo --- IOT/lib/Capteur/include/Capteur.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/lib/Capteur/include/Capteur.h b/IOT/lib/Capteur/include/Capteur.h index b1a9333..4bb52c3 100644 --- a/IOT/lib/Capteur/include/Capteur.h +++ b/IOT/lib/Capteur/include/Capteur.h @@ -27,7 +27,7 @@ virtual bool tar(int val = 0); /** * @brief lit la valeur du capteur * - * @return String retour la valeur avec l'unité + * @return String retour la valeur */ virtual String read() = 0; -- 2.47.1 From aed8706921a3cab04d234be9b2b1726d6b9adb5e Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 11:07:38 +0200 Subject: [PATCH 04/35] feat: implemente ultrasond in Capteur --- IOT/lib/Capteur/include/Ultrason.h | 38 ++++++++++++++++++++++++++++++ IOT/lib/Capteur/src/Ultrason.cpp | 19 +++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 IOT/lib/Capteur/include/Ultrason.h create mode 100644 IOT/lib/Capteur/src/Ultrason.cpp diff --git a/IOT/lib/Capteur/include/Ultrason.h b/IOT/lib/Capteur/include/Ultrason.h new file mode 100644 index 0000000..186803c --- /dev/null +++ b/IOT/lib/Capteur/include/Ultrason.h @@ -0,0 +1,38 @@ +#ifndef ULTRASON_H +#define ULTRASON_H + +#include +#include + +#include "Capteur.h" + +class Ultrason: public Capteur{ +public: + + /** + * @brief Construct a new Ultrason object + * + * @param trigeur pin trigeur du capteur ultra son + * @param echo pin echo du capteur ultra son + * @param fullVall valeur a la quel la poubelle est pleine + */ + Ultrason(int trigeur, int echo, String fullVall); + + /** + * @brief lit la valeur du capteur ultra son + * + * @return String retour la valeur + */ + String read(); + +private: + + /** + * @brief capteur utiliser ultrason utiliser pour la mesure + * + */ + Ultrasonic* capteur; +}; + + +#endif // ULTRASON_H diff --git a/IOT/lib/Capteur/src/Ultrason.cpp b/IOT/lib/Capteur/src/Ultrason.cpp new file mode 100644 index 0000000..2ade553 --- /dev/null +++ b/IOT/lib/Capteur/src/Ultrason.cpp @@ -0,0 +1,19 @@ +#include "../include/Ultrason.h" + + + +Ultrason::Ultrason(int trigeur, int echo, String fullVall): + Capteur("D",fullVall){ + this->capteur = new Ultrasonic(trigeur, echo); +} + +String Ultrason::read(){ + int sortie = this->capteur->read(); + if (sortie > this->fullVall.toInt()) + { + this->full = true; + }else{ + this->full = false; + } + return String(sortie); +} \ No newline at end of file -- 2.47.1 From a533973e9c4208d9eff25a80bb5b02c43c614ad7 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 11:27:21 +0200 Subject: [PATCH 05/35] fix: revert full/empty --- IOT/lib/Capteur/src/Ultrason.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/lib/Capteur/src/Ultrason.cpp b/IOT/lib/Capteur/src/Ultrason.cpp index 2ade553..cd25d41 100644 --- a/IOT/lib/Capteur/src/Ultrason.cpp +++ b/IOT/lib/Capteur/src/Ultrason.cpp @@ -9,7 +9,7 @@ Ultrason::Ultrason(int trigeur, int echo, String fullVall): String Ultrason::read(){ int sortie = this->capteur->read(); - if (sortie > this->fullVall.toInt()) + if (sortie < this->fullVall.toInt()) { this->full = true; }else{ -- 2.47.1 From e002adacdd47dd8cb41a827c0c9ddb4e5b3288cb Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 11:27:39 +0200 Subject: [PATCH 06/35] add testing main program --- IOT/include/Program.h | 4 +++- IOT/src/Program.cpp | 15 ++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/IOT/include/Program.h b/IOT/include/Program.h index 549809b..88b39e4 100644 --- a/IOT/include/Program.h +++ b/IOT/include/Program.h @@ -4,6 +4,8 @@ #include #include #include "API.h" +#include "Capteur.h" +#include "Ultrason.h" class Program{ public: @@ -26,7 +28,7 @@ private: * @brief capteur ultra son pour le niveau de remplissage de la poubelle * */ - Ultrasonic *ultrasonic; + Capteur *ultrasonic; /** * @brief Réference de l'API pour les calls diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index bf73cd5..6825d40 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -7,18 +7,19 @@ Program::Program(){ Serial.begin(MONITOR_SPEED); ////////API/////// - this->api = new API(USER_NAME, USER_PASSWORD, API_HOST); - this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1); + //this->api = new API(USER_NAME, USER_PASSWORD, API_HOST); + //this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1); //////CAPTEUR///// - this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO); + this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, String(10));//TODO: mettre la valeur en config } void Program::loop(){ - int distance = this->ultrasonic->read(); + String distance = this->ultrasonic->read(); - this->api->sendValue(JSONVar::stringify(distance), TRASHCAN_ONE, "W", false); + //this->api->sendValue(distance, TRASHCAN_ONE, "W", false); Serial.print("Distance in CM: "); - Serial.println(distance); - delay(10000); + Serial.print(distance); + Serial.println(this->ultrasonic->isFull()); + delay(1000); } \ No newline at end of file -- 2.47.1 From f01844bed8aa9883c8b1a8cc4e0417aed67a650c Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 11:29:18 +0200 Subject: [PATCH 07/35] fix: decommante api --- IOT/src/Program.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 6825d40..203ef8e 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -7,8 +7,8 @@ Program::Program(){ Serial.begin(MONITOR_SPEED); ////////API/////// - //this->api = new API(USER_NAME, USER_PASSWORD, API_HOST); - //this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1); + this->api = new API(USER_NAME, USER_PASSWORD, API_HOST); + this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1); //////CAPTEUR///// this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, String(10));//TODO: mettre la valeur en config @@ -17,7 +17,7 @@ Program::Program(){ void Program::loop(){ String distance = this->ultrasonic->read(); - //this->api->sendValue(distance, TRASHCAN_ONE, "W", false); + this->api->sendValue(distance, TRASHCAN_ONE, "D", this->ultrasonic->isFull()); Serial.print("Distance in CM: "); Serial.print(distance); Serial.println(this->ultrasonic->isFull()); -- 2.47.1 From db3ce5025b9887f83a1656a7745c74df659c4c7d Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 11:32:26 +0200 Subject: [PATCH 08/35] feat: add getType --- IOT/lib/Capteur/include/Capteur.h | 2 ++ IOT/lib/Capteur/src/Capteur.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/IOT/lib/Capteur/include/Capteur.h b/IOT/lib/Capteur/include/Capteur.h index 4bb52c3..b4d282a 100644 --- a/IOT/lib/Capteur/include/Capteur.h +++ b/IOT/lib/Capteur/include/Capteur.h @@ -39,6 +39,8 @@ virtual String read() = 0; */ bool isFull(); +String getValType(); + protected: /** diff --git a/IOT/lib/Capteur/src/Capteur.cpp b/IOT/lib/Capteur/src/Capteur.cpp index 0bb35d3..dd14148 100644 --- a/IOT/lib/Capteur/src/Capteur.cpp +++ b/IOT/lib/Capteur/src/Capteur.cpp @@ -14,4 +14,9 @@ bool Capteur::tar(int val){ bool Capteur::isFull(){ return this->full; +} + + +String Capteur::getValType(){ + return this->type; } \ No newline at end of file -- 2.47.1 From 7b0d866d6f4f0f895013c6196dbf4b3b615355e0 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 11:34:11 +0200 Subject: [PATCH 09/35] feat: use getvaltype in main program --- IOT/src/Program.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 203ef8e..b881d85 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -17,7 +17,7 @@ Program::Program(){ void Program::loop(){ String distance = this->ultrasonic->read(); - this->api->sendValue(distance, TRASHCAN_ONE, "D", this->ultrasonic->isFull()); + this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull()); Serial.print("Distance in CM: "); Serial.print(distance); Serial.println(this->ultrasonic->isFull()); -- 2.47.1 From cc583d0947251f0e9489ac58609d47abbf6479cd Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 13:44:07 +0200 Subject: [PATCH 10/35] add todo --- IOT/lib/Capteur/src/Ultrason.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/lib/Capteur/src/Ultrason.cpp b/IOT/lib/Capteur/src/Ultrason.cpp index cd25d41..3154f0e 100644 --- a/IOT/lib/Capteur/src/Ultrason.cpp +++ b/IOT/lib/Capteur/src/Ultrason.cpp @@ -16,4 +16,4 @@ String Ultrason::read(){ this->full = false; } return String(sortie); -} \ No newline at end of file +}//TODO: faire en sorte que full se reset avec une autre val \ No newline at end of file -- 2.47.1 From d67e4a9da815559eba2a85e5b960b713662c44bf Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 13:44:41 +0200 Subject: [PATCH 11/35] add humitemp class for DHT capteur --- IOT/lib/Capteur/include/HumiTemp.h | 34 ++++++++++++++++++++++++++++++ IOT/lib/Capteur/src/HumiTemp.cpp | 27 ++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 IOT/lib/Capteur/include/HumiTemp.h create mode 100644 IOT/lib/Capteur/src/HumiTemp.cpp diff --git a/IOT/lib/Capteur/include/HumiTemp.h b/IOT/lib/Capteur/include/HumiTemp.h new file mode 100644 index 0000000..71a8632 --- /dev/null +++ b/IOT/lib/Capteur/include/HumiTemp.h @@ -0,0 +1,34 @@ +#ifndef HUMI_TEMP_H +#define HUMI_TEMP_H + +#include +#include +#include "Capteur.h" + +class HumiTemp : public Capteur{ + +public: + + /** + * @brief Construct a new Humi Temp object + * + * @param pin pin du capteur dht + * @param type type de capteur dht (11,22,...) + * @param fullVal valeur au quel la poubelle est considéré comme pleinne + */ + HumiTemp(int pin, String type, String fullVall); + + /** + * @brief lit le capteur d'humi/temp + * + * @return String valeur format "XX/YY" X% et Y°C + */ + String read(); +private: + + DHT* capteur; + +}; + + +#endif //HUMI_TEMP_H \ No newline at end of file diff --git a/IOT/lib/Capteur/src/HumiTemp.cpp b/IOT/lib/Capteur/src/HumiTemp.cpp new file mode 100644 index 0000000..65e0ac3 --- /dev/null +++ b/IOT/lib/Capteur/src/HumiTemp.cpp @@ -0,0 +1,27 @@ +#include "../include/HumiTemp.h" + + +HumiTemp::HumiTemp(int pin, String type, String fullVall): + Capteur("H/T",fullVall){ + this->capteur = new DHT(pin,type); + this->capteur->begin(); +} + +String HumiTemp::read(){ + String sortie = ""; + int hum = this->capteur->readHumidity(true); + int temp = this->capteur->readTemperature(false,true); + + //valeur pour un élevage d'astico de pèche selon chatGPT + if((temp > 20 && temp < 30) && (hum > 60 && hum < 80)){ + this->full = true + }else{ + this->full = false + } + + sortie += String(hum); + sortie += "/"; + sortie += String(temp); + return sortie; +} +//TODO: faire en soirte qu'il y ai un nombre de cycle pour l'aparition d'asticots (entre 1 et 3 jours) \ No newline at end of file -- 2.47.1 From c89b6d14799414e968dbf55bdc7f6bbe978bb78a Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 13:45:05 +0200 Subject: [PATCH 12/35] typo: ";" --- IOT/lib/Capteur/src/HumiTemp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IOT/lib/Capteur/src/HumiTemp.cpp b/IOT/lib/Capteur/src/HumiTemp.cpp index 65e0ac3..9ddc11c 100644 --- a/IOT/lib/Capteur/src/HumiTemp.cpp +++ b/IOT/lib/Capteur/src/HumiTemp.cpp @@ -14,9 +14,9 @@ String HumiTemp::read(){ //valeur pour un élevage d'astico de pèche selon chatGPT if((temp > 20 && temp < 30) && (hum > 60 && hum < 80)){ - this->full = true + this->full = true; }else{ - this->full = false + this->full = false; } sortie += String(hum); -- 2.47.1 From d8ed35483fc97c605ddcb81d48a504b724aff691 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 13:48:07 +0200 Subject: [PATCH 13/35] add todo --- IOT/lib/Capteur/src/HumiTemp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/lib/Capteur/src/HumiTemp.cpp b/IOT/lib/Capteur/src/HumiTemp.cpp index 9ddc11c..0cde489 100644 --- a/IOT/lib/Capteur/src/HumiTemp.cpp +++ b/IOT/lib/Capteur/src/HumiTemp.cpp @@ -13,7 +13,7 @@ String HumiTemp::read(){ int temp = this->capteur->readTemperature(false,true); //valeur pour un élevage d'astico de pèche selon chatGPT - if((temp > 20 && temp < 30) && (hum > 60 && hum < 80)){ + if((temp > 20 && temp < 30) && (hum > 60 && hum < 80)){//TODO: passer les valeurs en config this->full = true; }else{ this->full = false; -- 2.47.1 From 4f18142cc6aa94bce97bdb3cda018017d2d444a3 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 13:50:07 +0200 Subject: [PATCH 14/35] feat: DHT in main program --- IOT/src/Program.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 856c406..9968d0b 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -12,10 +12,9 @@ Program::Program(){ //////CAPTEUR///// - this->dht = new DHT(DHTPIN, DHTTYPE); - dht->begin(); - this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, String(10));//TODO: mettre la valeur en config + this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, "10");//TODO: mettre la valeur en config + this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80"); } void Program::loop(){ -- 2.47.1 From 4fe37fdf226abbe17022dfb21dfdbdcb894577fa Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 13:50:16 +0200 Subject: [PATCH 15/35] dht in main program --- IOT/include/Program.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IOT/include/Program.h b/IOT/include/Program.h index 150a09d..04458d3 100644 --- a/IOT/include/Program.h +++ b/IOT/include/Program.h @@ -7,6 +7,7 @@ #include "API.h" #include "Capteur.h" #include "Ultrason.h" +#include "HumiTemp.h" class Program{ public: @@ -29,7 +30,7 @@ private: * @brief capteur humi/temp * */ - DHT *dht; + Capteur *dht; /** * @brief capteur ultra son pour le niveau de remplissage de la poubelle -- 2.47.1 From edfdc6107fafeab80ec8152d8fcc2291910c0add Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 13:51:56 +0200 Subject: [PATCH 16/35] add reading in main program --- IOT/src/Program.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 9968d0b..658577d 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -14,7 +14,7 @@ Program::Program(){ //////CAPTEUR///// this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, "10");//TODO: mettre la valeur en config - this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80"); + this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config } void Program::loop(){ @@ -22,12 +22,12 @@ void Program::loop(){ //TODO: envoyer les infos des capteur par la suite - Serial.println("Temperature = " + String(dht->readTemperature())+" °C"); - Serial.println("Humidite = " + String(dht->readHumidity())+" %"); + Serial.println("humiTemp = " + this->dht->read()); //this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull()); Serial.print("Distance in CM: "); Serial.print(distance); Serial.println(this->ultrasonic->isFull()?" true":" false"); + delay(1000); } \ No newline at end of file -- 2.47.1 From 7574061becf5b2be53280cdcf16911fe6e43bf4a Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 17:25:03 +0200 Subject: [PATCH 17/35] feat : gestion Capteur DJT (a tester) --- IOT/lib/Capteur/include/HumiTemp.h | 1 + IOT/lib/Capteur/src/HumiTemp.cpp | 3 +-- IOT/src/Program.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/IOT/lib/Capteur/include/HumiTemp.h b/IOT/lib/Capteur/include/HumiTemp.h index 71a8632..d94473a 100644 --- a/IOT/lib/Capteur/include/HumiTemp.h +++ b/IOT/lib/Capteur/include/HumiTemp.h @@ -24,6 +24,7 @@ public: * @return String valeur format "XX/YY" X% et Y°C */ String read(); + private: DHT* capteur; diff --git a/IOT/lib/Capteur/src/HumiTemp.cpp b/IOT/lib/Capteur/src/HumiTemp.cpp index 0cde489..10fbd56 100644 --- a/IOT/lib/Capteur/src/HumiTemp.cpp +++ b/IOT/lib/Capteur/src/HumiTemp.cpp @@ -1,9 +1,8 @@ #include "../include/HumiTemp.h" - HumiTemp::HumiTemp(int pin, String type, String fullVall): Capteur("H/T",fullVall){ - this->capteur = new DHT(pin,type); + this->capteur = new DHT(pin, type.c_str()); this->capteur->begin(); } diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 658577d..ff791af 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -19,15 +19,15 @@ Program::Program(){ void Program::loop(){ String distance = this->ultrasonic->read(); - - //TODO: envoyer les infos des capteur par la suite - - Serial.println("humiTemp = " + this->dht->read()); + String humitemp = this->dht->read(); //this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull()); - Serial.print("Distance in CM: "); - Serial.print(distance); + Serial.print("Distance in CM = " + distance); Serial.println(this->ultrasonic->isFull()?" true":" false"); + //this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull()); + Serial.print("humiTemp = " + this->dht->read()); + Serial.println(this->dht->isFull()?" true":" false"); + delay(1000); } \ No newline at end of file -- 2.47.1 From 84cd9912c94bbc22ba4d3c3dbf9972e23aaf3631 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 19:32:42 +0200 Subject: [PATCH 18/35] add todo to main program --- IOT/src/Program.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index d92eab6..63f0dfc 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -15,6 +15,7 @@ Program::Program(){ this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, "10");//TODO: mettre la valeur en config this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config + //TODO: init balance } void Program::loop(){ @@ -29,5 +30,7 @@ void Program::loop(){ Serial.print("humiTemp = " + this->dht->read()); Serial.println(this->dht->isFull()?" true":" false"); + //TODO: Lire balance + delay(1000); } \ No newline at end of file -- 2.47.1 From 493e571e321e10a10631f82ef4fc22ab963cf04a Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 20:14:57 +0200 Subject: [PATCH 19/35] WIP refactor classe balance --- .../{Balance => Capteur}/include/Balance.h | 53 +++++++++---------- IOT/lib/{Balance => Capteur}/src/Balance.cpp | 0 IOT/src/Program.cpp | 1 + 3 files changed, 25 insertions(+), 29 deletions(-) rename IOT/lib/{Balance => Capteur}/include/Balance.h (66%) rename IOT/lib/{Balance => Capteur}/src/Balance.cpp (100%) diff --git a/IOT/lib/Balance/include/Balance.h b/IOT/lib/Capteur/include/Balance.h similarity index 66% rename from IOT/lib/Balance/include/Balance.h rename to IOT/lib/Capteur/include/Balance.h index ad5ef1f..9d98c77 100644 --- a/IOT/lib/Balance/include/Balance.h +++ b/IOT/lib/Capteur/include/Balance.h @@ -3,36 +3,27 @@ #include #include -class Balance { +#include "Capteur.h" + +class Balance: public Capteur{ public: /** * @brief constructeur * - * @param doutPin : pin DOUT du module HX711 - * - * @param sckPin : pin horloge du module HX711 - * - * @param poidsRef : valeur de poids posée sur la balance ref en grammes - */ - Balance(int doutPin, int sckPin); + * @param[in] doutPin : pin DOUT du module HX711 + * @param[in] sckPin : pin horloge du module HX711 + * @param[in] fullVall : valeur a la quel la poubelle est pleine + */ + Balance(int doutPin, int sckPin, String fullVall); /** - * @brief determine le poids - * - * @return poids (double) - */ - double getValue(); - - /** - * @brief determine la moyenne poids - * - * @param nbMesure : nombre de mesure effectues pour la moyenne - * - * @return moyenne poids (double) - */ - double getAverage(int nbMesure); + * @brief lit la valeur du capteur de poid + * + * @return String retour la valeur + */ + String read(); /** * @brief tare et scale a 0, et recuperation de la valeur brut du plateau @@ -49,12 +40,21 @@ public: */ boolean calibration(int poidsRef,int moyenne_calibration); - //TODO: faire doc setCalibration fact + /** + * @brief Set the Calibration Fact object + * + * @param caliFact facteur de calibration calculer par calibration + */ void setCalibrationFact(int caliFact); - + //XXX: finir implémentation classe capteur private: + /** + * @brief Variable issue de la librairie HX711 qui permet d'utiliser les fonctions de celle-ci + */ + HX711 scale; + /** * @brief true = calibration et false = erreur */ @@ -65,11 +65,6 @@ private: */ int calibrationFact; - /** - * @brief Variable issue de la librairie HX711 qui permet d'utiliser les fonctions de celle-ci - */ - HX711 scale; - /** * @brief Valeur moyenne brute du poids sans rien sur la balance juste le plexiglas */ diff --git a/IOT/lib/Balance/src/Balance.cpp b/IOT/lib/Capteur/src/Balance.cpp similarity index 100% rename from IOT/lib/Balance/src/Balance.cpp rename to IOT/lib/Capteur/src/Balance.cpp diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 63f0dfc..6dc6238 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -16,6 +16,7 @@ Program::Program(){ this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config //TODO: init balance + //calibration factor : 1077 } void Program::loop(){ -- 2.47.1 From 8477942be82cf88a5f9fe2678e6e9ac5793fb93c Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 21:52:59 +0200 Subject: [PATCH 20/35] fix main --- IOT/src/main.cpp | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/IOT/src/main.cpp b/IOT/src/main.cpp index b403c05..2ab92c1 100644 --- a/IOT/src/main.cpp +++ b/IOT/src/main.cpp @@ -1,47 +1,15 @@ #ifndef TESTING #include -// #include "Program.h" +#include "Program.h" -// Program* program; - -// void setup() { -// program = new Program(); -// } - -// void loop() { -// program->loop(); -// } - - -#include "Balance.h" - -Balance *balance; - -void setup(){ - Serial.begin(MONITOR_SPEED); - balance = new Balance(14,15); - - Serial.print("start calibr : "); - balance->initCalibration(); - - Serial.println("OK"); - - // Serial.print("posé poids"); - // delay(5000); - // Serial.println("OK"); - // balance->calibration(500, MOYENNE_CALIBRATION); - // Serial.println("END calibration"); - - balance->setCalibrationFact(1077); +Program* program; void setup() { - program = new Program(); + program = new Program(); } -void loop(){ - // delay(500); - Serial.println(balance->getValue()); +void loop() { + program->loop(); } - #endif \ No newline at end of file -- 2.47.1 From 2b318c00f91cb49b6b9487cd90ff6a6ff6a52a91 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 22:00:51 +0200 Subject: [PATCH 21/35] fix: add api adresse --- IOT/config.ini | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/IOT/config.ini b/IOT/config.ini index 1a4201b..990649b 100644 --- a/IOT/config.ini +++ b/IOT/config.ini @@ -28,11 +28,10 @@ build_flags = -D POID_DOUT=14 -D POID_SCK=15 - -D MOYENNE_CALIBRATION=20 - - ; trash can ID -D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\" -D TRASHCAN_TWO=\"4brip5fwm001bs9\" + -D API_HOST=\"iot.epi.cb85.software\" + -- 2.47.1 From e939ee757da01b117a980cd0920b140cfedfbeb4 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 22:01:10 +0200 Subject: [PATCH 22/35] refactor: balance lib --- IOT/lib/Capteur/include/Balance.h | 2 +- IOT/lib/Capteur/src/Balance.cpp | 42 +++++++++++++------------------ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/IOT/lib/Capteur/include/Balance.h b/IOT/lib/Capteur/include/Balance.h index 9d98c77..7b95342 100644 --- a/IOT/lib/Capteur/include/Balance.h +++ b/IOT/lib/Capteur/include/Balance.h @@ -53,7 +53,7 @@ private: /** * @brief Variable issue de la librairie HX711 qui permet d'utiliser les fonctions de celle-ci */ - HX711 scale; + HX711* capteur; /** * @brief true = calibration et false = erreur diff --git a/IOT/lib/Capteur/src/Balance.cpp b/IOT/lib/Capteur/src/Balance.cpp index 9858416..07721ae 100644 --- a/IOT/lib/Capteur/src/Balance.cpp +++ b/IOT/lib/Capteur/src/Balance.cpp @@ -1,20 +1,23 @@ #include "../include/Balance.h" -Balance::Balance(int doutPin, int sckPin) { +Balance::Balance(int doutPin, int sckPin, String fullVall): + Capteur("W", fullVall){ - scale.begin(doutPin, sckPin); + this->capteur = new HX711(); + this->capteur->begin(doutPin, sckPin); this->initialized = false; - scale.set_scale(); - scale.tare(); + this->capteur->set_scale(); + this->capteur->tare(); this->initialVal = 0; this->calibrationFact = 0; + this->initCalibration(); } boolean Balance::initCalibration() { - scale.set_scale(); - scale.tare(); - this->initialVal = scale.read_average(20); + this->capteur->set_scale(); + this->capteur->tare(); + this->initialVal = this->capteur->read_average(20); return true; } @@ -23,11 +26,11 @@ boolean Balance::calibration(int poidsRef,int moyenne_calibration) { int rawValref = 0; // Valeur brute de plexiglas et poids réf int tempPoids = 0; // C'est la valeur du poids en grammes calculée grâce au facteur de calibration - rawValref = scale.read_average(moyenne_calibration); + rawValref = this->capteur->read_average(moyenne_calibration); this->calibrationFact = (rawValref - this->initialVal) / poidsRef; do { - scale.set_scale(calibrationFact); - tempPoids = scale.get_units(5); + this->capteur->set_scale(calibrationFact); + tempPoids = this->capteur->get_units(5); if (tempPoids < poidsRef) { calibrationFact -= 1; } else if (tempPoids > poidsRef) { @@ -37,26 +40,17 @@ boolean Balance::calibration(int poidsRef,int moyenne_calibration) { return initialized = true; } -double Balance::getAverage(int nbMesure) { +String Balance::read() { - if (initialized == true) { - return scale.get_units(nbMesure); + if (this->initialized == true) { + return String(this->capteur->get_units()); } else { - return 0; - } -} - -double Balance::getValue() { - - if (initialized == true) { - return scale.get_units(); - } else { - return 0; + return "0"; } } void Balance::setCalibrationFact(int caliFact){ this->initialized = true; this->calibrationFact = caliFact; - scale.set_scale(caliFact); + this->capteur->set_scale(caliFact); } -- 2.47.1 From 36dd744da5048bcf25ffc3193477f452df4bf8a8 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 22:01:20 +0200 Subject: [PATCH 23/35] add balance to main program --- IOT/include/Program.h | 4 +--- IOT/src/Program.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/IOT/include/Program.h b/IOT/include/Program.h index 94947e1..075a386 100644 --- a/IOT/include/Program.h +++ b/IOT/include/Program.h @@ -44,9 +44,7 @@ private: * @brief capteur poid pour le niveau de remplissage de la poubelle * */ - Balance *balance; - -//TODO chagé type to capteur + Capteur *balance; /** * @brief Réference de l'API pour les calls diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 6dc6238..fc5618d 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -14,14 +14,14 @@ Program::Program(){ //////CAPTEUR///// this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, "10");//TODO: mettre la valeur en config this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config - - //TODO: init balance - //calibration factor : 1077 + this->balance = new Balance(POID_DOUT,POID_SCK,"500");//TODO: mettre la valter en donfig + this->balance->tar(1077); } void Program::loop(){ String distance = this->ultrasonic->read(); String humitemp = this->dht->read(); + String poid = this->balance->read(); //this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull()); Serial.print("Distance in CM = " + distance); @@ -32,6 +32,9 @@ void Program::loop(){ Serial.println(this->dht->isFull()?" true":" false"); //TODO: Lire balance + //this->api->sendValue(poid, TRASHCAN_TWO, this->balance->getValType(), this->balance->isFull()); + Serial.print("humiTemp = " + this->dht->read()); + Serial.println(this->dht->isFull()?" true":" false"); delay(1000); } \ No newline at end of file -- 2.47.1 From d69dc54f485243a29d4568e4b2e3433f1d980b11 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 22:11:53 +0200 Subject: [PATCH 24/35] fix: indent --- IOT/lib/Capteur/include/Capteur.h | 88 +++++++++++++++---------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/IOT/lib/Capteur/include/Capteur.h b/IOT/lib/Capteur/include/Capteur.h index b4d282a..5a701cc 100644 --- a/IOT/lib/Capteur/include/Capteur.h +++ b/IOT/lib/Capteur/include/Capteur.h @@ -7,59 +7,59 @@ class Capteur{ public: -/** - * @brief Construct a new Capteur object - * - * @param[in] type type de mesure lue (T/H, W, D,...) - * @param[in] fullVal valeur a la quel la poubelle est considéré comme pleine - */ -Capteur(String type, String fullVal); + /** + * @brief Construct a new Capteur object + * + * @param[in] type type de mesure lue (T/H, W, D,...) + * @param[in] fullVal valeur a la quel la poubelle est considéré comme pleine + */ + Capteur(String type, String fullVal); -/** - * @brief tar le capteur si il a besoins d'être tarré - * - * @param[in] val *opt* si le capteur a besoins d'une valeur de ref pour être tarré - * @return true si la tarre a bien réussi (ou si il n'a pas besoins de tarre) - * @return false erreur durrant la tar - */ -virtual bool tar(int val = 0); + /** + * @brief tar le capteur si il a besoins d'être tarré + * + * @param[in] val *opt* si le capteur a besoins d'une valeur de ref pour être tarré + * @return true si la tarre a bien réussi (ou si il n'a pas besoins de tarre) + * @return false erreur durrant la tar + */ + virtual bool tar(int val = 0); -/** - * @brief lit la valeur du capteur - * - * @return String retour la valeur - */ -virtual String read() = 0; + /** + * @brief lit la valeur du capteur + * + * @return String retour la valeur + */ + virtual String read() = 0; -/** - * @brief revoie la valeur full - * - * @return true la poubelle est pleine - * @return false la poubelle n'est pas pleine - */ -bool isFull(); + /** + * @brief revoie la valeur full + * + * @return true la poubelle est pleine + * @return false la poubelle n'est pas pleine + */ + bool isFull(); -String getValType(); + String getValType(); protected: -/** - * @brief la poubelle est pleinne - * est mis a jours par read() - */ -bool full; + /** + * @brief la poubelle est pleinne + * est mis a jours par read() + */ + bool full; -/** - * @brief type de mesure lue (T/H, W, D,...) - * - */ -String type; + /** + * @brief type de mesure lue (T/H, W, D,...) + * + */ + String type; -/** - * @brief valeur a la quel la poubelle est considéré comme pleine - * - */ -String fullVall; + /** + * @brief valeur a la quel la poubelle est considéré comme pleine + * + */ + String fullVall; }; -- 2.47.1 From 2b4e0fd9eaf3fa7200aded908018c227ced23c8f Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 22:12:06 +0200 Subject: [PATCH 25/35] fix: rm todo --- IOT/src/Program.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index fc5618d..1443c2f 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -31,7 +31,6 @@ void Program::loop(){ Serial.print("humiTemp = " + this->dht->read()); Serial.println(this->dht->isFull()?" true":" false"); - //TODO: Lire balance //this->api->sendValue(poid, TRASHCAN_TWO, this->balance->getValType(), this->balance->isFull()); Serial.print("humiTemp = " + this->dht->read()); Serial.println(this->dht->isFull()?" true":" false"); -- 2.47.1 From 922d6e85f06e8de2f309ee3b9e8360715173c9c5 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 May 2023 22:12:28 +0200 Subject: [PATCH 26/35] change setCalibrationFact to tar --- IOT/lib/Capteur/include/Balance.h | 9 +++++---- IOT/lib/Capteur/src/Balance.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/IOT/lib/Capteur/include/Balance.h b/IOT/lib/Capteur/include/Balance.h index 7b95342..430b7a6 100644 --- a/IOT/lib/Capteur/include/Balance.h +++ b/IOT/lib/Capteur/include/Balance.h @@ -41,13 +41,14 @@ public: boolean calibration(int poidsRef,int moyenne_calibration); /** - * @brief Set the Calibration Fact object + * @brief tar le capteur de poids * - * @param caliFact facteur de calibration calculer par calibration + * @param[in] val valeur de référence du capteur + * @return true si la tarre a bien réussi (ou si il n'a pas besoins de tarre) + * @return false erreur durrant la tar */ - void setCalibrationFact(int caliFact); + bool tar(int val = 0); - //XXX: finir implémentation classe capteur private: /** diff --git a/IOT/lib/Capteur/src/Balance.cpp b/IOT/lib/Capteur/src/Balance.cpp index 07721ae..23eee99 100644 --- a/IOT/lib/Capteur/src/Balance.cpp +++ b/IOT/lib/Capteur/src/Balance.cpp @@ -49,8 +49,9 @@ String Balance::read() { } } -void Balance::setCalibrationFact(int caliFact){ +bool Balance::tar(int val){ this->initialized = true; - this->calibrationFact = caliFact; - this->capteur->set_scale(caliFact); + this->calibrationFact = val; + this->capteur->set_scale(val); + return this->initialized; } -- 2.47.1 From 107ca935b84f49456ac78361b62ec99b8c527aef Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 10:26:50 +0200 Subject: [PATCH 27/35] add debug poids --- IOT/lib/Capteur/src/Balance.cpp | 7 ++++--- IOT/src/Program.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/IOT/lib/Capteur/src/Balance.cpp b/IOT/lib/Capteur/src/Balance.cpp index 23eee99..2f0f69b 100644 --- a/IOT/lib/Capteur/src/Balance.cpp +++ b/IOT/lib/Capteur/src/Balance.cpp @@ -41,13 +41,14 @@ boolean Balance::calibration(int poidsRef,int moyenne_calibration) { } String Balance::read() { - + int sortie = (int)this->capteur->get_units(); + this->full = sortie > this->fullVall.toInt(); if (this->initialized == true) { - return String(this->capteur->get_units()); + return String(sortie); } else { return "0"; } -} +}//TODO: update isfull bool Balance::tar(int val){ this->initialized = true; diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 1443c2f..6dd0b61 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -14,7 +14,7 @@ Program::Program(){ //////CAPTEUR///// this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, "10");//TODO: mettre la valeur en config this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config - this->balance = new Balance(POID_DOUT,POID_SCK,"500");//TODO: mettre la valter en donfig + this->balance = new Balance(POID_DOUT,POID_SCK,"100");//TODO: mettre la valter en donfig this->balance->tar(1077); } @@ -28,12 +28,14 @@ void Program::loop(){ Serial.println(this->ultrasonic->isFull()?" true":" false"); //this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull()); - Serial.print("humiTemp = " + this->dht->read()); + Serial.print("humiTemp = " + humitemp); Serial.println(this->dht->isFull()?" true":" false"); //this->api->sendValue(poid, TRASHCAN_TWO, this->balance->getValType(), this->balance->isFull()); - Serial.print("humiTemp = " + this->dht->read()); - Serial.println(this->dht->isFull()?" true":" false"); + Serial.print("poid = " + poid); + Serial.println(this->balance->isFull()?" true":" false"); + + Serial.println(); delay(1000); } \ No newline at end of file -- 2.47.1 From 3a45e8e9b568c02024af99c55fca63dc502fe081 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 11:32:51 +0200 Subject: [PATCH 28/35] feat: config cull to config --- IOT/config.ini | 5 +++++ IOT/src/Program.cpp | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/IOT/config.ini b/IOT/config.ini index 990649b..4cffd14 100644 --- a/IOT/config.ini +++ b/IOT/config.ini @@ -35,3 +35,8 @@ build_flags = -D API_HOST=\"iot.epi.cb85.software\" + ;---CAPTEUR FULL CONFIG--- + + -D ULTRA_SOUND_FULL=\"10\" + -D DHT_FULL=\"20:30/60:80\" + -D POID_FULL=\"100\" \ No newline at end of file diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 6dd0b61..cb6b295 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -12,9 +12,9 @@ Program::Program(){ //////CAPTEUR///// - this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, "10");//TODO: mettre la valeur en config - this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config - this->balance = new Balance(POID_DOUT,POID_SCK,"100");//TODO: mettre la valter en donfig + this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, ULTRA_SOUND_FULL); + this->dht = new HumiTemp(DHTPIN, DHTTYPE, DHT_FULL); + this->balance = new Balance(POID_DOUT,POID_SCK, POID_FULL); this->balance->tar(1077); } -- 2.47.1 From a34b4acbc0dddecc4c0f17beb1d6b04686d7a884 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 11:48:03 +0200 Subject: [PATCH 29/35] add 3eme poubelle id --- IOT/config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/config.ini b/IOT/config.ini index 4cffd14..f08cdf3 100644 --- a/IOT/config.ini +++ b/IOT/config.ini @@ -31,7 +31,7 @@ build_flags = ; trash can ID -D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\" -D TRASHCAN_TWO=\"4brip5fwm001bs9\" - + -D TRASHCAN_THREE=\"n4il9ckl5016aqi\" -D API_HOST=\"iot.epi.cb85.software\" -- 2.47.1 From 95aabd89031bd0899a5f4be6b090b90e43a6ed21 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 11:48:42 +0200 Subject: [PATCH 30/35] fix: rm todo --- IOT/lib/Capteur/src/Balance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/lib/Capteur/src/Balance.cpp b/IOT/lib/Capteur/src/Balance.cpp index 2f0f69b..33b2376 100644 --- a/IOT/lib/Capteur/src/Balance.cpp +++ b/IOT/lib/Capteur/src/Balance.cpp @@ -48,7 +48,7 @@ String Balance::read() { } else { return "0"; } -}//TODO: update isfull +} bool Balance::tar(int val){ this->initialized = true; -- 2.47.1 From 19b716aaf2c13fec77e82bad1618701e4c25f736 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 12:01:20 +0200 Subject: [PATCH 31/35] feat: full test ok --- IOT/src/Program.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index cb6b295..b7eb6d1 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -8,7 +8,7 @@ Program::Program(){ ////////API/////// this->api = new API(USER_NAME, USER_PASSWORD, API_HOST); - //this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1); + this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1); //////CAPTEUR///// @@ -23,15 +23,15 @@ void Program::loop(){ String humitemp = this->dht->read(); String poid = this->balance->read(); - //this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull()); + this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull()); Serial.print("Distance in CM = " + distance); Serial.println(this->ultrasonic->isFull()?" true":" false"); - //this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull()); + this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull()); Serial.print("humiTemp = " + humitemp); Serial.println(this->dht->isFull()?" true":" false"); - //this->api->sendValue(poid, TRASHCAN_TWO, this->balance->getValType(), this->balance->isFull()); + this->api->sendValue(poid, TRASHCAN_THREE, this->balance->getValType(), this->balance->isFull()); Serial.print("poid = " + poid); Serial.println(this->balance->isFull()?" true":" false"); -- 2.47.1 From 2708df56a61dea36e135de499dcaa019bc505bd6 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 16:55:37 +0200 Subject: [PATCH 32/35] fix typo --- IOT/lib/Capteur/include/Balance.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/lib/Capteur/include/Balance.h b/IOT/lib/Capteur/include/Balance.h index 430b7a6..8481eea 100644 --- a/IOT/lib/Capteur/include/Balance.h +++ b/IOT/lib/Capteur/include/Balance.h @@ -28,7 +28,7 @@ public: /** * @brief tare et scale a 0, et recuperation de la valeur brut du plateau */ - boolean initCalibration(); + bool initCalibration(); /** * @brief initialisation du calibrage -- 2.47.1 From fa43f372797d9c99e62bab7a3d6ad292219c305e Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 16:55:58 +0200 Subject: [PATCH 33/35] fix typo 2 --- IOT/lib/Capteur/include/Balance.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/lib/Capteur/include/Balance.h b/IOT/lib/Capteur/include/Balance.h index 8481eea..c53f70a 100644 --- a/IOT/lib/Capteur/include/Balance.h +++ b/IOT/lib/Capteur/include/Balance.h @@ -38,7 +38,7 @@ public: * * @return renvoi un true si calibration bien effectue */ - boolean calibration(int poidsRef,int moyenne_calibration); + bool calibration(int poidsRef,int moyenne_calibration); /** * @brief tar le capteur de poids -- 2.47.1 From e4cf250092af5bc1267722f6b6e98f29123022af Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 16:58:19 +0200 Subject: [PATCH 34/35] fix typo --- IOT/lib/Capteur/include/Balance.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOT/lib/Capteur/include/Balance.h b/IOT/lib/Capteur/include/Balance.h index c53f70a..dc7c2ec 100644 --- a/IOT/lib/Capteur/include/Balance.h +++ b/IOT/lib/Capteur/include/Balance.h @@ -59,7 +59,7 @@ private: /** * @brief true = calibration et false = erreur */ - boolean initialized; + bool initialized; /** * @brief Facteur de calibration obtenu par : (val brute poids ref - val brute poids plexiglas)/ poids ref -- 2.47.1 From 79d5ecde9e2191ff8f5ff5038510071f6888e2ac Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 9 May 2023 17:06:20 +0200 Subject: [PATCH 35/35] docs: update class diagram --- IOT/docs/diagram/class.puml | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/IOT/docs/diagram/class.puml b/IOT/docs/diagram/class.puml index 4073667..36bc169 100644 --- a/IOT/docs/diagram/class.puml +++ b/IOT/docs/diagram/class.puml @@ -18,7 +18,49 @@ Class Program { + setup() } +abstract Class Capteur { + # full: bool + # type: String + # fullVall: String + + Capteur(type: String, fullVal: String) + + {abstract} tar(val: int): bool + + {abstract} read(): String = 0 + + isFull(): bool + + getValType(): String +} +class Balance{ + - capteur: HX711* + - initialized: bool + - calibrationFact: int + - initialVal: long + + Balance(doutPin: int, sck: int, fullVal:String) + + read(): String + + initCalibration(): bool + + calibration(poidsRef: int, moyenneCalibration: int): bool + + tar(val: int = 0): bool +} + +class Ultrason{ + - capteur: DHT* + + HumiTemp(pin: int, type: String, fullVal: String) + + read(): String +} + +class Ultrason{ + - capteur: Ultrasonic* + + Ultrason(triguer: int, echo: int, fullVal: String) + + read(): String +} + +Balance --|> Capteur +Ultrason --|> Capteur +HumiTemp --|> Capteur + + +Program <-- Balance +Program <-- Ultrason +Program <-- HumiTemp @enduml \ No newline at end of file -- 2.47.1