Compare commits
No commits in common. "b62d0d74c6a469e22d01f179439e5ab83b21e46b" and "19ae3cf10f23602c620a04c4a3ca92a0c7ee8008" have entirely different histories.
b62d0d74c6
...
19ae3cf10f
@ -28,15 +28,11 @@ build_flags =
|
|||||||
-D POID_DOUT=14
|
-D POID_DOUT=14
|
||||||
-D POID_SCK=15
|
-D POID_SCK=15
|
||||||
|
|
||||||
|
-D MOYENNE_CALIBRATION=20
|
||||||
|
|
||||||
|
|
||||||
; trash can ID
|
; trash can ID
|
||||||
-D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\"
|
-D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\"
|
||||||
-D TRASHCAN_TWO=\"4brip5fwm001bs9\"
|
-D TRASHCAN_TWO=\"4brip5fwm001bs9\"
|
||||||
-D TRASHCAN_THREE=\"n4il9ckl5016aqi\"
|
|
||||||
|
|
||||||
-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\"
|
|
@ -18,49 +18,7 @@ Class Program {
|
|||||||
+ setup()
|
+ 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
|
@enduml
|
@ -6,9 +6,6 @@
|
|||||||
#include <Ultrasonic.h>
|
#include <Ultrasonic.h>
|
||||||
|
|
||||||
#include "API.h"
|
#include "API.h"
|
||||||
#include "Capteur.h"
|
|
||||||
#include "Ultrason.h"
|
|
||||||
#include "HumiTemp.h"
|
|
||||||
#include "Balance.h"
|
#include "Balance.h"
|
||||||
|
|
||||||
class Program{
|
class Program{
|
||||||
@ -32,19 +29,20 @@ private:
|
|||||||
* @brief capteur humi/temp
|
* @brief capteur humi/temp
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Capteur *dht;
|
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
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Capteur *ultrasonic;
|
Ultrasonic *ultrasonic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief capteur poid pour le niveau de remplissage de la poubelle
|
* @brief capteur poid pour le niveau de remplissage de la poubelle
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Capteur *balance;
|
Balance *balance;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Réference de l'API pour les calls
|
* @brief Réference de l'API pour les calls
|
||||||
|
@ -3,32 +3,41 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <HX711.h>
|
#include <HX711.h>
|
||||||
|
|
||||||
#include "Capteur.h"
|
class Balance {
|
||||||
|
|
||||||
class Balance: public Capteur{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief constructeur
|
* @brief constructeur
|
||||||
*
|
*
|
||||||
* @param[in] doutPin : pin DOUT du module HX711
|
* @param 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
|
* @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, String fullVall);
|
Balance(int doutPin, int sckPin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief lit la valeur du capteur de poid
|
* @brief determine le poids
|
||||||
*
|
*
|
||||||
* @return String retour la valeur
|
* @return poids (double)
|
||||||
*/
|
*/
|
||||||
String read();
|
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
|
* @brief tare et scale a 0, et recuperation de la valeur brut du plateau
|
||||||
*/
|
*/
|
||||||
bool initCalibration();
|
boolean initCalibration();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief initialisation du calibrage
|
* @brief initialisation du calibrage
|
||||||
@ -38,34 +47,29 @@ public:
|
|||||||
*
|
*
|
||||||
* @return renvoi un true si calibration bien effectue
|
* @return renvoi un true si calibration bien effectue
|
||||||
*/
|
*/
|
||||||
bool calibration(int poidsRef,int moyenne_calibration);
|
boolean calibration(int poidsRef,int moyenne_calibration);
|
||||||
|
|
||||||
|
//TODO: faire doc setCalibration fact
|
||||||
|
void setCalibrationFact(int caliFact);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief tar le capteur de poids
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
bool tar(int val = 0);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Variable issue de la librairie HX711 qui permet d'utiliser les fonctions de celle-ci
|
|
||||||
*/
|
|
||||||
HX711* capteur;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief true = calibration et false = erreur
|
* @brief true = calibration et false = erreur
|
||||||
*/
|
*/
|
||||||
bool initialized;
|
boolean initialized;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Facteur de calibration obtenu par : (val brute poids ref - val brute poids plexiglas)/ poids ref
|
* @brief Facteur de calibration obtenu par : (val brute poids ref - val brute poids plexiglas)/ poids ref
|
||||||
*/
|
*/
|
||||||
int calibrationFact;
|
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
|
* @brief Valeur moyenne brute du poids sans rien sur la balance juste le plexiglas
|
||||||
*/
|
*/
|
62
IOT/lib/Balance/src/Balance.cpp
Normal file
62
IOT/lib/Balance/src/Balance.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#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);
|
||||||
|
}
|
@ -1,67 +0,0 @@
|
|||||||
#ifndef CAPTEUR_H
|
|
||||||
#define CAPTEUR_H
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
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();
|
|
||||||
|
|
||||||
String getValType();
|
|
||||||
|
|
||||||
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
|
|
@ -1,35 +0,0 @@
|
|||||||
#ifndef HUMI_TEMP_H
|
|
||||||
#define HUMI_TEMP_H
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <DHT.h>
|
|
||||||
#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
|
|
@ -1,38 +0,0 @@
|
|||||||
#ifndef ULTRASON_H
|
|
||||||
#define ULTRASON_H
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <Ultrasonic.h>
|
|
||||||
|
|
||||||
#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
|
|
@ -1,58 +0,0 @@
|
|||||||
#include "../include/Balance.h"
|
|
||||||
|
|
||||||
Balance::Balance(int doutPin, int sckPin, String fullVall):
|
|
||||||
Capteur("W", fullVall){
|
|
||||||
|
|
||||||
this->capteur = new HX711();
|
|
||||||
this->capteur->begin(doutPin, sckPin);
|
|
||||||
this->initialized = false;
|
|
||||||
this->capteur->set_scale();
|
|
||||||
this->capteur->tare();
|
|
||||||
this->initialVal = 0;
|
|
||||||
this->calibrationFact = 0;
|
|
||||||
this->initCalibration();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean Balance::initCalibration() {
|
|
||||||
|
|
||||||
this->capteur->set_scale();
|
|
||||||
this->capteur->tare();
|
|
||||||
this->initialVal = this->capteur->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 = this->capteur->read_average(moyenne_calibration);
|
|
||||||
this->calibrationFact = (rawValref - this->initialVal) / poidsRef;
|
|
||||||
do {
|
|
||||||
this->capteur->set_scale(calibrationFact);
|
|
||||||
tempPoids = this->capteur->get_units(5);
|
|
||||||
if (tempPoids < poidsRef) {
|
|
||||||
calibrationFact -= 1;
|
|
||||||
} else if (tempPoids > poidsRef) {
|
|
||||||
calibrationFact += 1;
|
|
||||||
}
|
|
||||||
} while (tempPoids != poidsRef);
|
|
||||||
return initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String Balance::read() {
|
|
||||||
int sortie = (int)this->capteur->get_units();
|
|
||||||
this->full = sortie > this->fullVall.toInt();
|
|
||||||
if (this->initialized == true) {
|
|
||||||
return String(sortie);
|
|
||||||
} else {
|
|
||||||
return "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Balance::tar(int val){
|
|
||||||
this->initialized = true;
|
|
||||||
this->calibrationFact = val;
|
|
||||||
this->capteur->set_scale(val);
|
|
||||||
return this->initialized;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String Capteur::getValType(){
|
|
||||||
return this->type;
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
#include "../include/HumiTemp.h"
|
|
||||||
|
|
||||||
HumiTemp::HumiTemp(int pin, String type, String fullVall):
|
|
||||||
Capteur("H/T",fullVall){
|
|
||||||
this->capteur = new DHT(pin, type.c_str());
|
|
||||||
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)){//TODO: passer les valeurs en config
|
|
||||||
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)
|
|
@ -1,19 +0,0 @@
|
|||||||
#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);
|
|
||||||
}//TODO: faire en sorte que full se reset avec une autre val
|
|
@ -1,41 +1,41 @@
|
|||||||
#include "Program.h"
|
#include "Program.h"
|
||||||
|
|
||||||
|
int distance;
|
||||||
|
|
||||||
Program::Program(){
|
|
||||||
////////SERIALS//////
|
|
||||||
Serial1.begin(MONITOR_SPEED);
|
|
||||||
Serial.begin(MONITOR_SPEED);
|
|
||||||
|
|
||||||
////////API///////
|
Program::Program()
|
||||||
|
// Serial
|
||||||
|
Serial.begin(MONITOR_SPEED); // motitor pour debug
|
||||||
|
Serial1.begin(MONITOR_SPEED); // port serie pour l'esp
|
||||||
|
|
||||||
|
///////INITIALISATION OBJ//////
|
||||||
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->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO);
|
||||||
|
this->balance = new Balance(POID_DOUT,POID_SCK);
|
||||||
|
this->dht = new DHT(DHTPIN, DHTTYPE);
|
||||||
|
///////INITIALISATION OK//////
|
||||||
|
|
||||||
|
Serial.print("start calibr : ");
|
||||||
|
this->balance->initCalibration();
|
||||||
|
this->balance->setCalibrationFact(1077);
|
||||||
|
Serial.println("OK");
|
||||||
|
|
||||||
//////CAPTEUR/////
|
//this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
||||||
this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, ULTRA_SOUND_FULL);
|
dht->begin();
|
||||||
this->dht = new HumiTemp(DHTPIN, DHTTYPE, DHT_FULL);
|
|
||||||
this->balance = new Balance(POID_DOUT,POID_SCK, POID_FULL);
|
|
||||||
this->balance->tar(1077);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::loop(){
|
void Program::loop(){
|
||||||
String distance = this->ultrasonic->read();
|
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);
|
|
||||||
Serial.println(this->ultrasonic->isFull()?" true":" false");
|
|
||||||
|
|
||||||
this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull());
|
//TODO: envoyer les infos des capteur par la suite
|
||||||
Serial.print("humiTemp = " + humitemp);
|
|
||||||
Serial.println(this->dht->isFull()?" true":" false");
|
|
||||||
|
|
||||||
this->api->sendValue(poid, TRASHCAN_THREE, this->balance->getValType(), this->balance->isFull());
|
Serial.println("Temperature = " + String(dht->readTemperature())+" °C");
|
||||||
Serial.print("poid = " + poid);
|
Serial.println("Humidite = " + String(dht->readHumidity())+" %");
|
||||||
Serial.println(this->balance->isFull()?" true":" false");
|
|
||||||
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
|
//this->api->sendValue(JSONVar::stringify(distance), TRASHCAN_ONE, "W", false); //TODO: faire estimation poubelle plenne
|
||||||
|
//this->api->sendValue(this->balance->getValue(), TRASHCAN_TWO, ,false); //TODO: faire estimation poubelle plenne
|
||||||
|
Serial.print("Distance in CM: ");
|
||||||
|
Serial.println(distance);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
@ -1,15 +1,47 @@
|
|||||||
#ifndef TESTING
|
#ifndef TESTING
|
||||||
|
|
||||||
#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() {
|
void setup() {
|
||||||
program = new Program();
|
program = new Program();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
program->loop();
|
// delay(500);
|
||||||
|
Serial.println(balance->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user