Compare commits
3 Commits
8477942be8
...
36dd744da5
Author | SHA1 | Date | |
---|---|---|---|
36dd744da5 | |||
e939ee757d | |||
2b318c00f9 |
@ -28,11 +28,10 @@ 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 API_HOST=\"iot.epi.cb85.software\"
|
||||||
|
|
||||||
|
@ -44,9 +44,7 @@ private:
|
|||||||
* @brief capteur poid pour le niveau de remplissage de la poubelle
|
* @brief capteur poid pour le niveau de remplissage de la poubelle
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Balance *balance;
|
Capteur *balance;
|
||||||
|
|
||||||
//TODO chagé type to capteur
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Réference de l'API pour les calls
|
* @brief Réference de l'API pour les calls
|
||||||
|
@ -53,7 +53,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief Variable issue de la librairie HX711 qui permet d'utiliser les fonctions de celle-ci
|
* @brief Variable issue de la librairie HX711 qui permet d'utiliser les fonctions de celle-ci
|
||||||
*/
|
*/
|
||||||
HX711 scale;
|
HX711* capteur;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief true = calibration et false = erreur
|
* @brief true = calibration et false = erreur
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
#include "../include/Balance.h"
|
#include "../include/Balance.h"
|
||||||
|
|
||||||
Balance::Balance(int doutPin, int sckPin) {
|
Balance::Balance(int doutPin, int sckPin, String fullVall):
|
||||||
|
Capteur("W", fullVall){
|
||||||
|
|
||||||
scale.begin(doutPin, sckPin);
|
this->capteur = new HX711();
|
||||||
|
this->capteur->begin(doutPin, sckPin);
|
||||||
this->initialized = false;
|
this->initialized = false;
|
||||||
scale.set_scale();
|
this->capteur->set_scale();
|
||||||
scale.tare();
|
this->capteur->tare();
|
||||||
this->initialVal = 0;
|
this->initialVal = 0;
|
||||||
this->calibrationFact = 0;
|
this->calibrationFact = 0;
|
||||||
|
this->initCalibration();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean Balance::initCalibration() {
|
boolean Balance::initCalibration() {
|
||||||
|
|
||||||
scale.set_scale();
|
this->capteur->set_scale();
|
||||||
scale.tare();
|
this->capteur->tare();
|
||||||
this->initialVal = scale.read_average(20);
|
this->initialVal = this->capteur->read_average(20);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,11 +26,11 @@ boolean Balance::calibration(int poidsRef,int moyenne_calibration) {
|
|||||||
int rawValref = 0; // Valeur brute de plexiglas et poids réf
|
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
|
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);
|
rawValref = this->capteur->read_average(moyenne_calibration);
|
||||||
this->calibrationFact = (rawValref - this->initialVal) / poidsRef;
|
this->calibrationFact = (rawValref - this->initialVal) / poidsRef;
|
||||||
do {
|
do {
|
||||||
scale.set_scale(calibrationFact);
|
this->capteur->set_scale(calibrationFact);
|
||||||
tempPoids = scale.get_units(5);
|
tempPoids = this->capteur->get_units(5);
|
||||||
if (tempPoids < poidsRef) {
|
if (tempPoids < poidsRef) {
|
||||||
calibrationFact -= 1;
|
calibrationFact -= 1;
|
||||||
} else if (tempPoids > poidsRef) {
|
} else if (tempPoids > poidsRef) {
|
||||||
@ -37,26 +40,17 @@ boolean Balance::calibration(int poidsRef,int moyenne_calibration) {
|
|||||||
return initialized = true;
|
return initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Balance::getAverage(int nbMesure) {
|
String Balance::read() {
|
||||||
|
|
||||||
if (initialized == true) {
|
if (this->initialized == true) {
|
||||||
return scale.get_units(nbMesure);
|
return String(this->capteur->get_units());
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return "0";
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double Balance::getValue() {
|
|
||||||
|
|
||||||
if (initialized == true) {
|
|
||||||
return scale.get_units();
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Balance::setCalibrationFact(int caliFact){
|
void Balance::setCalibrationFact(int caliFact){
|
||||||
this->initialized = true;
|
this->initialized = true;
|
||||||
this->calibrationFact = caliFact;
|
this->calibrationFact = caliFact;
|
||||||
scale.set_scale(caliFact);
|
this->capteur->set_scale(caliFact);
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,14 @@ Program::Program(){
|
|||||||
//////CAPTEUR/////
|
//////CAPTEUR/////
|
||||||
this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, "10");//TODO: mettre la valeur en config
|
this->ultrasonic = new Ultrason(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO, "10");//TODO: mettre la valeur en config
|
||||||
this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config
|
this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config
|
||||||
|
this->balance = new Balance(POID_DOUT,POID_SCK,"500");//TODO: mettre la valter en donfig
|
||||||
//TODO: init balance
|
this->balance->tar(1077);
|
||||||
//calibration factor : 1077
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::loop(){
|
void Program::loop(){
|
||||||
String distance = this->ultrasonic->read();
|
String distance = this->ultrasonic->read();
|
||||||
String humitemp = this->dht->read();
|
String humitemp = this->dht->read();
|
||||||
|
String poid = this->balance->read();
|
||||||
|
|
||||||
//this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull());
|
//this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull());
|
||||||
Serial.print("Distance in CM = " + distance);
|
Serial.print("Distance in CM = " + distance);
|
||||||
@ -32,6 +32,9 @@ void Program::loop(){
|
|||||||
Serial.println(this->dht->isFull()?" true":" false");
|
Serial.println(this->dht->isFull()?" true":" false");
|
||||||
|
|
||||||
//TODO: Lire balance
|
//TODO: Lire balance
|
||||||
|
//this->api->sendValue(poid, TRASHCAN_TWO, this->balance->getValType(), this->balance->isFull());
|
||||||
|
Serial.print("humiTemp = " + this->dht->read());
|
||||||
|
Serial.println(this->dht->isFull()?" true":" false");
|
||||||
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user