The intelligent eco-house or house (for short) described in this document has been designed within the Erasmus+ EcoThings Project 2021-1-ES01-KA220-SCH-000034349. The purpose of this house is to serve as a mock-up in order to evaluate the set of proposed electronics in the context of an intelligent ecological house using similar principles of real passive houses and energy saving systems. As a consequence, the design has been oriented in providing low-cost solutions, considering as well as manufacturing aspects including 3D printing and laser cutting.

Before reaching the proposed solution, we have explore several ideas in a brainstorming preliminary phase. Ideas were not too much elaborated, and indeed some of them are technically difficult and complex, but during this phase, we were seeking trying to bring new ideas upfront and indeed, some of these ideas were indirectly included in the final version of the proposed prototype, others were simply discarded or left for a future version, due to its complexity.

The following diagram summarizes the connections between the ESP32 microcontroller and selected components. Details about connections will be provided below:

In the EcoThings Project, we propose to use the ESP32 micro-controller. Other micro-controllers such as Raspberry Pi Pico can be used as well, but the following documentation is just for the implementation using a ESP32.

An ESP32 processor is a microcontroller that has the following features [1]:

  • Processor: Xtensa dual-core (or single-core) 32-bit LX6 microprocessor, operating at 160 or 240 MHz and performing at up to 600 DMIPS and ultra low power (ULP) co-processor
  • Memory: 320 KiB RAM, 448 KiB ROM
  • Wireless connectivity: Wi-Fi: 802.11 b/g/n, Bluetooth: v4.2 BR/EDR and BLE (shared with Wi-Fi).
  • Peripherals interfaces: Up to 34 programmable GPIOs, 12-bit SAR ADC up to 18 channels,        2 8-bit DACs, 10 touch sensors, 4 SPI, 2 I²S interfaces, 2 I²C interfaces, 3 UART, SD/SDIO/CE-ATA/MMC/eMMC host controller, SDIO/SPI slave controller, Ethernet MAC interface with dedicated DMA and planned IEEE 1588 Precision Time Protocol support, CAN bus 2.0, Infrared remote controller (TX/RX, up to 8 channels), Pulse counter (capable of full quadrature decoding), Motor PWM, LED PWM (up to 16 channels), Hall effect sensor, ultra low power analog pre-amplifier.
  • Security: IEEE 802.11 standard security features all supported, including WPA, WPA2, WPA3 (depending on version)[5] and WLAN Authentication and Privacy Infrastructure (WAPI).
  • Secure boot: Flash encryption, 1024-bit OTP, up to 768-bit for customers, cryptographic hardware acceleration: AES, SHA-2, RSA, elliptic curve cryptography (ECC), random number generator (RNG)
  • Power management: Internal low-dropout regulator, Individual power domain for RTC; 5 μA deep sleep current; wake up from GPIO interrupt, timer, ADC measurements, capacitive touch sensor interrupt.

As it can be seen, it includes many peripheral features, but most of them are shared, which means that any pin can be used as a GPIO (general-purpose input/output pin), but they might include also additional features, such as ADC (analog to digital converters), PWM signals, bus signals such as I2C or SPI, etc… [2]

Wemos D1R32 board (or similar boards such as EspDuino-32) include a ESP32 processor with a pin layout that is compatible with Arduino Uno. Arduino Uno has become a very popular board in the past and many projects propose to use that board as a quick start kit to learn electronics. Wemos D1R32 can be seen as an Arduino Uno board with much more powerful capabilities, including WiFi and Bluetooth, which is ideal for IoT project as well as for compatibility reasons develop basic electronic projects.

It includes a USB connector to easily upload code and Arduino IDE tool (programming tool for Arduino boards) can be used too with this board.

ESP32 has upto 18 ADC pins that use three converters ADC0, ADC1 and ADC2 with multiple channels, which means that depending on the pin used, we will access to a specific hardware resource. However, the Wemos D1R32 board, only some ADC pins are available and distributed as follows:

  • ADC1-CH0 (GPIO 36)
  • ADC1-CH3 (GPIO 39)
  • ADC1-CH6 (GPIO 34)
  • ADC1-CH7 (GPIO 35)
  • ADC2-CH0 (GPIO 4)
  • ADC2-CH2 (GPIO 2)
  • ADC2-CH4 (GPIO 13)
  • ADC2-CH5 (GPIO 12)
  • ADC2-CH6 (GPIO 14)
  • ADC2-CH7 (GPIO 27)
  • ADC2-CH8 (GPIO 25)
  • ADC2-CH9 (GPIO 26)

