Smart Home in the Classroom with Arduino

FunduinoPublished on

Das Smart Home Education System – Aufbau, 16 Module und Home Assistant

Willkommen beim Funduino Smart Home Education System. Dieses Lern- und Experimentierset richtet sich an technikbegeisterte Lernende, Lehrkräfte und Ausbilder, die Smart-Home-Technik, Sensorik, Aktorik und das Internet der Dinge praxisnah vermitteln möchten.

An Bord sind Sensoren für Temperatur, Luftfeuchtigkeit, Licht, Bewegung, Flüssigkeit, Gas und Entfernung – dazu Aktoren wie Servo, Lüfter, LEDs, OLED-Display, WS2812-Beleuchtung und Lautsprecher, gesteuert von einem ESP32 mit WLAN und Bluetooth.

Diese Anleitung führt dich durch den Aufbau, die Einrichtung der Arduino IDE und alle 16 Module einzeln – jedes mit eigenem Beispielsketch. Am Ende kannst du Sensorwerte auswerten, Aktoren ansteuern und eigene Automatisierungen bauen. Zum Schluss zeigen wir, wie du das ganze System in Home Assistant einbindest.

Model workshop of the Funduino Smart Home Education System
The Funduino Smart Home Education System

Hardware overview

The Funduino smart home system consists of a model workshop enhanced with an electronics board, giving every project a connection to everyday life.

The following components are mounted on the board:

  • No. 1: Red LED – connected to pin 25
  • No. 2: Green LED – connected to pin 26
  • No. 3: Push button – connected to pin 23
  • No. 4: Buzzer (piezo speaker) – connected to pin 19
  • No. 5: Potentiometer – connected to pin 39
  • No. 6: Ultrasonic distance sensor – connected to pins 17 and 18
  • No. 7: OLED display with SSD1306 chip – connected via I²C: SCL 22 and SDA 21
  • No. 8: Fan – connected to pin 4
  • No. 9: VS1838 IR receiver for remote controls – connected to pin 16
  • No. 10: WS2812 interior lighting with 8 LEDs – connected to pin 15
  • No. 11: DHT11 temperature and humidity sensor – connected to pin 14
  • No. 12: Light intensity sensor (LDR) – connected to pin 35
  • No. 13: PIR motion sensor – connected to pin 13
  • No. 14: Servo for the automatic door – connected to pin 12
  • No. 15: MQ135 gas sensor – connected to pin 34
  • No. 16: Moisture sensor – connected to pin 36

The fan can also be switched on manually using the button on the front.

Front of the smart home board with numbered components
Front view of the circuit board
Back of the smart home board with numbered components
Rear view of the circuit board
1 / 2

Setup and preparation

The assembly consists of two sections.

First, assemble the model workshop. It’s quick and self-explanatory.

In the second step, add the board’s components: plug the servo, WS2812 LED bar, MQ135 sensor, fan, and humidity sensor into the back.

Important notes:

  • Servo: It is mounted on the back using the black plastic holder. Use the two screws of equal size supplied with the servo. Insert them through the board from the front and screw them into the plastic holder.
  • Fan: Attach it by hand from the back using the supplied white nylon screws and nuts. The fan’s round sticker should face inward.

Then install the board in the right side panel. First, remove the acrylic panels from the model, lift the upper black brace with the small headlights, and insert the board so that it is secured on all sides. Then put the acrylic panels back in.

Do not install the door yet! It is only installed once the servo has been programmed and set to 90 degrees - otherwise it will move through an arbitrary range or hit the sides.

Set up the Arduino IDE for the ESP32

The Smart Home runs on an ESP32. There are many ways to program it - in this guide, we use the Arduino IDE throughout.

1. Install the Arduino IDE

Download the Arduino IDE from arduino.cc and install it as usual.

2. Add ESP32 support

To make the IDE recognize the ESP32, go to File › Preferences and enter this address in the “Additional Board Manager URLs” field:

https://dl.espressif.com/dl/package_esp32_index.json

