Arduino Grove - Gas Sensor(O₂)

Arduino, Seeeduino Serials and mutants. Share your problems and experence on arduino compatible board such as seeeduino/stalker, etc.

Moderators: violet, salmanfarisvp

Post Reply
linio.nanel
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Tue Oct 16, 2018 1:58 pm

Arduino Grove - Gas Sensor(O₂)

Post by linio.nanel » Tue Oct 16, 2018 2:11 pm

Hello there

I bought a new Grove - Gas Sensor(O₂) and loaded the code from the Seed Wiki Website.
Unfortunately, the displayed values are totally wrong (see screenshot). Does any one of you have an idea why?

Thank you for your answers in advance

Code: Select all

// Grove - Gas Sensor(O2) test code
// Note:
// 1. It need about about 5-10 minutes to preheat the sensor
// 2. modify VRefer if needed

const float VRefer = 3.3;       // voltage of adc reference

const int pinAdc   = A0;

void setup() 
{
    // put your setup code here, to run once:
    Serial.begin(9600);
    Serial.println("Grove - Gas Sensor Test Code...");
}

void loop() 
{
    // put your main code here, to run repeatedly:
    float Vout =0;
    Serial.print("Vout =");

    Vout = readO2Vout();
    Serial.print(Vout);
    Serial.print(" V, Concentration of O2 is ");
    Serial.println(readConcentration());
    delay(500);
}

float readO2Vout()
{
    long sum = 0;
    for(int i=0; i<32; i++)
    {
        sum += analogRead(pinAdc);
    }

    sum >>= 5;

    float MeasuredVout = sum * (VRefer / 1023.0);
    return MeasuredVout;
}

float readConcentration()
{
    // Vout samples are with reference to 3.3V
    float MeasuredVout = readO2Vout();

    //float Concentration = FmultiMap(MeasuredVout, VoutArray,O2ConArray, 6);
    //when its output voltage is 2.0V,
    float Concentration = MeasuredVout * 0.21 / 2.0;
    float Concentration_Percentage=Concentration*100;
    return Concentration_Percentage;
}
Attachments
Unbenannt.PNG
Screenshot of the Serial Monitor
Unbenannt.PNG (24.22 KiB) Viewed 1185 times

bill.yu
Elementary-4
Elementary-4
Posts: 400
Joined: Mon Apr 02, 2018 11:05 am

Re: Arduino Grove - Gas Sensor(O₂)

Post by bill.yu » Tue Oct 16, 2018 4:25 pm

Hi there,

Please try this code include the calibration.

https://github.com/SeeedDocument/forum_ ... _value.zip thanks.

linio.nanel
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Tue Oct 16, 2018 1:58 pm

Re: Arduino Grove - Gas Sensor(O₂)

Post by linio.nanel » Fri Oct 19, 2018 4:01 pm

Thanks a lot it works ! :D

Post Reply