Arduino Microcotroller

Lav din egen  CO2 måler med disse komponenter:

  • Arduino Uno
  • 6V Strømforsyning
  • MG811 sensor
  • Breadboard og ledninger
  • LCD display (valgfrit)
  • Potentiometer (valgfrit kun nødvendigt til display udgave)

 

Til at bygge en CO2 måler med display skal du bruge dette Arduino sketch:

// include the library code:
#include// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int CO2pin=A0;
int Sensorvalue;
float Voltage;
float CO2ppm;
float e = 2.7182818284590452353602874713527;void setup() {
pinMode(CO2pin, INPUT);
Serial.begin(9600);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“CO2 ppm”);
}void loop() {
Sensorvalue = analogRead(CO2pin);
Voltage = (5000./1023.)*Sensorvalue;
CO2ppm = 179884*pow(e,-0.006787338754623*Voltage);
Serial.println(CO2ppm);
delay(5000);
lcd.setCursor(0, 1);
lcd.print(CO2ppm);
}