3. Install the ESP32 board package

Go to Tools › Board › Board Manager, enter “ESP32” in the search field, select “ESP32 by Espressif Systems” and click Install.

4. Select the board and port

Under Tools › Board, select “ESP32 Dev Module”; under Tools › Port, select the port your ESP32 is connected to (for example, COM3). The correct port is usually the most recently added entry.

5. Sketch structure

An Arduino program is called a sketch and has two sections: setup() runs once to prepare things, while your main logic runs repeatedly in loop().

Important when uploading: After clicking the upload arrow, the sketch is compiled first, which takes a few seconds. As soon as the upload starts, you need to press the “Boot” button on the ESP32 - its memory can only be written to in this mode. If you don't press the button, the process will stop with an error message. This applies to every sketch in this guide.

Module 1: Red LED

Plug the ESP32 into the board and connect the USB cable. It is already connected to all the modules on the board - you don't need to wire anything.

To get started, use the red LED on pin 25 and make it blink once per second. This also checks that the board, port, and upload are working.

Red LED on the Smart Home board
The red LED on pin 25
Make a red LED blink
// Auf der Platine ist die rote LED mit dem digitalen Pin 25 des ESP32 verbunden.
int ledPin = 25;

void setup()
{
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  digitalWrite(ledPin, HIGH);  // LED an
  delay(1000);                 // 1 Sekunde warten
  digitalWrite(ledPin, LOW);   // LED aus
  delay(1000);                 // 1 Sekunde warten
}

Module 2: Green LED

Program the green LED in the same way as the red one. In the sketch, you only need to change the output pin: the green LED is connected to pin 26, not pin 25.

Green LED on the smart home board
The green LED on pin 26
Make the green LED blink
// Die grüne LED hängt an Pin 26 statt an Pin 25.
int ledPin = 26;

void setup()
{
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  digitalWrite(ledPin, HIGH);  // LED an
  delay(1000);                 // 1 Sekunde warten
  digitalWrite(ledPin, LOW);   // LED aus
  delay(1000);                 // 1 Sekunde warten
}

Module 3: Push Button

In this example, the push button turns both LEDs on simultaneously for 5 seconds.

Pressing the button sends a voltage to input pin 23 of the ESP32. A pulldown resistor is also connected in the circuit (below the push button). It ensures that the pin is pulled back down to GND as soon as you release the button.

If the button does not respond as expected: The sketch sets the pin with pinMode(BUTTON_PIN, INPUT_PULLUP). With an external pull-down resistor, pinMode(BUTTON_PIN, INPUT) is sufficient - try that in this case.

Button on the smart home board
The button on Pin 23
Button: turn on both LEDs for 5 seconds
#define LED_RED    25
#define LED_GREEN  26
#define BUTTON_PIN 23

