Smart Home pins
This page lists the pins of the Smart Home board. The numbers come from the board’s definition in the firmware. They are GPIO numbers: the numbers the ESP32-S3 chip gives its pins, and the numbers the firmware passes to machine.Pin.
You do not need them to use the house. Use home.temperature_sensor, home.fan and the other parts from the Smart Home page. You need the numbers when you wire something of your own, or when you read the firmware.
Sensors and button
Section titled “Sensors and button”| Part | In code | GPIO |
|---|---|---|
| Temperature and humidity sensor (DHT11) | home.temperature_sensor |
36 |
| Motion sensor | home.motion_sensor |
37 |
| Gas sensor | home.gas_sensor |
16 |
| Light sensor | home.light_sensor |
17 |
| Knob | home.knob |
8 |
| Button | home.button |
1 |
| Battery sensor | home.battery |
4 |
The gas sensor and the light sensor are on GPIO 16 and 17. The Wi-Fi radio also uses the analog hardware behind those two pins, so the firmware tries a lost reading again, and if it still fails it returns the last real reading. The knob is on GPIO 8, which the radio does not use.
The button reads 0 when it is pressed, because the firmware turns on the pin’s pull-up. Holding it for 5 seconds also makes the house forget its Wi-Fi networks. See Wi-Fi setup.
The battery voltage is divided down before it reaches GPIO 4: 20000 ohms on the top side and 10000 ohms on the bottom side, and the chip’s reference is 3.3 volts. The pin sees one third of the battery voltage, so home.battery.voltage() multiplies by three.
RFID reader
Section titled “RFID reader”The RFID reader is an MFRC522 on SPI bus 1, at 4 MHz.
| RFID signal | GPIO |
|---|---|
| SCK (clock) | 12 |
| MOSI (data to the reader) | 11 |
| MISO (data from the reader) | 13 |
| CS (chip select) | 10 |
RGB lamp
Section titled “RGB lamp”| Colour | GPIO |
|---|---|
| Red | 9 |
| Green | 21 |
| Blue | 14 |
On every Smart Home board the pin that the silkscreen calls RED lights green, and the pin it calls GREEN lights red. The labels are wrong and the LED is right, so the firmware swaps them. The table above names each pin by the colour it really lights. home.rgb_led.set_color(r, g, b) means what it says: the first number is red.
Screen
Section titled “Screen”The screen is a 1.3 inch OLED, 128 by 64 dots, with an SH1106 chip. It is on I2C bus 0, at address 0x3C.
| Bus signal | GPIO |
|---|---|
| SCL (clock) | 47 |
| SDA (data) | 48 |
The module has an address pad, marked 0x78 and 0x7A in 8-bit form, which are 0x3C and 0x3D in 7-bit form. The firmware uses 0x3C. A module with the pad set the other way does not answer, and the screen stays blank.
Number display
Section titled “Number display”A three-digit display (a TM1637 chip), with brightness 7.
| Number display signal | GPIO |
|---|---|
| CLK (clock) | 40 |
| DIO (data) | 39 |
Lights, buzzer, servo and fan
Section titled “Lights, buzzer, servo and fan”| Part | In code | GPIO |
|---|---|---|
| LED 1 | home.led1 |
39 |
| LED 2 | home.led2 |
38 |
| Buzzer | home.buzzer |
18 |
| Servo (the door) | home.servo |
7 |
| Fan | home.fan |
41 |
The current Smart Home board has no LED on GPIO 39 or GPIO 38. The firmware still has home.led1 and home.led2 for those two pins, so a program that uses them runs without an error, but nothing lights. Use home.rgb_led for a light you can see.
Shared pins
Section titled “Shared pins”One pin belongs to two parts. This is on purpose: the chip does not have enough pins for every accessory, so parts that are alternatives share a pin, and you choose which one you are using.
| GPIO | Used by | Also used by |
|---|---|---|
| 39 | LED 1 | Number display (DIO) |
The firmware switches the number display on at start-up, so it holds GPIO 39. See also the note about LED 1 and LED 2 on the Smart Home page.
PWM and timers
Section titled “PWM and timers”| Part | PWM frequency | Channels |
|---|---|---|
| RGB lamp | 1000 Hz | 3 |
| LED 2 | 1000 Hz | 1 |
| Buzzer | changes with every note | 1 |
| Servo | 50 Hz | 1 |
| Fan | 100 Hz | 1 |
The ESP32-S3 has 8 PWM channels in all, and these parts use most of them.
Timer 0 plays the buzzer’s notes. Timer 1 watches the button for the 5-second Wi-Fi reset.