Another important feature is the use of I2C and SPI buses, because with these buses, we can connect to other compatible devices using much less pins. In particular, the I2C pins are available in the following pins:

  • SDA (GPIO 21)
  • SCL (GPIO 22)

While SPI (VSPI) pins are available in the following ones:

  • MISO (GPIO 19)
  • MOSI (GPIO 23)
  • CLK (GPIO 18)
  • CS (GPIO 5)

PWM signals can be generated using any  GPIO pin (programmatically, we can assign attach a pin to a specific PWM channel, upto 16 PWM channels).

Since the board has the same layout as an Arduino board, it is convenient to map pin names used in ESP32 and Arduino Uno (Atmega 328p), so that if we connect on top of the Wemos D1R32 board a shield (that is another electronic with a specific circuit to be used), it is very likely that this shield has been designed originally for Arduino Uno board, so they are physically compatible and (luckily) also electronically compatible (at least in some of the boards we have tested such as the Arduino Uno Sensor Shield and the Multisensor shield).

In particular, we will describe the mapping between the Wemos D1R32 board together with the Arduino Sensor shield, which is basicall a board with many pins that provide easy access to Vcc and Gnd pins as well as signal pins. This is very convenient if we want to avoid using proto-boards with hundreds of cables.

Thus, when using a Wemos D1R32 board and a Arduino Sensor Shield, we will actually connect all devices to the Arduino Sensor Shield that will be indeed connected to the ESP32 processors as follows:

Wemos D1 R32Arduino Uno Sensor ShieldWemos D1 R32Arduino Uno Sensor Shield
IO26D2IO23D11
IO25D3IO19D12
IO17D4IO18D13
IO16D5IO2A0
IO27D6IO4A1
IO14D7IO35A2
IO12D8IO34A3
IO13D9IO36A4
IO5D10IO39A5

There are multiple ways to connect living room electronics to the ESP32 through the Arduino Shield. Here, we propose a specific connection setting:

ComponentPIN NAMEESP32 PINArduino Shield
NTC SensorAnalog Input36A4
Resistors 120ΩDigital Output26D2
FANDigital Output17D4
Living Room ServoDigital Output25D3
TFT ScreenTFT_CLK18D13
TFT_SDA23D11
TFT_CS13D9
TFT_RST5D10
TFT_RS27D6
ESP32 Cam with Infrared SensorI2C21SDA
22SCL

With this electronic proposal, we can regulate the room temperate and safe some energy in a smart way. We can also display interesting variables on the screen just to monitor actual energy saved/consumed, room temperature and any other variable of interest. Here you can find a full connection diagram as well as some circuit examples to start coding with the proposed electronics.

Breadboard connection example:

Resistor and motor control:

https://www.tinkercad.com/things/5t1euEOYuPw

Temperature control:

https://www.tinkercad.com/things/eQBM9LuhSOn

Passive House example:

https://www.tinkercad.com/things/2ZwHmyCP0P9

Assuming that the temperature of the ground coming from the ventilation system (fan) is constant and fixed to 19ºC, we can stablish a temperature control policy based on the outside temperature (assumed to be provided via an external service such as a OpenWeather), room temperature (from NTC sensor) and setpoint temperature (user sets this temperature). Also considering that the amount of long-term energy of a heater is much higher that activating a fan and at the same time the energy required to activate the fan is higher than the energy required to open the window, we can stablish the following rules:

TemperaturesHeaterFanWindow
Room<Ground<Setpoint<OutsideOffOffOpen
Room<Ground<Outside<SetpointOnOffClosed
Room<Setpoint<Ground<OutsideOffOffOn
Room<Setpoint<Outside<GroundOffOffOpen
Room<Outside<Ground<SetpointOnOffClosed
Room<Outside<Setpoint<GroundOffOnOff
Ground<Room<Setpoint<OutsideOffOffOn
Ground<Room<Outside<SetpointOnOffOff
Ground<Setpoint<Room<OutsideOffOnClosed
Ground<Setpoint<Outside<RoomOffOnClosed
Ground<Outside<Room<SetpointOnOffClosed
Ground<Outside<Setpoint<RoomOffOffOpen
Setpoint<Room<Ground<OutsideOffOffClosed
Setpoint<Room<Outside<GroundOffOffClosed
Setpoint<Ground<Room<OutsideOffOnClosed
Setpoint<Ground<Outside<RoomOffOnClosed
Setpoint<Outside<Room<GroundOffOffOpen
Setpoint<Outside<Ground<RoomOffOffOpen
Outside<Room<Ground<SetpointOnOffClosed
Outside<Room<Setpoint<GroundOffOnClosed
Outside<Ground<Room<SetpointOffOffClosed
Outside<Ground<Setpoint<RoomOffOffOpen
Outside<Setpoint<Room<GroundOffOffOpen
Outside<Setpoint<Ground<RoomOffOffOpen

