Compare commits
No commits in common. "36dd744da5048bcf25ffc3193477f452df4bf8a8" and "8477942be82cf88a5f9fe2678e6e9ac5793fb93c" have entirely different histories.
36dd744da5
...
8477942be8
@ -28,10 +28,11 @@ build_flags =
|
||||
-D POID_DOUT=14
|
||||
-D POID_SCK=15
|
||||
|
||||
-D MOYENNE_CALIBRATION=20
|
||||
|
||||
|
||||
; trash can ID
|
||||
-D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\"
|
||||
-D TRASHCAN_TWO=\"4brip5fwm001bs9\"
|
||||
|
||||
|
||||
-D API_HOST=\"iot.epi.cb85.software\"
|
||||
|
||||
|
@ -44,7 +44,9 @@ private:
|
||||
* @brief capteur poid pour le niveau de remplissage de la poubelle
|
||||
*
|
||||
*/
|
||||
Capteur *balance;
|
||||
Balance *balance;
|
||||
|
||||
//TODO chagé type to capteur
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
HX711* capteur;
|
||||
HX711 scale;
|
||||
|
||||
/**
|
||||
* @brief true = calibration et false = erreur
|
||||
|
@ -1,23 +1,20 @@
|
||||
#include "../include/Balance.h"
|
||||
|
||||
Balance::Balance(int doutPin, int sckPin, String fullVall):
|
||||
Capteur("W", fullVall){
|
||||
Balance::Balance(int doutPin, int sckPin) {
|
||||
|
||||
this->capteur = new HX711();
|
||||
this->capteur->begin(doutPin, sckPin);
|
||||
scale.begin(doutPin, sckPin);
|
||||
this->initialized = false;
|
||||
this->capteur->set_scale();
|
||||
this->capteur->tare();
|
||||
scale.set_scale();
|
||||
scale.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);
|
||||
scale.set_scale();
|
||||
scale.tare();
|
||||
this->initialVal = scale.read_average(20);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -26,11 +23,11 @@ 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);
|
||||
rawValref = scale.read_average(moyenne_calibration);
|
||||
this->calibrationFact = (rawValref - this->initialVal) / poidsRef;
|
||||
do {
|
||||
this->capteur->set_scale(calibrationFact);
|
||||
tempPoids = this->capteur->get_units(5);
|
||||
scale.set_scale(calibrationFact);
|
||||
tempPoids = scale.get_units(5);
|
||||
if (tempPoids < poidsRef) {
|
||||
calibrationFact -= 1;
|
||||
} else if (tempPoids > poidsRef) {
|
||||
@ -40,17 +37,26 @@ boolean Balance::calibration(int poidsRef,int moyenne_calibration) {
|
||||
return initialized = true;
|
||||
}
|
||||
|
||||
String Balance::read() {
|
||||
double Balance::getAverage(int nbMesure) {
|
||||
|
||||
if (this->initialized == true) {
|
||||
return String(this->capteur->get_units());
|
||||
if (initialized == true) {
|
||||
return scale.get_units(nbMesure);
|
||||
} else {
|
||||
return "0";
|
||||
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;
|
||||
this->capteur->set_scale(caliFact);
|
||||
scale.set_scale(caliFact);
|
||||
}
|
||||
|
@ -14,14 +14,14 @@ Program::Program(){
|
||||
//////CAPTEUR/////
|
||||
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->balance = new Balance(POID_DOUT,POID_SCK,"500");//TODO: mettre la valter en donfig
|
||||
this->balance->tar(1077);
|
||||
|
||||
//TODO: init balance
|
||||
//calibration factor : 1077
|
||||
}
|
||||
|
||||
void Program::loop(){
|
||||
String 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);
|
||||
@ -32,9 +32,6 @@ void Program::loop(){
|
||||
Serial.println(this->dht->isFull()?" true":" false");
|
||||
|
||||
//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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user