mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-05 12:54:57 +00:00
Added code for the MQ5 gas sensor
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
|
||||
#define DHTPIN 4
|
||||
#define DHTTYPE DHT11
|
||||
#define MQ5_PIN 2
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
dht.begin();
|
||||
pinMode(MQ5_PIN, INPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -15,6 +17,8 @@ void loop() {
|
||||
|
||||
float h = dht.readHumidity();
|
||||
float t = dht.readTemperature();
|
||||
|
||||
int mq5Value = analogRead(MQ5_PIN);
|
||||
|
||||
if (isnan(h) || isnan(t)) {
|
||||
Serial.println("Fout bij het lezen van de sensor!");
|
||||
@@ -26,4 +30,7 @@ void loop() {
|
||||
Serial.print(" %\tTemperatuur: ");
|
||||
Serial.print(t);
|
||||
Serial.println(" *C");
|
||||
|
||||
Serial.print("MQ5 waarde: ");
|
||||
Serial.println(mq5Value);
|
||||
}
|
Reference in New Issue
Block a user