Compare commits
81 Commits
feat/AR_Ar
...
master
Author | SHA1 | Date | |
---|---|---|---|
ef9040ffed | |||
23651cb6d5 | |||
0037b1831a | |||
7b21441976 | |||
650290ab67 | |||
ef447b2dc7 | |||
830d40a777 | |||
29e1c1b73a | |||
b9b6d71ba0 | |||
b0c90360b8 | |||
f2bd530d4e | |||
d814d16733 | |||
ddefd7e15f | |||
b62d0d74c6 | |||
79d5ecde9e | |||
e4cf250092 | |||
fa43f37279 | |||
2708df56a6 | |||
19b716aaf2 | |||
95aabd8903 | |||
a34b4acbc0 | |||
3a45e8e9b5 | |||
107ca935b8 | |||
922d6e85f0 | |||
2b4e0fd9ea | |||
d69dc54f48 | |||
36dd744da5 | |||
e939ee757d | |||
2b318c00f9 | |||
8477942be8 | |||
493e571e32 | |||
84cd9912c9 | |||
6744680a1f | |||
19ae3cf10f | |||
cd677468ae | |||
7574061bec | |||
edfdc6107f | |||
4fe37fdf22 | |||
4f18142cc6 | |||
d8ed35483f | |||
c89b6d1479 | |||
d67e4a9da8 | |||
cc583d0947 | |||
60ec85a572 | |||
b26a27dc5b | |||
fa6662e885 | |||
a47ec78e1c | |||
7b0d866d6f | |||
db3ce5025b | |||
f01844bed8 | |||
e002adacdd | |||
a533973e9c | |||
aed8706921 | |||
e8b420f3f7 | |||
5b7f0f3d3e | |||
4cafc40d61 | |||
69bd4f57e3 | |||
c40be321fb | |||
90b9ca279c | |||
17b344732f | |||
![]() |
9b0b5bedd8 | ||
![]() |
e088b4e304 | ||
![]() |
b3da67f31e | ||
![]() |
884169e745 | ||
![]() |
36bdb86343 | ||
![]() |
5784e38fbb | ||
![]() |
9811022b76 | ||
a150d1c17f | |||
96ebd89dd3 | |||
370a16441b | |||
71a07cc552 | |||
b1787886c6 | |||
8928ab9922 | |||
9b6c1beb8d | |||
2fefc9f96d | |||
d63eff681e | |||
ca61a66ca6 | |||
3a37f93ef7 | |||
7b5d4a071b | |||
2e4b24df10 | |||
b1728b0509 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -78,4 +78,4 @@ crashlytics-build.properties
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/unity
|
||||
|
||||
IOT/docs/doxygen output/*
|
||||
IOT/docs/doxygen output/*
|
||||
|
@ -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
|
18
IOT/config.cppcheck
Normal file
18
IOT/config.cppcheck
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="1">
|
||||
<builddir>.cppcheck-build</builddir>
|
||||
<platform>Unspecified</platform>
|
||||
<analyze-all-vs-configs>true</analyze-all-vs-configs>
|
||||
<check-headers>true</check-headers>
|
||||
<check-unused-templates>false</check-unused-templates>
|
||||
<max-ctu-depth>10</max-ctu-depth>
|
||||
<exclude>
|
||||
<path name="./.pio/" />
|
||||
</exclude>
|
||||
<suppressions>
|
||||
<suppression>noCopyConstructor</suppression>
|
||||
<suppression>noExplicitConstructor</suppression>
|
||||
<suppression>unusedFunction</suppression>
|
||||
<suppression>noOperatorEq</suppression>
|
||||
</suppressions>
|
||||
</project>
|
@ -14,7 +14,40 @@ 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\"
|
||||
-D DHTPIN=2
|
||||
|
||||
; ULTRASON pin
|
||||
; 5v
|
||||
-D ULTRA_SOUND_TRIGD=12
|
||||
-D ULTRA_SOUND_ECHO=13
|
||||
|
||||
; 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\"
|
||||
|
||||
-D EXAMPLE_NUMBER=69
|
||||
|
||||
;---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\"
|
@ -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
|
@ -1,4 +1,10 @@
|
||||
; Add additionnal environments in this file
|
||||
; Debug environemnt
|
||||
[env:test]
|
||||
test_build_src = true
|
||||
build_type = debug
|
||||
build_flags = ${env.build_flags}
|
||||
-D TESTING
|
||||
|
||||
; Default production environment
|
||||
[env:prod]
|
||||
|
@ -1,6 +1,17 @@
|
||||
#ifndef PROGRAM_H
|
||||
#define PROGRAM_H
|
||||
|
||||
#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:
|
||||
/**
|
||||
@ -17,5 +28,35 @@ public:
|
||||
|
||||
private:
|
||||
/* data */
|
||||
|
||||
/**
|
||||
* @brief capteur humi/temp
|
||||
*
|
||||
*/
|
||||
Capteur *dht;
|
||||
|
||||
/**
|
||||
* @brief capteur ultra son pour le niveau de remplissage de la poubelle
|
||||
*
|
||||
*/
|
||||
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
|
||||
*
|
||||
*/
|
||||
API *api;
|
||||
};
|
||||
#endif
|
@ -40,9 +40,7 @@ public:
|
||||
* @return false il y a une erreur durran l'envoie
|
||||
*/
|
||||
bool sendValue(String val, String poubelleID, String unit, bool full);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief connect l'utilisateur a l'api et met a jour le token
|
||||
*
|
||||
@ -51,6 +49,9 @@ private:
|
||||
*/
|
||||
bool connect();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
/**
|
||||
* @brief ID de l'utilisateur
|
||||
*
|
||||
@ -86,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;
|
||||
|
||||
@ -59,7 +61,8 @@ bool API::connect(){
|
||||
this->client->println();
|
||||
|
||||
|
||||
while (!client->available()) {}
|
||||
while (!client->available()) {
|
||||
}
|
||||
|
||||
String responce = "";
|
||||
while (client->available()) {
|
||||
@ -77,7 +80,10 @@ bool API::connect(){
|
||||
this->client->stop();
|
||||
|
||||
sortie = true;
|
||||
|
||||
if (JSONVar::stringify(JSONVar::parse(str)["code"]) == "400") {
|
||||
Serial.println("Failed to authenticate");
|
||||
return false;
|
||||
}
|
||||
return sortie;
|
||||
}
|
||||
|
||||
@ -115,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;
|
||||
}
|
76
IOT/lib/Capteur/include/Balance.h
Normal file
76
IOT/lib/Capteur/include/Balance.h
Normal 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
|
67
IOT/lib/Capteur/include/Capteur.h
Normal file
67
IOT/lib/Capteur/include/Capteur.h
Normal file
@ -0,0 +1,67 @@
|
||||
#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
|
35
IOT/lib/Capteur/include/HumiTemp.h
Normal file
35
IOT/lib/Capteur/include/HumiTemp.h
Normal file
@ -0,0 +1,35 @@
|
||||
#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
|
38
IOT/lib/Capteur/include/Ultrason.h
Normal file
38
IOT/lib/Capteur/include/Ultrason.h
Normal file
@ -0,0 +1,38 @@
|
||||
#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
|
58
IOT/lib/Capteur/src/Balance.cpp
Normal file
58
IOT/lib/Capteur/src/Balance.cpp
Normal 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;
|
||||
}
|
22
IOT/lib/Capteur/src/Capteur.cpp
Normal file
22
IOT/lib/Capteur/src/Capteur.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#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;
|
||||
}
|
34
IOT/lib/Capteur/src/HumiTemp.cpp
Normal file
34
IOT/lib/Capteur/src/HumiTemp.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#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);
|
||||
|
||||
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 > mintemp && temp < maxtemp) && (hum > minhum && hum < maxhum)){
|
||||
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)
|
19
IOT/lib/Capteur/src/Ultrason.cpp
Normal file
19
IOT/lib/Capteur/src/Ultrason.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#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.substring(0, this->fullVall.indexOf("/")).toInt())
|
||||
{
|
||||
this->full = true;
|
||||
}else if (sortie > this->fullVall.substring(this->fullVall.indexOf("/")+1, this->fullVall.length()).toInt()){
|
||||
this->full = false;
|
||||
}
|
||||
return String(sortie);
|
||||
}
|
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();
|
||||
}
|
@ -38,6 +38,11 @@ monitor_flags =
|
||||
lib_deps =
|
||||
bportaluri/WiFiEsp@^2.2.2 ; gestion des commande 'AT' de l'esp01
|
||||
arduino-libraries/Arduino_JSON@^0.2.0 ; gestion des json
|
||||
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
|
||||
|
||||
|
@ -2,9 +2,47 @@
|
||||
|
||||
|
||||
Program::Program(){
|
||||
|
||||
////////SERIALS//////
|
||||
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);
|
||||
|
||||
|
||||
//////CAPTEUR/////
|
||||
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->screen->clear();
|
||||
}
|
||||
|
||||
void Program::loop(){
|
||||
String distance = this->ultrasonic->read();
|
||||
String humitemp = this->dht->read();
|
||||
String poid = this->balance->read();
|
||||
|
||||
|
||||
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");
|
||||
|
||||
Serial.println("humiTemp = " + humitemp);
|
||||
this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull());
|
||||
Serial.println(this->dht->isFull()?" true":" false");
|
||||
|
||||
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();
|
||||
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
#ifndef TESTING
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Program.h"
|
||||
|
||||
@ -10,3 +12,4 @@ void setup() {
|
||||
void loop() {
|
||||
program->loop();
|
||||
}
|
||||
#endif
|
23
IOT/test/main.cpp
Normal file
23
IOT/test/main.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
#include "test.h"
|
||||
void setup() {
|
||||
delay(2000);
|
||||
// start unit tests engine
|
||||
UNITY_BEGIN();
|
||||
Serial.begin(115200);
|
||||
RUN_TEST(TestWifiBeginConnected);
|
||||
RUN_TEST(TestWifiBeginNotConnected);
|
||||
RUN_TEST(TestConnectAPI);
|
||||
// RUN_TEST(TestConnectAPIFailed);
|
||||
RUN_TEST(TestSendValue);
|
||||
|
||||
|
||||
UNITY_END();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
10
IOT/test/test.h
Normal file
10
IOT/test/test.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef TEST_H
|
||||
#define TEST_H
|
||||
|
||||
void TestWifiBeginConnected();
|
||||
void TestWifiBeginNotConnected();
|
||||
void TestConnectAPI();
|
||||
void TestConnectAPIFailed();
|
||||
void TestSendValue();
|
||||
|
||||
#endif
|
48
IOT/test/test_api.cpp
Normal file
48
IOT/test/test_api.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "test.h"
|
||||
#include <unity.h>
|
||||
#include "API.h"
|
||||
|
||||
|
||||
//Testing WifiBegin function
|
||||
void TestWifiBeginConnected() {
|
||||
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
||||
|
||||
Serial1.begin(MONITOR_SPEED);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(true, api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1), "Wifi not connected");
|
||||
|
||||
}
|
||||
|
||||
void TestWifiBeginNotConnected() {
|
||||
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
||||
|
||||
Serial2.begin(MONITOR_SPEED);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(false, api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial2), "Wifi connected");
|
||||
|
||||
}
|
||||
|
||||
//Testing Connect function
|
||||
void TestConnectAPI() {
|
||||
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
||||
|
||||
Serial1.begin(MONITOR_SPEED);
|
||||
api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(true, api->connect(), "Not Connected");
|
||||
}
|
||||
|
||||
//FIXME: boucle inf when connection failed
|
||||
void TestConnectAPIFailed() {
|
||||
API* api = new API("Carl", "toto", API_HOST);
|
||||
|
||||
Serial1.begin(MONITOR_SPEED);
|
||||
api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(false, api->connect(), "Connected");
|
||||
}
|
||||
|
||||
//Testing SendValue function
|
||||
void TestSendValue() {
|
||||
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
||||
|
||||
Serial1.begin(MONITOR_SPEED);
|
||||
api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(true, api->sendValue("30", "gdnuxl0wlgurtj3", "W", true), "Not Connected to server");
|
||||
}
|
10
README.md
10
README.md
@ -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) |
|
Loading…
x
Reference in New Issue
Block a user