Sponsored links

The mailbox with a built-in "scale" that notifies me by e-mail when a mail arrives has been completed!

Sponsored links


I have completed a mailbox that detects the arrival of mail by weight and notifies me by e-mail.

Sponsored links

Weighing with HX711

Using a strain gage and the HX711 module that digitizes the value, I was able to build a "scale" and measure the weight. It measures the weight once a minute and sends the data to Ambient. We left it outdoors for a while to see if it would work stably over the long term.

In the long run, we found that the weight fluctuated depending on the day and time, even though there were no objects on the scale. Therefore, instead of judging that the mail has arrived because of the number of grams, we will use the method of judging the presence or absence of mail by the change in weight, i.e., "the mail has arrived because of the increase in the number of grams from the previous measurement.

I also found that the HX711 would occasionally measure abnormal values like noise. I was able to mitigate the problem considerably with a simple algorithm, but there were still rare cases where abnormal values were measured.

Therefore, even if the measured weight changes and exceeds the specified amount of change, the mail is not immediately judged to have been delivered, but is judged to have been delivered when the same weight is measured in the next measurement.

Making ESP32 work with batteries

I also made a DCDC converter circuit so that the ESP32 can run on batteries. Our goal was to make it work even with two batteries, but the ESP32 consumes a lot of power when connecting to a wireless LAN, so the voltage drops and the ESP32 sometimes hangs up. I gave up on the two batteries and decided to run it on three rechargeable batteries.


Now that I have the hardware, I can create the program. The program is as follows

  1. Measuring the weight
  2. Initialize past weight history with current value if not waking up from DeepSleep
  3. If the weight of the last time (one minute ago) and the weight of this time both increased by more than 2g from the weight measured two (2) minutes ago, the mail is considered to have arrived
  4. If the mail was determined to have been delivered last time and the weight this time is more than 50% less than the weight measured one time before, the mail is determined to have been removed
  5. Measuring the voltage of the battery
  6. When mail is received or removed, send weight, voltage, and presence of mail to Ambient
  7. Send email when mail is received
  8. Go into DeepSleep for 1 minute

The above is the program. Number 6 sends data to Ambient because we wanted to log it, but if you don't need logging, it's an unnecessary program.

I used Keri's Lab's Mail.h for the program to send mail with ESP32 in Number 7.

Thanks to this Mail.h, I can now easily send gmail from ESP32.

The entire completed program can be downloaded here.

When using this service, please make sure to set up your SSID, password, and email account appropriately.

Here is the log of the execution.

We measured the weight three times, two minutes ago, one minute ago, and now, and confirmed that if the weight one minute ago and this time were both 2g more than two minutes ago, the email would be sent.

Now that the device and the program are complete, I can set it up in the mailbox.

Setup and Testing

We installed a "scale" in the mailbox and a circuit on top of the mailbox.

Put a postcard in the mailbox to try it out.

Not long after, an email arrived on my smartphone. Since it's an email, there's a bit of a delay until the email is received.

However, I have finally completed a mailbox with a built-in "scale" that will notify me when the mail arrives! I think this will stop people from noticing that the mail has arrived and leaving it until the next day.

I'll use it for a while and see how it goes. I'm also concerned about the battery life.

2021.4.6 Additions

The program was sometimes not responding when mail arrived, so we fixed the program.

End of addition

Copied title and URL