Posted on 2 Comments

The ESPGateway – Part 2: Applications

One ESP32 alone is already a powerful microcontroller. But what can you do when you have two modules built into one device? In this blog post, we discuss applications for the ThingPulse ESPGateway

The ESPGateway features two ESP32-WROVER-IB modules. Read more about the design of the device in this article. What can you do with two modules of this powerful microprocessor under hood?

PAX Counter

Most people these days walk around with one or more internet connected devices: smart phones, smart watches, laptops, tablets, etc. And these devices are usually looking for networks by sending out probing messages. These probing requests make it possible to estimate the number of people or passengers (PAX) at a certain location.

I write “estimate” because this is never an exact number for various reasons: not everybody has a device sending these messages while others have two devices. But this measurement lets you say something about the fluctuation of crowds, make predictions and safely and timely provide more resources.

This tool of course can be used for different reasons and not all of them are good. A while back researches showed that it can be used to closely track the movement of people if you only have enough points to receive the probe requests. Cell phone manufacturers then started to implement countermeasures such as using random MAC (sender) addresses. So now the privacy of a single user is much better protected while it still is possible to say something the number of people in a certain location.

ESP32 as uplink

The PAXCounter project by Cyberman54 is capable of measuring the number of people with an ESP32. Since regular WiFi traffic is not possible while the ESP32 is in promiscuous mode we cannot send the measurements to a logging server all the time with the same ESP32. It is possible to write the measurements to an SD Card, send it over LoRaWAN or to any via the SPI protocol.

Because the ESPGateway has two ESP32 modules we can use one to count the WiFi and Bluetooth devices nearby while the other ESP module sends the measurements over WiFi and MQTT to a logging server where the numbers can be analyzed and visualized.

The latest version of the PAXCounter firmware can even listen in on devices with activated COVID-19 exposure notification systems. Smartphones expose this Bluetooth service when people have installed the COVID tracking apps of their respective countries.

The external antennas of the ESPGateway let you cover a bigger area than a comparable PAXCounter could by using the PCB antenna. This means we can very well use it in big locations to measure (and possibly limit) the number of people at a given time.

ESPNow Gateway

Espressif, the designer of the ESP-chip family has developed a proprietary protocol in the 2.4GHz band which lets ESP8266 and ESP32 modules exchange messages with very little overhead. This protocol is called ESPNow. Normally a WiFi device needs to go through several states before it is connected and can exchange payload. The physical connection to the access point, DHCP negotiation to get an IP, then the connection to the (application) server needs to be established.

ESPNow on the other hand is much leaner and can send a small message in less than 500ms. For any given application of the ESP32 the WiFi connection is probably the most battery hungry part of the program. By reducing the time the device is sending and receiving packages over the air we can effectively save a lot of energy and thus prolong battery life. For a sensor node measuring temperature and humidity, this can add many days, weeks or even months of battery life before it needs to get replaced or recharged.

Two ESP32 to the rescue

But an ESP32 alone cannot use the ESP32 protocol, it needs a counterpart. The two modules might talk just to each other or one can forward a message to the internet or through a private network. Depending on the WiFi channel the to WiFi can be managed by the same ESP32. But if ESPNow and WiFi have to use different channels then a full duplex mode is not possible. This increases the chance that we lose messages because the ESP32 has to turn off one interface to communicate on the other.

So why not use two ESP32 connected to each other? One will listen for messages on the ESP-Now protocol while the other forwards the messages over WiFi and MQTT. And since the ESPGateway comes in such a beautiful enclosure nobody will complain about an additional router device. Ok, there probably will be somebody complaining about any additional device but at least it looks pretty, eh?

Bluetooth Gateway

Xiaomi Flower Care Sensor

More and more devices have a Bluetooth interface. Usually, they have such an interface so that smartphones can connect to them and read out the data. In the picture above you can see a Xiaomi Flower Care moisture sensor installed in my home. We have a couple of those in various flower pots across the appartment.

With a regular ESP32 module I couldn’t read out the data from all the BLE enabled devices. But thanks to the ESPGateway’s huge external antenna this has become possible. One sensor is 10 meters away from the gateway and the signal has to travel through two brick walls and yet it is capable to read out the sensor data.


Another device my ESPGateway talks to is this Xiaomi BLE Temperature and Humidity sensor. Again thanks to the bigger reach of the ESPGateway I can read the data from all sensors in my apartment.

This application actually requires only one ESP32 module since the BLE and WiFi can be used at the same time. So you can use the other ESP32 to calculate fractals or mine bitcoins. Why? Because we can!

2 thoughts on “The ESPGateway – Part 2: Applications

  1. Is it possible to further enhance the ESPGateway to support PoE interface? I have at the moment Home Assistant system working at remote location, where various devices are connected into HA server direct via USB-connection. No additional free USB interfaces are available. Other connections are made via WiFi or LAN-interface. In order to power up all external devices I have already seven AC/DC adapters connected into outlets of the UPS system. There is no more room to extent this kind of powering, so I like to use PoE connected devices in future.

    1. PoE support would indeed be a nice and very obvious new feature. However, we decided to keep complexity and cost low until we see significant customer demand for PoE. This hasn’t materialized yet.

Leave a Reply

Your email address will not be published. Required fields are marked *