Compare commits
19 Commits
95aabd8903
...
master
Author | SHA1 | Date | |
---|---|---|---|
ef9040ffed | |||
23651cb6d5 | |||
0037b1831a | |||
7b21441976 | |||
650290ab67 | |||
ef447b2dc7 | |||
830d40a777 | |||
29e1c1b73a | |||
b9b6d71ba0 | |||
b0c90360b8 | |||
f2bd530d4e | |||
d814d16733 | |||
ddefd7e15f | |||
b62d0d74c6 | |||
79d5ecde9e | |||
e4cf250092 | |||
fa43f37279 | |||
2708df56a6 | |||
19b716aaf2 |
@ -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
|
@ -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\"
|
||||
@ -25,6 +33,7 @@ build_flags =
|
||||
-D ULTRA_SOUND_ECHO=13
|
||||
|
||||
; Capteur poids
|
||||
; 3,3v
|
||||
-D POID_DOUT=14
|
||||
-D POID_SCK=15
|
||||
|
||||
@ -36,7 +45,9 @@ build_flags =
|
||||
-D API_HOST=\"iot.epi.cb85.software\"
|
||||
|
||||
;---CAPTEUR FULL CONFIG---
|
||||
|
||||
-D ULTRA_SOUND_FULL=\"10\"
|
||||
;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\"
|
@ -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
|
@ -10,6 +10,7 @@
|
||||
#include "Ultrason.h"
|
||||
#include "HumiTemp.h"
|
||||
#include "Balance.h"
|
||||
#include "OledScreen.h"
|
||||
|
||||
class Program{
|
||||
public:
|
||||
@ -46,6 +47,12 @@ private:
|
||||
*/
|
||||
Capteur *balance;
|
||||
|
||||
/**
|
||||
* @brief OledScreen
|
||||
*
|
||||
*/
|
||||
OledScreen* screen;
|
||||
|
||||
/**
|
||||
* @brief Réference de l'API pour les calls
|
||||
*
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
@ -28,7 +28,7 @@ public:
|
||||
/**
|
||||
* @brief tare et scale a 0, et recuperation de la valeur brut du plateau
|
||||
*/
|
||||
boolean initCalibration();
|
||||
bool initCalibration();
|
||||
|
||||
/**
|
||||
* @brief initialisation du calibrage
|
||||
@ -38,7 +38,7 @@ public:
|
||||
*
|
||||
* @return renvoi un true si calibration bien effectue
|
||||
*/
|
||||
boolean calibration(int poidsRef,int moyenne_calibration);
|
||||
bool calibration(int poidsRef,int moyenne_calibration);
|
||||
|
||||
/**
|
||||
* @brief tar le capteur de poids
|
||||
@ -59,7 +59,7 @@ private:
|
||||
/**
|
||||
* @brief true = calibration et false = erreur
|
||||
*/
|
||||
boolean initialized;
|
||||
bool initialized;
|
||||
|
||||
/**
|
||||
* @brief Facteur de calibration obtenu par : (val brute poids ref - val brute poids plexiglas)/ poids ref
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
52
IOT/lib/OledScreen/include/OledScreen.h
Normal file
52
IOT/lib/OledScreen/include/OledScreen.h
Normal 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
|
56
IOT/lib/OledScreen/src/OledScreeen.cpp
Normal file
56
IOT/lib/OledScreen/src/OledScreeen.cpp
Normal 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();
|
||||
}
|
@ -42,6 +42,7 @@ lib_deps =
|
||||
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
|
||||
|
||||
|
@ -6,9 +6,13 @@ 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/////
|
||||
@ -16,6 +20,8 @@ Program::Program(){
|
||||
this->dht = new HumiTemp(DHTPIN, DHTTYPE, DHT_FULL);
|
||||
this->balance = new Balance(POID_DOUT,POID_SCK, POID_FULL);
|
||||
this->balance->tar(1077);
|
||||
|
||||
this->screen->clear();
|
||||
}
|
||||
|
||||
void Program::loop(){
|
||||
@ -23,19 +29,20 @@ void Program::loop(){
|
||||
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 = " + humitemp);
|
||||
Serial.println("humiTemp = " + humitemp);
|
||||
this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull());
|
||||
Serial.println(this->dht->isFull()?" true":" false");
|
||||
|
||||
//this->api->sendValue(poid, TRASHCAN_TWO, this->balance->getValType(), this->balance->isFull());
|
||||
Serial.print("poid = " + poid);
|
||||
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();
|
||||
|
||||
delay(1000);
|
||||
}
|
@ -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) |
|
Reference in New Issue
Block a user