The device informs about the weather with a color set. It also provides ways to change the location or the lighthouse's color from a smartphone using Bluetooth Low Energy.
You can find all the necessary files in these packages:
app/lighthouse_weather
: a Flutter mobile appstation
: a Python service for RPiprint
: the 3D print filesmedia
: photos and screenshots
⚠️ This project has been migrated to support Bluetooth Low Energy
See Using Bluetooth Low Energy between Raspberry Pi and Flutter
Checkout the branch feature_classic_bluetooth to use Classic Bluetooth protocol on RFCOMM.
Read How I built a lighthouse weather station? to see how this was created.
⚠️ Make sure your RPi usesPython3
andpip3
(see the Adafruit guide).
On RPi ZW, we need to install the following dependencies:
$ sudo apt install python3-dbus
$ sudo pip3 install Adafruit-Blinka
$ sudo pip3 install adafruit-circuitpython-neopixel
Enable the "experimental" flag to bluetooth deamon in bluez
:
$ sudo nano /etc/systemd/system/dbus-org.bluez.service
Add -E
flag at the end of line:
ExecStart=/usr/lib/bluetooth/bluetoothd -E
Then, restart the Pi as follows:
$ sudo reboot
On the Pi, by using echo -e 'show\nquit' | sudo bluetoothctl
, you will get the following output:
Controller XX:XX:XX:XX:XX:XX (public)
Name: raspberrypi
Alias: LighthouseWeatherStation
...
Copy-paste the MAC address XX:XX:XX:XX:XX:XX
into the mobile app, in /lib/bloc/bluetooth/bluetooth_bloc.dart
:
final String _nameLighthouseStation = 'LighthouseWeatherStation';
final String _addressLighthouseStation = 'XX:XX:XX:XX:XX:XX';
Go to OpenWeatherMap and get an api key.
You have to copy-paste it in the Python script instead of xxx
:
appid = 'appid=xxx'
$ sudo python3 main.py
This should output:
GATT application running
GATT application registered
GATT advertisement registered
---
Update weather
Request response: 18°C (weather: 803)
Color selected: (255, 255, 0)
...
Then, when a device is connected, the output should add Sending
line:
Update weather
Request response: 18°C (weather: 803)
Color selected: (255, 255, 0)
Sending: D=19,W=803,C=6454880
...
When the device is off:
When set a custom color (white for example):