ESP32-S3 mailbox alert

A reed switch in the mailbox and a magnet on the flap: when the flap opens to drop the post, the yellow LED lights and a coin sound plays. The reed switch is wired like the kit's button, two wires; the LED stays on until you stop the program, so you see the post later too.

The program

Chip BASIC: every line is one instruction you can read and change. The compiler checks it at every release of the site.

10 IF BUTTON("A") THEN LED yellow, on : SOUND "coin"
20 WAIT 200
30 GOTO 10

What you should see: with the flap closed everything is off; when it opens, the yellow LED lights and stays on, and the coin sound plays while the flap is open. In the simulator the button stands in for the flap.

▶ Open it in the IDE

In the simulator you see the logic run right away, with no hardware. The simulator does not check the wires: you check those on the board, and the IDE's wiring check walks you through it.

The parts

The compiler finds the parts in the program. Each has its own page with a test program to run before you build the whole thing.

How to wire it to an ESP32-S3

  1. + → ESP32-S3: GPIO5
  2. − → ESP32-S3: GND
  3. + yellow → ESP32-S3: GPIO2Through a 220 Ω resistor
  4. − → ESP32-S3: GNDCommon ground: this link is mandatory.
  5. Signal → ESP32-S3: GPIO6Internal pull-up: pressed reads as 1
  6. GND → ESP32-S3: GNDCommon ground: this link is mandatory.

If it does not work

The lights: the program runs but nothing happens
The LED is the wrong way round, or the series resistor is missing. The long leg goes on the board pin's side, the short one towards GND, with the resistor in between (220 Ω, or 470 Ω on the UNO R4).
The buzzer: the program runs but nothing happens
The signal does not reach the buzzer: the wire is on the wrong pin, or the negative pole is not on GND. The signal goes to the pin shown in the diagram, the negative pole to GND.
The button: the program runs but nothing happens
The button is turned: the two legs in use are already joined inside the button. Seat it across the breadboard's middle gap and use two legs opposite each other on the diagonal.

What you can change

Mount the reed switch where the magnet ends up when the flap opens. For another sound change "coin" on line 10 (beep, tada, mario). Ask Chip to turn the LED off with a second button once you have collected the post.

Which boards it works on

  • ESP32-S3 Freenove: yes
  • Nordic nRF54LM20 DK: yes
  • Arduino UNO R4 WiFi: yes