Compare commits
1 Commits
9b6c1beb8d
...
DHT11_test
Author | SHA1 | Date | |
---|---|---|---|
b1728b0509 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
IOT/docs/doxygen output/*
|
|
@ -15,7 +15,7 @@ build_flags =
|
|||||||
; DO NOT TOUCH --- END
|
; DO NOT TOUCH --- END
|
||||||
|
|
||||||
-D API_HOST=\"iot.epi.cb85.software\"
|
-D API_HOST=\"iot.epi.cb85.software\"
|
||||||
|
-D DHTTYPE=\"DHT11\"
|
||||||
-D MOYENNE_CALIBRATION=20
|
-D DHTPIN=2
|
||||||
|
|
||||||
|
|
||||||
|
2740
IOT/docs/Doxyfile
2740
IOT/docs/Doxyfile
File diff suppressed because it is too large
Load Diff
@ -1,24 +0,0 @@
|
|||||||
@startuml Class Diagram
|
|
||||||
|
|
||||||
|
|
||||||
Class API {
|
|
||||||
- user: String
|
|
||||||
- password: String
|
|
||||||
- serveurHost: String
|
|
||||||
- https: bool
|
|
||||||
- client: WiFiEspClient*
|
|
||||||
- connect(): bool
|
|
||||||
+ API(user: String, password: String, host: String, https: bool = true)
|
|
||||||
+ wifiBegin(wifiId: String, wifiPass: String, espSerial: Stream*): bool
|
|
||||||
+ sendValue(val: String, pouvelleID: String, unit: String, full: bool): bool
|
|
||||||
}
|
|
||||||
|
|
||||||
Class Program {
|
|
||||||
+ Program()
|
|
||||||
+ setup()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@enduml
|
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef PROGRAM_H
|
#ifndef PROGRAM_H
|
||||||
#define PROGRAM_H
|
#define PROGRAM_H
|
||||||
|
|
||||||
|
#include "DHT.h"
|
||||||
|
|
||||||
class Program{
|
class Program{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -17,5 +19,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief capteur humi/temp
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
DHT *dht;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
@ -21,25 +21,25 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Initialise la connection Wifi de l'esp
|
* @brief Initialise la connection Wifi de l'esp
|
||||||
*
|
*
|
||||||
* @param[in] wifiId nom du wifi
|
* @param wifiId nom du wifi
|
||||||
* @param[in] wifiPass mot de passe du wifi
|
* @param wifiPass mot de passe du wifi
|
||||||
* @param[in] espSerial port serie de l'esp (hard ou soft)
|
* @param espSerial port serie de l'esp (hard ou soft)
|
||||||
* @return true la connexion a bien fonctionner
|
* @return true la connexion a bien fonctionner
|
||||||
* @return false erreur a la connexion
|
* @return false erreur a la connexion
|
||||||
*/
|
*/
|
||||||
bool wifiBegin(String wifiID, String wifiPass, Stream* espSerial);
|
bool wifiBegin(String wifiId, String wifiPass, Stream* espSerial);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief envoie la valeur d'un capteur de poubelle à l'api
|
* @brief envoie la valeur d'un capteur de poubelle à l'api
|
||||||
*
|
*
|
||||||
* @param[in] val valeur du capteur
|
* @param val valeur du capteur
|
||||||
* @param[in] poubelleID ID de la poubelle
|
* @param poubelleID ID de la poubelle
|
||||||
* @param[in] unit uniter de mesure du capteur *(ex: g, cm, degree,...)
|
* @param unit uniter de mesure du capteur *(ex: g, cm, degree,...)
|
||||||
* @param[in] full poubelle est considéré comme pleine
|
* @param full poubelle est considéré comme pleine
|
||||||
* @return true la valeur s'est bien envoyer
|
* @return true la valeur s'est bien envoyer
|
||||||
* @return false il y a une erreur durran l'envoie
|
* @return false il y a une erreur durran l'envoie
|
||||||
*/
|
*/
|
||||||
bool sendValue(String val, String poubelleID, String unit, bool full);
|
bool sendValute(String val, String poubelleID, String unit, bool full);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -81,7 +81,7 @@ bool API::connect(){
|
|||||||
return sortie;
|
return sortie;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool API::sendValue(String val, String poubelleID, String valUnit, bool full){
|
bool API::sendValute(String val, String poubelleID, String valUnit, bool full){
|
||||||
JSONVar data;
|
JSONVar data;
|
||||||
data["value"] = val;
|
data["value"] = val;
|
||||||
data["trash_id"] = poubelleID;
|
data["trash_id"] = poubelleID;
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
#ifndef BALANCE_H
|
|
||||||
#define BALANCE_H
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <HX711.h>
|
|
||||||
|
|
||||||
class Balance {
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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 tare et scale a 0, et recuperation de la valeur brut du plateau
|
|
||||||
*/
|
|
||||||
boolean initCalibration();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief initialisation du calibrage
|
|
||||||
*
|
|
||||||
* @param[in] poidsRef : poid de reférence pour la calibration
|
|
||||||
* @param[in] moyenne_calibration : nombre de valeurs a lire pour une mesure
|
|
||||||
*
|
|
||||||
* @return renvoi un true si calibration bien effectue
|
|
||||||
*/
|
|
||||||
boolean calibration(int poidsRef,int moyenne_calibration);
|
|
||||||
|
|
||||||
//TODO: faire doc setCalibration fact
|
|
||||||
void setCalibrationFact(int caliFact);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief true = calibration et false = erreur
|
|
||||||
*/
|
|
||||||
boolean initialized;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Facteur de calibration obtenu par : (val brute poids ref - val brute poids plexiglas)/ poids ref
|
|
||||||
*/
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
long initialVal;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,62 +0,0 @@
|
|||||||
#include "../include/Balance.h"
|
|
||||||
|
|
||||||
Balance::Balance(int doutPin, int sckPin) {
|
|
||||||
|
|
||||||
scale.begin(doutPin, sckPin);
|
|
||||||
this->initialized = false;
|
|
||||||
scale.set_scale();
|
|
||||||
scale.tare();
|
|
||||||
this->initialVal = 0;
|
|
||||||
this->calibrationFact = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean Balance::initCalibration() {
|
|
||||||
|
|
||||||
scale.set_scale();
|
|
||||||
scale.tare();
|
|
||||||
this->initialVal = scale.read_average(20);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
this->calibrationFact = (rawValref - this->initialVal) / poidsRef;
|
|
||||||
do {
|
|
||||||
scale.set_scale(calibrationFact);
|
|
||||||
tempPoids = scale.get_units(5);
|
|
||||||
if (tempPoids < poidsRef) {
|
|
||||||
calibrationFact -= 1;
|
|
||||||
} else if (tempPoids > poidsRef) {
|
|
||||||
calibrationFact += 1;
|
|
||||||
}
|
|
||||||
} while (tempPoids != poidsRef);
|
|
||||||
return initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
double Balance::getAverage(int nbMesure) {
|
|
||||||
|
|
||||||
if (initialized == true) {
|
|
||||||
return scale.get_units(nbMesure);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double Balance::getValue() {
|
|
||||||
|
|
||||||
if (initialized == true) {
|
|
||||||
return scale.get_units();
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Balance::setCalibrationFact(int caliFact){
|
|
||||||
this->initialized = true;
|
|
||||||
this->calibrationFact = caliFact;
|
|
||||||
scale.set_scale(caliFact);
|
|
||||||
}
|
|
@ -38,7 +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
|
||||||
bogde/HX711@0.7.5 ; lib pour la balance
|
adafruit/DHT sensor library@^1.4.4 ; DHT11 lib
|
||||||
|
adafruit/Adafruit Unified Sensor@^1.1.9 ; adafruit sensor lib (required by DHT11)
|
||||||
; example:
|
; example:
|
||||||
; erropix/ESP32 AnalogWrite@^0.2
|
; erropix/ESP32 AnalogWrite@^0.2
|
||||||
|
|
||||||
|
@ -2,9 +2,19 @@
|
|||||||
|
|
||||||
|
|
||||||
Program::Program(){
|
Program::Program(){
|
||||||
|
// INIT OBJ
|
||||||
|
this->dht = new DHT(DHTPIN, DHTTYPE);
|
||||||
|
|
||||||
|
Serial.begin(MONITOR_SPEED);
|
||||||
|
dht->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::loop(){
|
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())+" %");
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
}
|
}
|
@ -1,41 +1,12 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
// #include "Program.h"
|
#include "Program.h"
|
||||||
|
|
||||||
// Program* program;
|
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);
|
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
program = new Program();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(){
|
void loop() {
|
||||||
// delay(500);
|
program->loop();
|
||||||
Serial.println(balance->getValue());
|
}
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user