void setup()
{
  pinMode(LED_RED, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  digitalWrite(LED_RED, LOW);
  digitalWrite(LED_GREEN, LOW);
}

void loop()
{
  if (digitalRead(BUTTON_PIN) == HIGH)  // If the button is pressed ...
  {
    digitalWrite(LED_RED, HIGH);    // turn on the red LED
    digitalWrite(LED_GREEN, HIGH);  // turn on the green LED
    delay(5000);                    // leave on for 5 seconds
    digitalWrite(LED_RED, LOW);     // turn off the red LED
    digitalWrite(LED_GREEN, LOW);   // turn off the green LED
  }
}

Module 4: Buzzer

You control the buzzer on the board in the same way as an LED: it only needs a voltage and then produces a tone. This tone always has the same pitch and cannot be changed, unlike with a speaker.

The buzzer is connected to pin 19.

Piezo buzzer on the smart home board
The piezo buzzer on pin 19
Buzzer: Turn the sound on and off alternately
int buzzer = 19;
void setup()
{
  pinMode(buzzer, OUTPUT);
}

void loop()
{
  digitalWrite(buzzer, HIGH);  // Sound on
  delay(1000);                 // Wait 1 second
  digitalWrite(buzzer, LOW);   // Sound off
  delay(5000);                 // Wait 5 seconds
}

Module 5: Potentiometer

The potentiometer is a rotary control. Depending on its position, a lower or higher voltage reaches pin 39. In the sketch, you convert the value using the map command and pass it to the red LED - it then lights up brighter or dimmer.

Keep the value range in mind: the ESP32 reads analog values at 12-bit resolution, so the readings range from 0 to 4095 - not from 0 to 1023 as with the Arduino UNO.

Potentiometer on the smart home board
The potentiometer on pin 39
Potentiometer: Adjust the brightness of the red LED
#define LED_RED 25
#define POT_PIN 39  // Potentiometer on ADC 39

void setup()
{
  pinMode(LED_RED, OUTPUT);
}

void loop()
{
  // The analog value is stored in the variable v.
  // The readings range from 0 to 4095.
  int v = analogRead(POT_PIN);

  // The map command converts values from 0 to 4095 into values from 0 to 255.
  int duty = map(v, 0, 4095, 0, 255);

  // A value between 0 and 255 is output on the red LED pin.
  // Depending on the position of the potentiometer, it shines brighter or dimmer.
  analogWrite(LED_RED, duty);
}

Module 6: Ultrasonic distance measurement

The sensor measures distances by sending an ultrasonic pulse (TRIG) and measuring the time until the echo returns (ECHO). The travel time gives the distance in centimeters.

The connections on the board:

  • TRIG – GPIO 18
  • ECHO – GPIO 17
  • Buzzer – GPIO 19

The sketch sends a 10-microsecond pulse, measures the echo time with pulseIn(), roughly converts it to centimeters (cm = µs / 58), and makes the buzzer beep in rhythm as soon as something is closer than 20 centimeters. This gives you a simple audible proximity warning.

Ultrasonic distance sensor on the smart home board
The ultrasonic sensor on pins 17 and 18
Ultrasonic: Distance warning with the buzzer
#define TRIG_PIN 18
#define ECHO_PIN 17
#define BUZZER   19

void setup()
{
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  pinMode(BUZZER, OUTPUT);
  digitalWrite(BUZZER, LOW);
}

void loop()
{
  // Messimpuls senden
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  // Echo messen: Zeit, bis die Schallwelle zurückgeworfen wurde
  long messzeit = pulseIn(ECHO_PIN, HIGH);
  long cm = messzeit / 58;

  // Buzzer steuern
  if (cm < 20)
  {
    digitalWrite(BUZZER, HIGH);
    delay(150);
    digitalWrite(BUZZER, LOW);
    delay(150);
  }
  else
  {
    digitalWrite(BUZZER, LOW);
    delay(50);
  }
}

Module 7: OLED display

This example initializes the SSD1306 OLED (I²C, address 0x3C) and displays the text “Funduino”. The ESP32's default I²C pins are SDA 21 and SCL 22.

The first time you use the display, you'll need a library: SSD1306Ascii.

  • Open the Arduino IDE
  • Tools › Manage Libraries (or Sketch › Include Library › Manage Libraries)
  • Enter SSD1306Ascii in the search field
  • Select the entry by Bill Greiman and install it

You can find more examples under File › Examples › SSD1306Ascii. There you can try out other fonts and font sizes - and there are also graphical elements you can display.

OLED display on the smart home board
The OLED display on the I²C bus
OLED display: Show text
#include <Wire.h>
#include <SSD1306Ascii.h>
#include <SSD1306AsciiWire.h>

SSD1306AsciiWire oled;

void setup()
{
  Wire.begin();                       // ESP32: SDA = 21, SCL = 22
  oled.begin(&Adafruit128x64, 0x3C);  // Start display (address 0x3C)
  oled.setFont(System5x7);            // simple font
  oled.clear();
  oled.setCursor(0, 0);
  oled.println("Funduino");           // Output text
}

void loop()
{
  // nothing else needed
}

Module 8: Fan

This sketch alternately turns the fan on pin 4 on for 5 seconds and off for 5 seconds.

Technical background: The fan is not connected directly to the ESP32 output pin, as its digital outputs provide very little current. Instead, pin 4 controls a transistor, which switches the 3.3-volt supply to the fan.

Despite this power switching circuit, a fan with relatively low power consumption is installed. Because the workshop has only a small volume, the airflow is still enough to fill the interior with outside air in a very short time.

When first used, new fans need a little time to break in so the lubricant is distributed evenly in the ball bearing. It may therefore be necessary to give the fan a brief push with your finger the first time you use it.

Fan on the front of the model workshop
The fan on pin 4
Fan: on for 5 seconds, off for 5 seconds
#define FAN_PIN 4
void setup()
{
  pinMode(FAN_PIN, OUTPUT);
}

void loop()
{
  digitalWrite(FAN_PIN, HIGH);  // ON
  delay(5000);
  digitalWrite(FAN_PIN, LOW);   // OFF
  delay(5000);
}

Module 9: Infrared Remote Control

With the VS1838, you can read codes from any infrared remote control. The module already provides demodulated signals. The sketch uses Armin Joachimsmeyer's IRremote library - install it first via the Library Manager.

What is the Serial Monitor?

The Serial Monitor is a window in the Arduino IDE that displays text sent from the microcontroller over the USB connection. Everything you send with Serial.print() appears there - ideal for viewing IR codes or sensor data. You can also send text back to the ESP32 using the input field at the bottom, but you won't need that here yet.

Here's how to open it: click the magnifying glass icon in the upper right or go to Tools › Serial Monitor. Set it to 115200 baud in the lower right - this must match the Serial.begin(115200) in the sketch.

Troubleshooting: If only garbled characters appear, the baud rate is incorrect. If nothing appears, check the port and whether the board is actually connected - if necessary, try resetting it. And close the monitor before uploading, as some systems otherwise block the port.

VS1838 infrared receiver on the smart home board
The VS1838 infrared receiver on pin 16
Infrared: Reading remote control button codes
#include <IRremote.hpp>
#define IR_PIN 16  // VS1838 signal on GPIO 16

void setup()
{
  Serial.begin(115200);
  delay(200);
  IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK);  // Start IR reception
  Serial.println("IR-Ready: Press a button on the remote control.");
}

