Today I will show you how Internet of Things can be used to visualize important information in a new way. This is something I did for an airline company and it uses their ticket sales during the day to change the color of a flower.
The company has a digital dashboard web page with their important business intelligence information, and the information is updated throughout the day. They wanted to show the most important information, the ticket sales, in a more visual way. I thought it would be nice if a flower in the office would change color depending on the sales. In the morning the flower is red, and as the budget is met it changes to yellow and finally green.
Here you can see the needed hardware for this lab, and in addition to the Arduino, the important component is an RGB LED (I used one with a common cathode). To connect everything, you need a breadboard, three resistors, and four jumper cables that have a (male) pin on each end. You will probably be fine with 220 ohm resistors, but for perfect color you should check the specification of the LED to be sure (in my case, the drop was 2 volts over the red pin and 3.1 volts over the other pins, so according to Ohms law I used a 180 ohm resistor for the red pin and two 100 ohm resistors for the other pins).
To setup the hardware, you start by disconnecting everything from its power source, and then connect the GND on the Arduino to the second (longest) pin of the LED. Then connect Arduino pin 11 to the first (red) LED pin, Arduino pin 10 to the third (green) LED pin, and Arduino pin 9 to the fourth (blue) LED pin.
On the server side, a small script gets the current sales, compare it to the budget, and depending on the result, it returns a color. I cannot share the script, but the following simple omnichannel service code will work for this lab…
<?php echo "ff0000"; ?>
…and as you can see it simply returns a color code. This service can be deployed to a cloud server, with the name color.php, and I showed how to do that in my previous video named “Omnichannel Services – First Service”.
Here is the Arduino code (sketch)…
const int redPin = 11;
const int greenPin = 10;
const int bluePin = 9;
char hex = "00\0";
serverData = String();
char c = httpClient.read();
serverData += c;
serverData.substring(0, 2).toCharArray(hex, 3);
analogWrite(redPin, strtoul(hex, NULL, 16));
serverData.substring(2, 4).toCharArray(hex, 3);
analogWrite(greenPin, strtoul(hex, NULL, 16));
serverData.substring(4, 6).toCharArray(hex, 3);
analogWrite(bluePin, strtoul(hex, NULL, 16));
…and after the initial include, the variables are defined (on lines 3-8). The setup initialize the bridge (on line 12), which allows communication between the microcontroller (32U4) and the microprocessor (AR9331, with Linux). Then the three pins are set to output mode (on lines 13-15). The eternal loop starts by retrieving the color value from the omnichannel service (on lines 20-26), and then each pin is set to the corresponding value of each color (on lines 27-32). Finally, there is delay of five seconds (on line 33) before the loop start over again.
Here are some photos of the flower as it changes color. To make the light a bit stronger, there is no problem in using two RGB LEDs, and the easiest way would be to connect them in parallel, which means that you would connect the second LED pins to the first (i.e. red to red, GND to GND, green to green, and blue to blue).
So there you have a real-world example of how Internet of Things can be used to show important information in a new way.