75 Commits

Author SHA1 Message Date
5f057c2278 feat: kicad 2023-05-23 10:21:56 +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
7574061bec feat : gestion Capteur DJT (a tester) 2023-05-02 17:25:03 +02:00
edfdc6107f add reading in main program 2023-05-02 13:51:56 +02:00
4fe37fdf22 dht in main program 2023-05-02 13:50:16 +02:00
4f18142cc6 feat: DHT in main program 2023-05-02 13:50:07 +02:00
d8ed35483f add todo 2023-05-02 13:48:07 +02:00
c89b6d1479 typo: ";" 2023-05-02 13:45:05 +02:00
d67e4a9da8 add humitemp class for DHT capteur 2023-05-02 13:44:41 +02:00
cc583d0947 add todo 2023-05-02 13:44:07 +02:00
60ec85a572 Merge branch 'master' into refactor/class-abstraite-capteur 2023-05-02 12:30:06 +02:00
b26a27dc5b Merge pull request 'feat: intégration DHT capteur (humi,temp)' (#26) from feat/DHT-11-humi-dans-temp-capteur into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#26
Reviewed-by: nico <nicolas.sansd@gmail.com>
Reviewed-by: MDeghaud <michel.deghaud@epitech.eu>
2023-05-02 11:51:56 +02:00
fa6662e885 fix and comment 2023-05-02 11:51:39 +02:00
a47ec78e1c Merge branch 'master' into feat/DHT-11-humi-dans-temp-capteur 2023-05-02 11:46:37 +02:00
7b0d866d6f feat: use getvaltype in main program 2023-05-02 11:34:11 +02:00
db3ce5025b feat: add getType 2023-05-02 11:32:26 +02:00
f01844bed8 fix: decommante api 2023-05-02 11:29:18 +02:00
e002adacdd add testing main program 2023-05-02 11:27:39 +02:00
a533973e9c fix: revert full/empty 2023-05-02 11:27:21 +02:00
aed8706921 feat: implemente ultrasond in Capteur 2023-05-02 11:07:38 +02:00
e8b420f3f7 fix: typo 2023-05-02 11:07:18 +02:00
5b7f0f3d3e refacto: main 2023-05-02 10:45:12 +02:00
4cafc40d61 feat: création classe abstraite capteur 2023-05-02 10:40:02 +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
17b344732f Merge pull request 'feat: Test_IOT' (#40) from feat/Test_IOT into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#40
Reviewed-by: nico <nicolas.sansd@gmail.com>
Reviewed-by: Clement <clement@jo85.com>
2023-04-25 10:54:13 +02:00
9b0b5bedd8 feat: add doc for secret 2023-04-24 16:52:08 +02:00
e088b4e304 Fix: remove useless file 2023-04-24 16:49:54 +02:00
b3da67f31e feat: Add end to end test for ultrasonic capteur 2023-04-24 16:05:50 +02:00
884169e745 feat: add Test for sendValue 2023-04-24 15:49:16 +02:00
36bdb86343 feat: Add Test for Connect API 2023-04-24 14:54:26 +02:00
5784e38fbb feat: add Test for WifiConnect API 2023-04-24 12:22:52 +02:00
9811022b76 Create Branche Test_IOT 2023-04-24 11:17:36 +02:00
a150d1c17f Merge pull request 'add cppcheck config' (#39) from feat--cppcheck into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#39
2023-04-24 11:00:25 +02:00
96ebd89dd3 add cppcheck config 2023-04-24 10:59:32 +02:00
370a16441b Merge pull request 'feat: capteur-ultrason' (#27) from feat--capteur-ultrason into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#27
Reviewed-by: 5OLE1L <mathis.ragot@epitech.eu>
Reviewed-by: nico <nicolas.sansd@gmail.com>
2023-04-24 10:47:13 +02:00
71a07cc552 Merge pull request 'feat/AR_Architecture' (#37) from feat/AR_Architecture into master
Reviewed-on: Epitech-T-DEV-811/T-DEV-811#37
Reviewed-by: 5OLE1L <mathis.ragot@epitech.eu>
Reviewed-by: Clement <clement@jo85.com>
2023-04-24 09:54:04 +02:00
b1787886c6 Merge branch 'master' into feat/AR_Architecture 2023-04-24 09:53:37 +02:00
8928ab9922 Merge pull request 'feat/AR_Architecture' (#33) from feat/AR_Architecture into master
Reviewed-on: https://gitea.cb85.software/Epitech-T-DEV-811/T-DEV-811/pulls/33
Reviewed-by: Clement <clement@jo85.com>
2023-04-11 16:09:36 +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
7b5d4a071b feat: add ultrasonic sensor and exemple 2023-04-04 15:37:55 +02:00
2e4b24df10 feat: untra son config 2023-04-04 14:36:45 +02:00
b1728b0509 feat: intégration DHT capteur 2023-04-04 11:22:24 +02:00
32 changed files with 2458 additions and 8 deletions

2
.gitignore vendored
View File

@ -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/*

18
IOT/config.cppcheck Normal file
View 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>

View File

@ -14,7 +14,38 @@ 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---
-D ULTRA_SOUND_FULL=\"10\"
-D DHT_FULL=\"20:30/60:80\"
-D POID_FULL=\"100\"

View File

@ -18,7 +18,50 @@ 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 Ultrason{
- capteur: DHT*
+ HumiTemp(pin: int, type: String, fullVal: String)
+ read(): String
}
class Ultrason{
- capteur: Ultrasonic*
+ Ultrason(triguer: int, echo: int, fullVal: String)
+ read(): String
}
Balance --|> Capteur
Ultrason --|> Capteur
HumiTemp --|> Capteur
API -> Program
Program <-- Balance
Program <-- Ultrason
Program <-- HumiTemp
@enduml

View File

@ -0,0 +1 @@
/run/media/clement/Data/Mes_Docmument/Documents/Epitech/T-DEV-811/projet/project/IOT/docs/schéma/shéma poubelle/_autosave-shéma poubelle.kicad_sch

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
(kicad_pcb (version 20221018) (generator pcbnew)
)

View File

@ -0,0 +1,77 @@
{
"board": {
"active_layer": 0,
"active_layer_preset": "",
"auto_track_width": true,
"hidden_netclasses": [],
"hidden_nets": [],
"high_contrast_mode": 0,
"net_color_mode": 1,
"opacity": {
"images": 0.6,
"pads": 1.0,
"tracks": 1.0,
"vias": 1.0,
"zones": 0.6
},
"selection_filter": {
"dimensions": true,
"footprints": true,
"graphics": true,
"keepouts": true,
"lockedItems": false,
"otherItems": true,
"pads": true,
"text": true,
"tracks": true,
"vias": true,
"zones": true
},
"visible_items": [
0,
1,
2,
3,
4,
5,
8,
9,
10,
11,
12,
13,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
32,
33,
34,
35,
36,
39,
40
],
"visible_layers": "fffffff_ffffffff",
"zone_display_mode": 0
},
"meta": {
"filename": "shéma poubelle.kicad_prl",
"version": 3
},
"project": {
"files": []
}
}

View File

@ -0,0 +1,327 @@
{
"board": {
"3dviewports": [],
"design_settings": {
"defaults": {
"board_outline_line_width": 0.1,
"copper_line_width": 0.2,
"copper_text_size_h": 1.5,
"copper_text_size_v": 1.5,
"copper_text_thickness": 0.3,
"other_line_width": 0.15,
"silk_line_width": 0.15,
"silk_text_size_h": 1.0,
"silk_text_size_v": 1.0,
"silk_text_thickness": 0.15
},
"diff_pair_dimensions": [],
"drc_exclusions": [],
"rules": {
"min_copper_edge_clearance": 0.0,
"solder_mask_clearance": 0.0,
"solder_mask_min_width": 0.0
},
"track_widths": [],
"via_dimensions": []
},
"layer_presets": [],
"viewports": []
},
"boards": [],
"cvpcb": {
"equivalence_files": []
},
"erc": {
"erc_exclusions": [],
"meta": {
"version": 0
},
"pin_map": [
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
2
],
[
0,
1,
0,
0,
0,
0,
1,
1,
2,
1,
1,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2
],
[
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
2
],
[
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
1,
2,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
0,
2,
1,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
],
"rule_severities": {
"bus_definition_conflict": "error",
"bus_entry_needed": "error",
"bus_to_bus_conflict": "error",
"bus_to_net_conflict": "error",
"conflicting_netclasses": "error",
"different_unit_footprint": "error",
"different_unit_net": "error",
"duplicate_reference": "error",
"duplicate_sheet_names": "error",
"endpoint_off_grid": "warning",
"extra_units": "error",
"global_label_dangling": "warning",
"hier_label_mismatch": "error",
"label_dangling": "error",
"lib_symbol_issues": "warning",
"missing_bidi_pin": "warning",
"missing_input_pin": "warning",
"missing_power_pin": "error",
"missing_unit": "warning",
"multiple_net_names": "warning",
"net_not_bus_member": "warning",
"no_connect_connected": "warning",
"no_connect_dangling": "warning",
"pin_not_connected": "error",
"pin_not_driven": "error",
"pin_to_pin": "warning",
"power_pin_not_driven": "error",
"similar_labels": "warning",
"simulation_model_issue": "ignore",
"unannotated": "error",
"unit_value_mismatch": "error",
"unresolved_variable": "error",
"wire_dangling": "error"
}
},
"libraries": {
"pinned_footprint_libs": [],
"pinned_symbol_libs": []
},
"meta": {
"filename": "shéma poubelle.kicad_pro",
"version": 1
},
"net_settings": {
"classes": [
{
"bus_width": 12,
"clearance": 0.2,
"diff_pair_gap": 0.25,
"diff_pair_via_gap": 0.25,
"diff_pair_width": 0.2,
"line_style": 0,
"microvia_diameter": 0.3,
"microvia_drill": 0.1,
"name": "Default",
"pcb_color": "rgba(0, 0, 0, 0.000)",
"schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.25,
"via_diameter": 0.8,
"via_drill": 0.4,
"wire_width": 6
}
],
"meta": {
"version": 3
},
"net_colors": null,
"netclass_assignments": null,
"netclass_patterns": []
},
"pcbnew": {
"last_paths": {
"gencad": "",
"idf": "",
"netlist": "",
"specctra_dsn": "",
"step": "",
"vrml": ""
},
"page_layout_descr_file": ""
},
"schematic": {
"annotate_start_num": 0,
"drawing": {
"dashed_lines_dash_length_ratio": 12.0,
"dashed_lines_gap_length_ratio": 3.0,
"default_line_thickness": 6.0,
"default_text_size": 50.0,
"field_names": [],
"intersheets_ref_own_page": false,
"intersheets_ref_prefix": "",
"intersheets_ref_short": false,
"intersheets_ref_show": false,
"intersheets_ref_suffix": "",
"junction_size_choice": 3,
"label_size_ratio": 0.375,
"pin_symbol_size": 25.0,
"text_offset_ratio": 0.15
},
"legacy_lib_dir": "",
"legacy_lib_list": [],
"meta": {
"version": 1
},
"net_format_name": "",
"page_layout_descr_file": "",
"plot_directory": "",
"spice_current_sheet_as_root": false,
"spice_external_command": "spice \"%I\"",
"spice_model_current_sheet_as_root": true,
"spice_save_all_currents": false,
"spice_save_all_voltages": false,
"subpart_first_id": 65,
"subpart_id_separator": 0
},
"sheets": [],
"text_variables": {}
}

View File

@ -0,0 +1,5 @@
(kicad_sch (version 20230121) (generator eeschema)
(paper "A4")
(lib_symbols)
(symbol_instances)
)

View File

@ -0,0 +1,20 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#
# HC-SR04
#
DEF HC-SR04 U 0 40 Y Y 1 F N
F0 "U" -250 -300 60 H V C CNN
F1 "HC-SR04" -100 300 60 H V C CNN
F2 "" 0 0 60 H V C CNN
F3 "" 0 0 60 H V C CNN
DRAW
S 0 250 -300 -250 0 1 0 N
X VCC 1 200 150 200 L 50 50 1 1 I
X TRIG 2 200 50 200 L 50 50 1 1 I
X ECHO 3 200 -50 200 L 50 50 1 1 I
X GND 4 200 -150 200 L 50 50 1 1 I
ENDDRAW
ENDDEF
#
#End Library

View File

@ -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]

View File

@ -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

View File

@ -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,11 @@ private:
*/
bool connect();
//TODO :: Check wifibegin avant
private:
/**
* @brief ID de l'utilisateur
*

View File

@ -59,7 +59,8 @@ bool API::connect(){
this->client->println();
while (!client->available()) {}
while (!client->available()) {
}
String responce = "";
while (client->available()) {
@ -77,7 +78,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;
}

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

@ -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

View 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

View 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

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

@ -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;
}

View File

@ -0,0 +1,26 @@
#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);
//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
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)

View 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.toInt())
{
this->full = true;
}else{
this->full = false;
}
return String(sortie);
}//TODO: faire en sorte que full se reset avec une autre val

View File

@ -0,0 +1,59 @@
#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 print the total amount on the screen
*
* @param amount The total amount to print in centimes
*/
void printAmount(int amount);
/**
* @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,76 @@
#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::printAmount(int amount) {
this->display->clearDisplay();
this->display->setCursor(0, 0);
this->display->setTextSize(2);
this->display->setTextColor(WHITE);
this->display->println(F(" Total: "));
this->display->println();
this->display->print(amount / 100);
this->display->print(F(","));
int centimes = amount % 100;
if (centimes < 10) {
this->display->print(F("0"));
}
this->display->println(centimes);
this->display->print(F(" EUR"));
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

@ -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

View File

@ -2,9 +2,49 @@
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.print("Distance in CM = " + distance);
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(this->dht->isFull()?" true":" false");
this->api->sendValue(poid, TRASHCAN_THREE, this->balance->getValType(), this->balance->isFull());
Serial.print("poid = " + poid);
Serial.println(this->balance->isFull()?" true":" false");
Serial.println();
delay(1000);
}

View File

@ -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
View 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
View 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
View 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");
}