-
Notifications
You must be signed in to change notification settings - Fork 1
Schematics

The main components of the schema are ESP-01S controller U2 and HC-12 controller U1. Both controllers are mounted on sockets J4, J5, J7, which allows their removal for reprogramming. ESP-01S TX is connected to HC-12 RX for data transmission. ESP's RX is not used for serial communications, and is reconfigured to serve as digital input to read the door sensor status. Similarly, since HC-12 is used only to transmit data, its TX output line is not connected.
Door sensor is implemented with a reed switch. Switch SW1 is connected via a ~40 cm two-wire cable ending with JST-XH on-board connector J1, J2. A switch needs to be "normally closed" (NC), so it stays open when mailbox door is closed (this is the state shown on the schematic: two switch halves side by side, switch magnetized). I have got an NC, type "B" reed switch, with both "normally open" (NO) and NC contacts. Quite counter-intuitively, the wire has to be connected to the NO contact in order to make it work as intended; you might need to experiment a bit. To allow proper reading, the switch is pulled up by resistor R1; consequently, it reads LOW when mailbox door is opened (switch is closed). The switch may (and does) bounce, but it is not essential for the application, so no specific protection from this was made.
ESP's GPIO2 is configured as a secondary serial line, and serves to transmit diagnostic log information via an on-board connector J9 (you can drop the connector safely, if logging is of no interest). Resistor R3 is used to pull up GPIO2 when diagnostic port is not connected. Without it, the ESP might not boot reliably (this was actually observed). Since GPIO2 also controls ESP's built-in LED, the (nice) side effect is that controller blinks blue shortly after the mailbox door was opened and before going to sleep.
ESP's GPIO0 is connected to the HC-12 SET line, and is used to send a wake up LOW pulse to HC-12 when coming out from deep sleep. Resistor R2 is recommended by HC-12 data sheet in order to protect controller pin from over-current. If this is not a concern, R2 can be removed (i.e., short-circuited).
Capacitor C2 serves to form a LOW impulse on ESP's reset line (RST). RST in ESP8266 is internally pulled up with a 12k resistor. When mailbox door is closed (switch SW1 is open), both poles of C2 stay pulled up, so no current flows, and nothing happens. When mailbox door opens (switch closes), the negative pole of C2 gets grounded, which, for a short moment, makes ESP's RST grounded too. As the capacitor charges, it stops conducting, and LOW potential on RST disappears. This forms a dirty, but reliable enough pulse to wake up ESP from deep sleep when mailbox door is opened.
A small capacitor C1 is used to protect HC-12 SET line from parasite noise. It was observed that when ESP goes to sleep, it causes some unwanted change of GPIO0 level (what it is, exactly, is difficult to tell without an oscilloscope). This noise causes HC-12 to wake up from its own deep sleep prematurely. The capacitor C1 "eats up" this noise.
Antenna AE1 is a 435.8 MHz monopole with a short coaxial feed connected via SMA connector to the case and, inside the case, with a SMA-to-IPX coaxial cable to the HC-12 antenna socket. See Antennas for more details.
The whole circuit is powered with one LS12450 battery BT1, inserted in a battery holder J10, J13. A large capacitor C3 is used to stabilize battery voltage during consumption peaks (on boot and during HC-12 data transmission). See Battery section for more details.
The following time diagram explains how the circuit works, taking as example a door opening for 3 seconds. Note that it is not a true oscillogramme, but rather my view of the process. Short events might not be drawn to scale.

