43 Commits

Author SHA1 Message Date
ef9040ffed Merge pull request 'fix: RM-all-todo' (#49) from fix-RM-all-todo into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#49
2023-05-14 23:26:53 +02:00
23651cb6d5 fix diagramme 2023-05-14 23:26:16 +02:00
0037b1831a rm debug 2023-05-14 23:17:05 +02:00
7b21441976 fix some thing 2023-05-14 23:16:16 +02:00
650290ab67 fix readme iot 2023-05-14 22:26:32 +02:00
ef447b2dc7 fix link in readme 2023-05-14 22:25:15 +02:00
830d40a777 fix api 2023-05-14 11:04:47 +02:00
29e1c1b73a Merge pull request 'feat: gestion oled screen' (#48) from feat/oled-screen into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#48
2023-05-14 09:16:31 +02:00
b9b6d71ba0 feat: commentaire for doc 2023-05-14 09:09:13 +02:00
b0c90360b8 feat: use oled screen lib 2023-05-14 09:06:08 +02:00
f2bd530d4e feat: add config and oled screen lib 2023-05-14 09:05:57 +02:00
d814d16733 feat: add oled screen lib 2023-05-14 09:05:23 +02:00
ddefd7e15f Merge remote-tracking branch 'origin/master' into feat/oled-screen 2023-05-13 13:00:15 +02:00
b62d0d74c6 Merge pull request 'feat: création classe abstraite capteur' (#44) from refactor/class-abstraite-capteur into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#44
Reviewed-by: nico <nicolas.sansd@gmail.com>
Reviewed-by: 5OLE1L <mathis.ragot@epitech.eu>
2023-05-13 12:58:50 +02:00
79d5ecde9e docs: update class diagram 2023-05-09 17:06:20 +02:00
e4cf250092 fix typo 2023-05-09 16:58:19 +02:00
fa43f37279 fix typo 2 2023-05-09 16:55:58 +02:00
2708df56a6 fix typo 2023-05-09 16:55:37 +02:00
19b716aaf2 feat: full test ok 2023-05-09 12:01:20 +02:00
95aabd8903 fix: rm todo 2023-05-09 11:48:42 +02:00
a34b4acbc0 add 3eme poubelle id 2023-05-09 11:48:03 +02:00
3a45e8e9b5 feat: config cull to config 2023-05-09 11:32:51 +02:00
107ca935b8 add debug poids 2023-05-09 10:26:50 +02:00
922d6e85f0 change setCalibrationFact to tar 2023-05-02 22:12:28 +02:00
2b4e0fd9ea fix: rm todo 2023-05-02 22:12:06 +02:00
d69dc54f48 fix: indent 2023-05-02 22:11:53 +02:00
36dd744da5 add balance to main program 2023-05-02 22:01:20 +02:00
e939ee757d refactor: balance lib 2023-05-02 22:01:10 +02:00
2b318c00f9 fix: add api adresse 2023-05-02 22:00:51 +02:00
8477942be8 fix main 2023-05-02 21:52:59 +02:00
493e571e32 WIP refactor classe balance 2023-05-02 20:14:57 +02:00
84cd9912c9 add todo to main program 2023-05-02 19:32:42 +02:00
6744680a1f Merge remote-tracking branch 'origin/master' into refactor/class-abstraite-capteur 2023-05-02 19:31:53 +02:00
19ae3cf10f Merge pull request 'feat: capteur_balance' (#35) from feat/balance into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#35
Reviewed-by: nico <nicolas.sansd@gmail.com>
2023-05-02 19:23:23 +02:00
cd677468ae Merge branch 'master' into feat/balance 2023-05-02 19:04:26 +02:00
69bd4f57e3 add balance to main program 2023-05-02 10:11:22 +02:00
c40be321fb feat: balance pin config 2023-05-02 10:11:11 +02:00
90b9ca279c Merge remote-tracking branch 'origin/master' into feat/balance 2023-04-25 10:59:11 +02:00
9b6c1beb8d Merge remote-tracking branch 'origin/master' into feat/balance 2023-04-11 14:07:49 +02:00
2fefc9f96d feat: test capteur poids OK 2023-04-11 12:54:53 +02:00
d63eff681e add Balance lib 2023-04-11 12:35:25 +02:00
ca61a66ca6 feat/ add lib HX711 2023-04-11 12:33:05 +02:00
3a37f93ef7 feat/add config 2023-04-11 12:32:49 +02:00
17 changed files with 432 additions and 73 deletions

View File

@ -3,4 +3,6 @@
## setup :
rename `secrets.ini.example` to `secrets.ini`
renomé `secrets.ini.example` to `secrets.ini` et le remplir
compiler avec Platform.io

View File

@ -14,6 +14,14 @@ build_flags =
-D MONITOR_SPEED=${config.monitor_speed}
; DO NOT TOUCH --- END
; taille ecran oled
; 3,3v
-D OLED_WIDTH=128
-D OLED_HEIGHT=64
; pin de reset de l'ecran oled
-D OLED_RESET=-1
; DHT pin and type
; 5v
-D DHTTYPE=\"DHT11\"
@ -24,9 +32,22 @@ build_flags =
-D ULTRA_SOUND_TRIGD=12
-D ULTRA_SOUND_ECHO=13
; API host url
-D API_HOST=\"iot.epi.cb85.software\"
; Capteur poids
; 3,3v
-D POID_DOUT=14
-D POID_SCK=15
; trash can ID
-D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\"
-D TRASHCAN_TWO=\"4brip5fwm001bs9\"
-D TRASHCAN_THREE=\"n4il9ckl5016aqi\"
-D API_HOST=\"iot.epi.cb85.software\"
;---CAPTEUR FULL CONFIG---
;valFull/valReset
-D ULTRA_SOUND_FULL=\"5/10\"
;tempmin:tempmax/hummin:humax
-D DHT_FULL=\"20:30/60:80\"
;poid max
-D POID_FULL=\"100\"

View File

@ -18,7 +18,61 @@ Class Program {
+ 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 HumiTemp{
- capteur: DHT*
+ HumiTemp(pin: int, type: String, fullVal: String)
+ read(): String
}
class Ultrason{
- capteur: Ultrasonic*
+ Ultrason(triguer: int, echo: int, fullVal: String)
+ read(): String
}
class OledScreen{
- display: Adafruit_SSD1306*
+ OledScreen(screenWidth: int, screenHeight: int, oledResetPin: int = -1)
+ welcome(): void
+ clear(): void
+ wifiWaiting(): void
+ printVal(distance: String, poid: String, humitemp: String): void
}
Balance --|> Capteur
Ultrason --|> Capteur
HumiTemp --|> Capteur
Program <-- Balance
Program <-- Ultrason
Program <-- HumiTemp
Program <- API
OledScreen -> Program
@enduml

View File

@ -4,10 +4,13 @@
#include <DHT.h>
#include <Arduino.h>
#include <Ultrasonic.h>
#include "API.h"
#include "Capteur.h"
#include "Ultrason.h"
#include "HumiTemp.h"
#include "Balance.h"
#include "OledScreen.h"
class Program{
public:
@ -38,6 +41,18 @@ private:
*/
Capteur *ultrasonic;
/**
* @brief capteur poid pour le niveau de remplissage de la poubelle
*
*/
Capteur *balance;
/**
* @brief OledScreen
*
*/
OledScreen* screen;
/**
* @brief Réference de l'API pour les calls
*

View File

@ -49,8 +49,6 @@ public:
*/
bool connect();
//TODO :: Check wifibegin avant
private:
@ -89,7 +87,11 @@ private:
*/
String token;
/**
* @brief wifi démmaré
*
*/
bool init;
};

View File

@ -8,15 +8,16 @@ API::API(String user, String password, String host, bool https){
this->https = https;
this->token = "";
this->client = new WiFiEspClient();
this->init = false;
}
bool API::wifiBegin(String wifiId, String wifiPass, Stream* espSerial){
WiFi.init(espSerial);
this->init = true;
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present"); // FIXME: rm debug
return false;
}
@ -28,6 +29,7 @@ bool API::wifiBegin(String wifiId, String wifiPass, Stream* espSerial){
return true;
}
bool API::connect(){
if(!this->init)return false;
this->client->stop();
bool sortie = false;
@ -119,6 +121,5 @@ bool API::sendValue(String val, String poubelleID, String valUnit, bool full){
this->client->println("Connection: close");
this->client->println();
this->token = "";//XXX: on rm le token a chaque fois car on sais pas si la requet a bien aboutie et donc si il y est encore bon
return true;
}

View File

@ -0,0 +1,76 @@
#ifndef BALANCE_H
#define BALANCE_H
#include <Arduino.h>
#include <HX711.h>
#include "Capteur.h"
class Balance: public Capteur{
public:
/**
* @brief constructeur
*
* @param[in] 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
*/
Balance(int doutPin, int sckPin, String fullVall);
/**
* @brief lit la valeur du capteur de poid
*
* @return String retour la valeur
*/
String read();
/**
* @brief tare et scale a 0, et recuperation de la valeur brut du plateau
*/
bool 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
*/
bool calibration(int poidsRef,int moyenne_calibration);
/**
* @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:
/**
* @brief Variable issue de la librairie HX711 qui permet d'utiliser les fonctions de celle-ci
*/
HX711* capteur;
/**
* @brief true = calibration et false = erreur
*/
bool initialized;
/**
* @brief Facteur de calibration obtenu par : (val brute poids ref - val brute poids plexiglas)/ poids ref
*/
int calibrationFact;
/**
* @brief Valeur moyenne brute du poids sans rien sur la balance juste le plexiglas
*/
long initialVal;
};
#endif

View File

@ -7,59 +7,59 @@ 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 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 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 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();
/**
* @brief revoie la valeur full
*
* @return true la poubelle est pleine
* @return false la poubelle n'est pas pleine
*/
bool isFull();
String getValType();
String getValType();
protected:
/**
* @brief la poubelle est pleinne
* est mis a jours par read()
*/
bool full;
/**
* @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 type de mesure lue (T/H, W, D,...)
*
*/
String type;
/**
* @brief valeur a la quel la poubelle est considéré comme pleine
*
*/
String fullVall;
/**
* @brief valeur a la quel la poubelle est considéré comme pleine
*
*/
String fullVall;
};

View File

@ -0,0 +1,58 @@
#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;
}

View File

@ -11,8 +11,16 @@ String HumiTemp::read(){
int hum = this->capteur->readHumidity(true);
int temp = this->capteur->readTemperature(false,true);
String stemp = this->fullVall.substring(0, this->fullVall.indexOf("/"));
String shum = this->fullVall.substring(this->fullVall.indexOf("/")+1, this->fullVall.length());
int mintemp = stemp.substring(0, stemp.indexOf(":")).toInt();
int maxtemp = stemp.substring(stemp.indexOf(":")+1, stemp.length()).toInt();
int minhum = shum.substring(0, shum.indexOf(":")).toInt();
int maxhum = shum.substring(shum.indexOf(":")+1, shum.length()).toInt();
//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
if((temp > mintemp && temp < maxtemp) && (hum > minhum && hum < maxhum)){
this->full = true;
}else{
this->full = false;

View File

@ -9,11 +9,11 @@ Ultrason::Ultrason(int trigeur, int echo, String fullVall):
String Ultrason::read(){
int sortie = this->capteur->read();
if (sortie < this->fullVall.toInt())
if (sortie < this->fullVall.substring(0, this->fullVall.indexOf("/")).toInt())
{
this->full = true;
}else{
}else if (sortie > this->fullVall.substring(this->fullVall.indexOf("/")+1, this->fullVall.length()).toInt()){
this->full = false;
}
return String(sortie);
}//TODO: faire en sorte que full se reset avec une autre val
}

View File

@ -0,0 +1,52 @@
#ifndef OLED_SCREEN_H
#define OLED_SCREEN_H
#include <Adafruit_SSD1306.h>
class OledScreen {
public:
/**
* @brief Construct a new Oled Screen object
*
* @param screenWidth The width of the screen
* @param screenHeight The height of the screen
* @param oledResetPin The pin used to reset the screen (default: -1)
*/
OledScreen(int screenWidth, int screenHeight, int oledResetPin = -1);
/**
* @brief display welcome screen
*/
void welcome();
/**
* @brief Clear the screen
*/
void clear();
/**
* @brief messsage for wifi waiting
*
*/
void wifiWaiting();
/**
* @brief show the sensor value
*
* @param distance length value
* @param poid weith value
* @param humitemp humidity and temperature value
*/
void printVal(String distance, String poid, String humitemp);
private:
Adafruit_SSD1306* display;
};
#endif

View File

@ -0,0 +1,56 @@
#include "../include/OledScreen.h"
OledScreen::OledScreen(int screenWidth, int screenHeight, int oledResetPin) {
this->display = new Adafruit_SSD1306(screenWidth, screenHeight, &Wire, oledResetPin);
if (!display->begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
this->display->clearDisplay();
}
void OledScreen::welcome() {
this->display->clearDisplay();
this->display->setCursor(0, 0);
this->display->setTextSize(2);
this->display->setTextColor(WHITE);
this->display->println(F("\nBienvenue!"));
this->display->display();
}
void OledScreen::printVal(String distance, String poid, String humitemp){
this->display->clearDisplay();
this->display->setCursor(0, 0);
this->display->setTextSize(2);
this->display->setTextColor(WHITE);
this->display->print(F("Dist:"));
this->display->print(distance);
this->display->println();
this->display->print(F("Poids:"));
this->display->print(poid);
this->display->println();
this->display->print(F("humi:"));
this->display->print(humitemp.substring(0,humitemp.indexOf("/")));
this->display->println();
this->display->print(F("temp:"));
this->display->print(humitemp.substring(humitemp.indexOf("/")+1,humitemp.length()));
this->display->println();
this->display->display();
}
void OledScreen::wifiWaiting() {
this->clear();
this->display->setCursor(0, 0);
this->display->setTextSize(2);
this->display->setTextColor(WHITE);
this->display->println(F("Connection\n"));
this->display->println(F(" WiFi...\n"));
this->display->println();
this->display->display();
}
void OledScreen::clear() {
this->display->clearDisplay();
}

View File

@ -41,6 +41,8 @@ lib_deps =
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
bogde/HX711@0.7.5 ; lib pour la balance
adafruit/Adafruit SSD1306@^2.5.7 ; librairie pour l'ecran oled
; example:
; erropix/ESP32 AnalogWrite@^0.2

View File

@ -6,28 +6,43 @@ Program::Program(){
Serial1.begin(MONITOR_SPEED);
Serial.begin(MONITOR_SPEED);
//////Oled Screen/////
this->screen = new OledScreen(OLED_WIDTH, OLED_HEIGHT, OLED_RESET);
this->screen->wifiWaiting();
////////API///////
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/////
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, ULTRA_SOUND_FULL);
this->dht = new HumiTemp(DHTPIN, DHTTYPE, DHT_FULL);
this->balance = new Balance(POID_DOUT,POID_SCK, POID_FULL);
this->balance->tar(1077);
this->dht = new HumiTemp(DHTPIN, DHTTYPE, "20:30/60:80");//TODO: mettre la valeur en config
this->screen->clear();
}
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);
this->screen->printVal(distance, poid, humitemp);
this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull());
Serial.println(this->ultrasonic->isFull()?" true":" false");
//this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull());
Serial.print("humiTemp = " + this->dht->read());
Serial.println("humiTemp = " + humitemp);
this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull());
Serial.println(this->dht->isFull()?" true":" false");
delay(1000);
Serial.println("poid = " + poid);
this->api->sendValue(poid, TRASHCAN_THREE, this->balance->getValType(), this->balance->isFull());
Serial.println(this->balance->isFull()?" true":" false");
Serial.println();
}

View File

@ -6,11 +6,10 @@
Program* program;
void setup() {
program = new Program();
program = new Program();
}
void loop() {
program->loop();
program->loop();
}
#endif

View File

@ -1,12 +1,10 @@
# Depot IOT VR
Lien du Gitea : (depot principale + gestion de projet)
https://gitea.cb85.software/Epitech-T-DEV-811/T-DEV-811
https://git.lab-ouest.org/Epitech-T-DEV-811/T-DEV-811
Lien de la CAO : https://cad.onshape.com/documents/d370ee863400195afb23d026/w/1a94981b6a6f71d70b075e30/e/d0feb75fc5a122c54598349b?renderMode=0&uiState=6422993bab4d903a51186392
### Mobile/Unity
Pour gérer l'AR, nous avons décider d'utiliser Unity et pour résoudre le souci de multi target en AR, nous avons utilisé Vuforia.
@ -21,7 +19,7 @@ coté IoT, les valeurs de chaque capteurs sont envoyé à l'API puis ensuite, l'
le champ 'unit' dans la collection trash correspond au type de capteur que l'IoT va envoyer a l'api. Le mapping suivant a été conventionner:
| Capteur | Unit | Valeur |
|----------------------|:----:|--------------------------------------|
| -------------------- |:----:| ------------------------------------ |
| Temperature/Humidité | T/H | 10.0;50 (10 degré et 50% d'humidité) |
| Poids | W | 200 (200 gram) |
| Distance | D | 40 (40 cm) |
| Poids | W | 200 (200 gram) |
| Distance | D | 40 (40 cm) |