This repository features an iBeacon Gateway implemented using ESP32 and ESP-IDF, primarily designed for position estimation using BLE. Additionally, it includes parsing data from a Milesight smart camera. The project uses MQTT to transmit data and integrates position estimation calculations based on RSSI values.
-
BLE Scanning and Filtering:
- Captures BLE advertisements and filters data based on UUIDs.
-
Position Estimation:
- Calculates distances using RSSI values with the formula:
RSSI = -10.0f * N * log10(distance) + RSSI(Distance.1m); Distance = 10^((RSSI(Distance.1m) - RSSI)/(10 * N)).
- Calculates distances using RSSI values with the formula:
-
Smart Camera Integration:
- Parses data from Milesight smart cameras, including parking space detection and occupancy information.
-
MQTT Communication:
- Publishes iBeacon and camera data to an MQTT broker over secure connections (MQTT over TLS).
-
Web Server:
- Provides an asynchronous server for managing configurations, including:
- UUID filters
- Environmental factors for position estimation
- Coordinate and tag management.
- Provides an asynchronous server for managing configurations, including:
-
Wi-Fi and Ethernet Support:
- Supports both Wi-Fi and ENC28J60 Ethernet connectivity for flexible deployment.
-
Persistent Storage:
- Stores parking and tag data in SPIFFS for long-term availability.
-
Scalable BLE and Camera Support:
- Supports up to 100 parking areas and multiple BLE tags.
-
BLE Scanning and UUID Filtering:
- The ESP32 scans for nearby BLE iBeacons and filters data by UUID before processing and rssi.
-
Position Estimation:
- Calculates distance from the beacon using RSSI values and predefined calibration parameters.
-
Smart Camera Data Integration:
- Parses real-time data from a Milesight smart camera for parking space monitoring.
-
Data Transmission via MQTT:
- Sends formatted JSON data to the MQTT broker for iBeacon and camera data.
├── components
│ ├── bt # Blueroid component
│ ├── eth_enc28j60 # Etherent component for enc28j60
│ ├── json # cJSON lib
├── main/
| ├── CMakeLists.txt # Build instructions
│ ├── async_server_utils.h # Generics for async webserver
│ ├── ble.c # BLE init, scanning, filtering
│ ├── cert.h # Cert and credintials for mqtts
│ ├── defs.h # Common includes, topic, generics for sending mqtt, utility
│ ├── main.c # Main interface for calling, task creation initing spiff,
│ initing etherent/wifi, init mqtt, ble
│ ├── mqtt.h # Mqtt init, publising data, logic for changing
│ comon params (x, y, uuid allowed list, env factor, rssi)
│ ├── parking.c # Parking parsing saving, logic for saving into a spiff,
│ ├── parking.h # Parking struct defs of func global parkings(100 max)
│ ├── server.c # Server implementation, saving parkings
│ ├── server.h # Server header
│ ├── tag.c # Tag implementation, saving tags
│ ├── tag.h # Tag header
│ └── wifi.h # WIFI implementation
├── ESP32_Guide.md # Detail description of used libs and esp32 overview
└── README.md # Project overview (this file)
- ESP32 Development Board (e.g., ESP32-WROOM-32 or similar)
- One or more iBeacon Devices
- Milesight Smart Camera (optional)
- Wi-Fi network for data transmission
- Optional: Power supply, enclosures, and mounting equipment
- ESP-IDF Framework (v4.x or later recommended)
- MQTT Broker (e.g., Mosquitto, AWS IoT, or HiveMQ)
- Python 3.x (for testing MQTT data or server-side applications)
-
Clone this repository:
git clone https://github.com/BlagojeBlagojevic/iBeaconGateway.git cd iBeaconGateway-main
-
Install and configure ESP-IDF:
- Follow the ESP-IDF Getting Started Guide.
-
Configure
config.h
with:- Wi-Fi credentials
- MQTT broker details
- UUID filter list
-
Build and flash the firmware:
idf.py build idf.py flash
Data is sent to the MQTT broker in the following JSON format:
{
"refpower": 0,
"uuid": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"majorID": 0,
"rssi": -65,
"minorID": 0,
"time": "2024-12-09T12:00:00Z",
"distance": 1.5,
"x": 0.0,
"y": 0.0
}
Camera events are parsed and sent to the MQTT broker in this format:
{
"event": "Parking Space Detection",
"device": "Network Camera",
"time": "2024-12-09T12:00:00Z",
"parking_area": "Area A",
"occupancy": 5
}
- Power on the ESP32, iBeacon devices, and the Milesight camera.
- Monitor MQTT topics for iBeacon and camera data.
- Verify position estimation outputs match expected distances based on known RSSI values.
Contributions are welcome! Feel free to submit a pull request or open an issue to suggest improvements or new features.
This project is licensed under the MIT License.