 i have an arduino sketch which reads the value of a grove O2 sensor and i was wondering how you convert the voltage into a percentage.

The magic keyword is "calibration". But you need to have another meter to compare your values against to do that. This is usually outside the capabilities of an average home user. Usually these sensor are not accurate enough to deliver absolute readings. Use them to see changes in the concentration that give you some hints about how much the concentration changed. But don't expect measurements that give you a percentage or a PPM value.

i think that it has come pre-calibrated. i have the voltage reading of about 0.73V and i was wondering how you would put it as a percentage.

The sensors web page gives you an estimation of the percentage value:

Here is the correlation between ME2-O2 output current and concentration of O2. The current of 20% concentration O2 is around 120uA. So the Grove SIGA voltage @ 20% concentration = R7 * Current(ME2-O2) * 121 = 100 * 120uA * 121 = 1.452V.

thanks :).
but how would you code it so that you put the voltage as a percentage in the code??

This is an example of the code and towards the bottom you will see the conversion from a voltage to a percentage of O2.

https://www.mouser.com/datasheet/2/744/Seeed_101020002-786509.pdf

``````#include <math.h>
const int buzzerPin=3; //Connect the Buzzer Grove module to Pin3, Digital 3
float WarningValue= 19.5; //The minimum sate concentration of O2 in air
void setup()
{
Serial.begin(9600); //Start the Serial connection
}
void loop()
{
//long unsigned a;
float sensorValue;
float sensorVoltage;
float Value_O2;
sensorVoltage =(sensorValue/1024)*5.0;
sensorVoltage = sensorVoltage/201*10000;
Value_O2 = sensorVoltage/7.43;
Serial.print("Concentration of O2 is ");
Serial.print(Value_O2,1);
Serial.println("%");
if(Value_O2<=WarningValue)
{
digitalWrite(3,HIGH);
6
}
else digitalWrite(3,LOW);
delay(1000);
}
}
``````

Yes, it would be nice to have a concentrated gas mixture to actually calibrate. Calibrated gas mixtures with certs can get pricey.

Ron

thanks for the code:) . i will test it now.