void loop()
{
  if (IrReceiver.decode())
  {
    // Print a brief summary and the raw code in HEX
    IrReceiver.printIRResultShort(&Serial);
    Serial.print("  Raw: 0x");
    Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);

    // Get ready for the next signal
    IrReceiver.resume();
  }
}

Module 10: WS2812 LED Bar

WS2812 LEDs are addressable RGB LEDs with a built-in controller. All eight pixels are connected in a chain to a single data line, which is connected to pin 15 on the ESP32.

Why is one wire enough? Each LED reads the first 24 bits (red, green, blue) from the data stream, keeps them for itself, and passes the rest on to the next LED - a so-called daisy chain. This allows the microcontroller to control all the pixels one after another using just one pin.

You’ll need a library for this sketch again: Adafruit NeoPixel.

WS2812 LED bar as interior lighting for the model workshop
The WS2812 LED bar with 8 pixels on pin 15
WS2812: eight pixels in eight colors
#include <Adafruit_NeoPixel.h>
#define WS_PIN    15
#define NUM_LEDS  8

Adafruit_NeoPixel strip(NUM_LEDS, WS_PIN, NEO_GRB + NEO_KHZ800);

void setup()
{
  strip.begin();
  strip.setBrightness(80);  // optional
}

void loop()
{
  strip.setPixelColor(0, strip.Color(255,   0,   0));  // Red
  strip.setPixelColor(1, strip.Color(  0, 255,   0));  // Green
  strip.setPixelColor(2, strip.Color(  0,   0, 255));  // Blue
  strip.setPixelColor(3, strip.Color(255, 255,   0));  // Yellow
  strip.setPixelColor(4, strip.Color(  0, 255, 255));  // Cyan
  strip.setPixelColor(5, strip.Color(255,   0, 255));  // Magenta
  strip.setPixelColor(6, strip.Color(255, 255, 255));  // White
  strip.setPixelColor(7, strip.Color(255, 128,   0));  // Orange

  strip.show();  // Display colors
}

