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.

Goal

Display weather data from a remote weather station onto a LEGO billboard using MQTT.

Materials

Hardware

Software

Instructions

Build Circuit

 

billboard-fritzing

LEDs 1&2

5v →   220ohm resistor →  LED →  Ground

OLED

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.

arduino-esp8266-boards-manager

  • Download the ESPEasy firmware and open the ESPEasy.ino file to configure.
    1. Set your SSID name and password.
    2. Set “DEFAULT_MQTT_TEMPLATE” to  true
    3. Set “DEFAULT_PROTOCOL” to (OpenHAB MQTT)
    4. (You can set the MQTT settings here or later in the running web service)
    5. Upload the firmware to the WeMos device once completed.

screen-shot-2016-09-09-at-8-55-23-pm

 

  • 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. 

screen-shot-2016-09-09-at-9-01-16-pm

Set the GPIO pin states.

screen-shot-2016-11-07-at-11-46-39-pm

Setup the OLED Device by hitting one of the “Edit” buttons and selecting “Display – OLED SSD1306”.

screen-shot-2016-09-09-at-9-12-57-pm

MQTT

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.

Install Mosquitto

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.

Node-RED

This software is a visual tool for wiring the Internet of Things and is pre-installed on Raspberry Pi’s running the Jessie image. 

Download

  1. Open the command shell for the Raspberry Pi and start Node-RED
node-red-start
  1. Then open a web browser and navigate to the Node-RED editor by entering the following URL.

http://yourIP:1880/

  1. Import the following flow to build the application.node-red-billboard-mqtt
  2. 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 accept an MQTT message on the topic “/sensors/iolcity/weather/#” and transmit it to the WeMos on the topic “/billboard/cmd”. Function nodes will format the message using JavaScript. 

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.

Build the LEGO billboard