fix: move IOT to capteur subfolder

This commit is contained in:
2023-06-25 10:38:25 +02:00
parent 36a1fe4d91
commit 8c588ed2c0
22 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,49 @@
#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,...)
*/
Capteur(String type);
/**
* @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 retourne le type de valeur lue
*
* @return String
*/
String getValType();
protected:
/**
* @brief type de mesure lue (T/H, W, D,...)
*
*/
String type;
};
#endif // CAPTEUR_H

View File

@ -0,0 +1,38 @@
#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,...)
*/
HumiTemp(int pin, uint8_t type);
/**
* @brief lit le capteur d'humi/temp
*
* @return String valeur format "XX/YY" X% et Y°C
*/
String read();
//TODO: faire commentaire
int getTemp();
int getHumi();
private:
DHT* capteur;
};
#endif //HUMI_TEMP_H

View File

@ -0,0 +1,13 @@
#include "../include/Capteur.h"
Capteur::Capteur(String type){
this->type = type;
}
bool Capteur::tar(int val){
return true;
}
String Capteur::getValType(){
return this->type;
}

View File

@ -0,0 +1,34 @@
#include "../include/HumiTemp.h"
HumiTemp::HumiTemp(int pin, uint8_t type):
Capteur("H/T"){
this->capteur = new DHT(pin, type);
this->capteur->begin();
}
int HumiTemp::getTemp(){
int temp = this->capteur->readTemperature();
if(isnan(temp)){
Serial.println(" DHT reading failed ");
return -1;
}
return temp;
}
int HumiTemp::getHumi(){
int hum = this->capteur->readHumidity();
if(isnan(hum)){
Serial.println(" DHT reading failed ");
return -1;
}
return hum;
}
String HumiTemp::read(){
String sortie = "";
sortie += String(this->getHumi());
sortie += "/";
sortie += String(this->getTemp());
return sortie;
}

46
IOT/Capteur/lib/README Normal file
View File

@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html