feat: création classe abstraite capteur #44
2
.gitignore
vendored
2
.gitignore
vendored
@ -78,4 +78,4 @@ crashlytics-build.properties
|
|||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/unity
|
# End of https://www.toptal.com/developers/gitignore/api/unity
|
||||||
|
|
||||||
IOT/docs/doxygen output/*
|
IOT/docs/doxygen output/*
|
||||||
|
@ -14,12 +14,19 @@ build_flags =
|
|||||||
-D MONITOR_SPEED=${config.monitor_speed}
|
-D MONITOR_SPEED=${config.monitor_speed}
|
||||||
; DO NOT TOUCH --- END
|
; 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_TRIGD=12
|
||||||
-D ULTRA_SOUND_ECHO=13
|
-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\"
|
-D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\"
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef PROGRAM_H
|
#ifndef PROGRAM_H
|
||||||
#define PROGRAM_H
|
#define PROGRAM_H
|
||||||
|
|
||||||
|
#include <DHT.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Ultrasonic.h>
|
#include <Ultrasonic.h>
|
||||||
#include "API.h"
|
#include "API.h"
|
||||||
@ -24,6 +25,12 @@ public:
|
|||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief capteur humi/temp
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
DHT *dht;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief capteur ultra son pour le niveau de remplissage de la poubelle
|
* @brief capteur ultra son pour le niveau de remplissage de la poubelle
|
||||||
*
|
*
|
||||||
|
@ -38,6 +38,8 @@ monitor_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
bportaluri/WiFiEsp@^2.2.2 ; gestion des commande 'AT' de l'esp01
|
bportaluri/WiFiEsp@^2.2.2 ; gestion des commande 'AT' de l'esp01
|
||||||
arduino-libraries/Arduino_JSON@^0.2.0 ; gestion des json
|
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
|
ericksimoes/Ultrasonic@^3.0.0 ; lib capteur ultra son
|
||||||
; example:
|
; example:
|
||||||
; erropix/ESP32 AnalogWrite@^0.2
|
; erropix/ESP32 AnalogWrite@^0.2
|
||||||
|
@ -8,18 +8,27 @@ Program::Program(){
|
|||||||
|
|
||||||
////////API///////
|
////////API///////
|
||||||
this->api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
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/////
|
//////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, String(10));//TODO: mettre la valeur en config
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::loop(){
|
void Program::loop(){
|
||||||
String distance = this->ultrasonic->read();
|
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 in CM: ");
|
||||||
Serial.print(distance);
|
Serial.print(distance);
|
||||||
Serial.println(this->ultrasonic->isFull());
|
Serial.println(this->ultrasonic->isFull()?" true":" false");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user