Module 11: Temperature and Humidity with the DHT11

The DHT11 measures temperature and humidity and sends both readings digitally over a single data line. On the board, it is connected to pin 14.

Required libraries via Tools › Manage Libraries:

  • DHT sensor library (by Adafruit)
  • Adafruit Unified Sensor (also installed as a dependency)

The first sketch displays the readings in the Serial Monitor. The second displays them on the OLED instead - this is your first time combining two modules.

DHT11 temperature and humidity sensor on the smart home board
The DHT11 on pin 14
DHT11: Temperature and Humidity in the Serial Monitor
#include <DHT.h>
#define DHTPIN  14      // DHT data pin on the ESP32
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup()
{
  Serial.begin(115200);
  dht.begin();
  Serial.println("DHT started. Reading temperature and humidity ...");
}

void loop()
{
  float hum  = dht.readHumidity();
  float temp = dht.readTemperature();  // in degrees Celsius

  if (isnan(hum) || isnan(temp))
  {
    Serial.println("Error reading from DHT!");
  }
  else
  {
    Serial.print("Temp: ");
    Serial.print(temp, 1);  // 1 means one decimal place
    Serial.print(" °C   Humidity: ");
    Serial.print(hum, 1);
    Serial.println(" %");
  }

  delay(2000);  // The DHT11 provides new readings at most about every 2 seconds.
}
DHT11: Display readings on the OLED display
#include <Wire.h>
#include <SSD1306Ascii.h>
#include <SSD1306AsciiWire.h>
#include <DHT.h>

#define DHTPIN  14
#define DHTTYPE DHT11  // change to DHT22 if needed

SSD1306AsciiWire oled;
DHT dht(DHTPIN, DHTTYPE);

void setup()
{
  Wire.begin();                       // ESP32: SDA = 21, SCL = 22
  oled.begin(&Adafruit128x64, 0x3C);  // OLED address 0x3C
  oled.setFont(System5x7);
  oled.clear();
  oled.println("DHT -> OLED");
  dht.begin();
}

void loop()
{
  float hum  = dht.readHumidity();
  float temp = dht.readTemperature();  // in degrees Celsius

  oled.clear();
  oled.setCursor(0, 0);

  if (isnan(hum) || isnan(temp))
  {
    oled.println("Error reading!");
  }
  else
  {
    oled.println("Funduino");
    oled.setCursor(0, 2);
    oled.print("Temp: ");
    oled.print(temp, 1);
    oled.println(" C");
    oled.setCursor(0, 3);
    oled.print("Humidity: ");
    oled.print(hum, 1);
    oled.println(" %");
  }

  delay(2000);
}

Module 12: Light intensity with the LDR

An LDR (photoresistor) changes its resistance with the light level: bright means lower resistance, dark means higher resistance. Together with a fixed resistor already on the board, it forms a voltage divider. This produces a measurable voltage between 0 and 3.3 volts at pin 35.

Simply hold your finger over the sensor while measuring—the readings change significantly. Later, you can use it to switch on the WS2812 lighting automatically.

Photoresistor on the smart home board
The light intensity sensor LDR on pin 35
LDR: Measure brightness
#define LDR_PIN 35  // Pin 35 am ESP32

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  // Unter raw wird der rohe Messwert als Zahl zwischen 0 und 4095 gespeichert.
  int raw = analogRead(LDR_PIN);

  // Der map-Befehl wandelt den Wert in einen prozentualen Wert um.
  int pct = map(raw, 0, 4095, 0, 100);

  Serial.print("LDR raw: ");
  Serial.print(raw);
  Serial.print("   Helligkeit: ");
  Serial.print(pct);
  Serial.println(" %");

  delay(200);
}

