Created
December 19, 2016 20:46
-
-
Save glebmtb/fe2b0183f8ba611d73acd98e5c81e9c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Nokia_5110.h" | |
#include "DHT.h" | |
#include "MQ135.h" | |
#define LCD_RST 7 | |
#define LCD_CE 6 | |
#define LCD_DC 5 | |
#define LCD_DIN 4 | |
#define LCD_CLK 3 | |
#define DHT_PIN 2 | |
#define DHT_TYPE DHT11 | |
#define MQ135_ANALOG_PIN 4 | |
Nokia_5110 lcd = Nokia_5110(LCD_RST, LCD_CE, LCD_DC, LCD_DIN, LCD_CLK); | |
DHT dht(DHT_PIN, DHT_TYPE); | |
MQ135 gasSensor = MQ135(MQ135_ANALOG_PIN); | |
void setup() { | |
lcd.println("DHTxx test!"); | |
dht.begin(); | |
lcd.clear(); | |
lcd.setContrast(55); | |
} | |
void loop() { | |
lcd.setCursor(0, 2); | |
lcd.print("MQ135: "); | |
int mq135 = analogRead(MQ135_ANALOG_PIN); | |
lcd.print(mq135); | |
lcd.println(""); | |
lcd.print("PPM: "); | |
lcd.print(gasSensor.getPPM()); | |
lcd.println(""); | |
lcd.println(""); | |
lcd.print("Zero: "); | |
lcd.print(gasSensor.getRZero()); | |
lcd.setCursor(0, 0); | |
lcd.print("DHT11: "); | |
int humidity = dht.readHumidity(); | |
int temperature = dht.readTemperature(); | |
if (isnan(humidity) || isnan(temperature)) { | |
lcd.setCursor(0, 4); | |
lcd.print("Failed sensor!"); | |
} else { | |
lcd.print(humidity); | |
lcd.print("% "); | |
lcd.print(temperature); | |
lcd.print("*C"); | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment