Giter VIP home page Giter VIP logo

esp32_ble2mqtt's Introduction

OH2MP ESP32 BLE2MQTT

An ESP32 based gateway that listens BLE beacons and sends the data via MQTT

Web-configurable BLE data collector that sends data to a MQTT broker. In my own configuration I have Mosquitto as a broker and InfluxDB + Telegraf with MQTT plugin. See CONFIG_EXAMPLES.md.

This software sends data as JSON to the broker. The data is specified to be compact to avoid high bills when this is used with a mobile internet with some data plan. See DATAFORMATS.md

The idea for this is home or RV use, not scientific environment. Because of that eg. the temperatures are only with 0.1°C precision and acceleration sensors of Ruuvi tags are simply ignored. It's not very important to know the acceleration while the tag is in a fridge and we want to keep data compact.

BLE beacons that are currently supported:

This is partly based on the same code as OH2MP ESP32 Smart RV and OH2MP ESP32 Ruuvicollector


Software prerequisities

You must install also PubSubClient and ESP32_BLE_Arduino from Arduino library manager.

Choose correct ESP32 board and change partitioning setting:
Tools -> Partition Scheme -> Huge APP(3MB No OTA)

Use the filesystem uploader tool to upload the contents of data library. It contains the html pages for the configuring portal.

By default the software assumes that there are maximum 16 beacons or tags, but this can be changed from the code, see row #define MAX_TAGS 16

Configuration option

The portal saves all configurations onto the SPIFFS filesystem. They are just text files, so you can precreate them and then your ESP32 Ruuvi Collector is preconfigured and you dont' have to use the portal at all. Just place yout configuration files into the data directory along the html files and upload them with ESP filesystem uploader.

See FORMATS.md.

LED behavior

Optionally an RGB LED can be connected to the board. It acts as a status indicator. At boot the LED shows a short color effect to see that it's working. Colors and meanings in operating mode:

  • off = nothing happening just now
  • cyan = BLE scanning active, but no beacons heard yet
  • blue = BLE beacon(s) heard
  • purple = end of BLE scanning
  • green = sending data to MQTT broker
  • red = cannot connect to WiFi
  • orange = WiFi connection works but cannot send data to MQTT broker

The LED pins are configurable from #define rows. The defaults are 21 red, 22 green and 23 blue. Every one should be connected with a eg. 1kΩ resistor.

TIP: connect an LDR to the cathode side of the LED. Then it will illuminate brighly in daylight but will be dimmed in the dark.


Portal mode

If the GPIO0 is grounded (same as BOOT button is pressed), the ESP32 starts portal mode. The pin can be also changed from the code, see row #define APREQUEST 0

In the start of portal mode the ESP32 is scanning 11 seconds for beacons. During the scan the color behavior of the LED is similar like in operating mode.

WiFi AP is not listening yet at the scanning period. After the LED starts illuminating green, connect to WiFi ESP32 BLE2MQTT, accept that there's no internet connection and take your browser to http://192.168.4.1/

The web GUI should be self explanatory.

It's a good idea to find out the Bluetooth MAC addresses of the beacons beforehand. For Ruuvi tags the easiest way is to use Ruuvi software. For other beacons eg. BLE Scanner by Bluepixel Technologies is a suitable app for Android.

The portal mode has a timeout. The unit will reboot after 2 minutes of inactivity and the remaining time is visible on the screen. This timeout can be changed from line #define APTIMEOUT The LED changes its color slowly from green to yellow and then red depending how near the timeout is.

There's almost no sanity checks for the data sent from the forms. This is not a public web service and if you want to mess up your board or try to make a denial of service using eg. buffer overflows, feel free to do so.

Sample screenshots from the portal

Portal main Sensors config MQTT config


esp32_ble2mqtt's People

Contributors

oh2mp avatar oh2th avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.