From 2e4b24df10724a5185a1c1eb6ad081dbab0b731a Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 4 Apr 2023 14:36:45 +0200 Subject: [PATCH 1/2] feat: untra son config --- IOT/config.ini | 3 +++ IOT/platformio.ini | 1 + 2 files changed, 4 insertions(+) diff --git a/IOT/config.ini b/IOT/config.ini index 11acf53..17d9e3f 100644 --- a/IOT/config.ini +++ b/IOT/config.ini @@ -16,5 +16,8 @@ build_flags = -D API_HOST=\"iot.epi.cb85.software\" + -D ULTRA_SOUND_TRIGD=12 + -D ULTRA_SOUND_ECHO=13 + -D EXAMPLE_NUMBER=69 diff --git a/IOT/platformio.ini b/IOT/platformio.ini index c06a691..494606e 100644 --- a/IOT/platformio.ini +++ b/IOT/platformio.ini @@ -38,6 +38,7 @@ monitor_flags = lib_deps = bportaluri/WiFiEsp@^2.2.2 ; gestion des commande 'AT' de l'esp01 arduino-libraries/Arduino_JSON@^0.2.0 ; gestion des json + ericksimoes/Ultrasonic@^3.0.0 ; lib capteur ultra son ; example: ; erropix/ESP32 AnalogWrite@^0.2 -- 2.47.1 From 7b5d4a071b8e7853053b988a4a05d70ff8605793 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 4 Apr 2023 15:37:55 +0200 Subject: [PATCH 2/2] feat: add ultrasonic sensor and exemple --- IOT/include/Program.h | 9 +++++++++ IOT/src/Program.cpp | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/IOT/include/Program.h b/IOT/include/Program.h index 53a6189..03e3115 100644 --- a/IOT/include/Program.h +++ b/IOT/include/Program.h @@ -1,6 +1,9 @@ #ifndef PROGRAM_H #define PROGRAM_H +#include +#include + class Program{ public: /** @@ -17,5 +20,11 @@ public: private: /* data */ + + /** + * @brief capteur ultra son pour le niveau de remplissage de la poubelle + * + */ + Ultrasonic *ultrasonic; }; #endif \ No newline at end of file diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 952be1b..1f87003 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -1,10 +1,18 @@ #include "Program.h" +int distance; + + Program::Program(){ - + Serial.begin(MONITOR_SPEED); + this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO); } void Program::loop(){ - + distance = this->ultrasonic->read(); + + Serial.print("Distance in CM: "); + Serial.println(distance); + delay(1000); } \ No newline at end of file -- 2.47.1