VizIoT

by EmbeddedIoT in Circuits > LEDs

1001 Views, 3 Favorites, 0 Comments

VizIoT

pic1.png

This project is very similar to a previous one I published (www.instructables.com/id/Connected-Mug), indeed it is based on the same Hardware components: LED strip lights and Arduino MKR1000.

As in the previous project, I like to visualize with changing LED lights some information from the web that is meaningful for me: temperature forecast for a given location, or stock price variation. In order to give an idea on how to exploit this prototype, I attached the lights to an old wall clock, so that just by looking at the clock I can figure out if I'm earning billions of dollars with my rising stocks.....

In this case the Arduino board controls LED lights in real time based on weather forecasts for a given location or based on variations in stock price; the information is retrieved by Arduino directly from the web by accessing YahooWeather and YahooFinance using code snippets generated by Temboo (temboo.com). I used Microsoft Azure IoT services In order to remotely control and configure the Arduino board (i.e. switch from YahooWeather to YahooFinance, and to select City name or stock name).

Hardware Components

20170102_133730_.jpg
friz.png

The hardware components and wiring are the same of the Connected-Mug instructable.

Hardware development board :

  • Arduino MKR1000

Hardware BOM :

  • 3x 100ohm resistors
  • 3x TIP122 NPN transistors
  • 1x power jack
  • 1x RGB LED Light Strip (AglaiaLT-S2)
  • Spare cables

The wiring to control LED strip with Arduino MKR1000 is based on this tutorial: https://www.instructables.com/id/ARDUINO-CONTROLLE...

Register an Account in Temboo and Generate App Key

Temboo2.png

Temboo is an IoT platform which offers solutions to build professional IoT applications; check www.temboo.com to learn more.

Among the free services offered by Temboo, there is the possibility to generate code snippets, called "Choreos" for several embedded platforms, included Arduino. "Choreos" can be used to connects hundreds of web services, like Yahoo, Google, Twilio etc. See more here : www.temboo.com/library

In this project, Temboo "Choreos" are used to generate the Arduino code necessary to retrieve weather forecasts and stock price variations from YahooWeather and YahooFinance respectively.

Temboo Choreos have been integrated in the Arduino sketch available in step 4; their usage requires to register a personal (free) trial account in Temboo and to generate a personal app key. In order to generate API key register an account in Temboo (https://temboo.com); from Temboo dashboard check your Application credentials as shown in the picture. Take note of credentials, you will have to copy and paste them in Arduino sketch as described in step 4.

Create an Account in Microsoft Azure and Register Your Device

For this project I wanted to add the possibility to remotely configure the board, in order to select at run time the city or stock name without having to recompile the code. There are several ways to do this, I decided not to add another connectivity (i.e. Bluetooth) and control Arduino remotely using WiFi.

Since I was working with Microsoft Azure IoT (https://github.com/Azure/azure-iot-sdks) for another project, and since libraries to connect Arduino with Azure IoT are already available, I decided to rely on these services to control the board from my laptop. The usage of Azure IoT requires to create a free trial account and to do some setup on your Azure account once created, in order to activate IoT services; if you are planning to work on IoT projects it is worth to spend some time on this and to check the information below; however, as described in next section, for this project you can also decide to skip the usage of Azure IoT services and hard code directly the configuration you want to test (thus recompiling the code each you want to change something in the configuration).

In order to use Azure IoT to control the Arduino board you have to :

  1. Register for a trial account in Microsoft Azure (https://azure.microsoft.com).
  2. Create an instance of IoT Hub, following instructions available here.
  3. Register your Arduino board to IoT Hub and generate the correspondent connection string by using DeviceExplorer tool provided by Microsoft (see instructions here).
  4. Once registered the Arduino board, take note of the connection string ; you have to paste it in the Arduino sketch as described in step 4.

Download and Configure Arduino Sketch

Attached the Arduino sketch. In order to connect with Microsoft Azure, Azure IoT C client library need to be included in the sketch; an older version of this library (AzureIoT, v0.1.0) was used in this project.

Configure the Arduino code with your credentials for Temboo and Azure IoT as described below.

Paste your Temboo credentials in file TembooAccount.h:

#define TEMBOO_ACCOUNT "embeddediot" // Your Temboo account name

#define TEMBOO_APP_KEY_NAME "myFirstApp" // Your Temboo app key name

#define TEMBOO_APP_KEY "vtxxxxxxx" // Your Temboo app key

Paste the connection string in file iothub_client_sample_http.c

static const char* connectionString = "HostName=xxx;DeviceId=xxx;SharedAccessKey=xxx";

In you don't want to use these services, leave NULL the connectionString variable, and type in directly in viziot_github.c the values for the selected mode (see step 5 and check working modes available in file data_types.h)

int app_mode_fixed = mkr_weather;

char modeArgsStatic[] = "STOCKS AAPL\n";

Edit SSID and Password for your WiFi Access Point in file viziot_github.c

char ssid[] = "xxxx"; // WiFi SSID name

char pass[] = "xxxx"; // WiFi SSID password


Compile Arduino sketch and flash the MKR1000 board

Downloads

Usage and Configuration of the Arduino Application

deviceExplorer.png

If you have created an account in Azure and generated a connection string for your Arduino board, you can control the board run time using a PC application (DeviceExplorer). If you don't want to use Azure IoT, you can skip this step.

  1. Once powered the Arduino board, the application connects to your configured Wi-Fi Access Point and later with the Azure IoTHub in your Azure account. LED lights are turned white once connection with Azure IoT is established.
  2. The application waits to receive commands via Microsoft Azure IoT
  3. Use Microsoft DeviceExplorer tool to monitor the status of your application and to change working mode (see here to learn how to use DeviceExplorer)
  4. In Data tab of your DeviceExplorer you can visualize messages sent from your Arduino MKR1000. In Message To Device tab you can type and send commands to Arduino MKR1000 in order to change the working mode of the application (see picture)
  5. The following commands sent to MKR1000 via Azure IoT are recognized by the application and can be used to configure the board:

"TEMP city_name", retrieve temperature for a given city name and change LED lights (from blue to red)

"STOCKS stock_name", retrieve stock price variation for a given stock name and change LED lights(green/red)

"TEST" --> test light colors

"QUIT" --> stop application

Use the VizIoT Project to Retrofit a Wall Clock

VizIoT

VizIoT can be used in interior design lighting projects or to retrofit existing devices. For example the video shows how I used it to retrofit a wall clock.