mirror of
https://github.com/MOSH-Insa-Toulouse/5ISS-2024-2025-MARIN--MULLER-BOUJON.git
synced 2025-06-08 14:00:49 +02:00
Merge branch 'master' of https://github.com/Lemonochrme/gaz-sensor-ptp-iss
This commit is contained in:
commit
bbb968e1a5
2 changed files with 14 additions and 14 deletions
|
@ -11,17 +11,15 @@ void Sensor::init(const uint8_t pin)
|
|||
digitalWrite(_pin, HIGH);
|
||||
}
|
||||
|
||||
float Sensor::get_value()
|
||||
float Sensor::get_analog()
|
||||
{
|
||||
/*
|
||||
float sensor_volt;
|
||||
float RS_gas; // Get value of RS in a GAS
|
||||
float ratio; // Get ratio RS_GAS/RS_air
|
||||
int sensorValue = analogRead(A0);
|
||||
sensor_volt=(float)sensorValue/1024*5.0;
|
||||
RS_gas = (5.0-sensor_volt)/sensor_volt; // omit *RL
|
||||
//-Replace the name "R0" with the value of R0 in the demo of First Test
|
||||
ratio = RS_gas/R0; // ratio = RS/R0
|
||||
*/
|
||||
return ((analogRead(_pin))/1024*5.0);
|
||||
return analogRead(_pin);
|
||||
}
|
||||
|
||||
// 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 RS_gas = (3.3-sensor_volt)/sensor_volt;
|
||||
return RS_gas/R0;
|
||||
}
|
|
@ -3,13 +3,15 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
constexpr uint8_t SENSOR_PIN = 36;
|
||||
constexpr uint8_t SENSOR_PIN = 34;
|
||||
constexpr float R0 = 0.8;
|
||||
|
||||
class Sensor {
|
||||
public:
|
||||
Sensor();
|
||||
void init(const uint8_t pin);
|
||||
float get_value();
|
||||
float get_analog();
|
||||
float get_RSR0();
|
||||
private:
|
||||
uint8_t _pin;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue