In this project, we are going to use ESP as a BLE beacon and BLE stations, which beacons are monitored by stations through Bluetooth Low Energy. The stations send the data to the server through the MQTT protocol, so that the server collects the information as a database and sends the necessary commands through this protocol. We use Mosquitto as the broker of MQTT.
- esp32 by Espressif Systems (Installation guide)
- NimBLE-Arduino
- PubSubClient
To install Mosquitto Broker:
sudo apt install -y mosquitto mosquitto-clients
To make Mosquitto broker automatically start with the boot:
sudo systemctl enable mosquitto.service
Test the installation:
mosquitto -v
With just the MQTT code, the sketch uses 52% of program storage space, and using ble scanner example from the original library will use 78% of program storage space. So, we can't use ble and wifi at the same time. As an alternative solution we use another library from here that only uses 42% of program storage space.
If the connection to the MQTT server is refused, check the configuration file:
cat /etc/mosquitto/conf.d/standard.conf
It has to be something like this:
listener 1883
protocol mqtt
allow_anonymous true
Then restart the mosquitto.service:
sudo systemctl restart mosquitto.service
python3 -m venv myvenv
Step 2. Activate the virtual environment (you can activate venv just by reopening the terminal instead of following commands).
# For Linux
source myvenv/bin/activate
# For Windows
./myvenv/Scripts/activate
pip3 install ipykernel
Step 4. (Optional) You can create a new kernel by the following command or just skip this step and select 'myvenv' kernel in step 6.
python3 -m ipykernel install --user --name=myproject
Step 5. Open a jupyter-notebook in VS Code by holding 'Ctrl+Shift+P' and selecting 'Create: New Jupyter Notebook'.
- The one you created in Step 4.
- Or just use this one: Python Environments -> myvenv (Python)
pip3 install -r requirements.txt