Professional Documents
Culture Documents
Learn about Arduino and the Arduino UNO and how you can integrate this board into your makerspace and coding program. Make interactive makerspace projects while learning to code and problem solve.
In this Lab Interface different sensors with esp32 that you have already interfaced with Arduino.
Lab Tasks
Serial.begin(115200);
/* Start the DHT11 Sensor */
dht.begin();
}
void loop()
{
float humi = dht.readHumidity();
float temp = dht.readTemperature();
Serial.print("Temperature: ");
Serial.print(temp);
Serial.print("ºC ");
Serial.print("Humidity: ");
Serial.println(humi);
delay(1000);
}
1
ESP with sensors Lab 7
delay(10);
/*
2
ESP with sensors Lab 7
PIR sensor tester
*/
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop() {
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
Serial.println("Motion detected!");
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH) {
// we have just turned of
Serial.println("Motion ended!");
// We only want to print on the output change, not state
pirState = LOW;
}
}
}
3
ESP with sensors Lab 7
Conclusion