Hi everyone,
I've been trying to get my SO2 sensor the 110-601 from Spec Sensors to work but have ran into a little trouble. I'm mostly using code used for a similar sensor from the same company but have modified it somewhat to work with the 110-601, but it still only gives wrong readings. I'm reading an average of 100 ppm, which would mean I should be very dead. A correct reading would be way below 0.1 ppm.
The sensor produces these results:
I'm using the same set up as the tutorial:
Could anybody help me figure out what I am doing wrong or missing?
Code used:
/*
Analog input, Serial output
Reads an analog gas sensor at pins A0,
Also prints the results to the serial monitor.
The circuit:
Gas sensor pin W (Working) connected to middle of resistor ladder (I used 10k and 100k).
Gas sensor C (counter) and R (reference) connected together and then jumped to analog pin A0.
10 kOhm resistor between W1/W2 and C/R.
created 01 Jul. 2017
by David Peaslee
*/
// these constants won't change. They're used to give names to the pins used:
const int analogInPin = A1; // Analog input pin that the sensor is attached to
const int resValue = 10000; // Value of 10kOhm resistor !change this to match your resistor
const float Vref = 1.1; //This is the voltage of the internal reference
const long int cOff = 68286; //286mV offset due to resistor ladder. Try taking the average of a long
//measurement of the counts without a sensor in place. This should give a good Zero.
const float Sf = 15.04; // sensitivity in nA/ppm,
//this is roughly about 1/2 the sensitivity of the barcode on the sensor. Try finding a known
//concentration of CO to measure, or just approximate.
const int extraBit = 256; //Number of samples averaged, like adding 8 bits to ADC
long int sensorValue = 0; // value read from the sensor
float currentValue = 0; // current read from the sensor
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// !!!set analog reference to 1.1 Volts!!!
analogReference(INTERNAL);
Serial.print("\n============");
Serial.print("\nStarting Program\n");
}
void loop() {
// read the analog in value:
sensorValue = 0;
for (int i = 0; i < extraBit; i++) {
sensorValue = analogRead(analogInPin) + sensorValue;
delay(3); // needs 2 ms for the analog-to-digital converter to settle after the last reading
}
sensorValue = sensorValue - cOff; //subtract the offset of the resistor ladder * 256.
// print the results to the serial monitor:
Serial.print("PPM = ");
Serial.print( ((float) sensorValue / extraBit / 1024 * Vref / resValue * 1000000000) / Sf);
Serial.print("\tnA = ");
Serial.print( (float) (sensorValue) / extraBit / 1024 * Vref / resValue * 1000000000);
Serial.print("\tCounts = " );
Serial.println(sensorValue);
//Trying to make each loop 1 second
delay(218); //1 second – 3ms*256ms (each adc read)-14ms (for printing)= 218ms
}