The IoL City has a local weather station but how do you broadcast the information for everybody to see? A digital billboard!
This project uses a Raspberry Pi running Node-RED to collect weather data from my previous Weather Station project and display it on an OLED screen powered by an ESP8266.
Display weather data from a remote weather station onto a LEGO billboard using MQTT.
- Raspberry Pi
- WeMos D1 mini (ESP8266)
- OLED 128×64 I2C screen
- 2x LEDs
- 2x 220ohm resistors
- Breadboard and wires
- LEGO bricks!
5v → 220ohm resistor → LED → Ground
Vcc, Ground, SDA → D2, SCL → D3
Configure WeMos D1 mini
The WeMos is an inexpensive development board based on the ESP8266 WiFi chip. To make things easy, a special firmware called ESPEasy has been written to allow the device to be configured from a web page instead of having to write a lot C++ code. The Arduino IDE is able to upload the firmware which makes this even easier to get started. Official Instructions
- Open the Arduino IDE and install the ESP8266 board support.
- Download the ESPEasy firmware and open the ESPEasy.ino file to configure.
- Set your SSID name and password.
- Set “DEFAULT_MQTT_TEMPLATE” to true
- Set “DEFAULT_PROTOCOL” to 5 (OpenHAB MQTT)
- (You can set the MQTT settings here or later in the running web service)
- Upload the firmware to the WeMos device once completed.
- Connect to the device’s management web page. You can do this by connecting to its own SSID “ESP-01” the first time using the credentials configured in the previous step (pw: configesp). The default IP for management is 192.168.4.1. Place that address in your browser to configure the initial settings. It will ask you to enter your SSID settings (if you didn’t configure them in the Arduino sketch). Once set, the device will connect to your network and display its IP address. Take note of this info quickly, because some computers will close the browser window automatically. Alternatively, you can statically assign the IP address in the sketch, but I prefer to assign address from my DHCP server as a best practice.
Set the GPIO pin states.
Setup the OLED Device by hitting one of the “Edit” buttons and selecting “Display – OLED SSD1306”.
In order for our “things” to connect to each other, they must have a way of communicating. MQTT is a publish/subscription messaging system that is simple and fast. It’s like the Twitter for machine-to-machine conversations. Each device will subscribe and/or publish to a topic, much like a #hashtag for a tweet. The payload will then contain the data being transmitted.
An MQTT broker is a server that manages the MQTT message flow and each device will connect to it. Mosquitto is a free open source broker that works perfectly on a Raspberry Pi.
More info on Raspberry Pi forum.
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key sudo apt-key add mosquitto-repo.gpg.key rm mosquitto-repo.gpg.key cd /etc/apt/sources.list.d/ sudo wget http://repo.mosquitto.org/debian/mosquitto-repo.list sudo apt-get update sudo apt-get install mosquitto mosquitto-clients
Mosquitto should now be listening on port 1883 of your Raspberry Pi. Use this address for your WeMos and Node-RED MQTT configurations.
This software is a visual tool for wiring the Internet of Things and is pre-installed on Raspberry Pi’s running the Jessie image.
- Open the command shell for the Raspberry Pi and start Node-RED
- Then open a web browser and navigate to the Node-RED editor by entering the following URL.
- Import the following flow to build the application.
- Double click on the purple MQTT nodes to set the MQTT broker to the IP address and port for your Mosquitto broker.
The flow will automatically start transmitting the message “Welcome to IoL City”. If you have built a weather station or have other sources of data, change the MQTT input nodes to match your topics. For an example of a Weather Station using MQTT, checkout the Weather Station project. Alternatively, you could get weather data using the Weather Underground service with the Node-RED node.