feat: création classe abstraite capteur #44

Merged
Clement merged 37 commits from refactor/class-abstraite-capteur into master 2023-05-13 10:58:51 +00:00
5 changed files with 31 additions and 6 deletions
Showing only changes of commit 60ec85a572 - Show all commits

2
.gitignore vendored
View File

@ -78,4 +78,4 @@ crashlytics-build.properties
# End of https://www.toptal.com/developers/gitignore/api/unity
IOT/docs/doxygen output/*
IOT/docs/doxygen output/*

View File

@ -14,12 +14,19 @@ build_flags =
-D MONITOR_SPEED=${config.monitor_speed}
; DO NOT TOUCH --- END
-D API_HOST=\"iot.epi.cb85.software\"
; DHT pin and type
; 5v
-D DHTTYPE=\"DHT11\"
-D DHTPIN=2
; ULTRASON pin
; 5v
-D ULTRA_SOUND_TRIGD=12
-D ULTRA_SOUND_ECHO=13
-D EXAMPLE_NUMBER=69
; API host url
-D API_HOST=\"iot.epi.cb85.software\"
; trash can ID
-D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\"

View File

@ -1,6 +1,7 @@
#ifndef PROGRAM_H
#define PROGRAM_H
#include <DHT.h>
#include <Arduino.h>
#include <Ultrasonic.h>
#include "API.h"
@ -24,6 +25,12 @@ public:
private:
/* data */
/**
* @brief capteur humi/temp
*
*/
DHT *dht;
/**
* @brief capteur ultra son pour le niveau de remplissage de la poubelle
*

View File

@ -38,6 +38,8 @@ 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
adafruit/DHT sensor library@^1.4.4 ; DHT11 lib
adafruit/Adafruit Unified Sensor@^1.1.9 ; adafruit sensor lib (required by DHT11)
ericksimoes/Ultrasonic@^3.0.0 ; lib capteur ultra son
; example:
; erropix/ESP32 AnalogWrite@^0.2

View File

@ -8,18 +8,27 @@ 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/////
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
}
void Program::loop(){
String distance = this->ultrasonic->read();
this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull());
//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(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull());
Serial.print("Distance in CM: ");
Serial.print(distance);
Serial.println(this->ultrasonic->isFull());
Serial.println(this->ultrasonic->isFull()?" true":" false");
delay(1000);
}