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 DHTPIN 4
|
||||||
#define DHTTYPE DHT11
|
#define DHTTYPE DHT11
|
||||||
|
#define MQ5_PIN 2
|
||||||
|
|
||||||
DHT dht(DHTPIN, DHTTYPE);
|
DHT dht(DHTPIN, DHTTYPE);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
dht.begin();
|
dht.begin();
|
||||||
|
pinMode(MQ5_PIN, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@@ -16,6 +18,8 @@ void loop() {
|
|||||||
float h = dht.readHumidity();
|
float h = dht.readHumidity();
|
||||||
float t = dht.readTemperature();
|
float t = dht.readTemperature();
|
||||||
|
|
||||||
|
int mq5Value = analogRead(MQ5_PIN);
|
||||||
|
|
||||||
if (isnan(h) || isnan(t)) {
|
if (isnan(h) || isnan(t)) {
|
||||||
Serial.println("Fout bij het lezen van de sensor!");
|
Serial.println("Fout bij het lezen van de sensor!");
|
||||||
return;
|
return;
|
||||||
@@ -26,4 +30,7 @@ void loop() {
|
|||||||
Serial.print(" %\tTemperatuur: ");
|
Serial.print(" %\tTemperatuur: ");
|
||||||
Serial.print(t);
|
Serial.print(t);
|
||||||
Serial.println(" *C");
|
Serial.println(" *C");
|
||||||
|
|
||||||
|
Serial.print("MQ5 waarde: ");
|
||||||
|
Serial.println(mq5Value);
|
||||||
}
|
}
|
Reference in New Issue
Block a user