Introduction: A Voice-Activated Weather Station With LEGO and Low-Code

About: A Low-Cost/Low-Code platform, for makers, citizen developers and IT experts

Use LEGO bricks and Hackeet Low-Code platform to build a voice-activated weather station that respects your privacy.

Step 1: The Project

In this project, we are going to show you how to build a funny and personalized weather station that reacts to voice and respects your privacy without being an engineer.

This station will take the form of an animated carousel built from LEGO bricks on which will be attached LEGO characters, each indicating a state of the weather (rainy, sunny, cloudy, alert). This station will be able to react to commands such as "Hey Snips, what's the weather like in Paris " by rotating the carousel to display the right character.

In order to achieve this, we are going to use stepper motors for rotating the carousel, Snips.ai for performing voice recognition, the OpenWeatherMap web service for getting forecast and Hackeet Low-Code platform to develop the the application that makes the glue between all these components. At the heart of the weather station will be a Raspberry Pi on which all applications will be installed and that will be in charge of all the magic.

Step 2: About Hackeet

Hackeet is a low-code visual programming tool that allows you to connect hardware or software components together to create Web Applications and Micro-services for Microsoft Windows, Raspberry Pi and Arduino / ESP8266 devices..
Designed for makers, small businesses, developers and anyone that is interested in technology, Hackeet allows you to create your own apps easily and at an incredible speed by connecting boxes instead of writing tons of code.

As we value privacy, Hackeet is not another "platform as a service" offering and does not use any hidden cloud architecture. Applications built with Hackeet run directly on your own hardware as regular private application.

Check out our website to get more details!

Step 3: Things

Hardware components
Raspberry Pi 3 Model B+ ×1

ULN2003 Motor Driver Board & 28BYJ-48 5V Stepper Motor ×1

LED (generic) ×1

LEGO Creator 3 in 1 - Modular Sweet Surprises ×1

LEGO Brick Box ×1

Adafruit Mini USB Microphone ×1

Software apps and online services

Hackeet Low-Code Platform

Snips.ai Voice Recognition platform

OpenWeatherMap REST API

Step 4: Let's Do Some LEGO!

Let's start building the project!

First of all, we have to build our station from LEGO bricks! Of course, the point here is not to teach you how to do LEGO (we guess that you all do know :-)). Nevertheless, if you want to save some time, we provide you with the diagrams of the design we have used for this project.

Basically, the general idea of this design is to divide the weather station in two parts:

  • a first part that will be used as a pedestal and that will host all the electronic cards (Raspberry Pi and ULN2003 driver board),
  • a second one that will be the decoration that will host the carousel, the stepper motor and the status LED Such design should allow you to easily change the decoration of your weather station without having to rebuild everything from scratch.

You can obviously use any design you want and any LEGO pack you have, not only the one we have put in the project's description (especially for the decoration) !! Just make sure to have enough room for the boards and the wiring.

Sketchup files for pedestal are available for download here!

Step 5: Carousel Configuration

Place the LEGO characters for each forecast value on your carousel in the following order:

Step 6: Hardware Assembly

Let's now consider wiring together all the hardware components.
In order to manage communication between the 28BYJ-48 stepper motor and the Raspberry Pi, we use a ULN2003 driver board that will be connected to the GPIO ports of the RPI .

We use a LED as a status indicator that will light when the weather station is ready to listen to the commands (after you say Hey, snips).

You can add a resistor between the Raspberry Pi and the LED to protect it if you wish.

Step 7: The Weather Station

The weather station is now fully assembled and the the final result should more or less look like the one above.

Step 8: Install Software

Get an OpenWeatherMap API Key

Forecast are retrieved from OpenWeatherMap using the REST API. In order to use it, you need to grab a free API Key here.


Install Snips.ai

In order to perform voice recognition, we use Snips.ai, a private by design voice assistant technology that is able to run on a Raspberry Pi 3.

To install it, please follow the directions at the page hereafter:

https://docs.snips.ai/getting-started/quick-start-...

Make sure that you have correctly installed the Snips.ai weather assistant (normally installed by default) by performing tests as described here.

Install Hackeet

Okay, so good so far! Let's now install Hackeet on your Raspberry Pi.