Module 13: PIR Motion Sensor SR602

A PIR (passive infrared) sensor like the SR602 detects rapid changes in infrared radiation in its field of view, for example when someone walks by. Inside, pyroelectric elements sit behind a Fresnel lens. When the sensor detects movement, it sets its output to HIGH and holds it there briefly.

In the sketch, you use this to build a small alarm system: when the sensor detects movement, the red LED lights up.

PIR motion detector on the smart home board
The SR602 motion detector on pin 13
Motion sensor: red LED when motion is detected
#define PIR_PIN 13
#define LED_RED 25

void setup()
{
  pinMode(PIR_PIN, INPUT);  // Der SR602 liefert ein aktives HIGH.
  pinMode(LED_RED, OUTPUT);
  digitalWrite(LED_RED, LOW);
}

void loop()
{
  int motion = digitalRead(PIR_PIN);

  if (motion == HIGH)
  {
    digitalWrite(LED_RED, HIGH);  // Alarm: Bewegung erkannt
  }
  else
  {
    digitalWrite(LED_RED, LOW);   // keine Bewegung
  }
}

Module 14: Servo and automatic door

A servo is a small geared motor with position feedback. You specify the target position using a control signal. Unlike a regular motor, a servo does not rotate continuously; it only moves within a range of about 180 degrees.

In the smart home, the servo opens the front door. Later, you can combine multiple modules for this: for example, the door can open at the press of a button or as soon as the ultrasonic sensor detects someone at the entrance.

The servo is powered by 3.3 volts and, like all servos, can briefly draw a lot of current. As a result, the LEDs may flicker while it moves.

About the door: It will only be installed now. The servo must be moved electronically to a suitable position beforehand so that the door later moves within the correct range and does not hit the sides. Set the servo to 90 degrees before installing the door.

Servo motor for the model workshop door
The servo for the automatic door on pin 12
Servo: Move to positions
#include <ESP32Servo.h>
#define SERVO_PIN 12

Servo servo;

void setup()
{
  servo.attach(SERVO_PIN);
}

void loop()
{
  servo.write(0);    delay(1000);  // 0 degrees
  servo.write(90);   delay(1000);  // 90 degrees
  servo.write(180);  delay(1000);  // 180 degrees
  servo.write(90);   delay(1000);  // back to 90 degrees
}

Module 15: MQ135 Gas Sensor

The MQ135 is a gas-sensitive resistor with a heater. That’s why it gets warm and is connected not to the 3.3-volt line, but to the USB cable’s 5-volt supply - it needs a little more power. Gases such as CO₂, ammonia, or alcohols change its resistance. On the board, it forms a voltage divider with a load resistor, and you can read the voltage at pin 34.

Example application in a smart home: In the workshop, the sensor is meant to detect escaping gases - such as spilled gasoline, gas from a gas-powered vehicle, or gas from a welding torch. You can simulate this with very small amounts of gas from a lighter. It’s enough to direct the gas inside with the fan for two seconds - you can switch the fan on manually with a button.

Warm-up time: The sensor needs a few minutes to heat up and for the readings to stabilize. It can already provide a rough trend right after switching it on, though. The readings should be understood as relative anyway - precise values would require calibration along with temperature and humidity compensation, which is not intended for this model's purpose.

MQ135 gas sensor on the smart home board
The MQ135 gas sensor on pin 34
MQ135: Gas reading in the serial monitor
#define MQ135_PIN 34

int messwert = 0;
int prozent = 0;

void setup()
{
  Serial.begin(115200);
  delay(200);
  Serial.println("MQ135 Start - bitte einige Minuten aufwaermen lassen");
}

void loop()
{
  messwert = analogRead(MQ135_PIN);

  // grobe Skalierung auf 0 bis 100 Prozent - nur als Tendenz!
  prozent = map(messwert, 0, 4095, 0, 100);

  Serial.print("MQ135 messwert: ");
  Serial.print(messwert);
  Serial.print("   Tendenz: ");
  Serial.print(prozent);
  Serial.println(" %");

  delay(500);
}

