Implementation of an ESP32 based sensor for detecting open/close condition of a Hall-effect sensor and communicating telemetry via Wifi to Google Cloud IoT Core and events to Pushover.
This is very much a "scratch your own itch" type project and is not intended for wide use. YMMV.
First version deployed. Major features:
- Hall-effect sensor to detect gate open/close
- The Ultra-Low Power coprocessor polls the Hall sensor while the main CPU remains in deep sleep (main CPU is active for only ~3-5 seconds per hour)
- Open/Close event notifications via Pushover
- Telemetry sent to GCP IoT Core every 15 minutes
Picture | Part | Description |
---|---|---|
EzSBC ESP32-01 | Power optimized ESP32 dev board | |
Melexis US5881 | Sensor to detect when gate is open/closed via magnetic field | |
Protected LG MJ1 18650 | Battery to power ESP32 and Hall sensor | |
Keystone 1042P | Battery holder | |
Polycase SK-12 | Water-resistant (IP66) enclosure w/ knock-outs | |
Polycase CG-3 cable gland | Water-resistant (IP68) ratcheting seal for Hall sensor cable | |
KJ Magnetics DX04B-N52 | 1" dia x 0.25" thick N52 neodymium disc magnet | |
10k ohm resistor | Pull-up for Hall sensor open-drain output pin |
Closeup of the tiny gap between magnet and hall sensor
Everything stuffed into the enclosure
Enclosure contents unpacked (yes, I used pin jumper/hookup wires. Not exactly corrosion resistant I know).
Closeup of the US5881 Hall sensor installed into three female pin jumper sockets. Pins are in order 1, 2, 3 from top to bottom. The resistor is applied across pins 1 (Vdd) and 3 (Output) to pull-up the sensor's output pin. Pin 2 is ground.
Why the slick and shiny appearance of the pin sockets and sensor? Thanks to the super- sophisticated conformal coating ... aka clear gel nail polish! ;)
Source | Current (milli-Amps) |
---|---|
ESP32 active, WiFi TX | 180.0 |
ESP32 deep sleep in ULP | 0.017 |
US5881 (3.3V * 10kOhm) | 0.330 |
- Big thank you to @TvE for the amazing Running Wifi Microcontrollers on Battery blog series.
Selection criteria
- Low deep-sleep power consumption on battery - needs to run for 45+ days on a 3,000 mAh 18650 battery.
- Development convenience - easy to use, integrated battery connector, no bugs/annoyances.
WROOM-32 based development board. Very high-quality Adafruit part with superb documentation.
Unfortunately has high quiescent power consumption (see https://blog.voneicken.com/2018/lp-wifi-esp32-boards/) making it a poor choice for powering via a battery. So Sad.
Out of the box 17uA quiescent power consumption. WROOM-32 based board just like the Feather. Great price.
The EzSBC lacks a battery controller so battery protection must be provided elsewhere. The sensor uses a 3,500 mAh LG MJ1 18650 with integrated protection board from LiIon Wholesale.
- Ensure multicast/broadcast filtering is enabled to prevent ARP and other random packets from potentially waking device.
- Increase DTIM period.
ESP32's on-board Hall effect sensor calibration varies between chips, is not that sensitive, and is fairly noisy. The Melexis US5881 is a great replacement. It reads as Vgnd/0 V when the south pole is present (0 from the ADC) and Vdd/3.3 V when "open" (4095 in the ADC).
- Disable GPIO pins 12 and 15 to prevent drain from internal pull-ups.
Copyright (c) 2020 int08h LLC. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.