mirror of
https://github.com/MOSH-Insa-Toulouse/5ISS-2024-2025-MARIN--MULLER-BOUJON.git
synced 2025-06-08 14:00:49 +02:00
Updated sensor.
This commit is contained in:
parent
87f1e992b9
commit
02e2fb71cd
2 changed files with 14 additions and 14 deletions
|
@ -11,17 +11,15 @@ void Sensor::init(const uint8_t pin)
|
||||||
digitalWrite(_pin, HIGH);
|
digitalWrite(_pin, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Sensor::get_value()
|
float Sensor::get_analog()
|
||||||
{
|
{
|
||||||
/*
|
return analogRead(_pin);
|
||||||
float sensor_volt;
|
}
|
||||||
float RS_gas; // Get value of RS in a GAS
|
|
||||||
float ratio; // Get ratio RS_GAS/RS_air
|
// Normally should be 5V, but the ADC can only see up to 3.3 on 12 bits
|
||||||
int sensorValue = analogRead(A0);
|
float Sensor::get_RSR0()
|
||||||
sensor_volt=(float)sensorValue/1024*5.0;
|
{
|
||||||
RS_gas = (5.0-sensor_volt)/sensor_volt; // omit *RL
|
float sensor_volt=(float)(analogRead(_pin))/((1<<12)*3.3);
|
||||||
//-Replace the name "R0" with the value of R0 in the demo of First Test
|
float RS_gas = (3.3-sensor_volt)/sensor_volt;
|
||||||
ratio = RS_gas/R0; // ratio = RS/R0
|
return RS_gas/R0;
|
||||||
*/
|
|
||||||
return ((analogRead(_pin))/1024*5.0);
|
|
||||||
}
|
}
|
|
@ -3,13 +3,15 @@
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
constexpr uint8_t SENSOR_PIN = 36;
|
constexpr uint8_t SENSOR_PIN = 34;
|
||||||
|
constexpr float R0 = 0.8;
|
||||||
|
|
||||||
class Sensor {
|
class Sensor {
|
||||||
public:
|
public:
|
||||||
Sensor();
|
Sensor();
|
||||||
void init(const uint8_t pin);
|
void init(const uint8_t pin);
|
||||||
float get_value();
|
float get_analog();
|
||||||
|
float get_RSR0();
|
||||||
private:
|
private:
|
||||||
uint8_t _pin;
|
uint8_t _pin;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue