mirror of
https://github.com/MOSH-Insa-Toulouse/5ISS-2024-2025-MARIN--MULLER-BOUJON.git
synced 2025-06-08 14:00:49 +02:00
Fixed issue with analog.
This commit is contained in:
parent
bbb968e1a5
commit
88e635bfb7
2 changed files with 7 additions and 2 deletions
|
@ -13,13 +13,13 @@ void Sensor::init(const uint8_t pin)
|
|||
|
||||
float Sensor::get_analog()
|
||||
{
|
||||
return analogRead(_pin);
|
||||
return (static_cast<float>(analogRead(_pin))/(1<<12))*3.3f;
|
||||
}
|
||||
|
||||
// Normally should be 5V, but the ADC can only see up to 3.3 on 12 bits
|
||||
float Sensor::get_RSR0()
|
||||
{
|
||||
float sensor_volt=(float)(analogRead(_pin))/((1<<12)*3.3);
|
||||
float sensor_volt=(static_cast<float>(analogRead(_pin))/(1<<12))*3.3f;
|
||||
float RS_gas = (3.3-sensor_volt)/sensor_volt;
|
||||
return RS_gas/R0;
|
||||
}
|
|
@ -113,7 +113,12 @@ void setup() {
|
|||
// Initialize SSD1306
|
||||
Init_SSD1306();
|
||||
delay(5000);
|
||||
|
||||
// Initialize Gateway from LoRa
|
||||
initGateway();
|
||||
|
||||
// Initialize Sensor
|
||||
gaz_sensor.init(SENSOR_PIN);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
Loading…
Add table
Reference in a new issue