Files
Jérôme Delacotte 7b30d6e298 first commit
2025-03-06 11:15:32 +01:00

75 lines
1.6 KiB
C++
Executable File

#include "Modules.h"
// int status = WL_IDLE_STATUS; // the Wifi radio's status
//WiFiClient client;
// Dallas
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
Modules::Modules()
{
}
void Modules::readTemperature()
{
int bcl = 0;
temp = -127;
DS18B20.requestTemperatures();
while (bcl < 10 && (temp < 0 || temp > 50)) {
temp = DS18B20.getTempCByIndex(0);
Serial.print("Temperature: ");
Serial.println(temp);
bcl++;
if (temp < 0 || temp > 50) {
Serial.print("Temp non lue");
Serial.println(temp);
delay(100);
}
}
}
//void Modules::barometre() {
// /* See Example: TypeA_WithDIPSwitches */
//
// delay(500);
// Serial.print("Barometre: ");
// //Serial.println(bmp.begin());
// // BMP
//
// if (bmp.begin()) {
// delay(1000);
// temp = bmp.readTemperature();
// pressure = bmp.readPressure() / 100.0;
// pression = pressure / 101.325;
// pression = pression * 0.760 * 100;
// // http://en.wikipedia.org/wiki/Atmospheric_pressure#Mean_sea_level_pressure
// // Serial.print("Presiure la nivelul marii (calculata) = ");
// presiune = bmp.readSealevelPressure(ALTITUDE) / 101.325;
// presiune = presiune * 0.760;
// Serial.print("Temperature="); Serial.println(temp);
// Serial.print("pressure="); Serial.println(pressure);
// Serial.print("pression="); Serial.println(pression);
//
// }
//}
void Modules::sleep(int sleepTime)
{
Serial.print("Go to sleep ");
Serial.println(sleepTime);
delay(20);
ESP.deepSleep(sleepTime * 1000000L); // Infini
//sleepWifi();
delay(200);
}
void Modules::readLuminosite()
{
lum = analogRead(PIN_LUM);
}