The proposed connections for the bedroom (considering that there are pins that are already being used by the electronics of the living room) is as follows:

ComponentPIN NAMEESP32 PINArduino Shield
LDR SensorAnalog Input39A5
MIC SensorAnalog Input/Digital Input35A2
PIR SensorDigital Input2A0
Bedroom ServoDigital Output4A1
RGB LED StripDigital Output12D8

With this electronic proposal, we can measure light and sound as well as detect the presence of someone in the room and then decide wether or not to switch on or off the lights and to open and close the window. Information about weather temperature as well as sunrise and sunset hours can be obtained via an IoT service, which might be useful also to help on the decision process.

Breadboard connection example (mic not included because is not available in TinkerCAD):

https://www.tinkercad.com/things/kb9ghMm3gYx

The proposed connection for the kitchen (considering that there are pins that are already been used by the electronics of the living room and bedroom) is as follows:

ComponentPIN NAMEESP32 PINArduino Shield
Gas SensorAnalog Input/Digital Input34A3
BuzzerDigital Output16D5
Flame SensorDigital Input19D12
Kitchen ServoDigital Output14D7

Breadboard connection example:

https://www.tinkercad.com/things/dGslUCgacXQ

PIR sensor:

PIR sensor SR602 is a pyroelectric infrared sensor, which allows for detecting the motion of

humans. This sensor can detect movement from a distance of up to 5 meters, although the best results will be achieved when the human is up to 3.5 meters away.

The KY-013 Analog Temperature Sensor module can measure ambient temperature based on the resistance of the thermistor on the board [3]. This module consists of a NTC thermistor connected to a 10 kΩ resistor. The thermistor resistance varies according to its surrounding temperature, thus, acting as a voltage divider, we can measure the temperature by measuring the output voltage. The relation between such voltage and temperature is non-linear, but their parameters are known based on the Steinhart-Hart equation [4].

The KY-026 Flame Sensor module detects infrared light emitted by fire

https://arduinomodules.info/ky-026-flame-sensor-module

The KY-018 uses a Light dependent resistor (LDR) to measure light intensity (the resistance will decrease in the presence of light).

https://arduinomodules.info/ky-018-photoresistor-module

Passive buzzer:

To generate melodies and alarms.

https://arduinomodules.info/ky-006-passive-buzzer-module

RGB LED strips

Mosfet module:

Any of these two, can be used to generate a high power analog output (driven by a PWM signal).

Mosfet module 400W 15A ICQUANZX

LR7843 MOSFET / FR120N MOSFET

Relay module:

If we use a relay, we can not generate analog outpus (PWM)

https://arduinomodules.info/ky-019-5v-relay-module/

Servos SG90

Position controlled motor

https://www.circuitschools.com/how-to-control-servo-motor-with-arduino-and-how-they-work/

Bill of materials:

NameQuantityComponent
R1-R1212100Ω resistor
P11Powerbank
R13-R1421kΩ resistor
U11Arduino Uno (or Wemos D1R32)
U21Photodiode
Q1-Q22TIP120
M11Fan motor
D11Diode

Bill of materials:

NameQuantityComponent
U11Arduino Uno (or Wemos D1R32)
Servo11Position servo
Jewel11NeoPixel Jewel
PIR11PIR sensor
R11Photoresistor
R2110kΩ resistor

Bill of materials:

NameQuantityComponent
U11Arduino Uno (or Wemos D1R32)
GAS11Gas sensor
Servo11Position servo
Piezo11Piezo electric buzzer
U21Photodiode
R111kΩ resistor
U31OAmp (comparer)
R2110kΩ resistor
Rpot1110kΩ potentiometer
R31100Ω resistor

References

[1] https://en.wikipedia.org/wiki/ESP32

[2] Electropeak.com

[3] https://arduinomodules.info/ky-013-analog-temperature-sensor-module/

[4] https://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation