Simple BLE to MQTT gateway
This app will scan for the Eddystone BLE advertisement packets from my ESP32 BLE sensor, and forward temperature, voltage and humidity values to the cloud.
How to use:
Please upload my ESP32 firmware (github.com/DSysoletin/ESP32_BLE_env_sensor) to your ESP32 board and connect the DHT11 sensor
If you want to use the binary, just skip this step. If you want to built the scanner, please do the following commands (from the clonned repo): $cd ./scanner $go build
To use the scanner with local MQTT server, you just need to specify the host and port (please note that scanner needs to be run from root user because it needs to have access to the hci device directly, not via BlueZ): #./scanner -host 127.0.0.1 -port 1883
To use the scanner with AWS IoT Core, please supply your certificates: #./scanner -host YOUR_ENDPOINT_URL.amazonaws.com -ssl -keypath ./IoT-sensor-test.private.key -pempath ./IoT-sensor-test.cert.pem
When the scanner will detect some Eddystone messages and parse it, it will publish them to the MQTT server. You’ll see prints like this: Publishing… 30:83:98:00:3c:2a/temperature 30:83:98:00:3c:2a/humidity 30:83:98:00:3c:2a/voltage
In this example, you can see the topics used for publishing the sensor data. Because topics include HW address of the sensor, several sensors can be used with one scanner app.
Read more here: Source link