Module 16: Raindrop Sensor

The sensor board has exposed conductive tracks. When moisture lands on them, it conducts a tiny current between the tracks, lowering the resistance. The module then outputs a voltage proportional to the moisture level at its signal output and sends it to pin 36.

Smart home application example: The sensor detects whether there is liquid on the workshop floor - whether something has spilled or even a pipe has burst.

To test it, simply touch the sensor with a slightly damp finger. The sketch displays the reading in the serial monitor: the green LED lights up when moisture is low, and the red one when it is high.

Humidity sensor with exposed traces
The water drop sensor on pin 36
Raindrop sensor: measure moisture and control LEDs
#define Tropfen_PIN 36  // Drop sensor, analog
#define LED_ROT     25
#define LED_GRUEN   26

void setup()
{
  Serial.begin(115200);
  pinMode(LED_ROT, OUTPUT);
  pinMode(LED_GRUEN, OUTPUT);
}

void loop()
{
  int raw = analogRead(Tropfen_PIN);        // 0 to 4095
  int Prozent = map(raw, 0, 4095, 0, 100);  // rough moisture in percent

  // Control LEDs
  if (raw > 100)  // threshold
  {
    digitalWrite(LED_ROT, HIGH);
    digitalWrite(LED_GRUEN, LOW);
  }
  else
  {
    digitalWrite(LED_ROT, LOW);
    digitalWrite(LED_GRUEN, HIGH);
  }

  // Output
  Serial.print("RAW: ");
  Serial.print(raw);
  Serial.print("   Moisture in percent: ");
  Serial.print(Prozent);
  Serial.println(" %");

  delay(200);
}

Integration into Home Assistant

This section assumes prior knowledge of Home Assistant. It briefly explains how to integrate the ESP32 on the Smart Home module with all its sensors and actuators.

1. Install ESPHome – In Home Assistant, go to Settings › Add-ons › Add-on Store, install the ESPHome add-on, then open and start it. ESPHome will then appear in the left sidebar.

2. Add a new device – In ESPHome, click NEW DEVICE and choose a name, for example esp32-nr1. The board selection doesn't matter for now; you'll overwrite it in the YAML shortly.

3. Add and edit the YAML – Open the device, click EDIT, and replace the contents with the configuration for the Funduino Smart Home. At a minimum, update the Wi-Fi credentials (ssid and password); you can also change the Name and Friendly Name. You can keep the API key and OTA password or generate new ones. If you change them, you'll need to pair the device with Home Assistant again.

4. Flash for the first time via USB – Connect the ESP32 via USB to the computer running ESPHome, then click INSTALL on the device. Select “Plug into this computer” or download the firmware manually and flash it with a web flasher. The ESP32 will then connect to your Wi-Fi. If that doesn't work, the fallback hotspot will start automatically so you can connect and correct the Wi-Fi credentials.

5. Add it to Home Assistant – Once the ESP32 is online, it usually appears automatically in Home Assistant under Settings › Devices & Services. Otherwise, add the ESPHome integration manually and enter esp32-nr1.local or the IP address shown in your router.

Home Assistant then automatically creates the entities: the push buttons and motion detectors as binary sensors, the two LEDs and alarm as switches, the fan as a fan, distance, brightness, MQ135, temperature, humidity, rotary dial, and drip sensor as sensors, the LED bar and LEDs 1 to 8 as lights, and the servo position as a number. The OLED runs in the background.

Later updates can be installed over Wi-Fi via OTA: in ESPHome, click INSTALL › Wirelessly.

The completed YAML configuration for the Funduino Smart Home is still missing here. Feel free to contact us if you need it.

Rate the instructions

Comments

Ask a question or share an experience

Contact us if something doesn’t work. Please include your board and the error message.

We review every comment before publication. Your email address remains with us.