ESP32-ExposureAPI-Scanner
This repository contains code to scan the official COVID19 Exposure API with an ESP32 using Bluetooth LE and shows a counter on an SSD1306 OLED display.
Code is based on BLE Exposure Notification Beeper which uses an LED and a piezo buzzer to notify about new detected devices but would not show the device count so I added the display part to it. You can still use the LED/Buzzer because this part is not touched in the code. In case you want to do so use this wiring:
| ESP32 pin | goes to |
|---|---|
| GPIO 0 | LED (+) |
| GPIO 2 | Buzzer (+) |
| GND | LED (-), Buzzer (-) |
How it works
The official Exposure API used by Apple and Google generates new device keys approx. every 15 Minutes. The scanner remembers these codes and won't notify you again if they're detected multiple times. After 20 minutes these devices will be removed from the counter because the keys are no longer valid.
You can adjust this timespan in the code by changing FORGET_AFTER_MINUTES.
Required Hardware
This ESP32 model uses these internal I²C and pins for the SSD1306 display:
| SSD1306 | goes to |
|---|---|
| I²C ADDRESS | 0x3c |
| SDA | 5 |
| SDC | 4 |
You can also use a separate SSD1306 but keep in mind to adjust the I²C adress and the pins in the code.
Installation with Arduino IDE
- Type
git clone https://git.susa.pw/jonas/ESP32-ExposureAPI-Scanner.gitin your terminal or download the master.zip and extract it - Open
ÈSP32-ExposureAPI-Scanner.inoin the Arduino IDE - In case you haven't already done it install ESP32 drivers
- In the Arduino IDE select
Tools > Board > ESP32 Dev Board - Press
CTRL + Uto compile and upload to the ESP32 Board
3D printed case
I recommend this case from Thingiverse. You can see it in the second image above.
In case you have an Anycubic i3 Mega printer at home you can use the sliced gcode file in the case/ folder. The file contains the top and bottom part and was sliced with Cura with highest printing accuracy. It will take approx. 3h to print.