When mailbox door opens, the reed switch goes to LOW level. C2 capacitor converts this step into an ESP8266 reset pulse, which wakes ESP from deep sleep. ESP-01S power consumption goes from nearly zero to ≈ 15 mA. It takes about 200 ms for the main program to take control. The program then forms a short pulse on HC-12 SET line, which wakes HC-12 from its own deep sleep. HC-12 idling consumption in FU4 mode is also about 15 mA. 400 ms are provided to HC-12 to become reliably operational. After that, ESP sends the first 8 bytes message to HC-12 with a speed of 1200 bod, which takes about 50 ms to arrive. HC-12 retransmits the same 8 bytes message on the air with a lower speed of 500 bod, spending about 130 ms. Its power consumption during transmission grows to ≈ 50 mA. Summing up the times, we can say that the message leaves transmitter within 0.7 s from the door opening moment. Then the circuit enters wait loop for the door closure, or 30 s timeout, whichever comes first. In this example, the door is closed after 3 seconds. The reed switch bounces, but is it not important, because the programs stops switch processing on the first HIGH level received. As soon as the door is closed, the program forms and sends the second, door closure message. Then the transmitter HC-12 is put into sleep mode. This is quite a lengthy process (≈ 500 ms), consisting of switching the serial channel from transmission into HC-12 command mode and sending it a command AT+SLEEP. Once HC-12 falls asleep, ESP puts itself in the deep sleep. At this point, the module is ready to receive the next door opening event.
It is important to note that no latching for ESP8266 RST line was implemented. It takes about 0.7 s from door closure for the module to go to sleep. If the door gets opened again in less than a second from closure, the controller will likely execute a cold restart instead of waking up from sleep. The opening event would be still delivered to a user, but along with a "reboot" message. This situation has been rarely observed in practice, so it is considered a minor issue.
PCB layout using 4x6 cm perfboard (facing parts; blue — backplane connections; orange — jumper wires; solid black — soldered parts; dashed black — removable parts' footprints; hexagons — nylon supports for elevated parts):

Soldered backplane:

Front view is shown below. The photo is taken from an earlier version, which does not include the resistor R3.

Same with controllers and peripherals inserted:

Fully assembled (with a simple piece of foam rubber used to hold the board in place):

In the latest version of enclosure a soldered whip antenna is replaced with an SMA connector and an external antenna. See Antennas for more details.
Installed:

I have got a collective mailbox with double walls. This allows fitting most of the parts below the floor, or behind the walls; the only visible part is a reed switch.

The receiver schema is extremely simple. Like for the remote module, the main components of the local module are ESP-01 controller U3 and HC-12 controller U1, mounted on sockets J4, J7, J9. Here, HC-12 is used only to receive data, so its TX pin is connected to ESP's RX. Conversely, HC-12's RX and ESP's TX (GPIO1) are not connected. In ESP-01, TX controls a built-in blue LED; this is used for LED-based notifications.
Similarly to the remote module, ESP's GPIO2 is used for a diagnostic serial line J10. In ESP-01 case, however, no specific boot problems have been observed, so no pull-up resistor was added.
ESP's GPIO0 is connected to a push button SW1. An internal pull-up is used (INPUT_PULLUP), so no external resistor was needed. Button short press is used to acknowledge a mailbox event, and long press is used to enter Wi-Fi configuration mode. Since GPIO0 has a special role in ESP8266, the button shall not be pressed during power up, otherwise the controller will not boot.
Since local module is constantly powered, sleep mode is not used; consequently, ESP's RST and HC-12's SET pins are not connected.
Antenna AE1 is a 435.8 MHz dipole with a very long coaxial feed connected via SMA connector to the case and, inside the case, with a SMA-to-IPX coaxial cable to the HC-12 antenna socket. See Antennas for more details.
The circuit is powered from a micro-USB connector J1 using an AMS1117-based 5V to 3.3V converter. Some capacitors, probably, would not hurt in this schematic, but no particular issue with power was observed. The converter is also mounted on a socket, J2; however, it could have been soldered to PCB directly.
PCB layout using 3x7 cm perfboard (facing parts; blue — backplane connections; orange — jumper wires; solid black — soldered parts; dashed black — removable parts' footprints; hexagons — nylon supports for elevated parts):

Soldered backplane:

Because inserting a micro-USB cable exerts quite a strong force on the board, the latter is fixed to the enclosure with four nylon bolts.
Front view with controllers and peripherals inserted:

Thin micro-USB connections are quite difficult to solder, so I opted for a pre-soldered connector with connection holes compatible with a perfboard. To make the button stand out of the enclosure, a model with a tall lever is used, and the button itself is further elevated with the help of a nylon support. Voltage converter is inserted into a header with long legs, bent at 90 degrees.
Fully assembled (with a test antenna):

Installed (for Raspberry Pi addon see Google Home):

| Schematic Ref | Description | Quantity | Price (€) |
|---|---|---|---|
| Remote Module | |||
| R:U1 | HC-12 SI4463 MCU | 1 | 2.13 |
| R:J4 | HC-12 Socket (2.5 mm Header Male-Female) | 5 pins | 0.05 |
| R:U2 | ESP-01S MCU | 1 | 1.30 |
| R:J5+J7 | ESP-01 Socket 2x4p | 1 | 0.06 |
| R:BT1 | Saft LS14250 3.6 V Battery | 1 | 1.50 |
| R:J10+J13 | 14250 Battery Holder | 1 | 0.28 |
| R:SW1 | HWP BS-31B Reed Switch | 1 | 1.78 |
| Ribbon Cable 2p | 40 cm | 0.05 | |
| Ferrule 0.5 mm² AWG22 | 2 | 0.01 | |
| R:AE1 | 435.8 MHz Monopole Antenna: Copper Install Wire 2.5 mm² | 155 mm | 0.10 |
| R:AE1 | 435.8 MHz Monopole Antenna: RG316 Coaxial Cable | 411 mm | 0.29 |
| R:AE1 | 435.8 MHz Monopole Antenna: RP-SMA Male Connector | 1 | 0.22 |
| R:AE1 | 435.8 MHz Monopole Antenna: 5 mm Heat Shrink Tube | 8 cm | 0.15 |
| U.FL IPX Female to RP-SMA Female Cable 215 mm | 1 | 1.08 | |
| R:R1,R3 | Resistor 10k Ohms | 2 | 0.02 |
| R:R2 | Resistor 330 Ohms | 1 | 0.01 |
| R:C1 | Electrolytic Capacitor 0.22 µF | 1 | 0.01 |
| R:C2 | Electrolytic Capacitor 10 µF | 1 | 0.01 |
| R:C3 | Electrolytic Capacitor 220 µF | 1 | 0.01 |
| R:J1 | JST-XH Male Connector 2p | 1 | 0.02 |
| R:J2 | JST-XH Female Connector 2p | 1 | 0.02 |
| R:J9 | Diagnostic Port Connector (2.5 mm Header Male-Male) | 2 pins | 0.02 |
| 4x6 cm Prototype PCB | 1 | 0.20 | |
| Nylon Hex Spacer M2.5 | 2 | 0.06 | |
| Nylon Nut M2.5 | 2 | 0.06 | |
| 24AWG Wire | 30 cm | 0.07 | |
| Tictac Case | 1 | 2.40 | |
| Foam Rubber | 6 cm | ~0 | |
| Solder & Flux | ~0 | ||
| Subtotal Remote Module | 11.91 | ||
| Remote Installation | |||
| Screw | 2 | 0.06 | |
| Bolt M2.5 | 2 | 0.06 | |
| Nut M2.5 | 2 | 0.06 | |
| Cable Tie | 1 | 0.03 | |
| Hot Glue | ⅒ stick | 0.01 | |
| Subtotal Remote Installation | 0.22 | ||
| Subtotal Remote | 12.13 | ||
| Local Module | |||
| L:U1 | HC-12 SI4463 MCU | 1 | 2.13 |
| L:J4 | HC-12 Socket (2.5 mm Header Male-Female) | 5 pins | 0.05 |
| L:U3 | ESP-01 MCU | 1 | 1.30 |
| L:J7+J9 | ESP-01 Socket 2x4p | 1 | 0.06 |
| L:U2 | AMS1117 5 V to 3.3 V Converter | 1 | 0.17 |
| L:J2 | Converter Socket (2.5mm Header Male-Female Long Needle) | 3 pins | 0.03 |
| L:AE1 | 435.8 MHz Dipole Antenna: Copper Install Wire 2.5 mm² | 310 mm | 0.20 |
| L:AE1 | 435.8 MHz Dipole Antenna: RG316 Coaxial Cable | 6 m | 4.37 |
| L:AE1 | 435.8 MHz Dipole Antenna: RP-SMA Male Connector | 1 | 0.22 |
| L:AE1 | 435.8 MHz Dipole Antenna: 5 mm Heat Shrink Tube | 2 cm | 0.04 |
| L:AE1 | 435.8 MHz Dipole Antenna: Cable Trunking | 50 cm | 0.25 |
| L:AE1 | 435.8 MHz Dipole Antenna: Cable Trunking Cap | 1 | 0.75 |
| U.FL IPX Female to RP-SMA Female Cable 215 mm | 1 | 1.08 | |
| L:SW1 | Push Button | 1 | 0.05 |
| L:J1 | MicroUSB B Female to DIP Adapter | 1 | 0.08 |
| L:J10 | Diagnostic Port Connector (2.5 mm Header Male-Male) | 2 pins | 0.02 |
| 3x7 cm Prototype PCB | 1 | 0.20 | |
| Nylon Hex Spacer M2.5 | 3 | 0.09 | |
| Nylon Bolt M2.5 | 4 | 0.12 | |
| Nylon Nut M2.5 | 7 | 0.21 | |
| 24AWG Wire | 20 cm | 0.05 | |
| Tictac Case | 1 | 2.40 | |
| USB A Male to microUSB Male Cable | 1 | 1.00 | |
| 230 V USB A Power Supply 0.5 A | 1 | 1.00 | |
| Solder & Flux | ~0 | ||
| Subtotal Local Module | 15.87 | ||
| Local Installation | |||
| Screw | 2 | 0.06 | |
| Cable Tie | 6 | 0.18 | |
| Subtotal Local Installation | 0.24 | ||
| Subtotal Local | 16.11 | ||
There are many ways of programming ESP-01 and HC-12 controllers, and, I am sure, this section will not teach you much. If you have got your own programming adapter for ESP01, it will surely do. I historically use Arduino Uno for such tasks, so the schematics are made for Arduino. Schematic for programming ESP-01 and ESP-01S is the same.

In this schematic, Uno serves just as a transparent USB-to-serial converter, so it is important that its own program does not intervene. To achieve this, first program Uno with a "BareMinimum" sketch (part of Arduino IDE distribution), then switch the board support to ESP8266 and program the ESP sketch. You can repeat ESP programming many times as long as you do not modify the Uno program.
Because Uno acts as a repeater, its connection scheme is a bit counter-intuitive. Uno TX is connected to ESP TX; Uno RX is connected to ESP RX. Because Uno uses TTL (5V) signalling, and ESP runs on lower 3.3V voltage, a voltage divider R1, R2 is needed on RX line. It will work without a divider too, but the chances of damaging the ESP are somewhat higher. In principle, a reverse conversion 3.3V to 5V would be needed on TX line, but Uno's TX is sensitive enough to work fine with 3.3V input.
There are many warnings in Internet that one should not power — not to say — program, ESP8266 from Arduino, because its 3.3V power line is too weak for that. In practice, I never observed an issue with my Uno and ESP-01, but if you run into a trouble, power ESP-01 from a separate 3.3V power supply.
This schematic is designed solely for programming, you cannot run a program in place, because ESP's GPIO0 is grounded. If this is needed, you have to add a push button or a switch onto the GPIO0 line. In practice, I also have a switch on ESP's VCC line, in order to conveniently power cycle ESP without removing from the socket; however, this is not strictly required.

HC-12 supports wide range of voltages, in mailbox schemas above it works with 3.3V; in programming schematic here it is connected to 5V, which is Arduino Uno's native voltage.
Unlike with ESP-01 programming, here Uno has to be preloaded with a HC-12 configuration sketch (see "rfconf" sketch in this project). Grounding HC-12's SET is needed to ensure communication speed of 9600 bod; otherwise HC-12 will respond with speed which was previously configured. Uno pins D8, D9 are arbitrarily selected; you can use other pins and update the "rfconf" sketch. Since the configuration sketch does its job in setup() function, order of powering up matters. Make sure HC-12 is connected and powered by the time you load the sketch into Uno; if not, power up HC-12 and reset Uno to run the program again. If you are connecting HC-12 pins one by one, make sure VCC is connected the last.
Development setup with breadboards:

Here the third board (connected to the laptop) is Arduino Uno R3 with an ESP8266 programming shield on top. Remote module breadboard is fit with a 18650 rechargeable battery (different from what is used in final setup). Breadboard wiring also includes some auxiliary circuitry allowing reprogramming the controllers without taking them out from their sockets.