ArduinoGeneral

Question on Arduino CO2 sensor

userHead Account cancelled 2018-01-29 14:37:15 1911 Views0 Replies
I set up my code for the sensor, but when I try to run it using the IDE serial monitor, it doesn't load. any tips? my code is most likely incorrect, can someone let me know what I'm doing wrong? heres the tutorial for the sensor. https://www.dfrobot.com/wiki/index.php/ ... d_Overview

int sensorIn = A0;

void setup( ) {
serial.begin(9600);
// 5
analogReference(DEFAULT);
}

void loop(){
//Read voltage
int sensorValue = analogRead(sensorIn) ;

// The analog signal is converted to a voltage
float voltage = sensorValue* (5000/1024.0) ;
if(voltage == 0)
{
Serial.printIn("Fault") ;
}
else if (voltage < 400)
{
Serial.printIn("preheating") ;
}
else
{\
int voltage_difference=voltage-400;
float concentration=voltage_difference*50.0/16.0;
// Print Voltgae
Serial.print("voltage:") ;
Serial.print(voltage) ;
Serial.printIn("mv");
//Print CO2 concentration
Serial.print(concentration);
Serial.printIn("ppm") ;
}
delay(120) ;
}