My main Arduino project for the last few months is trying to design and build a monitor that wirelessly sends an alert to the house when mail has been delivered in the mailbox or a vehicle goes through the front gate. I wanted the sender unit to be solar powered and use an ESP32. Reed switches to be used for the mailbox sensors and a RCWL-0516 movement sensor to monitor the driveway. Alert data to be sent to a receiver in the house using ESPNOW and a receiver based on another ESP32 with 16×2 LCD displays data and sounds an alert. I also wanted the option for an email to be sent using IFTTT when mail is delivered for use when we are away.
It didn’t seem too complicated, but like with many things, some things that I expected to be difficult were easier than I expected and some things I thought would be easy I am still trying to solve. I had intended on putting up detailed notes and the code, but as yet what I have has bits that I am not confident with. It would just add to the mountain of poor advice online. I may put it online later. In the meantime, here is some info about what I was trying to achieve and some of the issues. Feel free to jump in the comments with ideas.
The sensor unit

Sensors: There are two reed switches used to monitor a letter flap and a door. A RCWL-0516 radar motion sensor is used to monitor the driveway.
Battery, solar and charging circuit: I’m using a 6V solar panel feeding into a TP4056 module
The monitor/receiver unit

ESP32 with a 16×2 LCD display that can display 4 modes: Current time, mail alert, driveway alert and stats. Speaker for displaying alert sounds.
Issues
Best method of charging the Li-ion cell
If I had decided to just monitor the mail, I probably would have not added solar charging. However, the motion sensor uses a few milliamps so I decided to have solar charging. Those cheap TP4056 modules seem to be very popular and people I respect are using them with small solar panels, so I chose to use one of those. It can be seen here above the green terminal blocks.

Later, I come across people saying these are not suitable with solar panels and we should be using an MPPT Solar Charge Controller and suggested this one. These are small, simple cheap modules as well, but I have concerns about these. The datasheet I located on Shotech lists the absolute maximum input voltage as 6.5V. My solar panel may exceed the maximum.
I don’t understand why the TP4056 is not suitable, other than the MPPT should have higher charging efficiency, but with the small drain and sizable panel I’m using efficiency shouldn’t be too important. I did find a part of the TP4056 did get quite warm around 60 deg C at times and I thought it may be better with the MPPT charger, but MPPT has a maximum junction temperature of 150 deg C so I’m interested to see how that aspect goes. I’ve ordered a few to experiment with.
Monitoring battery voltage has not been reliable
I thought it would be interesting to monitor both the battery and solar panel voltages and include these in the data sent to the receiver. I set up voltage dividers and recorded ADC values and generater a conversion formula. I believe my conversion of values work correctly but there is something wrong with the way I am getting the raw values. The converted voltage can vary by as much as 116mV for the battery voltage depending if there is sun shining on the panel or not.
Constant resetting while triggered from sleep
The ESP32 is set up to spend most of its time in deep sleep. It is set to wake when the mail or driveway sensors are triggered, using the external wakeup. It uses this:
// EXTERNAL WAKE UP (ext1)
// Wake up the ESP32 if any of the pins you’ve selected are high;
esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
I assumed that the μC would wake up only be triggered to wake up when one of the selected pins changed state to high, but I appear to be wrong. The μC continually cycles while ever the pin is high. That means if the door is not properly closed then it would repeatedly cycle and send alerts. I have solved this by calculating the time since the last wakeup and ignoring any that are less than 3 seconds that were triggered by the same pin. I’m not sure if there was a better way to deal with this.
Dealing with range
The sender and receiver are about 70m apart. Initially I was going to use a cheap 433MHz module that I had, but it didn’t get much further than about 10m. LoRa is probably the obvious choice, but I don’t have any and don’t have experience with those. Besides, ESP32 has ESPNOW built-in so I tried giving it a go. It has a long range (or long enough range) mode. In tests it only just made the distance. I tried to learn as much as I could about LR mode. This is often referred to as Long Range mode, but I also read where someone thought it was Low Rate mode. I’m not really sure which it is but presumably reducing the rate should help to increase the range. I don’t know if I have set it up incorrectly but I’m not seeing any successful improvement in the range.
I also tried setting the power of the sender to it’s highest level using:
WiFi.setTxPower(WIFI_POWER_19_5dBm);
but that doesn’t seen to improve the range much either. The sender module has an external antenna which does make some improvement. In hindsight, it may have been better to use a LoRa module.
Setting the wifi channel
By default, ESPNOW uses wifi channel 0. That was fine until I wanted the receiver to get the time from the internet and attempt to send notification emails. It looks like to do this the receiver has to use the same channel as the wifi and then the Sender/sensor has to use the same as the receiver. On top of that our wifi router chooses a channel automatically. We are in a rural area and was able to update the router settings to always use the same channel. This works but I would have rather not done that.
IFTTT not working
I’ve got a sketch that connects to the internet and uses a webhook with IFTTT to send an email. I thought this may be useful if we are away. While the demo sketch works, I’m getting errors when I use it in this project.
Radar detector unreliable
Initially I thought these cheap RCWL-0516 ‘radar’ sensors were going to be perfect for the job, but that has not turned out to be the case for this project at least.

While the sensor is sometimes marketed as a doppler effect radar sensor, some believe it doesn’t actually rely on the doppler effect. This page by Roger Clark is an excellent source of information. It suggests it doesn’t actually use the doppler effect. Not that it matters for this project.
A challenge in my set up is that the mailbox is near the road and the radar sensor detects movement from all or most directions. I was getting some triggering by vehicles going past. This is despite my sensors having really poor sensitivity. I bought a packet of 5 of them and they all seem to be bad. I have an older HW-MD6 sensor that is much more sensitive, but I think that will just pick up more passing vehicles. I tried adding shielding to make them more directional, but I couldn’t get much improvement.
This is an interesting resource. It turned me off these sensors RCWL-0516 Microwave Radar Sensor Experiences? I’m now looking at PIR sensors instead. They have the benefit that that they are more directional. I’ve just started testing a cheap HC-SR501 sensor, but so far are getting too many false alerts.
Worth it?
It would probably been cheaper and easier to buy one. However, despite all the issues, it’s been an interesting challenge. We are being sent alerts when the mail is delivered which has given me the incentive to keep going. It’s just taking much longer than I expected.
Leave a comment