To install Hackeet and get a free trial license, follow the directions described at the page hereafter : Hackeet : Get Started

At last, once Hackeet is installed and is up and running, open a terminal window on your Raspberry Pi and copy paste the following command to finally install the application that will manage the weather station :

hpm package https://cloud.nitenslux.com LEGOWeatherStation.2.1.5

This command will install the application that will actually operate the weather station and all its dependencies on your Raspberry Pi. Upon successful completion, you should have a new icon installed on your Raspberry Pi's desktop.

Step 9: Configure the Application

Now that the hardware part is achieved and the software has been installed, we need to perform some configuration steps to have the weather station running properly. To do this, edit the configuration file stored on your Raspberry Pi at the following location :


/home/pi/Hackeet/applications/LEGOWeatherStation/server_configuration.json

This file is the following one :

{
"documentation": { "version":"1.0.0", "title":"Title of your web service here", "description":"Description of the web service here", "license":"Link to the web service license file" }, "server": { "server_name":"MyWebApp", "root":".", "bot_file":"application.lego.raspberry.weatherstation.server.bot", "index":"/themes/default/index.html", "login":"/themes/default/login.html", "http_port":8100, "auth":"Auth", "application_directory":"/home/pi/Hackeet/", "pages":{} }, "settings": { "CategoriesFile" : "/home/pi/Hackeet/applications/LEGOWeatherStation/data/categories.json", "City" : "Paris", "Country" : "FR", "Key" : "your_OpenWeatherMap_Key", "RefreshPeriodMinutes" : 5, "ResetPeriodSec" : 20, "ForecastDurationHours" : 0.5, "NumberOfPositions" :4, "StartPosition":0, "StepsByRevolution":2048, "ComPort":"COM4", "Pin1":37, "Pin2":38, "Pin3":35, "Pin4":36, "StatusPin" : 40, "Frequency":450, "SnipsInstance" : "127.0.0.1", "Demo" : 0, "DebugFile" : 0 }, "interface": { "screens":[] } }

Edit the Key parameter to set your actual OpenWeatherMap key.
Edit the StepsByRevolution parameter to set the number of steps by revolution for your stepper motor. By default, we consider that there are 2048 steps by revolution.

Set the Frequency parameter to specify the frequency (in Hertz) at which the motor will operate (typically between 200 and 500). If you set a value that is too high, your engine may miss events and may not work properly.

Finally, specify a location for which the weather station will default to the upcoming weather by setting the City and Country parameters.

Step 10: Start the Application

First, before starting the application, manually adjust the carousel to display the "sunny" LEGO character, which is the default start position.


There are several ways to start the application:

  • by double-cliking on the desktop icon,
  • by using a terminal window and typing the following command: /home/pi/Hackeet/applications/LEGOWeatherStation/bin/hackeet.lego.weather.station.sh

You can also use the crontab to start the application automatically each time the Raspberry Pi boots. If you choose this method, you may find the tool Cron Gui very useful.

At startup, the carousel rotates to show the upcoming weather for the default location specified in your configuration file. Once done, the weather station is now ready to process queries. Try out your weather station, starting with the wake word, followed by a query. For instance:

Hey Snips, what is the weather in Paris, France

The carousel then rotates to display the forecast for the requested location and, after a short time, returns to the position of the forecast for the default location.

Step 11: Troubleshooting

To date, it may occur situations where you may need to stop the application using the kill command. To identify the processes attached to the application, execute the command :

ps aux | grep hackeet

Step 12: Under the Hood

A few last words on programming with Hackeet. As mentioned earlier, Hackeet aims to partially replace traditional hand coding with a visual programming approach. So, instead of having the traditional C ++, Javascript or Java code, the entire application we developed for our weather station is just the diagram above.

We will not go into details on how to program with Hackeet. If you would like more information on this topic, we recommend you visit our website for documents and tutorials. You can also check out our previous project that describes the basics of programing with Hackeet.

The Hackeet schema of the application has been installed on your Raspberry Pi at the same time as the application itself. If you want to edit it in order to study it or to hack it, start Hackeet and open the following file:

/home/pi/Hackeet/applications/LEGOWeatherStation/design/raspberry/application.lego.raspberry.weatherstation.server.design