Skip navigation
2015

graphic.PNGThe Internet of Holiday Lights RoadTest+ is running from December 8th to January 23rd 2015

Previous Activity:

Blog Summary #000 : Internet of Holiday Lights RoadTest Plus 2014

Blog Summary #001 : Internet of Holiday Lights RoadTest Plus 2014

Blog Summary #002 : Internet of Holiday Lights RoadTest Plus 2014

NameSuper Awesome Blog Time
Viorel M. AlexeNo Updates
Stephen Baird

IoT Christmas Ornaments - The Software, Part 1

IoT Christmas Ornaments - The Wrapup

The Internet of Holiday Lights RoadTest Plus - Review

Jan Cumps

Compare the Infineon RGB libraries that spawned from the Internet of Holiday Lights

Internet of Holiday Lights: Road Test Plus review

[Christmas Wreath of Things] Internet of Holiday Lights - Bonus kicker: the IoT talks (a spoken tribute to Science Fair kits)

Massimiliano Dibitonto

Social Xmas Tree 2

Jack Franklin

Internet of Holiday Lights - Houston, we have a problem

Internet of Holiday Lights - Mr Oakes to the rescue!

Matteo Furlan

Publish data with MQTT - The smart entrance - Internet of Holiday Lights RoadTest

Get a working webcam on Arduino Yun - The smart entrance - Internet of Holiday Lights RoadTest

The Internet of HOliday Lights RoadTest Plus - Review

Send email with photo on movement - The smart entrance - Internet of Holiday Lights RoadTest

Gurinder Singh GillNo Updates
Saurabh Gohe

Blog Post #2 : Smartphone Controlled Lighting System - Sending Commands Via Bluetooth,  For Internet of Holiday Lights RoadTest Plus 2014...

Introduction to the Arduino Yun #1

Introduction to the Arduino Yun #2

Blog Post #3 : Smartphone Controlled Lighting System - Sending Commands Via IR Remote  For Internet of Holiday Lights RoadTest Plus 2014...

Smartphone Controlled Lighting System - Sending Commands Via Bluetooth

Blog Post #4 : Smartphone Controlled Lighting System - Sending Commands Via A Web Browser,  For Internet of Holiday Lights RoadTest Plus 2014...

The Internet of Holiday Lights RoadTest Plus - Review

Blog Post #5 : Smartphone Controlled Lighting System - Final Sum-up of My Project,  For Internet of Holiday Lights RoadTest Plus 2014...

Lukas Hornby

No Updates

Jordan Lui

The Internet of Holiday Lights RoadTest Plus - Review

RoadTest Internet of Holiday Lights: Apartment Lighting Extravaganza Post 4

Jordan's Holiday Lights Roadtest entry

Clem Martins

[IoT Christmas Sparkle Ball] The mirror works finally

[IoT Christmas Sparkle Ball] Trying to Connect  Lights

The Internet of Holiday Lights RoadTest Plus - Review

Peter Oakes

BYOB Party #11 - Stars for the tree. From Re-flow to Wow, how to make a tree topper fit for any tree

BYOB Party #12, "Creating a control page to add remote ability for your IoT of Holiday Lights"

BYOB Party #13, "Announcing guest callers from around the world "

BYOB Party #14, "Welcome Texas... Instruments that is"

The Internet of Holiday Lights RoadTest Plus - Review

BYOB Party #15, News year resolution in coding practices. Infineon, UNO the NRF24L01 coding walk through.

BYOB Party #16 - The BIG Event finally arrives

Mohan PalanisamyNo Updates
Aby Raj

No Updates

Inderpreet Singh

[Dynamic Living-room Lights] Building the Mood Lights

[Dynamic Living Room Lights] The XMAS Tree

[Dynamic Living-Room Lights] IoT Holiday Lights Minions

[Dynamic Living-Room Lights] The Big Picture - The Final Build

[Dynamic Living-Room Lights] Paho For Python - Writing better code

[Dynamic Living-Room Lights] The Tree Code explained - Write a protocol with interrupts.

[Dynamic Living-Room Lights] The project Summary and Demo Video

The Internet of Holiday Lights RoadTest Plus - Review

[Dynamic Living-room Lights] Converting a wireless router into a YUN

Francesco Truzzi

[Arduino Light Spots] Client building and coding + 3W RGB LED + Infineon shield!

The Internet of Holiday Lights RoadTest Plus - Review

Eric TsaiNo Updates
Madhuri Vaghasia

My IoT Holiday Lightings...#4: Final Build 1

The Internet of HOliday Lights RoadTest Plus - Review

My IoT Holiday Lighting...#5: Final Build 2

Frederick Vandenbosch

[Christmas Tree] Internet of Holiday Lights - Song-based Lighting

[Christmas Tree] Internet of Holiday Lights - Finished Build

The Internet of Holiday Lights RoadTest Plus - Review

Darcy WalkerNo Updates
Robert WatersNo Updates
kkrampa

Arduino Uno

Posted by kkrampa     Jan 27, 2015

Hi all, I would like to know if it is possible to embed a multimeter  onto any arduino? Or simply is there a way to load functions of a multimeter to an arduino?

Links to Previous Posts

Preface

My project for the Internet of Holiday lights was based around our living room which was not very livable. It was a mess and with the upcoming holidays I wanted to set the living room in such a way that it would be suitable for entertaining guests. Additionally I wanted to accomplish the above mentioned in such a way that the holiday lighting becomes part of the living room and I don't need to remove it after the holidays. Hence the concept of Dynamic Living-room Lighting.

 

In the previous posts, I have review the YUN and the infineon shield and have presented an overview of the project system. I also setup the place for the lighting with some homemade arts and crafts and give a preview of the system setup. I explained the Library I made for the Infineon Shield as well as the implementation for the MoodLights and made them Dynamic. I also made a XMAS Tree with LEDs and some stuff. I connected them to the YUN and made the control for the Xmas Tree Dynamic and static. It is now integrated into the OpenHAB interface and the YUN works as a relay. I have made the minions dance using a DIY approach and connected them to an RPi. I also wrote a python script to get mentions on twitter and play music while controlling the minions. I also showed you the final build but not yet a video. post, I go back to the minions and make them learn MQTT.

 

Aftermath Report

The lights project has been appreciated a lot by guests and I am convinced that some future projects should be designed such that they can be showcased in our now IOT living room. My experiments with the Infineon shield will have to wait until such time when my wife will allow me to take the controller down. Hence I am preparing a IoT bench light around the same concept which can also serve as a notification system.

 

On the other side, I recently purchased a TPL ink WR740N wireless router which has the same atheros chip set as the YUN. I was successful in installing openwrt which is the same Linux district as the YUN. The absence of a memory card slot and io pins are felt but I have found the UART pins and hope to connect an Arduino Nano to it which will add future project prospects. I am currently trying to compile some basic programs for socket clients so that I may extend some functionality over the network and will update once I have something worth showing.

 

The router details

I got this TPL-Link WR740N on an online store for 800INR with version 4.28 on the label. The image below is of the router itself.

15%2B-%2B2

The antenna is non-removable and its a no thrills, no frills router. For the kind of BW I get here, this is no problem for surfing the internet.

 

Getting Linux

The Linux distro in the YUN is the OpenWRT which is available at www.openwrt.org and there is a whole list of routers supported. The current stable version is Barrier Breaker and to download the binary, go to

https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/

There is a long list of binaries which have been compiled according to manufacturer but these are all meant for the atheros ar7xx series based routers. I got the https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-factory.… which is the latest at the time. Next to flash your router with the binary, no fancy tools are needed. Simply login to the router at 192.168.0.1 which is the default address or whatever you set it to be. In the system part, there is an option to update the firmware... so update it with the OpenWRT binary. Let it reboot and connect via the wired ethernet port since the default configuration is for the wlan0 to be down. Login to 192.168.1.1 and customize. Once you set the root password, you can start using SSH to login to the router as well. Below is a screenshot of that...

 

yQBZ1PBL4Ycs616yCCymOclhRYjpr5VqztOOyOvIByQ=w1024-h768-no

More to come

It was quite easy to get here and all it took was the right few steps. I am attempting to solder some serial port headers and will post again once I am good and ready. Hope this helps and if there are any inputs, please feel free to leave a comment at the end.

 

Cheers,

IP

Here is the video I made at the conclusion of the Holiday of Internet Lights RoadTest!

 

Hope you enjoy it!

 

It was a great learning experience that certainly got me hooked on the world of Arduino and I'm looking forward to learning a lot more!

 

 

Preface:

 

     I was not expecting to soldier the headers on the Infineon shield. So I went out to buy a soldier kit. I even got helping hands with magnifying glass. But I realized that with no skills here I was fighting an uphill battle.Also finding the headers was not expected. I did manage to find a bag of them at frys for $2. Also picked up wire at 24 AWG with a stripper/cutter. After using it a while, I decided 18AWG is better since it had more tensile strength. I scavenged an old power supply having both 5V and 12V with a common GND. Since the plug was to something unique, I used the 18AWG wire with a doubled copper core. Here are the results.

 

First attempt:

 

     When I tried the first time using the helping hands, I discovered they held the board fine, but how to get headers in straight? So here is what happened:

 

CAM01986.jpg

     When I realized what happened, it was too late. Now I proceeded to learn to de-soldier. When out and bought a wick and a suction tool. Getting back discovered, suction tool with soldiering iron too hard. Tried the wick next and had some success removing soldier. But not enough to remove the header.

 

Second Attempt

 

     Late one night, I decided when all is quiet I can try again. This time I added a tool to hold iron(last time the stand was too hard to hold hot iron and I burned myself). Maybe better prepared means better results. See what I did now:

 

CAM01987.jpg

 

     Opps! I got so busy I forgot to get right side. Late at night not a good idea. So I conclude I should go to school and have enrolled in an embedded class for MCU's I figure I can find someone to help me work through these issues. Thanks for reading my trials and tribulations on this project. BTW, I will continue to completion even if the contest ends! LOL

 

PS. The sparkle ball got pushed back due to all the other upfront issues. In a later blog I will share how to build the mirror.

 

 

Back to the main blog BYOB Party #1, "Bring you own Bulbs" - The Internet of Holiday Lights

 

 

In the earlier blog about the Infineon I evaluated the demo and created a library to drive the board from that code which worked out quite well, but it was not complete from the IoT of Holiday Lights perspective

 

Radio interface to Mrs YUN was missing along with a few commands already demonstrated in various videos

 

This will provide a quick walk through the current level of the code highlighting a few of the aspects to control the lights attached to the shield

 

infinion LED Controller.pngArduino_Uno_Angle.jpg24L01.jpg

 

first the need to add in all the libraries for the NRF24L01, the Infineon and support libraries

// Bunch of constants in the form of definitions
// 1 = output debug to serial port, 0 = no debug
#define debug 1
/* Include needed Lbraries */
#include <SPI.h>
#include <Wire.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
#include <Infineon.h>
#include <avr/pgmspace.h>
/* End include libraries */

Infineon RGBLEDS = Infineon();

 

The Infinion.h is the library I created from the original demo, then added a couple extra features like a colour lookup and an ability to directly set the colour by name

 

Here is the enum from Infineon.h

typedef enum  {White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Aqua, Teal, Blue, Navy, Fuchsia, Purple} Colours;

 

this allows you to set the colour by a friendly name

 

and in the main Infineon.c file the actual support code for this

void Infineon::SETCOLOUR(uint8_t Colour)
{
  switch(Colour)
  {
  case White: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x800, 0x800, 0x800);break;
  case Silver: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0xC00, 0xC00, 0xC00);break;
  case  Gray: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x800, 0x800, 0x800);break;
  case Black: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0);break;
  case Red: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0xFFF, 0x0, 0x0);break;
  case Maroon: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x800, 0x0, 0x0);break;
  case Yellow: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0xFFF, 0xFFF, 0x0);break;
  case Olive: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x800, 0x800, 0x0);break;
  case Lime: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x0, 0xFFF, 0x0);break;
  case Green: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x0, 0x800, 0x0);break;
  case Aqua: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x0, 0xFFF, 0xFFF);break;
  case Teal: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x0, 0x800, 0x800);break;
  case Blue: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0xFFF);break;
  case Navy: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x800);break;
  case Fuchsia: I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0xFFF, 0x0, 0xFFF);break;
  case Purple:I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, 0x800, 0x0, 0x800);break;
  default: break;
  }

 

As you can see this is easy to extend and adjust the colours to get them right, currently some are a bit off when using an LED 12V string as the output., this function can probably be optimized if needed but for now it is easy to follow and update

 

Back to the main code, skipping the parts related to the radio as there described in the other blog entries

now we come to the variables and enums related to the mode of operation and timing control

enum modes {cSOLID, cFLASH, cRAINBOW};
modes colourMode = cSOLID ; // mode 0 = static, 1 = flash, 2 = rainbow
boolean isBright = true;
int flashTime = 500; // 500mS
int nextFlash ;

//enumeration to make accessing the command strings easier
enum {hello, SETCOLOUR, RED, GREEN, BLUE, WHITE, FLASH, RAINBOW,
      OFF  };
//Command Strings
PROGMEM const char helloCmd[]     = "Hello";
PROGMEM const char SETCOLOURCmd[]    = "SETCOLOUR";
PROGMEM const char REDCmd[]      = "RED";
PROGMEM const char GREENCmd[]    = "GREEN";
PROGMEM const char BLUECmd[]     = "BLUE";
PROGMEM const char WHITECmd[]    = "WHITE";
PROGMEM const char FLASHCmd[]    = "FLASH";
PROGMEM const char RAINBOWCmd[]  = "RAINBOW";
PROGMEM const char OFFCmd[]   = "OFF";

 

Rainbow has not yet been implemented but Flash has and is described below, the last few parameters re-use some of my tutorial code from this series Fast Track to Arduino Programming, if you want to know the details, please feel free to go look

suffice to say here that it defines the commands that can be received over the serial port of the NRF radio, the SETColourCmd was demonstrated being used from the WEB Page demo utilizing the colour wheel

 

Skipping down to the setup() loop we see a style of mine that I encourage others to follow. That is to modularize our code right from the start, unless your running out of Flash and really need to get that last byte back, there is no reason not to and you will quickly understand the benefits of seperating the various parts of functionality (Easy of maintenance, Understanding, editing and debugging)

 

void setup()
{
  // initialize serial:
  Serial.begin(57600);
  // do other setup here as needed
  initialiseNRF();


  Wire.begin();
  initialiseInfineon();
  nextFlash = millis();
  // initialise all the digital outputs
}

 

As you can see, the work to initialize the Infineon board and the radio have been abstracted into separate functions and now the setup() function is easy to read and understand without having to know what is happening elsewhere

 

the same thing goes for the main loop

void loop()
{
  // Notice how the main loop is very simple and the functions
  // seperate the logic into easily manageable parts
  if (CheckSerial())
  {
    DoCommand(inputBuffer, "\0");
  }

  if (CheckNRF())   
  {
    DoCommand(NRFrdata, "\0");
    SendNRFTest(); // echo back command
  }

  // Do other stuff
  switch (colourMode)
  {
    case  cFLASH: infinionFLASH() ; break;
    case cRAINBOW: infinionRAINBOW() ;break;
  }
}

for all this code does, there is not a lot in the main loop as it is all extracted into small manageable functions

 

the first to calls (Check Serial and Check NRF basically do the same thing but with very different hardware, one checks the serial port for a message and if found it puts the message into a buffer, returns it to here and then it is passed to the DoCommand() function to be processed

the CheckNRF function call does the exact same thing except it checks the NRF Radio for data

 

lastly if a colour mode command has been sent in, the loop will call a function associated with that command. That is all that is required int he main loop to process commands from multiple sources and manage modes etc. yet with all that, just like the setup() method, it is easy to follow and understand without having to know the details of all the functions it uses

 

that brings me to a tip... Please please name functions something meaningful and the same goes for variables, it makes life so much easier when you go back at a later date to change things or if you share the code

 

Now skipping past the code described in my tutorials we come to the first specific function to use the RGB shield

void infinionSetRGB(char* RGBColour)
{
  //char printbuf[32];
  long number = (long) strtol( RGBColour, NULL, 16);
  long r = number >> 16;
  long g = number >> 8 & 0xFF;
  long b = number & 0xFF;
  RGBLEDS.I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, r << 4, g << 4, b << 4);
  //sprintf(printbuf, "%s - Number: %ld - R: %d, G: %d, B: %d\n", RGBColour, number, r, g, b);
  //Serial.print(printbuf);
}

 

As you can see again, short, simple and easy to follow, this function allows the colour to be set by passing in the RGB value in HEX

 

void infinionSetColour(Colours colour)
{
  colourMode = cSOLID;
  RGBLEDS.I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0FFF);
  RGBLEDS.SETCOLOUR(colour );
}

this function on the other hand takes an enumeration value as input and translates this to the RGB value by calling the library function RGBLEDS.SETCOLOUR(colour), I know there is not much here but you have to agree it make the upper code far easier to understand by wrapping the details into a function

 

void infinionFLASH()
{
  if (millis() >= nextFlash + flashTime)
  {
    if (isBright )
    {
      RGBLEDS.I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0000);
      isBright = false;
    }
    else
    {
      RGBLEDS.I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0FFF);
      isBright = true;
    }
    nextFlash = millis();
  }
}

lastly the above function shows how the Infineon shield built in functionality can be used to to manipulate the LEDs without having to touch the basic colour settings. This function simply flashes the LEDs in what ever colour they happen to be in (Does not change them or care what it is currently set to) and simply varies the dimming level as a separate and independent value on the shield. The micro controller on the shield takes care of the rest, even adding nice graceful transitions from one intensity to the other if the board has been configured with a FADERATE property.

 

Thats pretty much it for the code walk through, I hope this helps you to get to grips with your Infineon card and remember, keep your code tidy if you can and modularize often, you will thank yourself later

This post is one my last on the Internet of Holiday Lights RoadTest. It has been quite the journey for me! When I started I barely knew what Arduino was and now I hope I have someone improved on that understanding. First off, thank you so much to the patience and generosity of peteroakes for helping to guide me through many concepts that were completely alien to me.

 

Please check out my RoadTest Review as well!

 

My progress through the IOT RoadTest was an interesting one. As a new beginner to the Arduino platform, I had to quickly learn some of the basics so that I could hit the ground running. I got a handful of components from Peter to get me started and also bought this lovely 60 pixel RGB LED light strip which I have been in love with since it arrived. After running the basic sketches to blink the pin 13 LED light, I then was able to go ahead and power the light strip after learning how to configure the Adafruit NeoPixel library. The result was a very rewarding mixture of brilliant, rich coloured light. What I didn't realize until much later is that I was actually improperly grounding the data line so the signal noise was adding extra rainbow to my display!

IMG_2488.jpg

It was easy to get addicted to Arduino after seeing pretty lights like this. I was hooked!

 

From that point on is where I started to hit my road blocks and adventures.

 

Serial Display screen

One of my biggest points of confusion came from trying to learn how to use a serial display screen. My main experience so far had been interacting with the NeoPixel strip so I was spoiled by the single data pin control style. Learning how to use the serial controlled 16x4 display meant that I had to learn how to hookup several more pins! I was initially daunted by the sheer number of pins and the fact that I had to go buy new hardware (potentiometer) but I eventually hooked up everything as follows. and figured I had stumbled upon the bable fish: All my text was coming out in Greek, Japanese, or simply gibberish.

 

IMAG0497.jpg

Greek characters appearing during a "Hello World" sketch

IMAG0504.jpg

I did not realize that I was programming in Japanese!

 

Remove%2BDB7.png

Trying to analyze the strange characters

 

I was going pretty crazy as I tried to analyze why the display was outputting Japanese characters. I began to figure that maybe one of the pins was consistently stuck in either a 0 or a 1 position, due to the fact that the strange characters often showed up in an array as seen above. What didn't make sense however, is that simply "Hello World" scripts were causing moving text all over this display.

 

I eventually gave up on trying to make this screen work. I encountered other issues with a seven segment display and also an older I2C controlled serial display. I realized that the display screen was truly secondary to my project and moved on.

 

Passive IR (PIR)

As the deadline was quickly approaching, I realized that the key to my project was accepting inputs from the environment and triggering changes in the lighting sequences. So I went with the simplest approach that I thought I could do with my crucial, remaining hours. I used a PIR sensor and a basic script to ensure that I was able to properly harness this little guy, and then tested the PIR with a single LED light:


IMG_2500.jpg

The PIR is working! The next step after shiny-flash lights was learning how to make this thing accept input from sensors

 

After getting the PIR to work, I got help from peteroakes and leveraged a darling little Arduino sketch which cycles LED sequences. He showed me the intricacies of the code and it is quite glorious: It is built to accept string commands that are then checked against an array of possible commands and then executed. While my application was much simpler (for this time at least!), I was able to run a simpler version that gives me the result below!

 

IMG_2520.jpg

My final product is an odd little Christmas tree with a lot of light power! The presents under the tree are the Yun and Infineon boards which I'll be learning more about into the future!

 

Thanks for reading! I've learned a lot in the process and look forward to learning more!

 

Links to Previous Posts

 

Preface

 

My project for the Internet of Holoday lights was based around our living room which was not very livable. It was a mess and with the upcoming holidays I wanted to set the living room in such a

way that it would be suitable for entertaining guests. Additionally I wanted to accomplish the above mentioned in such a way that the holiday lighting becomes part of the living room and I don't need to remove it after the holidays. Hence the concept of Dynamic Living-room Lighting.

 

In this post, I do a summary of the concept, the final result and problems faced and lessons learned. Lets go.

 

The concept

 

The original concept of the project came from the fact that we have a very disorganized living room. Element14, Infineon and MCM Electronics sponsored some parts and I wanted to make them the hero of this project. Additionally iot.Eclipse.org provided some pretty nifty tools to work from. I started by drafting an idea around the Infineon RGB LED Shield and the fact that the YUN has the capability to connect to a Wi-Fi Network. Being an Electrical Engineer I am not an expert on software development and GUIs and hence I took to something that I understand which is OpenHAB. The design was drafted and the first few blogs were published around a focused plan. The target was not only to build the electronics but to demonstrate how practically the things fit into real life. And thus I began one module at a time.

 

The Implementation

 

Hence I began working with the YUN and the Infineon RGB LED Shield and in the process I did a review and to make life easier, I wrote a library for the shield. In order to control the YUN, I used kartben sir's original code and added my own twist to it so that it can received the data in a predefined format. I added some basic Low Pass Filter and connected the audio to the system and made the lights dance to the music. The lights were meant for the living room and hence me and my wife moved to make the Living Room more usable. A DIY frame later, the LEDs were up above the curtains and I hooked them up for the final build.  For the interface, I used OpenHAB to make things pretty for the user. The code is similar to Javascript without the HTML to present it and presented it to the world.

 

With the Lights functional, I moved on to create the tree which used up another arduino and the communication was established over a wire. I used RGB LEDs that can be chained together and 120 LEDs on the tree make for some pretty bright lights. I wrote the code for the Tree which I explained in my last blog and the whole thing lit up like... christmas! The tree can light up according to music or a fixed color by Software or in predefined patterns.

 

The lights and sound needed some dance. My wife and I made minions(pun intended) and I used some element14 boxes to make a crank-piston arrangement and added a motor. This made the minions dance and I wrote a blog post about it so that anyone can make it at home. Moving on, I added a raspberry Pi to the mix since my YUN was busy behind the curtains(literally). A python script later, I was able to read tweets mentions and hashtags and I used it to trigger a minion Dance whenever someone mentioned @ip_v1 on twitter with #happynewyear or #HappyChristmas. It is so much fun and there is a blog post about that as well. I also added a little MQTT to it so that I could control the minions using OpenHAB and now they sing and dance on queue.

 

The final build was completed, cleaned and documented. A fireplace was fabriacated out of styrofoam and a wooden shelf was converted into a snowy scene for the minions to stand. The shelf lights are controlled via IR Control and added ambiance to the shelf. The completed system is demonstrated in a 10minute video below.

 

For more images about the build, please visit, [Dynamic Living-Room Lights] The Big Picture - The Final Build for the graphic details.

 

The Demonstration

 

I made the video with the help of my wife and it was the first time I actually edited a video which made it a long learning process. The end result is given below.

 

Lessons learned and future work

 

I deviated from my normal 'humongous designs that spread everywhere' to a smaller more focused design this time. I experimented with the arduino YUN, python and PAHO, I reused my knowledge of OpenHAB and made the best use of Cardboard boxes from Element14 that I could and the end result was a much more presentable system than I had imagined. I plan to expand the Infineon Shield capabilities to use DMX for audio in the future and in doing so I will be able to relieve the YUN from driving the LEDS. Additionally, I need to buy better LEDs since the ones I have are not very bright even though they get the job done. IF I get my hands on a 3D printer, the first thing I need to do is make a better mechanical arrangement for the minions because the cardboard and styrofoam arrangement tends to wear out with time.

 

Conclusion

 

It was fun. I had planned on finishing the project before the holidays but I ended up doing a lot more tweaking and the final system is something that will stay in the living room as a permanent resident. The tree will also be a permanent resident as well and everytime someone asks why, we can demonstrate the system and christmas will never actually be over. I have tried to put up as much detail as possible and hope that next year someone will take a piece of this project to their living room and sends me a tweet and makes the minions sing and dance.

 

Thank you,

Inderpreet Singh

Link to previous posts

 

Preface

 

My project for the Internet of Holoday lights was based around our living room which was not very livable. It was a mess and with the upcoming holidays I wanted to set the living room in such a way that it would be suitable for entertaining guests. Additionally I wanted to accomplish the above mentioned in such a way that the holiday lighting becomes part of the living room and I don't need to remove it after the holidays. Hence the concept of Dynamic Living-room Lighting.

 

In the previous posts, I have review the YUN and the infineon shield and have presented an overview of the project system. I also setup the place for the lighting with some homemade arts and crafts and give a preview of the system setup. I explained the Library I made for the Infineon Shield as well as the implementation for the MoodLights and made them Dynamic. I also made a XMAS Tree with LEDs and some stuff. I connected them to the YUN and made the control for the Xmas Tree Dynamic and static. It is now integrated into the OpenHAB interface and the YUN works as a relay. I have made the minions dance using a DIY approach and connected them to an RPi. I also wrote a python script to get mentions on twitter and play music while controlling the minions. I also showed you the final build but not yet a video. post, I go back to the minions and make them learn MQTT.

 

In this post while I wait for my video to upload, I explain the code for the tree

 

The problem

 

The basic issue that I was facing is the ability to connect two pieces of my project which is the YUN and the Tree together. I initially though of using a wireless route but in the end, since I needed to send a direct audio line to the tree anyways, hence I chose to use the wired approach and an old school way of doing things on it. There are a couple of methods of doing what I am doing like libraries and stuff and any suggestions are welcome.

 

The Approach

 

My approach was to build in two steps.

Step 1. Build the communication

Step 2. Build the activity functions around the communication.

I will briefly explain the code for both in the next few sections.

 

The communications code

I built the communications part on top of the serial interface of the arduino. I generally use the interrupts system in any microcontroller since it makes sure I 'don't wanna miss a thinngg'(-Aerosmith). Sorry about that pun.

Anyways I start with the example code on the arduino and I use the Serial Event example

 

String inputString = "";        // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete







void setup() {
  // initialize serial:
  Serial.begin(9600);
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}


void loop() {
  // print the string when a newline arrives:
  if (stringComplete) {
    Serial.println(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}


/*
  SerialEvent occurs whenever a new data comes in the
hardware serial RX.  This routine is run between each
time loop() runs, so using delay inside loop can delay
response.  Multiple bytes of data may be available.
*/
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}






Here you can see that there is a function called serialEvent() which executes automatically every time the arduino receives a character. There are two global variables that can be accessed from anywhere in the arduino program where we save the received string and a notification flag that a string was completely received. BUT I don't need that so I start by deleting way the code in the functions and write my own.

 

The serialEvent is supposed to be triggered everytime I get a single byte over the UART and hence the code becomes something like...

 

void serialEvent() {
  while (Serial.available()) {
      // Read a char
      char inChar = (char)Serial.read();
      if(inChar==':'){                        // Start New Frame
          memset(ptr, 0, FRAMESIZE);
          inFrame=true;
          myIndex=0;
      }
      if(inFrame==true  && myIndex<FRAMESIZE){ // Add a byte
            *(ptr+myIndex)=inChar;
            myIndex++;
      }
      if(myIndex==FRAMESIZE){
          inFrame=false;
          if(inChar=='#')
            memcpy(&myFrame, ptr, FRAMESIZE);
      }
  }
}






 

In my code, I have a global flag inFrame which tells me if I am in between frame receives. The reason why I have it as a global and not a static is because I later want to implement a timer and a time out which means that if it takes too long to receive a complete frame then prolly something is wrong and I need to discard the data because something went wrong.

In this code I simply wait for ':' which is my start of frame and then use memset to initialize the space with 0s and set some flags. In the next iteration, the function will be 'inFrame' and hence it will copy the data to the memory. I understand pointers so I just use that instead of the dozen other methods. I also check for my maxFrameSize since my protocol has a fixed frame size. I can use a variable frame size too but maybe some other day.

In the end if the received data matches the frame size, we check for the endofframe which is a '#'. Everything in between can be a ascii character or anthing else but our code does not care about that. The question is what is that pointer pointing to?

 

The protocol

 

I made a structure for my protocol and it's quite simple.

struct sFrame{
    char cStart; // Expect :
    char cMode;  // A-Audio, M-Manual with RGB, P-Pattern
    char cRed;
    char cGreen;
    char cBlue;
    char cEnd;
};

As you can see that there are char type variables for everything. These can be replaced but again not our motive right now. In the global space, I do the following.

 

struct sFrame myFrame, buffer;            // Object to store the frame
char *ptr = (char*)&buffer;      // Point to the object

 

This creates an object without using the heap (malloc) since I will need a fixed size throughout the lifetime of my system. Next I create a pointer to this buffer BUT cast it into a char type. This makes sure when I ptr++, I jump to the next char in my structure. Easy! But how do I use this?

 

The Loop

 

The code for the loop is given below.

 

void loop() {
  // print the string when a newline arrives:


  if(myFrame.cMode=='A'){
      //Serial.println("Audio Mode");
      hue0 = constrain(map(analogRead(channel), 0, 400, 0, 255), 0, 255);  // Read Audio
      uint32_t color0 = Wheel(hue0);
      //Shift the current values.
      for (i = 0; i<NUMPIXELS; i++){
          data_array[i+1] = data_array[i];
      }
      data_array[0] = color0;
      for(i=0; i<NUMPIXELS; i++){
          pixels.setPixelColor(i, data_array[i]);
          pixels.show(); // This sends the updated pixel color to the hardware.
      }
  }else if(myFrame.cMode=='M'){ // Manual mode
        for(i=0; i<NUMPIXELS; i++){
          pixels.setPixelColor(i, pixels.Color(myFrame.cGreen, myFrame.cRed, myFrame.cBlue));
          pixels.show(); // This sends the updated pixel color to the hardware.
      }
  }else if(myFrame.cMode=='P' && myFrame.cRed==0x00){
        rainbowCycle(20);
  }else if(myFrame.cMode=='P' && myFrame.cRed==0x01){
        colorWipe(pixels.Color(240, 0, 0), 200); // Red
        colorWipe(pixels.Color(0, 240, 0), 200); // Green
        colorWipe(pixels.Color(0, 0, 240), 200); // Blue
        colorWipe(pixels.Color(240, 240, 0), 200); // Red
        colorWipe(pixels.Color(0, 240, 240), 200); // Green
        colorWipe(pixels.Color(240, 0, 240), 200); // Blue
  }
}

 

In this example, I use the functions from Adafruit's NeoPixel Library to implement the patterns. When in the loop, I check for the mode settings. If its A then so something and if M then do something and if P then do something else. The serial interrupt takes care of serial communication in the background. Since I have created simple objects for the structure hence I can access the member functions with the . operator. Nothing to it.

 

Conclusion

I wanted to write a short article to explain the working of asynchronous events on a microcontroller and here it is. This is the simplest possible implementation and you can expand it as you like. There is no library code size since there is no library and I hope you got something while reading this. Any suggestions are most welcome and I if you do a project and use any snippet, just say Hi in the comments.

 

 

Thanks,

IP

Gotcha!

 

Massive thank you to Mr Peter Oakes. I'm pretty certain we all owe him a massive thank you for his sportsmanship in this competition. If it wasn't for him i would never have completed this roadtest at all and so I am extremely grateful and honoured.

 

Now, although I did state that my microphone situation wasn't exactly going to plan, I instead took Peter's advice to use my phone(or any other mp3 device) to play music that I would then hook up to the analog input of the arduino. After realising that cutting up a pair if earphones was harder than I thought, I decided that it would be much easier to hook up some wires to an aux cable...and it worked!

 

I then set about using this input to control the led strip. Thankfully I had the Infineon library handy and so cooked up a couple of if else statements to check an average volatage out of every 100.

 

Now in terms of review...

 

I have no real negatives about the arduinos. They've proven to be extremely useful and versatile time and time again, and are extremely resilient so even newbies will find it hard to break them(I found that out after putting 5v through my yun...). However i do have a bone or two to pick with the shield.

 

First of all, what's up with the lack of pins! This may not be such a big problem but the fact that i had to buy my own arduino pins off of ebay set my project back by possibly weeks, and to be honest it will hardly affect the cost of the board itself. I'm not too fussed about them not being soldered on, it can just be a pain to find them.

 

Secondly, as many of you know, there are very little "Hello World" programs out there for this shield(before this roadtest anyways). I would really like to see at least some guidance or simple examples on Infineons website as if it wasn't for the Infineon library this project would have been a lot more complicated for everyone.

 

Thank you for this amazing oppurtunity, and your time, and I will (hopefully) see you all soon!

 

Jack Franklin

Unfortunately, I didn't manage to complete all of the features I had hoped for with my ornaments. Not long after Christmas I caught a flu that knocked me out pretty completely for a surprisingly long time, and when I finally returned to the land of the living I had to play catch-up in my personal and professional life, so my ornaments got pushed to the back burner. Even so, I had high hopes for completing them within the time provided by the contest, but when I jumped into programming the Yun it was just too different from what I had done before and I ran out of time.

 

The ornaments are in a minimally usable state: The physical objects themselves are designed and readily printable, the library I wrote to control the Infineon board works, and the prototype I built does just what it should. The only thing it's missing is the IoT half of the project, so unfortunately you can't remote control the colors, and they don't yet act as notification devices.

 

I still intend to complete them, because it's still a neat project, but unfortunately I won't be able to do so within the timeline set for the contest. C'est la vie.

 

Building the Ornament

 

Step one, naturally, is to print the parts. Attached to this post you will find the three files you need: ornament mk2 - outer top.stl and ornament mk2 - outer bottom.stl will produce the outer shell of the ornament, while ornament mk2 - inner.stl will produce half of the inner support structure for the strip lights (you'll need to print two copies of this one). I've also included the source file that creates these STLs, ornament mk2.scad, and if you're so inclined (and are familiar with openscad) you can make modifications to the design.

 

Once you have them printed, you'll notice both the inner and outer shells have five holes in them. These are sized so pieces of 1.75mm filament will fit into them and can be used to anchor the halves together (or simply to align them if you plan to add additional glue). Depending on your printer's first layer calibration you may need to help the holes out with a quick bit of trimming or drilling, but don't expand them too much as you want lots of friction to hold the filament bits in place.

 

inner halves with filament.jpg

After you have the two inner pieces printed and assembled, you'll want to attach the LED strips. The design is sized for the commonly available 5050 LED strip lights, although I believe most LED strip lights are fairly uniform in terms of strip size, it's just LED size that changes. But you may find that assumption to be incorrect. If it does turn out to be wrong, you've got the source file and can easily modify the channel widths to fit.

 

I found that hot glue works well for attaching the strips to the plastic. Once they're tacked down (careful to avoid the solder pads on either end!) it's time to wire. You want to connect the strips in series, and you want to connect each solder pad to the identical pad on the next strip (i.e. 12v to 12v, red to red, green to green, etc). You also want to make sure both you leave two LED strips with unconnected top pads when you're finished linking all of your strips, because this is where the input and output connections will go.

 

I chose one strip to be "strip one", then connected the bottom of that strip to the top of "strip two". I did the same for strip two and strip three, as well as strip three and strip four. I then connected the bottom of strip four to the bottom of strip five. This left the top of strip one and strip five open so I could have the input and output connections coming out on the same side. Luckily for us, these LED strips are non-polar, so you don't need to worry about orientation or getting the right sides together at all.

 

wired up sm.jpg

In the above picture, you can see the strips attached and wired together, with the input connection already in place. I made a bit of a mistake in that I soldered the input wire in place before threading it through the hole in the outer shroud. The hole in the shroud is easily big enough to allow both sets of wires to pass, but the connectors won't fit. So make sure you don't do what I did, and thread your wires through the outer shell first.

 

Once everything is wired together, start on your next one! Using the "4pin male to female extension wire" for LED strips, which you can easily find on Amazon, you can link together as many ornaments as you need. A single 5m roll of LED strips should make ten separate ornaments, and a single Infineon shield can easily power them all simultaneously.

 

When all the ornaments are assembled and connected, wire the first one back into the Infineon board, and upload the Arduino sketch and library found in this post: IoT Christmas Ornaments - The Software, Part 1

 

The linked post explains how to change the code to make it do what you'd like and, for now, that's all you can do. Unless you'd like to finish the incomplete Yun/IoT portion of the project... or you don't mind waiting. Sooner or later I'll get these working correctly, but for now, this is where the project ends.

 

It was a fun time, and interesting components, but in the end life got in the way and slowed things down too much.

Disaster has struck!

 

Over the weekend I received my Adafruit Electret Microphone. I eagerly soldered the included pins onto the board and set about testing it with the arduino's analog inputs. However, there seems to be no actual output. I looked on adafruit's website and found their example code but I was still unsuccessful:

 

serial output.png

As you can see from the image, the output is always constant. I've tried making sounds near the microphone, an arms length away and even tapped the damn thing and still nothing!

 

This unfortunately means that it is highly unlikely that my project, or at least desired plan, will be finished by the deadline. I will still try to make some form of useful project, by creating an app on my phone, but without any working microphone the project simply won't be finished. I apologise severely to all of the community, as I feel I have let you down and wasted the time of some very kind people.

 

On the (slightly) brighter side of things, I will still continue this project after the deadline! I believe that without the pressure of a deadline i will be able to solve my problems with the microphone and finally get this working. I will still produce a review of the components and a final blog on the app.

 

Thank you dearly for all your time,

 

Jack Franklin

 

HERE IS A LIST OF MY PREVIOUS POSTS :

 

Blog Post #1 : Introduction To My Project "Smartphone Controlled Lighting System" For Internet of Holiday Lights RoadTest Plus 2014...

Blog Post #2 : Smartphone Controlled Lighting System - Sending Commands Via Bluetooth,  For Internet of Holiday Lights RoadTest Plus 2014...

Blog Post #3 : Smartphone Controlled Lighting System - Sending Commands Via IR Remote  For Internet of Holiday Lights RoadTest Plus 2014...

Blog Post #4 : Smartphone Controlled Lighting System - Sending Commands Via A Web Browser,  For Internet of Holiday Lights RoadTest Plus 2014...

 

 

Dear All,

              This Road Test was my start up point in the world of IoT, I never worked on any thin IoT before this, I worked and have learned many new things because of this road test, thanks to Element14 for this opportunity.


As I wrote in my application for the road test that " I wanted to work on a Smartphone Lighting System ",  my main aim was do do something related to IoT, but is should also be easy to understand for every one even beginners, I also wanted to do the same task via at least 3 methods so that the anyone can choose and make this thing for themselves, and enjoy electronics.


So here are my three methods.


1). Via IR Remote : This method is the most budget friendly of all my three methods, I wanted to make this because it's light on the pocket, easy to make and easy to use for an entire family, every one knows how to press buttons on a remote. The hardware required is an Arduino, Infineon RGB shield, RGB LED strip, TSOP1738, a IR Remote and power supplies. 

The complete description and codes can be found on my blog Post HERE. 

                                                 

                                                                 

 

2). Via Bluetooth :  Bluetooth was my second choice, because it's easy to use, and ever smartphone Bluetooth, and also because every thing is better with Bluetooth ( According to Dr. Sheldon Cooper ). The hardware required is an Arduino, Infineon RGB shield, RGB LED strip, HC-06 or HC-05 Bluetooth module, A android or Windows smartphone and power supplies. The complete description and codes can be found on my blog Post HERE.

 

 

                                                                 

 

 

3). Via A Web Browser :  My final choice was to make it work with a web browser, as it was my First IoT project I didn't wanted to make it very complicated. It's not that hard to make once you get the hold of it, it's not that simple if it's your first IoT project, But fortunately Arduino has good examples in the " Bridge " library, those examples helped me allot. This method will work for both PCs and Phones/Tablets. I made a special HTML app for this purpose. The hardware required is an Arduino YUN, Infineon RGB shield, RGB LED strip and power supplies. The complete description and codes can be found on my blog Post HERE.

 

                                                                 

 

So these were the three methods I used to accomplish a simple task of changing the colors of a RGB LED strip.

It was a great learning experience for me so thanks again for this opportunity for me, and I got to compete with some of the most talented People and work with awesome hardware i.e. Arduino YUN and Infineon RGB shield. It was my First IoT project so please do forgive if I made any silly mistakes...

Previous posts..

My IoT Holiday Lightings...#1: Introduction

My IoT Holiday Lightings...#2: First prototype

My IoT Holiday Lightings...#3 some more options Added

My IoT Holiday Lightings...#3: Second prototype with Music Controlled lightings and more options..

My IoT Holiday Lightings...#4: Final Build 1

http://www.element14.com/community/roadTestReviews/1936


Dear All,

Here is final Demo video of my IoT Holiday Lightnings Application...


Here is pic of my final demo setup...

1.jpg

Here is schematic of my music control light circuit designed around TLV082 opamp..

DSC02765.JPG

Here are Pics of boards connection...

3.jpg


4.jpg

Here is pic of GUI for PC...

6.jpg

I have attached all codes and Processing GUI Application for this project here... All attachments are Open Source... Feel free to use/modify the contents for your need...


Thanks to element14, arduino, infineon and eclipse for giving me this opportunity...

Looking forward for upcoming road tests and design challenges...

(prev. post is Get a working webcam on Arduino Yun - The smart entrance - Internet of Holiday Lights RoadTest read this to have a working webcam on Arduino Yun)


In this post I will explain how to start a python script or possibly any other program / bash by our Arduino sketch Yun.
In particular, I am going to explain the procedure to have a motion detector (using a HC RS04 ultrasound sensor) that allows to send a photo by email in case it detects a change of distance of at least 2cm in two successive measurements in 'arc of about 60ms.

 

So let's see what are the steps necessary to accomplish this purpose.

 

Get a working python with support to HTTPS/SSL doing in SSH :

opkg update                      #updates the available packages list
opkg install distribute          #it contains the easy_install command line tool
opkg install python-openssl      #adds ssl support to python


 

I have positioned the sendemail.py (download it from attached file) in the /www/cgi-bin with FileZilla. [sendemail.py taken from http://dev.mikamai.com/post/76945627390/you-cant-touch-this-an-evil-arduino-based]

The sendmail.py was edited with my email ad login parameters of gmail.

IMPORTANT : go to https://www.google.com/settings/security/lesssecureapps and enable this option to have a working script!!

 

This is the script that I have loaded in my Arduino Yun that send an email when the distance have a delta > 2cm.

#include <Bridge.h>
#include <Wire.h>

//HC RS04 ultrasound sensor
int triggerPort = 4;
int echoPort = 2;

Process p;

void setup() {
    Wire.begin();
    Bridge.begin();
    Serial.begin(115200);

    //ultrasound sensor
    pinMode( triggerPort, OUTPUT );
    pinMode( echoPort, INPUT );

}

void commandGetImage(int n){
  p.runShellCommand("fswebcam --device /dev/video0 --resolution 640x480 --jpeg 95 --save /www/"+String(n)+".jpg --palette MJPEG --no-banner"); //takes the picture
  while(p.running()); //wait till the process ends
}

float getDistance(){
  digitalWrite( triggerPort, LOW );

  //send one impulse of 10microsec on trigger
  digitalWrite( triggerPort, HIGH );
  delayMicroseconds( 10 );
  digitalWrite( triggerPort, LOW );

  float duration = pulseIn( echoPort, HIGH );
  float centimeter = 0.034 * duration / 2;

  if( duration > 58000 ){
    duration=-1;
    centimeter=-1;
  }

  if (centimeter==0){
    Serial.println("ERROR - 0 cm - get again the distance");
    delay(10);
    centimeter=getDistance();
  }

  return centimeter;
}

void loop() {
    float d,prev=getDistance();
    float delta=0;

    while (true){
        delta=0;
        //get the first distance
        prev=getDistance();
        //get the image
        commandGetImage(0);//0.jpg is the image file taken
        //wait 50ms
        delay(50);
        //get the second distance
        d=getDistance();
        //calculate the delta
        delta=abs(d-prev);
        //if the delta is big send email - a movement is recognised!
        if(delta>2){
           Serial.print(" delta= "+String(delta) + "["+String(prev)+"cm,"+String(d)+"cm]");
           Serial.print("\nSENDING...");
          p.runShellCommand("python /www/cgi-bin/sendemail.py /www/" +String(0)+".jpg"); //sends the picture via email
          while(p.running()); //wait till the process ends
          Serial.println("E-MAIL SENDED");
        }else{
          Serial.print(".");
          delay(50);     
        }
    }
}


I finished the mirrors and here is a few pictures showing the early results:

 

CAM01982.jpg

 

 

CAM01983.jpg

 

     I am pleased with the results. I would be using the shield except I cannot soldier the headers on. After a few boo boo's, I have just one chance to get them right!

Wish me luck tonight.

 

Clem

Hello Everyone, This is my forth blog post for the Internet Of Holiday Lighting Road Test, in this post I will explain how did I managed to perform to change the color of RGB led strip with a Web Browser . The setup is really simple it's just the Arduino YUN , the Infineon RGB shield and A RGB Strip.

Below ars pictures of the setup :

WP_20150122_19_54_18_Pro 1.jpg  WP_20150122_19_54_55_Pro.jpg

 

                                                                WP_20150122_19_54_48_Pro.jpg

The Sketch ( Program ) is based upon the "MailboxReadMessage" example in the " Bridge " library, and the demo code for the Infineon RGB shield, The arduino is always ready to receive messages from a local computer in the same Wi-Fi network, and what I did was to read the message and equate it to predefined colors. example : I just had to type "192.168.1.17/mailbox/red"

to turn the red LED on. Below is the full code :

 

#define ADDRESS                    0x15EUL

  #define INTENSITY_RED              0x11U
  #define INTENSITY_GREEN            0x12U
  #define INTENSITY_BLUE     0x13U
  #define INTENSITY_RGB              0x14U
  #define CURRENT_RED                0x21U
  #define CURRENT_GREEN              0x22U
  #define CURRENT_BLUE               0x23U
  #define CURRENT_RGB                0x24U
  #define OFFTIME_RED                0x41U
  #define OFFTIME_GREEN              0x42U
  #define OFFTIME_BLUE     0x43U
  #define WALKTIME                   0x50U
  #define DIMMINGLEVEL               0x60U
  #define FADERATE                   0x61U

  #define READ_INTENSITY_RED         0x81U
  #define READ_INTENSITY_GREEN       0x82U
  #define READ_INTENSITY_BLUE        0x83U
  #define READ_CURRENT_RED           0x84U
  #define READ_CURRENT_GREEN         0x85U
  #define READ_CURRENT_BLUE          0x86U
  #define READ_OFFTIME_RED           0x87U
  #define READ_OFFTIME_GREEN         0x88U
  #define READ_OFFTIME_BLUE          0x89U
  #define READ_WALKTIME              0x8AU
  #define READ_DIMMINGLEVEL          0x8BU
  #define READ_FADERATE              0x8CU



  #define SAVEPARAMETERS             0xA0U

  #define BCCUMODID                  0x50030008U
  #define CHIPID                     0x40010004U
  #define REDINTS                    0x500300A0U // BCCU_CH5
  #define REDINT                     0x500300A4U
  #define BLUEINTS                   0x50030078U
  #define STARTWALK                  0x50030018U

  #include <Wire.h>
  #include <Mailbox.h>



  char string;
  unsigned int c[2] = {0};
  unsigned int d[4] = {0};
  unsigned int on = 0;
  unsigned int message = 0;
  unsigned long redcurr = 0;
  unsigned long greencurr = 0;
  unsigned long bluecurr = 0;
  unsigned long redoff = 0;
  unsigned long greenoff = 0;
  unsigned long blueoff = 0;
  unsigned long redint = 0x00;
  unsigned long greenint = 0x00;
  unsigned long blueint = 0x00;
  unsigned long fadetime = 0x00;
  unsigned long walk = 0x00;
  unsigned long brightness = 1;



void setup() {               


    Serial.begin(9600);
   pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  // Initialize Bridge and Mailbox
  Bridge.begin();
  Mailbox.begin();
  digitalWrite(13, HIGH);
    Wire.begin();
   
    while (on != 1) // Wait for shield to respond, keep setting the values till it does
    {
      I2CWRITE2BYTES (ADDRESS, FADERATE, 0x0000); // Immediate fade
      I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0000); // 0% brightness level
      on = I2CREAD(ADDRESS, READ_DIMMINGLEVEL); // Request for brightness level
      if (message == 1 && on == 0) // If message received and dimming level = 0%, "message" is set in the I2CREAD function
      {
        message = 0;
        on = 1; // break out of loop
      }
    }
   
    // now we will chane the values again and wait till there being red back
    while (redcurr != 0x15 || greencurr != 0x15 || bluecurr != 0x15 || redoff != 0x38 || greenoff != 0x39 || blueoff != 0x38 || brightness != 0)
    {
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0000, 0x000, 0x0000); // Off Light
  // Ensure that parameters are set up correctly. Read back and check. If wrong, write and read again.
        redcurr = I2CREAD (ADDRESS, READ_CURRENT_RED); // Read the red current intensity
  greencurr = I2CREAD (ADDRESS, READ_CURRENT_GREEN); // Read the green current intensity
  bluecurr = I2CREAD (ADDRESS, READ_CURRENT_BLUE); // Read the blue current intensity
  redoff = I2CREAD (ADDRESS, READ_OFFTIME_RED); // Read the off-time of the red channel
  greenoff = I2CREAD (ADDRESS, READ_OFFTIME_GREEN); // Read the off-time of the green channel
  blueoff = I2CREAD (ADDRESS, READ_OFFTIME_BLUE); // Read the off-time of the blue channel
  brightness = I2CREAD (ADDRESS, READ_DIMMINGLEVEL); // Read the dimming level
       
        I2CWRITE2BYTES (ADDRESS, OFFTIME_RED, 0x38); // Set off-time of red channel to 0x38
  I2CWRITE2BYTES (ADDRESS, OFFTIME_GREEN, 0x39); // Set off-time of green channel to 0x39
  I2CWRITE2BYTES (ADDRESS, OFFTIME_BLUE, 0x38); // Set off-time of blue channel to 0x38
  I2CWRITE2BYTES (ADDRESS, CURRENT_RED, 0x15); // Set current intensity of red channel to 0x15
  I2CWRITE2BYTES (ADDRESS, CURRENT_GREEN, 0x15); // Set current intensity of green channel to 0x15
  I2CWRITE2BYTES (ADDRESS, CURRENT_BLUE, 0x15); // Set current intensity of blue channel to 0x15
  I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0000); // LEDs all off as any intensity * 0 will = 0
    }

    delay(100); // OK, so were getting response from the infineon so read back values from slave and print them
    Serial.print("Red Int: ");     redint = I2CREAD (ADDRESS, READ_INTENSITY_RED); // request from shield red colour intensity
    Serial.print("Green Int: ");   greenint = I2CREAD (ADDRESS, READ_INTENSITY_GREEN); // request from shield green colour intensity
    Serial.print("Blue Int: ");    blueint = I2CREAD (ADDRESS, READ_INTENSITY_BLUE); // request from shield blue colour intensity
    Serial.print("Red Curr: ");    redcurr = I2CREAD (ADDRESS, READ_CURRENT_RED); // request from shield peak current reference of red channel
    Serial.print("Green Curr ");   greencurr = I2CREAD (ADDRESS, READ_CURRENT_GREEN); // request from shield peak current reference of green channel
    Serial.print("Blue Curr: ");   bluecurr = I2CREAD (ADDRESS, READ_CURRENT_BLUE); // request from shield peak current reference of blue channel
    Serial.print("Red PWM: ");     redoff = I2CREAD (ADDRESS, READ_OFFTIME_RED); // request from shield off-time of red channel
    Serial.print("Green PWM: ");   greenoff = I2CREAD (ADDRESS, READ_OFFTIME_GREEN); // request from shield off-time of green channel
    Serial.print("Blue PWM: ");    blueoff = I2CREAD (ADDRESS, READ_OFFTIME_BLUE); // request from shield off-time of blue channel
    Serial.print("Walk: ");        walk = I2CREAD (ADDRESS, READ_WALKTIME); // request from shield walk-time
    Serial.print("Brightness: ");  brightness = I2CREAD (ADDRESS, READ_DIMMINGLEVEL); // request from shield brightness level
    Serial.print("FadeTime: ");    fadetime = I2CREAD (ADDRESS, READ_FADERATE); // request from shield fade rate
   
    // now setup for test
   
    I2CWRITE2BYTES (ADDRESS, OFFTIME_RED, 0x38); // Set off-time of red channel to 0x38
    I2CWRITE2BYTES (ADDRESS, OFFTIME_GREEN, 0x39); // Set off-time of green channel to 0x39
    I2CWRITE2BYTES (ADDRESS, OFFTIME_BLUE, 0x38); // Set off-time of blue channel to 0x38
    I2CWRITE6BYTES (ADDRESS, CURRENT_RGB, 0x80, 0x80, 0x80); // Set current of red channel to 0x80 = 780mA
    I2CWRITE2BYTES (ADDRESS, FADERATE, 0x0000); // Fade Rate between intensities --> 0.0s
    I2CWRITE2BYTES (ADDRESS, WALKTIME, 0x0000); // walk time between colors = 0s
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0555, 0x0555, 0x0555); // low level White Light
    I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0FFF); // Maximum dimming level means inensity settings are directly used
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0);
   


}

  // the loop routine runs over and over again forever:
  void loop() {
    String msg;


  // if there is a message in the Mailbox
  if (Mailbox.messageAvailable()){
    // read all the messages present in the queue
    while (Mailbox.messageAvailable())
    {
      Mailbox.readMessage(msg);
    //  Serial.println(msg);
    if (msg=="red"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0); // red
      delay(100); 
      }
      else if (msg=="off"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x000, 0x0, 0x0); // red
      delay(100); 
      }
      else if (msg=="green"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0); // red
      delay(100); 
      }
      else if (msg=="blue"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0fff); // red
      delay(100); 
      }
      else if (msg=="white"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0fff, 0x0fff); // red
      delay(100); 
      }
      else if (msg=="cyan"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0fff); // red
      delay(100); 
      }
      else if (msg=="purple"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0fff); // red
      delay(100);
     }
      else if (msg=="yellow"){
       I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0999, 0x0); // red
      delay(100);
    }
        else if (msg=="orange"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0444, 0x0); // red
      delay(100);
    }
      else if (msg=="aqua"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0888, 0x0fff); // red
      delay(100);
    }
      else if (msg=="pink"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0888); // red
      delay(100);
    }
    else if (msg=="teal"){
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0888); // red
      delay(100);
    }
     
  delay(1000);
    } 
  }
}








// Infineon functions follow
/*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined I2C Commands i.e. INTENSITY_RED, INTENSITY_GREEN, INTENSITY_BLUE
                   unsigned int Data - 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 2 bytes of word to the I2C bus line
  */

  void I2CWRITE2BYTES (int Address, int Command, unsigned int Data)
  {
    unsigned int upperByte, lowerByte; // Separate 4 byte data into 2 byte values
    lowerByte = Data;
    upperByte = Data >> 8;
   
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // Putting address into correct format
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD)); // Start I2C transmission
    Wire.write(byte(lowerSLAD)); // address lower 8 bits of i2c address
    Wire.write(byte(Command)); // write command
    Wire.write(byte(upperByte)); // write data
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);
     
  }
   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined I2C Commands i.e. INTENSITY_RGB, CURRENT_RGB
                   unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree - Three 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 6 bytes of word to the I2C bus line
  */

  void I2CWRITE6BYTES (unsigned int Address, unsigned int Command, unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree) // DataOne: Red, DataTwo: Green, DataThree: Blue
  {
    unsigned int upperByte, lowerByte; // Split each Data parameter into upper and lower 8 bytes because I2C format sends 8 bytes of data each time
    lowerByte = DataOne;
    upperByte = DataOne >> 8;
   
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    lowerByte = DataTwo;
    upperByte = DataTwo >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    lowerByte = DataThree;
    upperByte = DataThree >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);
     
  }

/*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined I2C Commands i.e. DMX16Bit
                   unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree, usigned int DataFour, unsigned int DataFive - Three 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 12 bytes of word to the I2C bus line
  */ 

  void I2CWRITE12BYTES (unsigned int Address, unsigned int Command, unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree, unsigned int DataFour, unsigned int DataFive, unsigned int DataSix) // DataOne: Red, DataTwo: Green, DataThree: Blue
  {
    unsigned int upperByte, lowerByte;
    lowerByte = DataOne;
    upperByte = DataOne >> 8;
   
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command)); // write command
    Wire.write(byte(upperByte)); // write 2 bytes
    Wire.write(byte(lowerByte));
   
    lowerByte = DataTwo;
    upperByte = DataTwo >> 8;
    Wire.write(byte(upperByte)); // write next two bytes
    Wire.write(byte(lowerByte));
   
    lowerByte = DataThree;
    upperByte = DataThree >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataFour;
    upperByte = DataFour >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataFive;
    upperByte = DataFive >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataSix;
    upperByte = DataSix >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);
     
  }

   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined read I2C Commands i.e. READ_INTENSITY_RED, READ_INTENSITY_GREEN, READ_INTENSITY_BLUE
  Parameters (OUT): None
  Return Value: Requested data from Shield will be sent back
  Description: This function will request 2 bytes of word from the shield
  */

  unsigned int I2CREAD (unsigned int Address, unsigned int Command) // Returns data sent by slave
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;
   
    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.endTransmission(false); // false for Repeated Start
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.requestFrom(upperSLAD, 2, true);
    unsigned int data = 0;
   
    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      message = 1;
      c[i] = Wire.read(); // receive a byte as character
      i++;
     
    }
    Wire.endTransmission(true);
   
    data = c[1]; // write data to serial monitor. c[1] is higher byte
    data = (data << 8) | c[0];  // shift left and combine with lower byte
    Serial.print("0x");
    if (data < 0x1000)
        Serial.print("0");
    Serial.println(data, HEX);
    return data;
  }

   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - DIRECTACCESS_READ
  Parameters (OUT): None
  Return Value: Requested data from the Shield will be returned
  Description: This function will request 4 bytes of data from shield.
  */

unsigned long I2CREAD_DIRECTACCESS (unsigned int Address, unsigned int Command, unsigned long registerAddress)
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // sending command + address
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
   
    unsigned int firstByte, secondByte, thirdByte, fourthByte;
    firstByte = registerAddress >> 24; // top byte
    secondByte = registerAddress >> 16;
    thirdByte = registerAddress >> 8;
    fourthByte = registerAddress; // bottom byte

    Wire.write(byte(firstByte));
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));
   
    Wire.endTransmission(false); // false for Repeated Start
   
    Wire.beginTransmission(byte(upperSLAD)); // request for read
    Wire.write(byte(lowerSLAD));
    Wire.requestFrom(upperSLAD, 4, true);
    unsigned long data = 0;
   
    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      d[i] = 0;
      d[i] = Wire.read(); // receive a byte as character
      i++;  
    }


    Wire.endTransmission(true);
   
    data = d[3]; // combining into one variable. Highest byte received first
    data = (data << 8) | d[2];
    data = (data << 8) | d[1];
    data = (data << 8) | d[0];
    Serial.print("0x");
    if (data < 0x10000000)
        Serial.print("0");
    Serial.println(data, HEX);
    return data;
  }
   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined I2C Commands i.e. DIRECTACCESS_OR, DIRECTACCESS_AND, DIRECTACCESS_MOVE
                   unsigned long registerAddress - address of target register
                   unsigned long Data - 32 bits data to be written to register
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 4 bytes of data to specified register
  */
  void I2CWRITE_DIRECTACCESS (unsigned int Address, unsigned int Command, unsigned long registerAddress, unsigned long Data) // For accessing registers directly
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // sending command + address
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
   
    unsigned int firstByte, secondByte, thirdByte, fourthByte; // Send address of register first
    firstByte = registerAddress >> 24; // top byte
    secondByte = registerAddress >> 16;
    thirdByte = registerAddress >> 8;
    fourthByte = registerAddress; // bottom byte

    Wire.write(byte(firstByte));
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));
   
    firstByte = Data >> 24; // top byte
    secondByte = Data >> 16;
    thirdByte = Data >> 8;
    fourthByte = Data; // bottom byte


    Wire.write(byte(firstByte)); // send 4 bytes of data
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));
    Wire.endTransmission(true);
   
  }
   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   unsigned int newAddress - Address the shield should change to
  Parameters (OUT): None
  Return Value: None
  Description: This function will change the I2C address of the slave
  */

  void CHANGEADDRESS (unsigned int Address, unsigned int newAddress)
  { 
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
    
    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(0x70)); // Command to change address
    lowerSLAD = (unsigned int) (newAddress & 0x00FF);
    upperSLAD = newAddress >> 7; // Split address into 2 bytes
    upperSLAD |= 0xF0; // 10 bit addressing: First 5 bits have to be 11110. 
    upperSLAD &= 0xFE;
    Wire.write(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.endTransmission(true);
  }

   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   unsigned int Command - DMXON, DMXOFF
  Parameters (OUT): None
  Return Value: None
  Description: This function will enable or disable DMX512 control on shield
  */

  void I2CDMX (unsigned int Address, unsigned int Command) // Switch off / on the DMX
  {
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // Putting address into correct format
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;
   
    Wire.beginTransmission(byte(upperSLAD)); // Start I2C transmission
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.endTransmission(true);

  }
   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
  Parameters (OUT): None
  Return Value: None
  Description: This function will request the shield to save configurations to flash memory
  */

  void I2CSAVEPARAM (unsigned int Address)
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(SAVEPARAMETERS)); // write SAVEPARAMETERS command
    Wire.endTransmission(false); // false for Repeated Start
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD)); // write to address lower 8 bits of slave address
    Wire.requestFrom(upperSLAD, 2, true);  // send READ request with upper slave address
    unsigned int data = 0;
   
    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      message = 1;
      c[i] = Wire.read(); // receive a byte as character
      i++;
    }
    Wire.endTransmission(true); // STOP condition
   
    data = c[1]; // print the data on serial monitor
    data = (data << 8) | c[0];
    Serial.print("0x");
    if (data < 0x1000)
        Serial.print("0");
    Serial.println(data, HEX);
  
  }

 

 

I also made a HTML web app for this purpose, so that i can have a convenient interface and no need to type the address in the address bar, it ran perfectly on the PC and in the chrome browser on an android device. Here is a screenshot :

                                       


                                                     

                                                 10942279_762408963850398_681303105_n (1).jpg

 

And here is the HTML code (Do change the address of my yun with your yun's address) :

 

 

<!doctype html>
<html>
<head>
<title>arduino LEDcolor</title>
<style type="text/css">
<--body{background-color:#abab00;}-->
h1{color:orange;text-align:center;text-decoration:none;}
h2{font-style:italic;}
p{color:#CC0052;text-indent:25px;font-size:20px;text-align:center}
table{text-align:center;}
#one{height:35px;width:75px;}
</style>
</head>
<body>
<h1> Internet of Holiday Lights !</h1>
<hr>
<p>Press button to select color... </p><br>
<table align="center">
<h3><h3>
<tr>
<td ><a href="http://192.168.1.17/mailbox/red" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value=""style="background-color:#FF0000" id="one"  /></a></td>
<td ><a href="http://192.168.1.17/mailbox/green" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" style="background-color:#00FF00"value="" id="one"/></a></td>
<td><a href="http://192.168.1.17/mailbox/blue" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#0000FF"id="one"/></a></td>
</tr>
<tr>
<td><a href="http://192.168.1.17/mailbox/yellow" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#FFFF00"id="one"/></a></td>
<td><a href="http://192.168.1.17/mailbox/purple" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#FF00FF"id="one"/></a></td>
<td><a href="http://192.168.1.17/mailbox/cyan" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#00FFFF"id="one"/></a></td>
</tr>
<tr>
<td><a href="http://192.168.1.17/mailbox/orange" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#FF3300"id="one"/></a></td>
<td><a href="http://192.168.1.17/mailbox/pink" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#FF0066"id="one"/></a></td>
<td><a href="http://192.168.1.17/mailbox/aqua" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#0099FF"id="one"/></a></td>
<tr>
<td><a href="http://192.168.1.17/mailbox/off" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="OFF" id="one"/></a></td>
<td><a href="http://192.168.1.17/mailbox/teal" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#006600"id="one"/></a></td>
<td><a href="http://192.168.1.17/mailbox/white" onclick="window.open('#','_blank');window.open(this.href,'_self');"><input type="button" value="" style="background-color:#FFFFFF"id="one"/></a></td>
</table>
</tr>
</body>
</html>

 

 

HERE is a demo video it explains more I can write :

 

                                                

 

So this is It, this is how I made the First IoT project of  my life, it was a great learning experience for me, and I got to compete with some of the most talented People and work with awesome hardware i.e. Arduino YUN and Infineon RGB shield. I will not feel bad if I don't get 3D printer, because this learning opportunity was the biggest prize for me, Thanks Element14 and specially doctorcdf for selecting me..

 

Link to previous posts

 

Preface

My project for the Internet of Holoday lights was based around our living room which was not very livable. It was a mess and with the upcoming holidays I wanted to set the living room in such a way that it would be suitable for entertaining guests. Additionally I wanted to accomplish the above mentioned in such a way that the holiday lighting becomes part of the living room and I don't need to remove it after the holidays. Hence the concept of Dynamic Living-room Lighting.

 

In the previous posts, I have review the YUN and the infineon shield and have presented an overview of the project system. I also setup the place for the lighting with some homemade arts and crafts and give a preview of the system setup. I explained the Library I made for the Infineon Shield as well as the implementation for the MoodLights and made them Dynamic. I also made a XMAS Tree with LEDs and some stuff. I connected them to the YUN and made the control for the Xmas Tree Dynamic and static. It is now integrated into the OpenHAB interface and the YUN works as a relay. I have made the minions dance using a DIY approach and connected them to an RPi. I also wrote a python script to get mentions on twitter and play music while controlling the minions. I also showed you the final build but not yet a video.

 

In this post, I go back to the minions and make them learn MQTT.

 

The problem

paho_logo_400.png

The basic issue I had failed to address was the fact that I had used a simple script to read tweets and make the minions giggle. I wanted there to be a way to trigger the minion dance via my web interface which is built on top of OpenHAB. There are a couple of ways to do this like remotely invoking a bash script etc but I thought since its MQTT time, why not? Hence I started looking at Paho for Python and this post turned into a tutorial for implementing MQTT Communication in a simple project. Lets see what we can do.

 

The Design

Now I come from a single threaded microcontroller world where you do just one thing at a time. If you want to do multiple things, you need to write a simple scheduler using a timer and I have done this for ages. Yes there are a lot of ready solutions out there and some lite RTOS as well, but I like to know my code size before the compiler and hence I have written my bits of schedulers(some times in assembly) for over a decade. Python can do a lot of this stuff on it's own so it was time to let google guide me. I needed a destination and my version of a design is shown below.

 

dea717c403e0f18fb7852509e3af1332.jpg

 

Hence its clear that since the MQTT Message can arrive anytime and my minion animation is around 45seconds, I need to get the messages in a separate thread. So how exactly does one do all that?

 

The Implementation

The implementation is simpler and the code in Template form is given below.

In order to install paho on the RPi, I executed the following commands in succession...

 

sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install paho-mqtt

 

 

Alternatively, You can...

wget  https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python get-pip.py
sudo pip install paho-mqtt

 

Alternatively you can build from source and the instructions are given at https://pypi.python.org/pypi/paho-mqtt I use setuptools in windows as well so the first version was the simplest for me.

 

Next the actual script. I wrote a template for future projects and it looks like...

 

#! /usr/bin/python

import paho.mqtt.client as mqtt
import time

#Global Stuff
Flag=0
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))
#Tell python to look at the global variable Flag
global Flag
Flag=1
    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    client.subscribe("/TheTopicIWantToListenTo")

# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
    print(msg.topic+": "+str(msg.payload))

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message

client.connect("iot.eclipse.org", 1883, 60)

#Start Loop
client.loop_start()

try:
     while True:
          if(Flag==1):
               print 'The Flag was set! Woohoo!'
               Flag=0
     print 'Doing Something Here'
     print 'Sleeping again'
     time.sleep(30)
except:
     print 'I made a boo boo'
finally:
     print 'All Clean up Now'
     client.loop_stop()
     # GPIO.cleanup() anyone?

 

The code is self explanatory. The try and except and finally are used to execute cleanup code which is a good practice in my mind. This can be used in your next project and I hope it gives the newbies a better place to start.

 

Conclusion

There are N number of ways to do something and I am still learning. I just wanted to share this little snippet and I hope it is useful. Please feel free to add something to the above if you feel it.

 

Cheers,

IP

Previous posts in this project:

 

 

Introduction

 

OK, this will be the final post for the Internet of Holiday Lights RoadTest Plus. It's been fun, frustrating, collaborative, etc ...

  • Fun, because I really enjoyed working with the Yun. I love Arduinos and the Yun's wireless programming and network connectivity just make it even better!
  • Frustrating, because I didn't get to where I wanted to be, due to unforeseen difficulties with the build.
  • Collaborative, because of the sharing and teaming up for special features.

 

Get ready for some picture overload! (the gallery function would've come in handy )

 

Building the Tree

 

The biggest (and hardest as turned out) part of this project was the build. I wanted to make a Christmas tree with both classic and modern elements.

 

The idea was to hollow a log and stuff the electronics inside. Unfortunately, hollowing the log did not work as planned, and my tools were not suited for this kind of work. I ended up going for an alternative with a plastic cylinder for the base after having wasted too much time on the log.

IMG_5672.JPGIMG_5724.JPGIMG_5725.JPG

The tree itself was easier. Using threaded rods cuts in different lengths, I created a tree structure with branches. The expectation was to have a long LED strip go from branch to branch in a spiral shape. This lead to the next problem with the build: the strip was not rigid enough to keep the spiral shape and would just hang loosely. To solve that issue, I came up with the idea to use some fence wire to which the LED strip would be attached. That worked.

IMG_5727.JPGIMG_5730.JPGDSCN3171.JPG

Finally, all the wires needed to be guided to the base of the tree and hidden as wel as possible. Zip ties came in extremely handy!

The tree is ready! It's not late for Christmas 2014, it's just ready a bit early for Christmas 2015

DSCN3174.JPGDSCN3175.JPGDSCN3176.JPG

Now, where do I store this until Christmas ... ?

 

Conclusion

 

We are now the proud owners of a digital Christmas tree which can be controlled either manually using our smartphone or tablet or automatically depending on the Christmas song that is currently playing.

 

Oh ... I almost forgot. It also tells me when other fellow e14 members' project is online!

 

This was fun building, I hope you had fun reading!

Previous posts in this project:

 

 

Introduction

 

One of the features I wanted to implement in this project, was to have the Christmas tree change colors and animations based on the title of the song that is being played at that moment.

The idea is to stream from an internet radio station, parse the song title and find certain keywords. Depending on the keyword, a combination of colors and animations would be applied.

 

Music

 

The play the music, I'm using the Raspberry Pi on which I'm running openHAB. Using MPD and MPC it is possible to play an internet radio stream and depending on the channel, obtain the title and performer.

 

Installing MPD (Music Player Daemon) and MPC (Music Player Controller) is easy:

pi@HolidayLights ~ $ sudo apt-get install mpd mpc







 

Once it is installed, it is possible to add an internet radio station to the playlist.

pi@HolidayLights ~ $ sudo mpc add http://helsinki.radiostreamlive.com/radiosantaclaus_mp3-high







 

The next thing to do, is to start playing the item in the playlist:

pi@HolidayLights ~ $ sudo mpc play
http://helsinki.radiostreamlive.com/radiosantaclaus_mp3-high
[playing] #1/1   0:00/0:00 (0%)
volume:  0%   repeat: off   random: off   single: off   consume: off







 

Once the item is playing, the status can be queried. This should provide information on the song as well. This specific command will be useful to parse the song title from.

pi@HolidayLights ~ $ sudo mpc status
Radio Santa Claus: Mariah Carey - O Holy Night
[playing] #1/1   0:03/0:00 (0%)
volume:  0%   repeat: off   random: off   single: off   consume: off







 

OK, with this, the music is taken care of, and the song information is available for further processing ... let's do that now!

 

Parsing

 

To process the song title, I'm using a Python script, called from openHAB using the "exec" binding.

 

The script takes care of parsing the song title from the "mpc status" command's output. This is the script:

 

pi@HolidayLights /opt/openhab/addons $ cat /home/pi/xmasradio.py

#!/usr/bin/env python
import subprocess

output = subprocess.check_output("mpc status | grep 'Radio Santa Claus:'", shell=True, stderr=subprocess.STDOUT)
output = output[output.find("-")+2:]

print output






 

Executing the script manually returns the following:

 

pi@HolidayLights ~ $ sudo ./xmasradio.py
All I Want For Christmas Is You

 

To do the same, but from openHAB, an entry is added to the items and the sitemap to call the script and bind to its output.

 

Item:

String xmasSong "Current song [%s]" (All) {exec="<[/home/pi/xmasradio.py:10000:REGEX((.*?))]"}





 

Sitemap:

        Frame label="Song" {
                Text item=xmasSong
        }





 

The result in the openHAB GUI:

Screen Shot 2015-01-21 at 19.40.27.png

 

Checking the openHAB logs, the song titles are properly updated with every new song:


2015-01-21 18:36:25 - xmasSong state updated to Oh Holy Night
2015-01-21 18:36:38 - xmasSong state updated to Oh Holy Night
2015-01-21 18:36:52 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:37:05 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:37:19 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:37:31 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:37:45 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:37:58 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:38:11 - xmasSong state updated to Visit now: radiosantaclaus.com -
2015-01-21 18:38:31 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:38:49 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:39:06 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:39:21 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:39:40 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:40:02 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:40:16 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:40:32 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:40:47 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:41:00 - xmasSong state updated to When My Heart Finds Christmas
2015-01-21 18:41:14 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:41:28 - xmasSong state updated to Visit now: radiosantaclaus.com -
2015-01-21 18:41:42 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:41:55 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:42:10 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:42:23 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:42:37 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:42:53 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:43:07 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:43:20 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:43:35 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:43:48 - xmasSong state updated to All I Want For Christmas (Is My Two Front Teeth)
2015-01-21 18:44:03 - xmasSong state updated to Sleigh Ride
2015-01-21 18:44:17 - xmasSong state updated to Sleigh Ride
2015-01-21 18:44:30 - xmasSong state updated to Sleigh Ride
2015-01-21 18:44:44 - xmasSong state updated to Sleigh Ride
2015-01-21 18:44:57 - xmasSong state updated to Visit now: radiosantaclaus.com -
2015-01-21 18:45:10 - xmasSong state updated to Sleigh Ride
2015-01-21 18:45:23 - xmasSong state updated to Sleigh Ride
2015-01-21 18:45:36 - xmasSong state updated to Sleigh Ride
2015-01-21 18:45:51 - xmasSong state updated to Sleigh Ride
2015-01-21 18:46:02 - xmasSong state updated to Merry Christmas For Everyone
2015-01-21 18:46:15 - xmasSong state updated to Merry Christmas For Everyone
2015-01-21 18:46:29 - xmasSong state updated to Merry Christmas For Everyone
2015-01-21 18:46:40 - xmasSong state updated to Merry Christmas For Everyone
2015-01-21 18:46:55 - xmasSong state updated to Merry Christmas For Everyone





 

Action

 

With the song title parsed, it's time to do something with it and have some pretty colors light up

 

An openHAB rule is in charge of identifying keywords and changing the colors based on those keywords. The rule could look like this, but can be customised at will:

 

rule "Parse Song Title"
when
        Item xmasSong changed
then
        var song = xmasSong.state.toString.trim
        logInfo("FILE", "Song: " + song)


        if(song.contains("radiosantaclaus")) {
                // do nothing, not a song title
                logInfo("FILE", "Match for 'radiosantaclaus', skip")
        } else if(song.contains("Christmas")) {
                logInfo("FILE", "Match for 'Christmas'")
                sendCommand( TreeLightColor, "255,0,0" )
                sendCommand( TopperLightColor, "0,255,20" )
                sendCommand( TopperLightColor2, "0,0,0" )
        } else if(song.contains("Santa")) {
                logInfo("FILE", "Match for 'Santa'")
                sendCommand( TreeLightColor, "255,0,0" )
                sendCommand( TopperLightColor, "255,255,255" )
                sendCommand( TopperLightColor2, "0,0,0" )
        } else if(song.contains("Snow")) {
                logInfo("FILE","Match for 'Snow'")
                sendCommand( TreeLightColor, "255,255,255" )
                sendCommand( TopperLightColor, "255,255,255" )
                sendCommand( TopperLightColor2, "0,0,0" )
        } else {
                logInfo("FILE","No match")
                sendCommand( TreeLightColor, "0,255,0" )
                sendCommand( TopperLightColor, "255,0,0" )
                sendCommand( TopperLightColor2, "0,0,0" )
        }
end




 

I gradually added more keywords and matching colors as songs played and I discovered more song titles.

The song titles are logged, and when there is no match, this is also reported. This allows me to check back later and add keywords for those songs as well.

 

2015-01-21 20:33:02.148 [INFO ] [org.openhab.model.script.FILE ] - Song: Silent Night
2015-01-21 20:33:03.653 [INFO ] [org.openhab.model.script.FILE ] - Match for 'Night'
2015-01-21 20:34:15.824 [INFO ] [org.openhab.model.script.FILE ] - Song: Visit now: radiosantaclaus.com -
2015-01-21 20:34:16.206 [INFO ] [org.openhab.model.script.FILE ] - Match for 'radiosantaclaus', skip
2015-01-21 20:34:40.592 [INFO ] [org.openhab.model.script.FILE ] - Song: Silent Night
2015-01-21 20:34:40.780 [INFO ] [org.openhab.model.script.FILE ] - Match for 'Night'
2015-01-21 20:36:44.820 [INFO ] [org.openhab.model.script.FILE ] - Song: Frosty The Snowman
2015-01-21 20:36:45.263 [INFO ] [org.openhab.model.script.FILE ] - Match for 'Snow'
2015-01-21 20:37:48.321 [INFO ] [org.openhab.model.script.FILE ] - Song: Visit now: radiosantaclaus.com -
2015-01-21 20:37:48.350 [INFO ] [org.openhab.model.script.FILE ] - Match for 'radiosantaclaus', skip
2015-01-21 20:38:00.437 [INFO ] [org.openhab.model.script.FILE ] - Song: Frosty The Snowman
2015-01-21 20:38:00.596 [INFO ] [org.openhab.model.script.FILE ] - Match for 'Snow'
2015-01-21 20:41:05.943 [INFO ] [org.openhab.model.script.FILE ] - Song: Visit now: radiosantaclaus.com -
2015-01-21 20:41:05.965 [INFO ] [org.openhab.model.script.FILE ] - Match for 'radiosantaclaus', skip
2015-01-21 20:41:31.507 [INFO ] [org.openhab.model.script.FILE ] - Song: Frosty The Snowman
2015-01-21 20:41:31.541 [INFO ] [org.openhab.model.script.FILE ] - Match for 'Snow'
2015-01-21 20:42:45.844 [INFO ] [org.openhab.model.script.FILE ] - Song: Under The Christmas Tree
2015-01-21 20:42:46.168 [INFO ] [org.openhab.model.script.FILE ] - Match for 'Christmas'




 

In the logging above, you'll see some titles return a matching keyword and others don't. There is also the occasional radio channel name appearing instead of the song title. This is filtered out and skipped.

 

The tree happily reacts to the changes in keywords and changes colors automatically:

DSCN3182.JPGDSCN3180.JPGDSCN3186.JPGDSCN3188.JPG

 

I'll be covering the actual build of the tree in my next and final post! Stay tuned! (here: [Christmas Tree] Internet of Holiday Lights - Finished Build)

Hello Everyone, This is my third blog post for the Internet Of Holiday Lighting Road Test, in this post I will explain how did I managed to perform to change the color of RGB led strip with a simple IR Remote. Below is a picture of the setup :

                                    WP_20150120_21_11_18_Pro[1].jpg

Please watch the demo video it explains more than I can write about it...

 

 

HERE IS A DEMO VIDEO :

 

                                                  

 

It is a very simple program, but first you will need to download this library : IRremote

once you do that everything is simple, just decode each button on your remote and make a case for each one of them.

the program simply reads the incoming hex code from your remote, and if the code match then the operation within the code is performed, in this code I have made it to change the color accordingly...




#include <IRremote.h>
#define SL_BD_RT 9600
#define RECV_PIN 7


#define RED 0XF720DF
#define GREEN 0XF7A05F
#define BLUE 0XF7609F
#define WHITE 0XF7E01F
#define CYAN 0XF7B04F
#define PINK 0XF76897
#define YELLOW 0XF728D7
#define ORANGE 0XF710EF
#define TEAL 0XF7A857
#define AQUA 0XF7906F
#define GOLD 0XF708F7
#define PURPLE 0XF748B7
#define OFF 0XF740BF




  #define ADDRESS                    0x15EUL

  #define INTENSITY_RED              0x11U
  #define INTENSITY_GREEN            0x12U
  #define INTENSITY_BLUE     0x13U
  #define INTENSITY_RGB              0x14U
  #define CURRENT_RED                0x21U
  #define CURRENT_GREEN              0x22U
  #define CURRENT_BLUE               0x23U
  #define CURRENT_RGB                0x24U
  #define OFFTIME_RED                0x41U
  #define OFFTIME_GREEN              0x42U
  #define OFFTIME_BLUE     0x43U
  #define WALKTIME                   0x50U
  #define DIMMINGLEVEL               0x60U
  #define FADERATE                   0x61U

  #define READ_INTENSITY_RED         0x81U
  #define READ_INTENSITY_GREEN       0x82U
  #define READ_INTENSITY_BLUE        0x83U
  #define READ_CURRENT_RED           0x84U
  #define READ_CURRENT_GREEN         0x85U
  #define READ_CURRENT_BLUE          0x86U
  #define READ_OFFTIME_RED           0x87U
  #define READ_OFFTIME_GREEN         0x88U
  #define READ_OFFTIME_BLUE          0x89U
  #define READ_WALKTIME              0x8AU
  #define READ_DIMMINGLEVEL          0x8BU
  #define READ_FADERATE              0x8CU



  #define SAVEPARAMETERS             0xA0U

  #define BCCUMODID                  0x50030008U
  #define CHIPID                     0x40010004U
  #define REDINTS                    0x500300A0U // BCCU_CH5
  #define REDINT                     0x500300A4U
  #define BLUEINTS                   0x50030078U
  #define STARTWALK                  0x50030018U

  #include <Wire.h>


  byte ledState;
  IRrecv irrecv(RECV_PIN);
  decode_results results;
  boolean power_state = LOW;

  unsigned int c[2] = {0};
  unsigned int d[4] = {0};
  unsigned int on = 0;
  unsigned int message = 0;
  unsigned long redcurr = 0;
  unsigned long greencurr = 0;
  unsigned long bluecurr = 0;
  unsigned long redoff = 0;
  unsigned long greenoff = 0;
  unsigned long blueoff = 0;
  unsigned long redint = 0x00;
  unsigned long greenint = 0x00;
  unsigned long blueint = 0x00;
  unsigned long fadetime = 0x00;
  unsigned long walk = 0x00;
  unsigned long brightness = 1;


void red(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0); // red
      delay(100); 
  }
void green(){
   I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0); // red
      delay(100);
  }
void blue(){
   I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0fff); // red
      delay(100);
  }
void white(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0fff, 0x0fff);
  delay(100);
  }
  void purple(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0fff);
  delay(100);
  }
  void yellow(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0999, 0x0);
  delay(100);
  }
  void cyan(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0fff);
  delay(100);
  }
  void pink(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0888);
  delay(100);
  }
  void teal(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0888);
  delay(100);
  }
  void off(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0);
  delay(100);
  }
  void orange(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0333, 0x0);
  delay(100);
  }
  void aqua(){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0999, 0x0fff);
  delay(100);
  }

void setup() {               


    Serial.begin(SL_BD_RT);
    Wire.begin();
    irrecv.enableIRIn();
   
    while (on != 1) // Wait for shield to respond, keep setting the values till it does
    {
      I2CWRITE2BYTES (ADDRESS, FADERATE, 0x0000); // Immediate fade
      I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0000); // 0% brightness level
      on = I2CREAD(ADDRESS, READ_DIMMINGLEVEL); // Request for brightness level
      if (message == 1 && on == 0) // If message received and dimming level = 0%, "message" is set in the I2CREAD function
      {
        message = 0;
        on = 1; // break out of loop
      }
     
    }
   
    // now we will chane the values again and wait till there being red back
    while (redcurr != 0x15 || greencurr != 0x15 || bluecurr != 0x15 || redoff != 0x38 || greenoff != 0x39 || blueoff != 0x38 || brightness != 0)
    {
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0000, 0x000, 0x0000); // Off Light
  // Ensure that parameters are set up correctly. Read back and check. If wrong, write and read again.
        redcurr = I2CREAD (ADDRESS, READ_CURRENT_RED); // Read the red current intensity
  greencurr = I2CREAD (ADDRESS, READ_CURRENT_GREEN); // Read the green current intensity
  bluecurr = I2CREAD (ADDRESS, READ_CURRENT_BLUE); // Read the blue current intensity
  redoff = I2CREAD (ADDRESS, READ_OFFTIME_RED); // Read the off-time of the red channel
  greenoff = I2CREAD (ADDRESS, READ_OFFTIME_GREEN); // Read the off-time of the green channel
  blueoff = I2CREAD (ADDRESS, READ_OFFTIME_BLUE); // Read the off-time of the blue channel
  brightness = I2CREAD (ADDRESS, READ_DIMMINGLEVEL); // Read the dimming level
       
        I2CWRITE2BYTES (ADDRESS, OFFTIME_RED, 0x38); // Set off-time of red channel to 0x38
  I2CWRITE2BYTES (ADDRESS, OFFTIME_GREEN, 0x39); // Set off-time of green channel to 0x39
  I2CWRITE2BYTES (ADDRESS, OFFTIME_BLUE, 0x38); // Set off-time of blue channel to 0x38
  I2CWRITE2BYTES (ADDRESS, CURRENT_RED, 0x15); // Set current intensity of red channel to 0x15
  I2CWRITE2BYTES (ADDRESS, CURRENT_GREEN, 0x15); // Set current intensity of green channel to 0x15
  I2CWRITE2BYTES (ADDRESS, CURRENT_BLUE, 0x15); // Set current intensity of blue channel to 0x15
  I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0000); // LEDs all off as any intensity * 0 will = 0
       
    }

    delay(100); // OK, so were getting response from the infineon so read back values from slave and print them
    Serial.print("Red Int: ");     redint = I2CREAD (ADDRESS, READ_INTENSITY_RED); // request from shield red colour intensity
    Serial.print("Green Int: ");   greenint = I2CREAD (ADDRESS, READ_INTENSITY_GREEN); // request from shield green colour intensity
    Serial.print("Blue Int: ");    blueint = I2CREAD (ADDRESS, READ_INTENSITY_BLUE); // request from shield blue colour intensity
    Serial.print("Red Curr: ");    redcurr = I2CREAD (ADDRESS, READ_CURRENT_RED); // request from shield peak current reference of red channel
    Serial.print("Green Curr ");   greencurr = I2CREAD (ADDRESS, READ_CURRENT_GREEN); // request from shield peak current reference of green channel
    Serial.print("Blue Curr: ");   bluecurr = I2CREAD (ADDRESS, READ_CURRENT_BLUE); // request from shield peak current reference of blue channel
    Serial.print("Red PWM: ");     redoff = I2CREAD (ADDRESS, READ_OFFTIME_RED); // request from shield off-time of red channel
    Serial.print("Green PWM: ");   greenoff = I2CREAD (ADDRESS, READ_OFFTIME_GREEN); // request from shield off-time of green channel
    Serial.print("Blue PWM: ");    blueoff = I2CREAD (ADDRESS, READ_OFFTIME_BLUE); // request from shield off-time of blue channel
    Serial.print("Walk: ");        walk = I2CREAD (ADDRESS, READ_WALKTIME); // request from shield walk-time
    Serial.print("Brightness: ");  brightness = I2CREAD (ADDRESS, READ_DIMMINGLEVEL); // request from shield brightness level
    Serial.print("FadeTime: ");    fadetime = I2CREAD (ADDRESS, READ_FADERATE); // request from shield fade rate
   
    // now setup for test
   
    I2CWRITE2BYTES (ADDRESS, OFFTIME_RED, 0x38); // Set off-time of red channel to 0x38
    I2CWRITE2BYTES (ADDRESS, OFFTIME_GREEN, 0x39); // Set off-time of green channel to 0x39
    I2CWRITE2BYTES (ADDRESS, OFFTIME_BLUE, 0x38); // Set off-time of blue channel to 0x38
    I2CWRITE6BYTES (ADDRESS, CURRENT_RGB, 0x80, 0x80, 0x80); // Set current of red channel to 0x80 = 780mA
    I2CWRITE2BYTES (ADDRESS, FADERATE, 0x0000); // Fade Rate between intensities --> 0.0s
    I2CWRITE2BYTES (ADDRESS, WALKTIME, 0x0000); // walk time between colors = 0s
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0555, 0x0555, 0x0555); // low level White Light
    I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0FFF); // Maximum dimming level means inensity settings are directly used
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0);


}

  // the loop routine runs over and over again forever:
void loop() {
if (irrecv.decode(&results)) {  //If IR receive results are detected
    Serial.println(results.value, HEX);
    switch (results.value) {
     
    case RED:
         red();
    break;


    case BLUE:
         blue();
    break;


  
    case GREEN:
         green();        
    break;


   case WHITE:
          white();
    break;
   
    case CYAN:
          cyan();
    break;
   
    case YELLOW:
          yellow();
    break;
   
    case PURPLE:
          purple();
    break;
   
    case AQUA:
          aqua();
    break;
   
    case OFF:
          off();
    break;
   
    case ORANGE:
          orange();
    break;
   
    case PINK:
          pink();
    break;
   
    case TEAL:
          teal();
    break;
   
   
   
   
    default:
       Serial.println("");
  }


    delay(20);  // 1/5 second delay for arbitrary clicks.  Will implement debounce later.
    irrecv.resume(); // Receive the next value
  }

}






// Infineon functions follow
/*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined I2C Commands i.e. INTENSITY_RED, INTENSITY_GREEN, INTENSITY_BLUE
                   unsigned int Data - 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 2 bytes of word to the I2C bus line
  */

  void I2CWRITE2BYTES (int Address, int Command, unsigned int Data)
  {
    unsigned int upperByte, lowerByte; // Separate 4 byte data into 2 byte values
    lowerByte = Data;
    upperByte = Data >> 8;
   
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // Putting address into correct format
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD)); // Start I2C transmission
    Wire.write(byte(lowerSLAD)); // address lower 8 bits of i2c address
    Wire.write(byte(Command)); // write command
    Wire.write(byte(upperByte)); // write data
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);
     
  }
   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined I2C Commands i.e. INTENSITY_RGB, CURRENT_RGB
                   unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree - Three 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 6 bytes of word to the I2C bus line
  */

  void I2CWRITE6BYTES (unsigned int Address, unsigned int Command, unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree) // DataOne: Red, DataTwo: Green, DataThree: Blue
  {
    unsigned int upperByte, lowerByte; // Split each Data parameter into upper and lower 8 bytes because I2C format sends 8 bytes of data each time
    lowerByte = DataOne;
    upperByte = DataOne >> 8;
   
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    lowerByte = DataTwo;
    upperByte = DataTwo >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    lowerByte = DataThree;
    upperByte = DataThree >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);
     
  }

/*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined I2C Commands i.e. DMX16Bit
                   unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree, usigned int DataFour, unsigned int DataFive - Three 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 12 bytes of word to the I2C bus line
  */ 

  void I2CWRITE12BYTES (unsigned int Address, unsigned int Command, unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree, unsigned int DataFour, unsigned int DataFive, unsigned int DataSix) // DataOne: Red, DataTwo: Green, DataThree: Blue
  {
    unsigned int upperByte, lowerByte;
    lowerByte = DataOne;
    upperByte = DataOne >> 8;
   
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command)); // write command
    Wire.write(byte(upperByte)); // write 2 bytes
    Wire.write(byte(lowerByte));
   
    lowerByte = DataTwo;
    upperByte = DataTwo >> 8;
    Wire.write(byte(upperByte)); // write next two bytes
    Wire.write(byte(lowerByte));
   
    lowerByte = DataThree;
    upperByte = DataThree >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataFour;
    upperByte = DataFour >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataFive;
    upperByte = DataFive >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataSix;
    upperByte = DataSix >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);
     
  }

   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined read I2C Commands i.e. READ_INTENSITY_RED, READ_INTENSITY_GREEN, READ_INTENSITY_BLUE
  Parameters (OUT): None
  Return Value: Requested data from Shield will be sent back
  Description: This function will request 2 bytes of word from the shield
  */

  unsigned int I2CREAD (unsigned int Address, unsigned int Command) // Returns data sent by slave
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;
   
    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.endTransmission(false); // false for Repeated Start
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.requestFrom(upperSLAD, 2, true);
    unsigned int data = 0;
   
    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      message = 1;
      c[i] = Wire.read(); // receive a byte as character
      i++;
     
    }
    Wire.endTransmission(true);
   
    data = c[1]; // write data to serial monitor. c[1] is higher byte
    data = (data << 8) | c[0];  // shift left and combine with lower byte
    Serial.print("0x");
    if (data < 0x1000)
        Serial.print("0");
    Serial.println(data, HEX);
    return data;
  }

   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - DIRECTACCESS_READ
  Parameters (OUT): None
  Return Value: Requested data from the Shield will be returned
  Description: This function will request 4 bytes of data from shield.
  */

unsigned long I2CREAD_DIRECTACCESS (unsigned int Address, unsigned int Command, unsigned long registerAddress)
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // sending command + address
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
   
    unsigned int firstByte, secondByte, thirdByte, fourthByte;
    firstByte = registerAddress >> 24; // top byte
    secondByte = registerAddress >> 16;
    thirdByte = registerAddress >> 8;
    fourthByte = registerAddress; // bottom byte

    Wire.write(byte(firstByte));
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));
   
    Wire.endTransmission(false); // false for Repeated Start
   
    Wire.beginTransmission(byte(upperSLAD)); // request for read
    Wire.write(byte(lowerSLAD));
    Wire.requestFrom(upperSLAD, 4, true);
    unsigned long data = 0;
   
    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      d[i] = 0;
      d[i] = Wire.read(); // receive a byte as character
      i++;  
    }


    Wire.endTransmission(true);
   
    data = d[3]; // combining into one variable. Highest byte received first
    data = (data << 8) | d[2];
    data = (data << 8) | d[1];
    data = (data << 8) | d[0];
    Serial.print("0x");
    if (data < 0x10000000)
        Serial.print("0");
    Serial.println(data, HEX);
    return data;
  }
   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   int Command - Defined I2C Commands i.e. DIRECTACCESS_OR, DIRECTACCESS_AND, DIRECTACCESS_MOVE
                   unsigned long registerAddress - address of target register
                   unsigned long Data - 32 bits data to be written to register
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 4 bytes of data to specified register
  */
  void I2CWRITE_DIRECTACCESS (unsigned int Address, unsigned int Command, unsigned long registerAddress, unsigned long Data) // For accessing registers directly
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // sending command + address
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
   
    unsigned int firstByte, secondByte, thirdByte, fourthByte; // Send address of register first
    firstByte = registerAddress >> 24; // top byte
    secondByte = registerAddress >> 16;
    thirdByte = registerAddress >> 8;
    fourthByte = registerAddress; // bottom byte

    Wire.write(byte(firstByte));
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));
   
    firstByte = Data >> 24; // top byte
    secondByte = Data >> 16;
    thirdByte = Data >> 8;
    fourthByte = Data; // bottom byte


    Wire.write(byte(firstByte)); // send 4 bytes of data
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));
    Wire.endTransmission(true);
   
  }
   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   unsigned int newAddress - Address the shield should change to
  Parameters (OUT): None
  Return Value: None
  Description: This function will change the I2C address of the slave
  */

  void CHANGEADDRESS (unsigned int Address, unsigned int newAddress)
  { 
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write
    
    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(0x70)); // Command to change address
    lowerSLAD = (unsigned int) (newAddress & 0x00FF);
    upperSLAD = newAddress >> 7; // Split address into 2 bytes
    upperSLAD |= 0xF0; // 10 bit addressing: First 5 bits have to be 11110. 
    upperSLAD &= 0xFE;
    Wire.write(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.endTransmission(true);
  }

   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                   unsigned int Command - DMXON, DMXOFF
  Parameters (OUT): None
  Return Value: None
  Description: This function will enable or disable DMX512 control on shield
  */

  void I2CDMX (unsigned int Address, unsigned int Command) // Switch off / on the DMX
  {
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // Putting address into correct format
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;
   
    Wire.beginTransmission(byte(upperSLAD)); // Start I2C transmission
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.endTransmission(true);

  }
   /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
  Parameters (OUT): None
  Return Value: None
  Description: This function will request the shield to save configurations to flash memory
  */

  void I2CSAVEPARAM (unsigned int Address)
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(SAVEPARAMETERS)); // write SAVEPARAMETERS command
    Wire.endTransmission(false); // false for Repeated Start
   
    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD)); // write to address lower 8 bits of slave address
    Wire.requestFrom(upperSLAD, 2, true);  // send READ request with upper slave address
    unsigned int data = 0;
   
    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      message = 1;
      c[i] = Wire.read(); // receive a byte as character
      i++;
    }
    Wire.endTransmission(true); // STOP condition
   
    data = c[1]; // print the data on serial monitor
    data = (data << 8) | c[0];
    Serial.print("0x");
    if (data < 0x1000)
        Serial.print("0");
    Serial.println(data, HEX);
  
  }

 

 

In my next blog post i will write about my final "True IoT" method for my smart phone lighting project....

I know this this post is not related to smartphone lighting, but as I wrote it in my application for this roadtest, so i did it...

markvenn

New Arduino Toys

Posted by markvenn     Jan 21, 2015

I have some new toys to add to my arsenal of kit! Along with a Pi camera I received two nice little additions to my box of bits. I now have a Ethernet shield and a Yun. Not sure how to pronounce Yun; should it be similar to gun? Or maybe similar to spoon. Perhaps someone can enlighten me?

 

Anyway, here are my new babies!

Arduinos.jpg

I was surprised to find the comment that the ethernet shield is no longer manufactured on the packing list. Grab them while you can guys! The ethernet shield has storage capability with the micro sd slot which can be used to serve files on the network that your mega or uno is connecting to. The Yun also has a micro sd slot that performs the same function but It has wifi capability too. In fact, when you turn it on, the instructions say to connect via wireless to the new network that is now being broadcast. Sweet!

yun rear.jpg

This is the rear of the Yun, the sd slot is on the left; I am soooooo looking forward to using this baby, I have so many ideas for something that bridges Linux and Arduino.

ethernet rear.jpg

 

The Yun is a neat bit of kit, matching Arduino magic with a linux operating system, albeit a tiny system, OpenWRT

 

On the Arduino site there is an excellent page with some info on, have a look at Arduino - ArduinoYun I reckon that once you read this you will realise you need one! Yun on element14 can be found here: Yun

 

 

On a side note, I am looking forward to the Tre being widely available. How can anything with a background that  "is partially the result of a close collaboration between Arduino and the BeagleBoard.org foundation." (Arduino - ArduinoBoardTre) not be a lovely bit of kit?

Link to previous posts

 

Preface

My project for the Internet of Holoday lights was based around our living room which was not very livable. It was a mess and with the upcoming holidays I wanted to set the living room in such a way that it would be suitable for entertaining guests. Additionally I wanted to accomplish the above mentioned in such a way that the holiday lighting becomes part of the living room and I don't need to remove it after the holidays. Hence the concept of Dynamic Living-room Lighting.

 

In the previous posts, I have review the YUN and the infineon shield and have presented an overview of the project system. I also setup the place for the lighting with some homemade arts and crafts and give a preview of the system setup. I explained the Library I made for the Infineon Shield as well as the implementation for the MoodLights and made them Dynamic. I also made a XMAS Tree with LEDs and some stuff. I connected them to the YUN and made the control for the Xmas Tree Dynamic and static. It is now integrated into the OpenHAB interface and the YUN works as a relay. I have made the minions dance using a DIY approach and connected them to an RPi. I also wrote a python script to get mentions on twitter and play music while controlling the minions.

 

In this post, I finally explain the bigger picture and the completed layout of the whole system.

 

Redoing some things

 

Many times it becomes essential to redo things in a project because of unforeseen circumstances but in my case it is mostly due to an uncontrollable urge to tweak things. Just like the motor for the minions had to be replaced, the final build had to be modified as well. I will simply go though each component in brief and it's installation for the final build.

The IoT Tree

The Tree has been explained in some detail in my previous post [Dynamic Living Room Lights] The XMAS Tree and in the living room, it was placed in the opposite corner so that it lights up a part of the room. The image below shows the placement and since the data transmission takes place over a serial link, I took a four core wire and laid it out 'inside' the wall. This way I use up three wires- GND/Common, Audio-In and Serial In.

ff4432562f7289df0c2385b8d6fbacf3.jpg

3e17169b648ffe5e078a054887aaace2.jpg

 

The length of the wire was increased and hence I had to drop the baudrate to 9600bps. I was lucky and it worked otherwise I would have to use something like modbus to talk to the remote. I was contemplating the use of the fourth wire for 5V since everything works off it, but I did not want unnecessary voltage drops messing with system operation. 120 leds suck up some current and their blinking causes spikes so I use a 1Amp SMPS for just the tree.

 

The Moodlights

These did not really get relocated, I just added a little extra wiring from the RGB LED Strip to the Infineon Shield. Image below shows the same.

1c0ab5c048e7a507af409c24ebd87861.jpg

I had to go out of the house for that wire... The LEDs themselves look good but the quality of LEDs is a bit questionable. I bought some RGBs 10MM lamps and will experiment with them before making any comments on that.

cddfcf7dc9211c1e323c52b5601f6023.jpg

That looks good.

 

The Controller YUN

The YUN performs two functions in my project- It controls the Curtain lights and the Infineon Shield AND it acts like a relay by talking to the MQTT Broker to get commands and sends them to the remote XMas Tree. I need to put it somewhere near the Curtain lights because the LEDs are to be switched ON and OFF at high speeds and lengthly wires can cause issues- for lighting, I am not so sure but for HF communication I am sure. Hence I decided it would be best to just keep it short and so I mounted the YUN and the Infineon Shield with the Filter Circuit in the corner. I wanted to make a case using plexiglass and glue like I did for the BeyondThePhone challenge, but right now I have a slight fear of my electric saw due to a recent accident and hence I will skip that. Hopefully, I will be able to 3D print cases for my next project.(hint hint ) My wall mounted solution is shown below.

62c5912d00947a819fa6297fb874f177.jpg

It is mounted crooked due to the curtain wires being shorter that they should be(my bad). I intend to complete this box at the earliest and with some better connectors too.

 

The Minion Shelf

One of the things that makes the whole setup unique is that the lights need not be taken down. For the tree I would image taking down some ornaments but the tree and its' lights will stay there. More inconspicuously, the minions will stay on the shelf waiting for a command. Now in my previous post, I had exposed the twitter capability which enables me to trigger the Minion Dance on the getting a mention tweet with a keyword. Additionally, I have in my OpenHAB system, a button which can be used to trigger the same music and dance action manually. This makes for a fun demo for visitors and is a good conversation starter.

My wife put things together in a more presentable fashion as shown in the images below.

a1b2ab4ca353aeb67d0356c6f6597547.jpg

afd9aa454eee0f7abd0065c864d6ed31.jpg

efaaf50a50a7f0d90696e24074b1ba83.jpg

You can see there are RGB LED strip at the back which are controlled via IR. The IR remote can control the lights and I will demonstrate this in a later video but these can also be controlled via OpenHAB.

 

Once everything is in place, I can finally take a look at the bigger picture.

 

The Bigger picture

So its time to look at the final build. First a look at what was...

8c1365e679f6a1171aaf4c3f15802016.jpg

From that to...

76acfa8bbd40a576b8746d39a5182bcc.jpg

and with only the curtain lights,

7d271075c5b11ecc0298cabb32abed6e.jpg

The Infineon RGB LED Shield Drives these and does a pretty good job too.(More in the Video in the next post.)

IMG_9397.jpg

It is clear how both the light have a unique effect on their respective parts of the room. If both are combined in OpenHAB, the result is...

c9136eca6e99ad4017c016a95ebdb671.jpg

The blue cold adds a cold mood to the room which is what the mood lighting is supposed to do. Success! More than that, the sound and flickering lights combo create a Disco Mood and I have a video in the next post to show that.

I did not think that the curtain lights would be enough, but actually they work quite well. I am running them within limits so as not to damage them. Once the challenge has ended, I will further experiment with the shield's capabilities especially the DMX interface.

 

The Software

I love using OpenHAB. It gets things done quicker and I like it so much that I have one RPi running it 24x7. I have explained how to create an interface using OpenHAB in a previous post and my current menu for the YUN is shown in the image below.

9ed7d5482ee311d054f289d8f0a6e311.jpg

The First Item is the color picker which is used both any and all items in manual mode. The MoodLight Mode selects either Manual (with color picker support) or Audio Mode(with direct audio influenced color change). The next item is the Tree Light which has four modes; The manual and audio are same as before and the additional P1 and P2 are pattern modes for predefined patterns. The fourth item is the Shelf lights switch which is used to turn the lights ON or OFF. These are pre-programmed with a sequence and can be replaced with any kind of lighting scheme. The last button is to make the Minions dance by pressing a button. Simply press the button and see them wiggle their' hiney!

 

That's it for now. Hope every one likes it.

 

Cheers,

IP

Back to initial blog BYOB Party #1, "Bring you own Bulbs" - The Internet of Holiday Lights

 

And so all good things come to an end and so it is for this project, as a final entry I present the end solution in its completion

 

The BYOB Party Night

 



As with so many who are putting in a real attempt at this holiday challenge , this has taken way more time than I expected (Probably well over a hundred hours maybe even twice that) but it has been a blast, loads learned, new friends made and hopefully those following along at home are learning allot of new stuff from the various posts from all the participants

 

For those who held back from applying, next time give it a go, some of use go overboard for fun, why... because we can but we try to make it educational and hopefully exciting, the reason for so many hours is we try so many alternative approaches and ideas before we settle on the one we want to present,we select ideas and approaches that others can follow without getting too expensive or complicated and as I think everyone on this project will agree, co-operation and sharing has gone a long way to make this one in my opinion, one of the best yet

 

For everyone reaching the finishing line, well done, you stayed the course, congratulations and I hope you had as much fun as I have, I cant wait to see all the final posts

 

I hope the co-operation continues through 2015 and beyond

 

The following diagram shows all the moving parts (As they say) of the BYOB Party, all of this will be shown working (At the same time) in the video I am currently editing to add to this, all code will also be shared via this blog page for you to use as you feel you want. (No Warranties )

Unfortunately looks can be deceiving, the pictures below make it look way simpler that it was, getting all this hardware to co-operate and talk to each other was not an easy task to start, once I had figured out the approach and waded through the bugs, it all came together. I hope you enjoy.

No Minions where harmed in the making of this project, though MANY where created or crashed the party

STAR.jpg

Some shots videos of individual displays

I thought I was finished with this road test, but the creative part of the brain refused to shut down. Here's my final throw at the [Christmas Wreath of Things] Internet of Holiday Lights - summary.


This is my tribute to Radio Shack / Tandy.

You pulled me into electronics. The imprint of my nose is probably still visible on the window of the shop that was once your store in Diest, Belgium.

A big thank you, and Fan Forever!



 

The road test is closing down. I had already submitted my final story. And then this idea materialized when I was updating a speaker picture to my Twitter series about the Radio Shack :

"Can I make the Yún shout out the names of my friends on element14?".

 

Turns out that I can (barely - I've stretched the memory of my Yún beyond believe).

Here's the article that got me on the rails: Is it possible to make Arduino talk without shield

 

My eldest daughter made an amplifier on the Science Fair 200 in One LAB (she isolated the amplifier part out of project 180 - octave generator)
while I was struggling to get the TSS library work on Ardiuino IDE 1.5.x and fitted it in the memory together with the MQTT lib.

She finished well before me.

Photo 20-01-15 21 01 27.jpg

 

Here's the result. You can hear the kit saying my name once, and peteroakes' name twice:

 

The video is a real capture of messages arriving. The speech you hear are real messages posted to the Eclipse IoT broker by fellow element14 members.

 

This is my final final entry. A big thank you to all: you know who you are. :like:

 

Some geek compliant pictures to close my campaign:

Photo 20-01-15 21 05 08.jpg Photo 20-01-15 21 03 29.jpg

Jan

Link to previous posts

 

Preface

 

My project for the Internet of Holoday lights was based around our living room which was not very livable. It was a mess and with the upcoming holidays I wanted to set the living room in such a way that it would be suitable for entertaining guests. Additionally I wanted to accomplish the above mentioned in such a way that the holiday lighting becomes part of the living room and I don't need to remove it after the holidays. Hence the concept of Dynamic Living-room Lighting.

 

In the previous posts, I have review the YUN and the infineon shield and have presented an overview of the project system. I also setup the place for the lighting with some homemade arts and crafts and give a preview of the system setup. I explained the Library I made for the Infineon Shield as well as the implementation for the MoodLights and made them Dynamic. I also made a XMAS Tree with LEDs and some stuff.

 

In this post I add a minion element to the project. I had initially planned to have a Santa Claus ring his bell everytime someone wishes me on twitter, but santa is busy and I have minions...

 

Getting Minions and assigning them positions

Now minions don't exactly submit their resume via email and the ones I have a pretty lazy hence I embarked on a long journey to... Well actually I had my wife make some We had two types of minions where the first type were lazy and wanted to enjoy the party by the fireplace. These were handmade by my wife and were featured in a previous blog. The second type were party type and I printed them out and cut out the outlines. Making these minions dance was a challenge since they needed some 'support'. Now I don't have a fancy 3Dprinter(hint hint )so I resorted to what I did have and that was a lot of empty element14 cardboard boxes. And thus began my evil plan to make the minions work overtime. Muahhaa ha ha! Take a look.

 

I took apart the cardboard boxes for raw materials.

903c742fc9f2065998315eb4913098a6.jpg

Next I used a stapler and a knife to make a prop.

b6d58bbfa37eed95aa99e223f7301135.jpg

 

Next I added some mechano part from an earlier experiment. These were quite cheap 10years ago when they were presented to me. Thus my CAM and PISTON Design began to emerge from the fires of mount cardboard.

9bf504ac1629d9fef286e226ceb83a25.jpg

The minions stood by and I used glue to MAKE them participate in my experiment. Their styrofoam spines stuck like... styrofoam!

9139616cc99b8373c11be1b3417bb32f.jpg

Laughing gas..!

aa9ea315d7552e66551f5eef5402a9d1.jpg

And lastly an old toy that was relieved of it's limbs, became useful again!

5ef6dd7e03f6642ca8de9659f19f6e77.jpg

 

With that, now I have minions that dance at will.

 

Epileptic Minions -

Disclaimer! No minions were harmed(without consent) in the making of this project. The minions do dance but since the mechanism is made from material that is not stiff enough, it tends to cause... kind of epilepsy in the minions. The motor and gear system I use is from a discarded toy and due to it's gear-ratios and placement of cam, the whole thing pulls around 300mA when working. See video below.

Its clear that its not perfect and a better mechanism would solve the problem. The reason why I did not use a servo motor is because I don't have any. I got one which I used for the minion bot for the 'forgetmenot' challenge. But it works and I am willing to admit that my minions dance bad, but they can dance.

Unfortunately, the geared system sucked up too much power and it broke down a few days ago. Hence I went out and bought out a geared motor and after a little DIY magic, I got the arrangement shown below.

3c6f760a1928a323f4e34c099b9ec138.jpg

 

Moving on to the control part...

 

A simple motor switch

The minions dance when a small voltage is supplied to the motor. This I need to control via the raspberry Pi. Why not the YUN? I will that part explain later. For now, I need to make a small circuit that enables me to connect a small motor to the raspberry pi. The input signal is from the raspberry pi and the motor runs on 5V. The new motors draw around 100 -175mA at 5V which is not bad and I made a little transistor driver which can work as a switch. In order to control the speed, I simply added a 1K present between the motor and the transistor. That should enable me to calibrate the speed without messing with the PWM module. See, I took care of the simple stuff in the simplest way! The circuit is shown in the images below.

5a89dff8888204e8d13d905ce0f2d322.jpg

 

The speed is adjusted and it looks a little better than before. How better, you be the judge of that but this is the best I could do. Now to control it via the RPi

 

Raspberry Pi program to control the motor

In order to control the motor, we need to write a program to toggle the GPIO which is connected to the transistor. This can be done in a number of languages but I chose python. This is relatively simple and there are lots of tutorials on the internet for this part. I wrote and tested some code and it is given below.

 

#! /bin/python
import RPi.GPIO as GPIO
import time


#setup the Pin for the control
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.output(18, false)


#loop the loop
while(True):
    GPIO.output(18, true)
    time.sleep(10)
    GPIO.output(18, false)
    time.sleep(10)







 

This works and makes the minions dance for 10 seconds and stay still for 10 seconds and repeat.

 

Getting Tweets with Python

In my initial proposal, I wanted to have Santa ring his bell to greetings published on twitter with me mentioned. In the present case, I would use them to make the minions dance. Easier said than done and there are a number of tutorials out there about accessing twitter and the like using python. In my case, I wanted the tweets with hashtags like #happynewyear and #happyholidays etc to trigger the actions. I want only tweets with mentions to me @ip_v1 on twitter which can be accomplished a number of ways. This would involve reading the twitter feed and finding mentions and then searching for hashtags. If one is found, then the action is to be initiated. Additionally some record of the hashtag must be retained so as to distinguish between redundant instances. In my experiments, I tried do thing by many methods where the timestamps were grabbed and a few other hoops but at the end, I found a simpler method that just works.

 

Say hello to Temboo

Temboo is an online service that allows you to generate code for IOT applications in a variety of languages and devices such as CC3200 and the Arduino YUN. I used it to generate code to get tweets with mentions in python. The tweets are received in JSON format but for my solution I don't care about that. I simple use the find function

 

#! /usr/bin/python

from temboo.Library.Twitter.Timelines import Mentions
from temboo.core.session import TembooSession


import json
import re
import time

#Some global stuff here
prt_dept=50 #dept of fingerprint characters
finger_print = 'NULL'
keywrd1 = '#happy'


# Create a session with your Temboo account details
session = TembooSession("inderpreet", "myFirstApp", "XXXX")


# Instantiate the Choreo
mentionsChoreo = Mentions(session)


# Get an InputSet object for the Choreo
mentionsInputs = mentionsChoreo.new_input_set()


# Set the Choreo inputs
mentionsInputs.set_AccessToken("XXXX")
mentionsInputs.set_AccessTokenSecret("XXXX")
mentionsInputs.set_ConsumerSecret("XXXX")
mentionsInputs.set_ConsumerKey("XXXX")


while(True):
    print '\n#######################\nWoke up!'
    #Code to get the mentions


    # Execute the Choreo
    mentionsResults = mentionsChoreo.execute_with_results(mentionsInputs)
    response = mentionsResults.get_Response();


    #My work begins here
    #Mentions are now in response so convert to lower case
    resp_lower=response.lower()


    #match string1
    index1=resp_lower.find(keywrd1)


    #IF we find a match, then
    if(index1>0):
        #get new fingerprint
        new_fingerprint = resp_lower[(index1-prt_dept):index1]


        #Compare Fingerprints for new and if it IS then...
        if(finger_print!=new_fingerprint):
            finger_print=new_fingerprint;
            #Do the required action here
            print 'Found New Mention'
        else:
            print '\nNothing New'
            #else Nothing
    #Sleep for 1 minute
    print 'Sleeping...'
    time.sleep(60)

 

This code works out and I have commented it for anyone who wants to modify it for their use and if you have a better way of doing this, please do let me know.

 

Putting it all together

Once I put together the code as well as the mechanical structure, the whole thing works. Below is a video demo for documentation purposes.

 

At this point I am almost done with my project but I need to complete the documentation for the actual living room. I hope to complete that tomorrow. A lot of time and energy has been put in to make this project and I hope everyone likes the results.

 

 

Cheers,

IP

Madhu here for my blog post after a long vacation! For today's post, I am going to talk about a project that I had worked on as a fun learning project.

 

I came across this wonderful tutorial on Adafruit's website for controlling different types of motors using the V2 Motor shield. The detailed instructions make it easy to get started and I want to adapt these for the MATLAB Support Package (SP) for Arduino. With the support package, you can connect to your Arduino from a MATLAB session - to acquire data from or to send data to the Arduino. I am using the motor shield here to illustrate the use. 

 

Once I made all the connections as shown in the figure below, I only had a few steps to follow.

AdafruitMotorShieldV2Example_01.png

 

The steps -

 

1) Create an Arduino object in MATLAB

 

arduinoObject = arduino('com4', 'Due', 'Libraries', 'Adafruit\MotorShieldV2')

 

2) Create an addOnShield object for the V2 Motor shield

 

addOnShield = addon(arduinoObject, 'Adafruit\MotorShieldV2')

 

3) Control the servo motor from port 1

 

servoMotor = servo(addOnShield, 1)

for angle = 0:0.2:1 % From minimum 0 degrees to maximum 180 degrees

    writePosition(servoMotor, angle);

    pause(1);

end

 

4) Control the stepper motor from port 1. Note that the servo port 1 is different from the Motor port 1 in Motor shield.

 

stepperMotor = stepper(addOnShield, 1, 200) % Example usage of stepper - stepper(shieldObject, portNum, StepsPerRevolution)

stepperMotor.RPM = 10;

move(stepperMotor, 200);

 

5) Control the DC motor from port 4

 

dcMotorObject = dcmotor(addOnShield, 4)

dcMotorObject.Speed = 0.2;

start(dcMotorObject);

 

Hope this will be useful to others as well, who are attempting to understand how to use MATLAB Support package for Arduino to control motors.

Hi there

 

In my initial blog post I suggested it would be good to not only have way more than the boards provided by the challange (UNO, YUN and Infinion) but also to mix it up a bit by introducing a foreigner into the mix

 

well I did, in the form of a TI launchpad CC3200

launchpad-cc3200-launchxl-thumbP1010361.jpgP1010362.jpg

This board has WIFI, full IO, 80Mhz MPU and a whole bunch more

 

The design goal is to have this board subscribe to its topics directly rather than relying on Mrs YUN and also to provide value while at the party by monitoring the temperature and reporting it through the Eclipse MQTT broker, all this while running on battery power...

 

This effectively shows that no matte the underlying technology, it is a straight forward task to get them all talking to each other reliably and effectively, this board is subscribing to topics published by the Arduinos in the challenge and also providing value to the mix tha can also be consumed by any technology, in this challenge it was a hardware less node... the WEB browser page use to control the party

 

my initial endevour was to use CCS (Code Composer Studio ) running the TO_RTOS (Real time Operating System) and have several tasks running, one to announce the temperature at the venue and one to highlight the remote guests as they arrive or are pinged via the element14_IoT topic on the PAHO / Ellipse broker

 

This proved to be much harder a learning curve than I anticipated and while I could easily get the addition of one or the other working in the RTOS, it proved impossible for now to get them both working, there is a steep learning curve to get to grips with the RTOS and also the simple link networking stack. alas it got the better of me and I eventually switch to Energia to complete the coding. I will circle back to this once I am more familuar with the required RTOS and Simplelink software, there are many hours of videos to go though first and as I had no responses from my calls to the experts I had to change.

 

So, using Energia is was a simple matter of finding the libraries for MQTT (PubSubClient.h) modified for the CC3200's built in WIFI. I found the library here Creating an IoT-connected sensor with Energia & MQTT | Energia

 

next was to add the ability to both publish and subscribe at the same time as I wanted to include a publication of the temperature sensors included on the launchpad. The current Energia comes with a sample for interfacing with the device from Adafruit but it needs a small tweak to get it running

 

Lastly I also want to control some Higher power LEDs that draw in the region over 300mA and require about 12V to operate, this is way beyond the ability of the control board alone. In my initial breif i also stated I wanted to have relay driven loads that could be up to mains supply voltage. In the interest of safety I decided to not use mains but still retain the relays and instead use these high power LED which is more than good enough to demonstrate the principle of operation (POC at its best ) This is the relay board I used (Only 4 channels needed but I had this already) and this is one set of LEDs to be used.

 

P1010315.JPGP1010316.JPG

 

The other part of this challenge was to have this unit be battery powered... come on down Battery Booster pack, the time is right

med_boostxl-battpack_fuel_tank.jpg

This has been running the board now for over 12 hours and no signs of being flat yet (Its not powering the LEDS but is driving the relays) and between  fvan, mcb1, jancumps and myself peteroakes, were keeping the relays busy .

 

So the code

 

/*
  - connects to an MQTT broker
  - publishes temperature sensor reading to the topic "BYOB-PARTY/PartyTemp and BYOB-PARTY/FloorTemp"
  - also subscribes to the element14_IoT topic and drives outputs based on who is online pinging the topic
  - supports mcb1, fvan, jancumps and peteroakes at the moment
*/


#include <WiFi.h>
#include <Wire.h>
#include "Adafruit_TMP006.h"
#include <PubSubClient.h>
#include <SPI.h> //only required if using an MCU LaunchPad + CC3100 BoosterPack. Not needed for CC3200 LaunchPad
WiFiClient wclient;


byte server[] = { 198, 41, 30, 241 }; //  Public Eclipse MQTT Brokers: http://mqtt.org/wiki/doku.php/public_brokers
byte ip[]     = { 172, 16, 0, 100 }; // gets overridden by the WIFI DHCP


unsigned long timerInterval = 5000; // interval between sensor writes
unsigned long timerNow = millis();// holder for current time to compare to sensorTimer


unsigned long LEDInterval = 10000; // 15 seconds on time
unsigned long LED1On = millis(); // holder for LED1 timer
unsigned long LED2On = millis(); // holder for LED2 timer
unsigned long LED3On = millis(); // holder for LED3 timer
unsigned long LED4On = millis(); // holder for LED4 timer


#define       WIFI_SSID         "xxxxxxxxx"
#define       WIFI_PWD          "xxxxxxxxx"


// Define Outputs
#define LED1 3
#define LED2 4
#define LED3 5
#define LED4 6




Adafruit_TMP006 tmp006(0x41);  // start with a diferent i2c address!


PubSubClient client(server, 1883, callback, wclient);


void callback(char* inTopic, byte* payload, unsigned int length){
  // Handle callback here

  // Allocate the correct amount of memory for the payload copy
  byte* p = (byte*)malloc(length);
  // Copy the payload to the new buffer
  memcpy(p,payload,length);
  p[length]= 0 ; // terminate the string

   Serial.print("Received from topic ");
   Serial.print(inTopic);
   Serial.print(" payload  ");
   Serial.println((char*) p);

  if (strcmp("peteroakes",(char*) p)==0)
  {
   LED1On = millis();
  }
  if (strcmp("jancumps",(char*) p)==0)
  {
   LED2On = millis();
  }
  if (strcmp("mcb1",(char*) p)==0)
  {
   LED3On = millis();
  }
  if (strcmp("fvan",(char*) p)==0)
  {
   LED4On = millis();
  }
  // Free the memory
  free(p);
}


void setup()
{
  //Initialize serial and wait for port to open:
  Serial.begin(115200);


  Serial.println("Start WiFi");
  WiFi.begin(WIFI_SSID, WIFI_PWD);
  while(WiFi.localIP() == INADDR_NONE) {
    Serial.print(".");
    delay(300);
  }
  Serial.println("");


  printWifiStatus();
    if (client.connect("thebreadBoardca")) {
      client.subscribe("element14_IoT");
    }
  timerNow = millis();

  // now spin up the temp sensor
    if (! tmp006.begin()) {
    Serial.println("No sensor found");
    while (1);
  }
    // initialize the digital pin as an output.
  pinMode(LED1, OUTPUT);digitalWrite(LED1, LOW);
  pinMode(LED2, OUTPUT);digitalWrite(LED2, LOW);
  pinMode(LED3, OUTPUT);digitalWrite(LED3, LOW);
  pinMode(LED4, OUTPUT);digitalWrite(LED4, LOW);
}


void loop()
{
if(timerNow + timerInterval  < millis()) {


  // Grab temperature measurements and print them.
  float objt = tmp006.readObjTempC();
  Serial.print("Object Temperature: "); Serial.print(objt); Serial.println("*C");
  float diet = tmp006.readDieTempC();
  Serial.print("Die Temperature: "); Serial.print(diet); Serial.println("*C");


  // convert into to char array
  String strobjt = (String)objt;
  String strdiet = (String)diet;


  int str_len = strobjt.length() + 1;  // Length (with one extra character for the null terminator)
  char char_array[str_len];  // Prepare the character array (the buffer)
  strobjt.toCharArray(char_array, str_len);  // Copy it over

  // publish data to MQTT broker
  client.publish("BYOB-PARTY/PartyTemp", char_array);


  str_len = strdiet.length() + 1;  // Length (with one extra character for the null terminator)
  strdiet.toCharArray(char_array, str_len);  // Copy it over

  // publish data to MQTT broker
  client.publish("BYOB-PARTY/FloorTemp", char_array);


  timerNow = millis(); // reset timer
}
client.loop();

updateLEDS();
}


void updateLEDS()
{
if(millis() - LED1On <= LEDInterval ) {
   // Serial.print("leds 1");
    digitalWrite(LED1, HIGH);
}
else
{
   // Serial.print("leds 0");
   digitalWrite(LED1, LOW);
}
if(millis() - LED2On <= LEDInterval ) {
   // Serial.print(" 1");
   digitalWrite(LED2, HIGH);
}
else
{
   // Serial.print(" 0");
   digitalWrite(LED2, LOW);
}
if(millis() - LED3On <= LEDInterval) {
   // Serial.print(" 1");
   digitalWrite(LED3, HIGH);
}
else
{
   // Serial.print(" 0");
   digitalWrite(LED3, LOW);
}

if(millis() - LED4On <= LEDInterval) {
   // Serial.println(" 1");
   digitalWrite(LED4, HIGH);
}
else
{
   // Serial.println(" 0");
   digitalWrite(LED4, LOW);
}
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());


  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
}





 

This does not use the more complex command handling I used for the Arduino based projects, I wanted to show that is can be simple enough with if then else statements where the logic or list of commands is not extensive

 

first thing to note that is typical in the MQTT world of programming is a callback function, in this case literally called "callback", this will catch the messages sent to this device based on the subscriptions it issues, there is a debug print statement to display what is received followed by a series of timer updates based on the message received. Also not that this routine does not directly turn on the LEDs, it does not need to

 

the set-up function is nothing out of the ordinary so ill skip the description for it except to say this is where the subscription call is made to the eclipse.org broker

 

Note in the loop() function that there is a large section of code wrapped with an if statement, this is handling the case of only transmitting the temperature every 1 second rather then every time through the loop. No delay() functions where used or harmed in the making of this code, therefore it is simple to add further functionality without compromising the timing

 

after this loop there is a single call to the client.loop() function, this allows the subscriptions to be checked for data and is required for the mqtt client subscriptions to function

 

lastly in the main loop() there is a call to updateLEDS(), this is where the work is done to determine if any of the LEDs need to be turned on or off

As can be seen from the code, the sequence is repeated for each LED timer and if the timer is active the LED is turned on, if Inactive then it is turned off, this could be optimized to not call the on or off outputs if the state is already there but for this simple code it is not required or necesary

 

That is all there is to this particular project, very simple and effective, the outputs listed above are simply connected to the Relay board and they drive through opto isolators to turn on and of the relays.

Oh, yes there was one other thing, once programmed the board was disconnected from the USB power and supplied by the Battery Booster pack. Works great.

 

One annoying thing I discovered was that during programming, you had to keep removing rto run and replace to program a jumper on the launchpad, i guess this is the one that is used to switch between run time mode and emulation mode, and Energia always programs the runtime flash when programming so while annoying to have to do it, I can understand.

 

Attached is the completed code for you to use as you like

 

Any questions feel free to ask

 

Peter

Back to main blog BYOB Party #1, "Bring you own Bulbs" - The Internet of Holiday Lights

 

This kind of brings back memories from the  "Euro vision Song Contest"

 

Welcome Belgium

Welcome Germany

Welcome Canada...

 

you get the idea

 

so what I wanted to do here was to have a matrix display to show a scrolling sign to say welcome to whom ever publishes their name to the "element14_IoT" topic of the Elclipse MQTT broker

 

I initially tried this using an arduino UNO and could get the display working no problems but there was no room for additional functionality like communications via radio and this was an important feature I wanted

 

over to Light Strip Larry, the MEGA star sports a significant amount of RAM and FLASH space, the Arduino mega was to be driving some WS2812 LED strips but this seemed more appropriate for a MEGA star and could work

 

Adafruit has a great article on getting this up and running on an UNO or MEGA and that part was straight forward, now all I needed was to modify it to handle an NRF24L01 while simultaneously driving a 32*128 pixel array of full colour LEDs, well we got there and this is the resulting code and wiring

 

This is the panel front and back

 

initial Adafruit article can be found here for those wanting to reproduce my project, all the wiring and code are there to get the first level of the project up and running

 

https://learn.adafruit.com/32x16-32x32-rgb-led-matrix

 

This shows the wiring into an UNO, the text is there to tell you the differences when using a MEGA, and yes you have to adhere to them or it will not work, I had to re-configure the NRF24L01 to work around this

 

With an UNO you rapidly run out of pins too which is another good reason to use a MEGA, here are my attempts

P1010331.jpgP1010360.jpg

the additional grey ribbon wire running off to the right on the mega is for the NRF24L01 radio

 

modifying the code was fairly straight forward

 

Adding the additional headers include statements (NRF stuff)

// Bunch of constants in the form of definitions
// 1 = output debug to serial port, 0 = no debug
#define debug 0
/* Include needed Lbraries */
#include <SPI.h>
#include <Wire.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
#include <avr/pgmspace.h>
#include <Infineon.h>
/* End include libraries */
#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library


 

note there is some code from other IoT-Holiday Lights in there, its been a hectic few weeks and I will eventually get to cleaning it all up

#define CLK 11  // MUST be on PORTB! (Use pin 11 on Mega)


this is the one item you can not ignore when moving to a mega

for the NRF radio I had to use alternate pins as seen in this config statement

RF24 radio(A5, 10);


 

This same code base has been used through many iterations of holiday light modules so most of the commands below can be ignored in this version, only "SETNAME" is used

//Command Strings
PROGMEM const char helloCmd[]     = "Hello";
PROGMEM const char SETNAMECmd[]    = "SETNAME";
PROGMEM const char REDCmd[]      = "RED";
PROGMEM const char GREENCmd[]    = "GREEN";
PROGMEM const char BLUECmd[]     = "BLUE";
PROGMEM const char WHITECmd[]    = "WHITE";
PROGMEM const char FLASHCmd[]    = "FLASH";
PROGMEM const char RAINBOWCmd[]  = "RAINBOW";
PROGMEM const char OFFCmd[]   = "OFF";


 

I was originally going to have the ability to send commands for other cool stuff but ran out of time

 

this is the main loop that monitors the NRF radio, the serial port and refreshes the display in a minimal loop

void loop()
{
  // Notice how the main loop is very simple and the functions
  // seperate the logic into easily manageable parts
  if (CheckSerial())
  {
    DoCommand(inputBuffer, "\0");
  }

  if (CheckNRF())   
  {
    DoCommand(NRFrdata, "\0");
    SendNRFTest(); // echo back command
  }

  doMatrix();
}

 

as you can see, there is a call to check the Serial followed by a call to the Radio followed by a call to update the display, if either of the calls to the radio or serial finds data then it will call the command function passing in the command found

 

Do matrix is the same as found on the Adafruit site so ill not go into details here except where I may make small changes

The DoCommand function is detailed on my tutorials as well no please refer to there for more details  ( Fast Track to Arduino Programming )

the one thing to note is that the case statement calls the setDisplayName function when the command is found, passing in with it any parameters that may also be present. remember that because we are using the NRF radios we have a max of 32bytes we can send including the command without getting into more sophisticated code so we have limits in the messages

    case  SETNAME :         SetDisplayName(Parameter, Parameter2 ); break;

 

so the interesting stuff is in this function

 

void SetDisplayName(char* newName, char* newName2)
{
  sprintf(str, "Happy New Year: %s %s ", newName, newName2);
  //strcpy(str, newName);
  textMin = sizeof(str) * -12;
}

 

As you can see, the changes are pretty simple if you ignore adding the NRF radio stuff and the command processing all of which is explained elsewhere

 

what this does is add the passed in parameters to the function, it inserts it into the greeting file and exists

 

the main routine loop as you recall includes a call to doMatrix(), this function takes care of all the business of the bouncy balls and rendering the text, a pretty neat bit of code and the libraries Adafruit include have all sorts of graphics ability too.

 

You may well ask why even bother with the command which takes away from having a longer message, well if it where omitted then there is a risk of receiving crap from other radios in the vicinity that could mess with the program and later you may want to extend what is done so you may as well have it in from the start

 

Thats pretty much it for this node, a fairly simple one pragmatically speaking and once running can be quite fun to use. As with the whole project, the NRF Radios prooved to be un reliable at anything more than a few feet, this may be due to all the equipment in the area but i will have to investigate that at another time, I have in the past got much better range out of them so I know it can be done. on the other hand, the new range of WIFI boards that sell for only a few $$$ look very interesting and if they proove to be reliable, I may ditch the NRF radios or at least the NRF24L01 versions altogether

 

There is a video in my closing blog that will demonstrate all I have talked about as far as the end functionality and it is quite cool

Back to primary blog BYOB Party #1, "Bring you own Bulbs" - The Internet of Holiday Lights

 

At the very beginning of this project kartben (Benjamin Cabe) kindly provided a demo for using the Infinion RGB Shield and with that demo was a colour wheel web page to remotely manage the output f the RGB LEDs

 

Now while this was a great demo, my plans for world domination my challange needed more, I have utilized at least four separate MQTT topics and some sub topics also.

 

Yes you can submit publications to a topic using an MQTT client installed on your machine or use one of the several test tools out there

 

MQTT SPI or MQTT Lense to name a couple of good ones but these are generic test tools and do there job very well but its not the same as a custom control page to do the job

 

this is what I came up with

 

 

Forgive my lack of graphics skills, I'm a software architect, not a UI designer, I can make things work, I struggle to make them pretty

 

As you can see, most of the page is just logos and stuff, all the interesting parts on on the left side, on to ensure it is still visible to most browsers even of a small screen, secondly as I said im not a graphics UI designer

 

You will recognize the colour wheel of course, I did re-configure it to send to a different topic and also shrink it down a bit

 

This was done by adjusting two files

 

main.js - the java script file loaded up to the browser to help with local code execution

var cw = Raphael.colorwheel($(".colorwheel_small"), 300, 130).color("#00F");
cw.onchange(function(c) {
  color = c;
})



 

Change the code from .colourwheel_large to .colourwheel_small and change the size to 300, note while we are here the declaration of the call back when the wheel is changed, all it will do is set the variable color. we will use this later

 

The file main.css also needs updating as even after these changes the space the wheel ocupied was still massive even though the wheel was now a better size, i tracked this down to a style override in the CSS file

 

/* Responsive: Portrait tablets and up */
@media screen and (min-width: 300px) {
  .container {
    max-width: 300px;
  }



 

look for the above and adjust to the setting your see here, i tried this on several browsers and it worked ok in all cases, originally it was set to 780px or there about. changing just the min-width was not enough, it needed both changing

 

to point he topic to one of my choosing modify the following line

function sendColor() {
  if (connected) {
  if (color != null) {
  var message = new Paho.MQTT.Message(color.toString().replace('#', ''));
  message.destinationName = "theBreadBoard_Strip";
  client.send(message);
  color = null;
  }
  }
}



 

where is says "theBreadBoard_Strip", in the original it is "Benjamin_Strip" or similar, you can change this to suit your needs

 

OK, so now this allows the page to sent to my topic and has freed up some room for more tools

 

I have 4 topics used on my project

 

"theBreadBoard_Strip" to adjust the LED strips connected to my Infinion board, this is covered by the wheel already so nothing more to do on this end except slow it down a bit

"element14_IoT" to ping my system presence for other E14 members, I also subscribe to this to affect change in two of my units as you will see in other blogs

"NeoStar" allows me to control my STAR based on the WS2812 LED chips

"BYOB-PARTY" is used to announce the temperature of the party room and the dance floor (Do I need a jacket, I don't know, why don't I check to see how warm it will be ) this topic also has two sub topics

"BYOB-PARTY/PartyTemp"

"BYOB-PARTY/FloorTemp

 

A single subscription topic of "BYOB-PARTY/#" will capture any changes under the BYOB-PARTY so it saves a subscription. I want to use this topic to display the temperatures on the browser, this means the browser will need to become  an MQTT subscriber, I will need to discover how to do this.

 

First things first, adding the additional publication logic for the Star and the messageing

 

looking at this code in the main.js file you will get an idea how to add functionality

client = new Paho.MQTT.Client("ws://iot.eclipse.org/ws", "id-" + new Date().getTime());

var connected = false;
function onConnect() {
  connected = true;
};


client.connect({
  onSuccess: onConnect
});


looking at the first  line you see the connection being made, the date bit at the end of the line is just to create a random client ID for the connection

next we have a variable to hold the connection status used later in the code

the function "onConnect()" is not called yet, this is the target of a call back when the connection eventually gets established

the code at line 9 above is declaring the call back, as you can see it is passing in the call the name of the call back funtion, once the connection is established, the target function is called and the variable is set.

 

function sendColor() {
  if (connected) {
  if (color != null) {
  var message = new Paho.MQTT.Message(color.toString().replace('#', ''));
  message.destinationName = "theBreadBoard_Strip";
  client.send(message);
  color = null;
  }
  }
}


This is the real working code, it sends the colour to the iot.eclipse.org site for the MQTT broker to process it, the color variable is declared at the top of the file and when this function gets called it will publish the current value but how is it called, glad you ask

 

at the very end of the file you will see this statement

setInterval(sendColor, 100);

 

it is not contained within a function so the page will execute it automatically, it sets up a re-occur timer to call the function in this case every 100mS, you may want to slow this down to say 500mS but it is a user choice

 

so thats how the basic demo page works (Without going into the operation of the wheel etc)

 

now to add my additional functionality

I need 8 buttons, one for each mode the star is programmed for, I inserted this into the HTML Body of the page (I will include as an attachment the complete code so you can see exactly where I put it)

  <table align="center">
        <tr><th style=" color:white ; align-content:center  " >Star Menues</th></tr>
        <tr><td  style="background-color:crimson" class="text-center">
            <input type="button" id="Button10" onclick="sendStar('AUTO')" value="Auto" />
            <input type="button" id="Button1" onclick="sendStar('ROTATE')" value="ROTATE"   />
            <input type="button" id="Button3" onclick="sendStar('ROTATE2')" value="ROTATE2"   />
            <input type="button" id="Button4" onclick="sendStar('EXPAND')" value="EXPAND"  />
        </td></tr>
        <tr><td  style="background-color:crimson" class="text-center">
            <input type="button" id="Button5" onclick="sendStar('EXPAND2')" value="EXPAND2"   />
            <input type="button" id="Button6" onclick="sendStar('CYCLE')" value="CYCLE"   />
            <input type="button" id="Button7" onclick="sendStar('RAINBOW')" value="RAINBOW"  />
            <input type="button" id="Button8" onclick="sendStar('WIPE')" value="WIPE" />
         </td></tr>
        </table>


 

as you can see, every button has an onclick event that calls a function called sendStar("xxx") and passes the function the command we need

the function is simply added to the main.js file

 

here it is

function sendStar(mode) {
    if (connected) {
        starMessage = mode;
        if (starMessage != null) {
            var message = new Paho.MQTT.Message(starMessage.toString());
            message.destinationName = "NeoStar";
            client.send(message);
        }
    }
}


as you can see it is pretty much identical to the color send function. easy right!, not again the use of that "connected" variable to ensure a connection was made before trying to send anything

 

between the HTML and the java script, that adds the functionality needed for the star.

the text sender is equally as simple

 

here is the HTML

     <table align="center" >
        <tr><th style=" color:antiquewhite ; align-content:center  ">Send a message to the Message Board</th></tr>
        <tr><td ><input type="text" id="myText" /><input type="button" id="Button9" onclick="sendText()" value="Send Text" /></td></tr>
    </table>


 

and here is the java function

function sendText() {
    if (connected) {
        dispMessage = document.getElementById("myText").value;
        if (dispMessage != null) {
            var message = new Paho.MQTT.Message(dispMessage.toString());
            message.destinationName = "element14_IoT";
            client.send(message);
        }
    }
}


 

again, almost identical... nice

 

ok so what about the two temperature gauges I showed you in the opening screen shot, that as it happens, ended up relatively simple too once I completed a bit of research

 

I could not easily find the info on the PAHO site but a little google goes a long way

Server send push notifications to client browser without polling | oriolrius.cat

this still uses the PAHO libraries (Well I still stayed with them anyway), needed to perform a little on-screen (In Browser debugging to get it all working properly) but here is the result of the effort

 

at the top of the script where the connection is intially made, we need to add a call back for when messages arrive back from the broker

client = new Paho.MQTT.Client("ws://iot.eclipse.org/ws", "id-" + new Date().getTime());
client.onMessageArrived = onMessageArrived;


 

The "onConnect()" function is added to so the subscription is made automatically when the connected is made

var connected = false;
function onConnect() {
  connected = true;
  client.subscribe("BYOB-PARTY/#", { qos: 1 });
};


 

I simplified the call compared to the material I found and of course added my own topic to the subscription

now of course we need the function to receive the data

function onMessageArrived(message) {
    if (message.destinationName == 'BYOB-PARTY/PartyTemp') {
        // document.getElementById("partytemperature").innerHTML = message.payloadString;
        analog0 = message.payloadString;
    }
    else if (message.destinationName == 'BYOB-PARTY/FloorTemp') {
        //document.getElementById("floortemperature").innerHTML = message.payloadString;
        analog1 = message.payloadString;
    }
};


so this is a little different to the other functions, first of all it required some digging to discover all the additional sub elements of the message structure to allow the topic and content to be extracted, the commented out code was left there to show how to directly target a couple of div takes with IDs declared to receive the updates. I used this to get it working before adding the gauge controls

 

Pay close attention to the checking for the correct topics that the page is interested in, I discovered that there is quite a few calls made to this function in operation, not all with topic data so dont delete the check if your only looking at one topic

 

my function above checks the topic and depending on the one arrived, it will update a variable and then exit. these variables are used by the gauges automatically. I am not going to go into detail regarding the operation of the gauges as this is included in a tutorial set I have posted on the forums. for expediency, I added the scripting for the gauges to the main index.html form

this is the html to add the gauges

    <table align="center">
        <tr>
            <td ><canvas id="Canvas0"></canvas></td>
           <td ><canvas id="Canvas1"></canvas></td>
        </tr>
    </table>


 

the following script is added to the header section of the page and is the libraries so to speek

     <script>
         var Gauge = function (b) {
             function l(a, b) { for (var c in b) "object" == typeof b[c] && "[object Array]" !== Object.prototype.toString.call(b[c]) && "renderTo" != c ? ("object" != typeof a[c] && (a[c] = {}), l(a[c], b[c])) : a[c] = b[c] } function q() { z.width = b.width; z.height = b.height; A = z.cloneNode(!0); B = A.getContext("2d"); C = z.width; D = z.height; t = C / 2; u = D / 2; f = t < u ? t : u; A.i8d = !1; B.translate(t, u); B.save(); a.translate(t, u); a.save() } function v(a) {
                 var b = new Date; G = setInterval(function () {
                     var c = (new Date - b) / a.duration; 1 < c && (c = 1); var f = ("function" ==
   typeof a.delta?a.delta:M[a.delta])(c);a.step(f);1==c&&clearInterval(G)},a.delay||10)}function k(){G&&clearInterval(G);var a=I-n,h=n,c=b.animation;v({delay:c.delay,duration:c.duration,delta:c.fn,step:function(b){n=parseFloat(h)+a*b;E.draw()}})}function e(a){return a*Math.PI/180}function g(b,h,c){c=a.createLinearGradient(0,0,0,c);c.addColorStop(0,b);c.addColorStop(1,h);return c}function p(){var m=93*(f/100),h=f-m,c=91*(f/100),e=88*(f/100),d=85*(f/100);a.save();b.glow&&(a.shadowBlur=h,a.shadowColor=
   "rgba(0, 0, 0, 0.5)");a.beginPath();a.arc(0,0,m,0,2*Math.PI,!0);a.fillStyle=g("#ddd","#aaa",m);a.fill();a.restore();a.beginPath();a.arc(0,0,c,0,2*Math.PI,!0);a.fillStyle=g("#fafafa","#ccc",c);a.fill();a.beginPath();a.arc(0,0,e,0,2*Math.PI,!0);a.fillStyle=g("#eee","#f0f0f0",e);a.fill();a.beginPath();a.arc(0,0,d,0,2*Math.PI,!0);a.fillStyle=b.colors.plate;a.fill();a.save()}function w(a){var h=!1;a=0===b.majorTicksFormat.dec?Math.round(a).toString():a.toFixed(b.majorTicksFormat.dec);return 1<b.majorTicksFormat["int"]?
   (h=-1<a.indexOf("."),-1<a.indexOf("-")?"-"+(b.majorTicksFormat["int"]+b.majorTicksFormat.dec+2+(h?1:0)-a.length)+a.replace("-",""):""+(b.majorTicksFormat["int"]+b.majorTicksFormat.dec+1+(h?1:0)-a.length)+a):a}function d(){var m=81*(f/100);a.lineWidth=2;a.strokeStyle=b.colors.majorTicks;a.save();if(0===b.majorTicks.length){for(var h=(b.maxValue-b.minValue)/5,c=0;5>c;c++)b.majorTicks.push(w(b.minValue+h*c));b.majorTicks.push(w(b.maxValue))}for(c=0;c<b.majorTicks.length;++c)a.rotate(e(45+c*(270/(b.majorTicks.length-
   1)))),a.beginPath(),a.moveTo(0,m),a.lineTo(0,m-15*(f/100)),a.stroke(),a.restore(),a.save();b.strokeTicks&&(a.rotate(e(90)),a.beginPath(),a.arc(0,0,m,e(45),e(315),!1),a.stroke(),a.restore(),a.save())}function J(){var m=81*(f/100);a.lineWidth=1;a.strokeStyle=b.colors.minorTicks;a.save();for(var h=b.minorTicks*(b.majorTicks.length-1),c=0;c<h;++c)a.rotate(e(45+c*(270/h))),a.beginPath(),a.moveTo(0,m),a.lineTo(0,m-7.5*(f/100)),a.stroke(),a.restore(),a.save()}function s(){for(var m=55*(f/100),h=0;h<b.majorTicks.length;++h){var c=
   F(m,e(45+h*(270/(b.majorTicks.length-1))));a.font=20*(f/200)+"px Arial";a.fillStyle=b.colors.numbers;a.lineWidth=0;a.textAlign="center";a.fillText(b.majorTicks[h],c.x,c.y+3)}}function x(a){var h=b.valueFormat.dec,c=b.valueFormat["int"];a=parseFloat(a);var f=0>a;a=Math.abs(a);if(0<h){a=a.toFixed(h).toString().split(".");h=0;for(c-=a[0].length;h<c;++h)a[0]="0"+a[0];a=(f?"-":"")+a[0]+"."+a[1]}else{a=Math.round(a).toString();h=0;for(c-=a.length;h<c;++h)a="0"+a;a=(f?"-":"")+a}return a}function F(a,b){var c=
   Math.sin(b),f=Math.cos(b);return{x:0*f-a*c,y:0*c+a*f}}function N(){a.save();for(var m=81*(f/100),h=m-15*(f/100),c=0,g=b.highlights.length;c<g;c++){var d=b.highlights[c],r=(b.maxValue-b.minValue)/270,k=e(45+(d.from-b.minValue)/r),r=e(45+(d.to-b.minValue)/r);a.beginPath();a.rotate(e(90));a.arc(0,0,m,k,r,!1);a.restore();a.save();var l=F(h,k),p=F(m,k);a.moveTo(l.x,l.y);a.lineTo(p.x,p.y);var p=F(m,r),n=F(h,r);a.lineTo(p.x,p.y);a.lineTo(n.x,n.y);a.lineTo(l.x,l.y);a.closePath();a.fillStyle=d.color;a.fill();
       a.beginPath();a.rotate(e(90));a.arc(0,0,h,k-0.2,r+0.2,!1);a.restore();a.closePath();a.fillStyle=b.colors.plate;a.fill();a.save()}}function K(){var m=12*(f/100),h=8*(f/100),c=77*(f/100),d=20*(f/100),k=4*(f/100),r=2*(f/100),l=function(){a.shadowOffsetX=2;a.shadowOffsetY=2;a.shadowBlur=10;a.shadowColor="rgba(188, 143, 143, 0.45)"};l();a.save();n=0>n?Math.abs(b.minValue-n):0<b.minValue?n-b.minValue:Math.abs(b.minValue)+n;a.rotate(e(45+n/((b.maxValue-b.minValue)/270)));a.beginPath();a.moveTo(-r,-d);a.lineTo(-k,
       0);a.lineTo(-1,c);a.lineTo(1,c);a.lineTo(k,0);a.lineTo(r,-d);a.closePath();a.fillStyle=g(b.colors.needle.start,b.colors.needle.end,c-d);a.fill();a.beginPath();a.lineTo(-0.5,c);a.lineTo(-1,c);a.lineTo(-k,0);a.lineTo(-r,-d);a.lineTo(r/2-2,-d);a.closePath();a.fillStyle="rgba(255, 255, 255, 0.2)";a.fill();a.restore();l();a.beginPath();a.arc(0,0,m,0,2*Math.PI,!0);a.fillStyle=g("#f0f0f0","#ccc",m);a.fill();a.restore();a.beginPath();a.arc(0,0,h,0,2*Math.PI,!0);a.fillStyle=g("#e8e8e8","#f5f5f5",h);a.fill()}
             function L(){a.save();a.font=40*(f/200)+"px Led";var b=x(y),h=a.measureText("-"+x(0)).width,c=f-33*(f/100),g=0.12*f;a.save();var d=-h/2-0.025*f,e=c-g-0.04*f,h=h+0.05*f,g=g+0.07*f,k=0.025*f;a.beginPath();a.moveTo(d+k,e);a.lineTo(d+h-k,e);a.quadraticCurveTo(d+h,e,d+h,e+k);a.lineTo(d+h,e+g-k);a.quadraticCurveTo(d+h,e+g,d+h-k,e+g);a.lineTo(d+k,e+g);a.quadraticCurveTo(d,e+g,d,e+g-k);a.lineTo(d,e+k);a.quadraticCurveTo(d,e,d+k,e);a.closePath();d=a.createRadialGradient(0,c-0.12*f-0.025*f+(0.12*f+0.045*f)/
             2,f/10,0,c-0.12*f-0.025*f+(0.12*f+0.045*f)/2,f/5);d.addColorStop(0,"#888");d.addColorStop(1,"#666");a.strokeStyle=d;a.lineWidth=0.05*f;a.stroke();a.shadowBlur=0.012*f;a.shadowColor="rgba(0, 0, 0, 1)";a.fillStyle="#babab2";a.fill();a.restore();a.shadowOffsetX=0.004*f;a.shadowOffsetY=0.004*f;a.shadowBlur=0.012*f;a.shadowColor="rgba(0, 0, 0, 0.3)";a.fillStyle="#444";a.textAlign="center";a.fillText(b,-0,c);a.restore()}Gauge.Collection.push(this);this.config={renderTo:null,width:200,height:200,title:!1,
                 maxValue:100,minValue:0,majorTicks:[],minorTicks:10,strokeTicks:!0,units:!1,valueFormat:{"int":3,dec:2},majorTicksFormat:{"int":1,dec:0},glow:!0,animation:{delay:10,duration:250,fn:"cycle"},colors:{plate:"#fff",majorTicks:"#444",minorTicks:"#666",title:"#888",units:"#888",numbers:"#444",needle:{start:"rgba(240, 128, 128, 1)",end:"rgba(255, 160, 122, .9)"}},highlights:[{from:20,to:60,color:"#eee"},{from:60,to:80,color:"#ccc"},{from:80,to:100,color:"#999"}]};var y=0,E=this,n=0,I=0,H=!1;this.setValue=
                 function(a){n=b.animation?y:a;var d=(b.maxValue-b.minValue)/100;I=a>b.maxValue?b.maxValue+d:a<b.minValue?b.minValue-d:a;y=a;b.animation?k():this.draw();return this};this.setRawValue=function(a){n=y=a;this.draw();return this};this.clear=function(){y=n=I=this.config.minValue;this.draw();return this};this.getValue=function(){return y};this.onready=function(){};l(this.config,b);this.config.minValue=parseFloat(this.config.minValue);this.config.maxValue=parseFloat(this.config.maxValue);b=this.config;n=
                 y=b.minValue;if(!b.renderTo)throw Error("Canvas element was not specified when creating the Gauge object!");var z=b.renderTo.tagName?b.renderTo:document.getElementById(b.renderTo),a=z.getContext("2d"),A,C,D,t,u,f,B;q();this.updateConfig=function(a){l(this.config,a);q();this.draw();return this};var M={linear:function(a){return a},quad:function(a){return Math.pow(a,2)},quint:function(a){return Math.pow(a,5)},cycle:function(a){return 1-Math.sin(Math.acos(a))},bounce:function(a){a:{a=1-a;for(var b=0,
                 c=1;;b+=c,c/=2)if(a>=(7-4*b)/11){a=-Math.pow((11-6*b-11*a)/4,2)+Math.pow(c,2);break a}a=void 0}return 1-a},elastic:function(a){a=1-a;return 1-Math.pow(2,10*(a-1))*Math.cos(30*Math.PI/3*a)}},G=null;a.lineCap="round";this.draw=function(){if(!A.i8d){B.clearRect(-t,-u,C,D);B.save();var g={ctx:a};a=B;p();N();J();d();s();b.title&&(a.save(),a.font=24*(f/200)+"px Arial",a.fillStyle=b.colors.title,a.textAlign="center",a.fillText(b.title,0,-f/4.25),a.restore());b.units&&(a.save(),a.font=22*(f/200)+"px Arial",
                 a.fillStyle=b.colors.units,a.textAlign="center",a.fillText(b.units,0,f/3.25),a.restore());A.i8d=!0;a=g.ctx;delete g.ctx}a.clearRect(-t,-u,C,D);a.save();a.drawImage(A,-t,-u,C,D);if(Gauge.initialized)L(),K(),H||(E.onready&&E.onready(),H=!0);else var e=setInterval(function(){Gauge.initialized&&(clearInterval(e),L(),K(),H||(E.onready&&E.onready(),H=!0))},10);return this}};Gauge.initialized=!1;
         (function(){var b=document,l=b.getElementsByTagName("head")[0],q=-1!=navigator.userAgent.toLocaleLowerCase().indexOf("msie"),v="@font-face {font-family: 'Led';src: url('fonts/digital-7-mono."+(q?"eot":"ttf")+"');}",k=b.createElement("style");k.type="text/css";if(q)l.appendChild(k),l=k.styleSheet,l.cssText=v;else{try{k.appendChild(b.createTextNode(v))}catch(e){k.cssText=v}l.appendChild(k);l=k.styleSheet?k.styleSheet:k.sheet||b.styleSheets[b.styleSheets.length-1]}var g=setInterval(function(){if(b.body){clearInterval(g);
             var e=b.createElement("div");e.style.fontFamily="Led";e.style.position="absolute";e.style.height=e.style.width=0;e.style.overflow="hidden";e.innerHTML=".";b.body.appendChild(e);setTimeout(function(){Gauge.initialized=!0;e.parentNode.removeChild(e)},250)}},1)})();Gauge.Collection=[];
         Gauge.Collection.get=function(b){if("string"==typeof b)for(var l=0,q=this.length;l<q;l++){if((this[l].config.renderTo.tagName?this[l].config.renderTo:document.getElementById(this[l].config.renderTo)).getAttribute("id")==b)return this[l]}else return"number"==typeof b?this[b]:null};function domReady(b){window.addEventListener?window.addEventListener("DOMContentLoaded",b,!1):window.attachEvent("onload",b)}
         domReady(function(){function b(b){for(var e=b[0],d=1,g=b.length;d<g;d++)e+=b[d].substr(0,1).toUpperCase()+b[d].substr(1,b[d].length-1);return e}for(var l=document.getElementsByTagName("canvas"),q=0,v=l.length;q<v;q++)if("canv-gauge"==l[q].getAttribute("data-type")){var k=l[q],e={},g,p=parseInt(k.getAttribute("width"),10),w=parseInt(k.getAttribute("height"),10);e.renderTo=k;p&&(e.width=p);w&&(e.height=w);p=0;for(w=k.attributes.length;p<w;p++)if(g=k.attributes.item(p).nodeName,"data-type"!=g&&"data-"==
         g.substr(0,5)){var d=g.substr(5,g.length-5).toLowerCase().split("-");if(g=k.getAttribute(g))switch(d[0]){case "colors":d[1]&&(e.colors||(e.colors={}),"needle"==d[1]?(d=g.split(/\s+/),e.colors.needle=d[0]&&d[1]?{start:d[0],end:d[1]}:g):(d.shift(),e.colors[b(d)]=g));break;case "highlights":e.highlights||(e.highlights=[]);g=g.split(",");for(var d=0,J=g.length;d<J;d++){var s=g[d].replace(/^\s+|\s+$/g,"").split(/\s+/),x={};s[0]&&""!=s[0]&&(x.from=s[0]);s[1]&&""!=s[1]&&(x.to=s[1]);s[2]&&""!=s[2]&&(x.color=
         s[2]);e.highlights.push(x)}break;case "animation":d[1]&&(e.animation||(e.animation={}),"fn"==d[1]&&/^\s*function\s*\(/.test(g)&&(g=eval("("+g+")")),e.animation[d[1]]=g);break;default:d=b(d);if("onready"==d)continue;if("majorTicks"==d)g=g.split(/\s+/);else if("strokeTicks"==d||"glow"==d)g="true"==g?!0:!1;else if("valueFormat"==d)if(g=g.split("."),2==g.length)g={"int":parseInt(g[0],10),dec:parseInt(g[1],10)};else continue;e[d]=g}}e=new Gauge(e);k.getAttribute("data-value")&&e.setRawValue(parseFloat(k.getAttribute("data-value")));
             k.getAttribute("data-onready")&&(e.onready=function(){eval(this.config.renderTo.getAttribute("data-onready"))});e.draw()}});window.Gauge=Gauge;
       
    </script>
    <style type="text/css">
    .centerText{
   text-align: center;
}
    .divBorder {
    border: 2px solid;
    border-radius: 15px;
    width: 810px;
    text-align: center;
    box-shadow: 6px 6px 3px #888888
}
    .myRange {
    border: 2px solid;
    height: 10px;
    display: block;
    margin: 20px;
    vertical-align: middle;
    text-align: center;
    border-radius: 5px;
    background-color: #444;
    box-shadow: 6px 6px 3px #888888
}


        .auto-style3 {
            width: 123px;
            height: 28px;
        }
        .auto-style4 {
            height: 28px;
        }
        .auto-style6 {
            width: 149px;
            text-align: center;
        }


    </style>


 

below the added HTML we also need the script to configure and activate the gauges

<script>
     var gauge0 = new Gauge({
         renderTo: 'Canvas0',
         width: 200, height: 200,
         maxValue: 100,
         valueFormat: { int: 2, dec: 2 },
         glow: true,
         units: 'Deg C', title: 'Party Room',
         majorTicks: ['0', '20', '40', '60', '80', '100'],
         strokeTicks: true,
         highlights: [{from: 00,to: 20,color: 'PaleGreen'}, {from: 20,to: 60,color: 'Khaki'}, {from: 60,to: 100,color: 'LightSalmon'}],
         animation: {delay: 10, duration: 300,fn: 'bounce' }
     });
     gauge0.onready = function () { setInterval(function () { gauge0.setValue(analog0); }, 1000); };
     gauge0.draw();


     var gauge1 = new Gauge({
         renderTo: 'Canvas1',
         width: 200, height: 200,
         maxValue: 100,
         units: 'Deg C', title: 'Dance Floor',
         valueFormat: { int: 2, dec: 2 },
         glow: true,
         majorTicks: ['0', '20', '40', '60', '80', '100'],
         strokeTicks: true,
         highlights: [{ from: 00, to: 20, color: 'PaleGreen' }, { from: 20, to: 60, color: 'Khaki' }, { from: 60, to: 100, color: 'LightSalmon' }],
         animation: { delay: 10, duration: 300, fn: 'bounce' }
     });
     gauge1.onready = function () {setInterval(function () {gauge1.setValue(analog1);}, 1000);};
     gauge1.draw();
</script>


This is where you get to configure the gauges as you need, in my case, setting the size, the range of the ticks and the format of the data.

the gauge1.onready functions activate the gauges and set a timer (1000) once a second in this case and as you can see, the analog variable mentioned above is now used to pass in the current value, the nice thing here is that the receiving of MQTT data and the updating of the gauge is completely separated making the code more stable and responsive.

 

and thats all there is too it, simple right (Well straight forward anyway)

 

if you have questions, please ask, dont be afraid to try this

 

Oh and the best thing of all, this complete web solution was hosted by the Arduino YUN itself, you dont have to expose your web pages to the outside world if you dont want to, of course if you do you can, and infact Cabe's demo was hosted right from his GIT source site... sweet.

 

I will attach the complete set-up for the yun as a zip file, simply extract it and save to the root of the uSD card to go into the yu,  the rest is simple, browse to arduino.local/sd and your page will appear

 

you should end up with an Arduino folder in the root of the SD card

The participants of the The Internet of Holiday Lights RoadTest Plus received these three devices:

  • Infineon Lighting RGB LED Arduino Shield
  • Arduino Yún
  • Arduino Uno

 

 

  • Evaluation Type:Evaluation Boards
  • Application you used the part in:[Christmas Wreath of Things] Internet of Holiday Lights - summary
  • Was everything in the box required?:Yes - complete
  • Comparable Products/Other parts you considered:There are plethora of other IoT capable development boards and RGB drivers
  • What were the biggest problems encountered?:USB connection to PC of the Arduino Yún

 

Scoring

Product Performed to Expectations:7
Specifications were sufficient to design with:10
Demo Software was of good quality:9
Demo was easy to use:7
Support materials were available:10
The price to performance ratio was good:10

TotalScore:53 / 60

 

Infineon Lighting RGB LED Arduino Shield

 

This board is tagged as an RGB driver shield. But it is actually a fully capable microcontroller all by itself.

The manual for the evaluation board says 'XMC1200 Microcontroller Series for Industrial Applications'.

And that's no lie. The board hosts an Infineon XMC1202. One of its peripherals is 'Brightness Color Control Unit (BCCU) for LED lighting control'.

 

When using it as an Arduino shield, your sketch talks to the controller using i2c.
But since the shield sports a debug header, you could just as well program the on-board controller.

shabaz has written about that in his RGB LED Shield from Infineon - Getting Started Guide.

 

Using the board is not difficult, but I think Infineon can do  a better job explaining the configuration parameters and the limits calculations.

It is all understandable if you read their documentation for the shield and inspect the schematics a few times.

A nice narrative explanation of the concepts wouldn't be bad though.

However, I give Infineon an A for the completeness of specifications and principles of LED driving operation - and the elaborate explanation of that part.

Several road testers have made a library for the board. Compare the Infineon RGB libraries that spawned from the Internet of Holiday Lights

 

A watch-out: the shield uses D14 and D15 for i2c.

This can be an issue when this board is stacked on other shields that don't have these two 'newer' pins (e.g.: some of SparkFun and Velleman shields).

I had to do some bodge-wiring in my design:

 

And a second watch-out. This board (at least my board) emits a high frequency pitch when driving the leds. The pitch changes depending on the intensity.

This can be annoying if you're using it in a silent place - and your dog may complain.


Arduino Yún

 

I'm not going to write down the capabilities of this board. I would only repeat what thousands of other reviewers have done before.

I'll just tell about my first experiences with the Yún.

 

Photo 17-01-15 17 59 12.jpg

 

I have skills in both Arduino development and Linux. So the only step I had to talke was to learn how to link the two worlds and how to get each of them connected to the PC.

 

Making the sketch world talk to the Linux world was so simple. I loaded the Bridge TimeCheck sketch, inspected it, and done.

It's all self-explanatory. Also the other interaction principles explained on arduino.cc Yún getting started page worked straight away.

Getting the Yún up and running and connecting it to my home WiFi was also easy. Follow instructions, and done. Works.

The same for telnetting into the Linux part. I used the instructions for Putty and was on the Linux prompt in minutes.

I've used the ATMega timer interrupts in my sketch. It worked well with calling the Linux part. So they really run beautifully in parallel.

 

The USB connectivity is another story. It's been playing up from the beginning that I installed the Yún and is continuing to be a * in the *.

Disclaimer: I have a recent PC, recent OS and the drivers all installed ok.

But at regular times, the Yún disappears from the radar. And it doesn't get re-listed when I unplug it and plug it in again.
Even rebooting the PC does not help. And I have pushed all possible reset buttons on the Yún to no avail.

 

The symptoms are these:

- the Yún is not visible in the IDE.

- there's no COM port assigned to a Yún

- the Yún appears as a problematic device in the device manager.

 

 

 

Fixing it requires one or two steps. I haven't figured out why it is sometimes one and sometimes two steps.

If I select the Choose Driver from the device manager, sometimes the Arduino Yun driver is listed.

In that case I select that driver, push next, and the Yún is back in the USB world.

Sometimes the Arduino Yun driver is not listed. Then I have to first select the standard Port driver first.

 

After that I can go back into the 'flagged device', and the Arduino Yun driver is available.

Upon re-selecting that, the Yun is USB-able again.

So yes, strange. May be related to my PC - but still, it's a normal recent one, and it happens.

 

And what's that with the USB and Ethernet connector position on the Yún? They interfere with almost every shield in existence.

Either the pins of your shield are to short. Or when they are long enough, the two metal connectors shortcut something on the underside of your shield. Why?

None of my shields I have at home fitted (SainSmart, Adafruit, Velleman, Infineon).

 

The internet of things talks

 

I drove the memory use of the Yún to red when I made a talking sketch.

I used the Yún to read out aloud the payload of messages I subscribed to .

Sketch uses 28,454 bytes (99%) of program storage space. Maximum is 28,672 bytes.

Global variables use 1,208 bytes (47%) of dynamic memory, leaving 1,352 bytes for local variables. Maximum is 2,560 bytes.

 

But it works. It took me 1 hour to adapt the TSS example to the Yún and latest IDE release, and 3 hours to bring the memory under the maximum.

Here you can hear the Yún shout out my name once, and peteroakes name twice.

The amplifier is a Science Fair 200 in One kit. That is my tribute to Radio Shack. A company that I care for a lot. Tandy: respect forever!

 

Early sketch (Works, there's a delay sometimes - but it can be a start point to get you going. You go and debug it please):

 

// needed for MQTT and Process lib
#include <Bridge.h>
// MQTT  includes start




#include <SPI.h>
#include <YunClient.h>
#include <IPStack.h>
#include <Countdown.h>
#include <MQTTClient.h>




#include <TTS.h>
TTS text2speech;  // speech output is digital pin 10








YunClient c; // replace by a YunClient if running on a Yun
IPStack ipstack(c);
MQTT::Client<IPStack, Countdown> client = MQTT::Client<IPStack, Countdown>(ipstack);




bool messageChanged = false;


// start MQTT functionality ====================================




void mqttInit() {
//  Ethernet.begin(mac); // replace by Bridge.begin() if running on a Yun
  Bridge.begin();


  // // Serial.println("MQTT Internet of Holiday Lights example");
  connect();
} 


void messageArrived(MQTT::MessageData& md) // this handler is called when a subscribed MQTT message arrives
{
  MQTT::Message &message = md.message;
text2speech.say((char*)message.payload); //    Test_Speech();
  client.yield(1000);


}


void connect()  // connect to the MQTT broker
{
  ipstack.connect("iot.eclipse.org", 1883);

  // // Serial.println("MQTT connecting");
  MQTTPacket_connectData data = MQTTPacket_connectData_initializer;      
  data.MQTTVersion = 3;
  data.clientID.cstring = "1cfee8dd0afc_yun"; //(char*)_id;
  client.connect(data);
  client.subscribe("element14_IoT", MQTT::QOS1, messageArrived);  
}


void sendAliveMessage() {
  if (!client.isConnected())
    connect();

  MQTT::Message message;

  message.qos = MQTT::QOS1;
  message.retained = false;
  message.dup = false;
  message.payload = (void *)"jancumps"; //(void*)payLoadBuf;
  message.payloadlen = 8; // strlen(payLoadBuf)+1;
  client.publish("element14_IoT", message);
  client.yield(1000);
} 


// end MQTT functionality ==============================


/*
void Test_Speech() {
// text2speech.setPitch(6); //higher values = lower voice pitch
// strcpy(printbuf, "Hello  master! How are you doin?");
text2speech.say(printbuf);
/* delay(500);
text2speech.setPitch(1); //lower values = higher voice pitch
strcpy(text, "I am fine, thankyou.");
text2speech.say(text);*/

/*
}


*/


void setup()
{


//  Serial.begin(9600);
//  delay(10000); // give me time to start the yun monitor
  // MQTT related tasks
  mqttInit();
}


void loop()
{

  // non timer related functionality comes here
//  static unsigned int uCounter = 0;
sendAliveMessage();
delay(60000);


//  uCounter++;


}

 

 

 

Arduino UNO

 

The most reviewed gizmo in the world. I didn't use it in my final design.

It had prototyping duty.

All not-IoT related parts have been prototyped on the UNO when the Yún was already ripping away on the Internet of Things.

 

IMG_3990.JPG


Hello Everyone, This is my second blog post for the Internet Of Holiday Lighting Road Test. In this post I will discussing how my setup for the Bluetooth Communication Between My phone and Arduino YUN, Below is the photo of my setup:


                              WP_20150116_20_31_11_Pro.jpg

                        

As you can see there are only 4 main components to this setup, Arduino Yun, Infineon RGB shield, HC-06 Bluetooth module and the RGB strip itself, so lets talk about the individual components:


Arduino YUN : Arduino yun is a great piece of hardware its easy to setup, easy to work with and almost free form the hassle of wire, I was fortunate to get it for free and to be able to experiment with it is a big deal for me, as I am a student and have no particular source of income I am really grateful to Element14 for giving me this opportunity. The setup of arduino yun is really simple if you watch these videos by Julian Ilett  which I did.

 

         

      

 

 

Infineon RGB Shield : The Infineon RGB shield is easy to work with and excellent i color reproduction, also the connectors for the RGB strip and

the power are nice, However the source material on it is less and the demo code is difficult to understand, what I did is took the demo code and just modified it according to my needs, I didn't wanted to change it so much that it stops working. The code for this project is given below :

 



// Infineon RGB_LED_Shield_Master_Tester
  // by Michelle Chia


  // Demonstrates I2C communication with the RGB LED Shield for safe configuration. Tested at 48Vin, 6V forward voltage LED. LED current up to 350mA.
  // Modified 13 August 2014

  #define ADDRESS                    0x15EUL

  #define INTENSITY_RED              0x11U
  #define INTENSITY_GREEN            0x12U
  #define INTENSITY_BLUE    0x13U
  #define INTENSITY_RGB              0x14U
  #define CURRENT_RED                0x21U
  #define CURRENT_GREEN              0x22U
  #define CURRENT_BLUE              0x23U
  #define CURRENT_RGB                0x24U
  #define OFFTIME_RED                0x41U
  #define OFFTIME_GREEN              0x42U
  #define OFFTIME_BLUE    0x43U
  #define WALKTIME                  0x50U
  #define DIMMINGLEVEL              0x60U
  #define FADERATE                  0x61U

  #define READ_INTENSITY_RED        0x81U
  #define READ_INTENSITY_GREEN      0x82U
  #define READ_INTENSITY_BLUE        0x83U
  #define READ_CURRENT_RED          0x84U
  #define READ_CURRENT_GREEN        0x85U
  #define READ_CURRENT_BLUE          0x86U
  #define READ_OFFTIME_RED          0x87U
  #define READ_OFFTIME_GREEN        0x88U
  #define READ_OFFTIME_BLUE          0x89U
  #define READ_WALKTIME              0x8AU
  #define READ_DIMMINGLEVEL          0x8BU
  #define READ_FADERATE              0x8CU



  #define SAVEPARAMETERS            0xA0U

  #define BCCUMODID                  0x50030008U
  #define CHIPID                    0x40010004U
  #define REDINTS                    0x500300A0U // BCCU_CH5
  #define REDINT                    0x500300A4U
  #define BLUEINTS                  0x50030078U
  #define STARTWALK                  0x50030018U

  #include <Wire.h>



  char string;
  unsigned int c[2] = {0};
  unsigned int d[4] = {0};
  unsigned int on = 0;
  unsigned int message = 0;
  unsigned long redcurr = 0;
  unsigned long greencurr = 0;
  unsigned long bluecurr = 0;
  unsigned long redoff = 0;
  unsigned long greenoff = 0;
  unsigned long blueoff = 0;
  unsigned long redint = 0x00;
  unsigned long greenint = 0x00;
  unsigned long blueint = 0x00;
  unsigned long fadetime = 0x00;
  unsigned long walk = 0x00;
  unsigned long brightness = 1;



void setup() {     


    Serial1.begin(9600);

    Wire.begin();

    while (on != 1) // Wait for shield to respond, keep setting the values till it does
    {
      I2CWRITE2BYTES (ADDRESS, FADERATE, 0x0000); // Immediate fade
      I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0000); // 0% brightness level
      on = I2CREAD(ADDRESS, READ_DIMMINGLEVEL); // Request for brightness level
      if (message == 1 && on == 0) // If message received and dimming level = 0%, "message" is set in the I2CREAD function
      {
        message = 0;
        on = 1; // break out of loop
      }
    }

    // now we will chane the values again and wait till there being red back
    while (redcurr != 0x15 || greencurr != 0x15 || bluecurr != 0x15 || redoff != 0x38 || greenoff != 0x39 || blueoff != 0x38 || brightness != 0)
    {
        I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0000, 0x000, 0x0000); // Off Light
  // Ensure that parameters are set up correctly. Read back and check. If wrong, write and read again.
        redcurr = I2CREAD (ADDRESS, READ_CURRENT_RED); // Read the red current intensity
  greencurr = I2CREAD (ADDRESS, READ_CURRENT_GREEN); // Read the green current intensity
  bluecurr = I2CREAD (ADDRESS, READ_CURRENT_BLUE); // Read the blue current intensity
  redoff = I2CREAD (ADDRESS, READ_OFFTIME_RED); // Read the off-time of the red channel
  greenoff = I2CREAD (ADDRESS, READ_OFFTIME_GREEN); // Read the off-time of the green channel
  blueoff = I2CREAD (ADDRESS, READ_OFFTIME_BLUE); // Read the off-time of the blue channel
  brightness = I2CREAD (ADDRESS, READ_DIMMINGLEVEL); // Read the dimming level

        I2CWRITE2BYTES (ADDRESS, OFFTIME_RED, 0x38); // Set off-time of red channel to 0x38
  I2CWRITE2BYTES (ADDRESS, OFFTIME_GREEN, 0x39); // Set off-time of green channel to 0x39
  I2CWRITE2BYTES (ADDRESS, OFFTIME_BLUE, 0x38); // Set off-time of blue channel to 0x38
  I2CWRITE2BYTES (ADDRESS, CURRENT_RED, 0x15); // Set current intensity of red channel to 0x15
  I2CWRITE2BYTES (ADDRESS, CURRENT_GREEN, 0x15); // Set current intensity of green channel to 0x15
  I2CWRITE2BYTES (ADDRESS, CURRENT_BLUE, 0x15); // Set current intensity of blue channel to 0x15
  I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0000); // LEDs all off as any intensity * 0 will = 0
    }

    delay(100); // OK, so were getting response from the infineon so read back values from slave and print them
    Serial.print("Red Int: ");    redint = I2CREAD (ADDRESS, READ_INTENSITY_RED); // request from shield red colour intensity
    Serial.print("Green Int: ");  greenint = I2CREAD (ADDRESS, READ_INTENSITY_GREEN); // request from shield green colour intensity
    Serial.print("Blue Int: ");    blueint = I2CREAD (ADDRESS, READ_INTENSITY_BLUE); // request from shield blue colour intensity
    Serial.print("Red Curr: ");    redcurr = I2CREAD (ADDRESS, READ_CURRENT_RED); // request from shield peak current reference of red channel
    Serial.print("Green Curr ");  greencurr = I2CREAD (ADDRESS, READ_CURRENT_GREEN); // request from shield peak current reference of green channel
    Serial.print("Blue Curr: ");  bluecurr = I2CREAD (ADDRESS, READ_CURRENT_BLUE); // request from shield peak current reference of blue channel
    Serial.print("Red PWM: ");    redoff = I2CREAD (ADDRESS, READ_OFFTIME_RED); // request from shield off-time of red channel
    Serial.print("Green PWM: ");  greenoff = I2CREAD (ADDRESS, READ_OFFTIME_GREEN); // request from shield off-time of green channel
    Serial.print("Blue PWM: ");    blueoff = I2CREAD (ADDRESS, READ_OFFTIME_BLUE); // request from shield off-time of blue channel
    Serial.print("Walk: ");        walk = I2CREAD (ADDRESS, READ_WALKTIME); // request from shield walk-time
    Serial.print("Brightness: ");  brightness = I2CREAD (ADDRESS, READ_DIMMINGLEVEL); // request from shield brightness level
    Serial.print("FadeTime: ");    fadetime = I2CREAD (ADDRESS, READ_FADERATE); // request from shield fade rate

    // now setup for test

    I2CWRITE2BYTES (ADDRESS, OFFTIME_RED, 0x38); // Set off-time of red channel to 0x38
    I2CWRITE2BYTES (ADDRESS, OFFTIME_GREEN, 0x39); // Set off-time of green channel to 0x39
    I2CWRITE2BYTES (ADDRESS, OFFTIME_BLUE, 0x38); // Set off-time of blue channel to 0x38
    I2CWRITE6BYTES (ADDRESS, CURRENT_RGB, 0x80, 0x80, 0x80); // Set current of red channel to 0x80 = 780mA
    I2CWRITE2BYTES (ADDRESS, FADERATE, 0x0000); // Fade Rate between intensities --> 0.0s
    I2CWRITE2BYTES (ADDRESS, WALKTIME, 0x0000); // walk time between colors = 0s
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0555, 0x0555, 0x0555); // low level White Light
    I2CWRITE2BYTES (ADDRESS, DIMMINGLEVEL, 0x0FFF); // Maximum dimming level means inensity settings are directly used
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0);



}

  // the loop routine runs over and over again forever:
  void loop() {
    String msg = "" ;



  if(Serial1.available()>0)
  {
    while(Serial1.available()>0)
    {
    msg += char(Serial1.read());
    delay(100);
    if(msg=="red"){
  I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0); // red
    delay(100);
  if(Serial1.available()>0){
    break;
      }
    } // wait 1000ms
  else if(msg=="green"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0); // green
    delay(100);
    if(Serial1.available()>0){
    break;
      }
  }
    else if(msg=="blue"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0fff); // blue
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }

    else if(msg=="white"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0fff, 0x0fff); // white
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }
    else if(msg=="purple"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0fff); // purple
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }
    else if(msg=="yellow"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0aaa, 0x0); // blue
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }
    else if(msg=="cyan"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0fff); // cyan
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }
    else if(msg=="pink"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0, 0x0333); // pink
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }
    else if(msg=="orange"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0fff, 0x0444, 0x0); // orange
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }
    else if(msg=="aqua"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0aaa, 0x0fff); // aqua
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }
    else if(msg=="teal"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0fff, 0x0444); // teal
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }
    else if(msg=="off"){
    I2CWRITE6BYTES (ADDRESS, INTENSITY_RGB, 0x0, 0x0, 0x0); // off
    delay(100);
    if(Serial1.available()>0){
    break;
      }
    }


  Serial.println(msg);
  }




  Serial1.flush();
}

    // change lamp colour to red

  }
//  }







// Infineon functions follow
/*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                  int Command - Defined I2C Commands i.e. INTENSITY_RED, INTENSITY_GREEN, INTENSITY_BLUE
                  unsigned int Data - 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 2 bytes of word to the I2C bus line
  */

  void I2CWRITE2BYTES (int Address, int Command, unsigned int Data)
  {
    unsigned int upperByte, lowerByte; // Separate 4 byte data into 2 byte values
    lowerByte = Data;
    upperByte = Data >> 8;

    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // Putting address into correct format
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write

    Wire.beginTransmission(byte(upperSLAD)); // Start I2C transmission
    Wire.write(byte(lowerSLAD)); // address lower 8 bits of i2c address
    Wire.write(byte(Command)); // write command
    Wire.write(byte(upperByte)); // write data
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);

  }
  /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                  int Command - Defined I2C Commands i.e. INTENSITY_RGB, CURRENT_RGB
                  unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree - Three 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 6 bytes of word to the I2C bus line
  */

  void I2CWRITE6BYTES (unsigned int Address, unsigned int Command, unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree) // DataOne: Red, DataTwo: Green, DataThree: Blue
  {
    unsigned int upperByte, lowerByte; // Split each Data parameter into upper and lower 8 bytes because I2C format sends 8 bytes of data each time
    lowerByte = DataOne;
    upperByte = DataOne >> 8;

    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write

    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    lowerByte = DataTwo;
    upperByte = DataTwo >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    lowerByte = DataThree;
    upperByte = DataThree >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);

  }

/*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                  int Command - Defined I2C Commands i.e. DMX16Bit
                  unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree, usigned int DataFour, unsigned int DataFive - Three 16bit data to be written to slave
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 12 bytes of word to the I2C bus line
  */

  void I2CWRITE12BYTES (unsigned int Address, unsigned int Command, unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree, unsigned int DataFour, unsigned int DataFive, unsigned int DataSix) // DataOne: Red, DataTwo: Green, DataThree: Blue
  {
    unsigned int upperByte, lowerByte;
    lowerByte = DataOne;
    upperByte = DataOne >> 8;

    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write

    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command)); // write command
    Wire.write(byte(upperByte)); // write 2 bytes
    Wire.write(byte(lowerByte));

    lowerByte = DataTwo;
    upperByte = DataTwo >> 8;
    Wire.write(byte(upperByte)); // write next two bytes
    Wire.write(byte(lowerByte));

    lowerByte = DataThree;
    upperByte = DataThree >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataFour;
    upperByte = DataFour >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataFive;
    upperByte = DataFive >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));


    lowerByte = DataSix;
    upperByte = DataSix >> 8;
    Wire.write(byte(upperByte));
    Wire.write(byte(lowerByte));
    Wire.endTransmission(true);

  }

  /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                  int Command - Defined read I2C Commands i.e. READ_INTENSITY_RED, READ_INTENSITY_GREEN, READ_INTENSITY_BLUE
  Parameters (OUT): None
  Return Value: Requested data from Shield will be sent back
  Description: This function will request 2 bytes of word from the shield
  */

  unsigned int I2CREAD (unsigned int Address, unsigned int Command) // Returns data sent by slave
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;

    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.endTransmission(false); // false for Repeated Start

    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.requestFrom(upperSLAD, 2, true);
    unsigned int data = 0;

    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      message = 1;
      c[i] = Wire.read(); // receive a byte as character
      i++;

    }
    Wire.endTransmission(true);

    data = c[1]; // write data to serial monitor. c[1] is higher byte
    data = (data << 8) | c[0];  // shift left and combine with lower byte
    Serial.print("0x");
    if (data < 0x1000)
        Serial.print("0");
    Serial.println(data, HEX);
    return data;
  }

  /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                  int Command - DIRECTACCESS_READ
  Parameters (OUT): None
  Return Value: Requested data from the Shield will be returned
  Description: This function will request 4 bytes of data from shield.
  */

unsigned long I2CREAD_DIRECTACCESS (unsigned int Address, unsigned int Command, unsigned long registerAddress)
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // sending command + address
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write

    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));

    unsigned int firstByte, secondByte, thirdByte, fourthByte;
    firstByte = registerAddress >> 24; // top byte
    secondByte = registerAddress >> 16;
    thirdByte = registerAddress >> 8;
    fourthByte = registerAddress; // bottom byte

    Wire.write(byte(firstByte));
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));

    Wire.endTransmission(false); // false for Repeated Start

    Wire.beginTransmission(byte(upperSLAD)); // request for read
    Wire.write(byte(lowerSLAD));
    Wire.requestFrom(upperSLAD, 4, true);
    unsigned long data = 0;

    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      d[i] = 0;
      d[i] = Wire.read(); // receive a byte as character
      i++;
    }


    Wire.endTransmission(true);

    data = d[3]; // combining into one variable. Highest byte received first
    data = (data << 8) | d[2];
    data = (data << 8) | d[1];
    data = (data << 8) | d[0];
    Serial.print("0x");
    if (data < 0x10000000)
        Serial.print("0");
    Serial.println(data, HEX);
    return data;
  }
  /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                  int Command - Defined I2C Commands i.e. DIRECTACCESS_OR, DIRECTACCESS_AND, DIRECTACCESS_MOVE
                  unsigned long registerAddress - address of target register
                  unsigned long Data - 32 bits data to be written to register
  Parameters (OUT): None
  Return Value: None
  Description: This function will write 4 bytes of data to specified register
  */
  void I2CWRITE_DIRECTACCESS (unsigned int Address, unsigned int Command, unsigned long registerAddress, unsigned long Data) // For accessing registers directly
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // sending command + address
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write

    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));

    unsigned int firstByte, secondByte, thirdByte, fourthByte; // Send address of register first
    firstByte = registerAddress >> 24; // top byte
    secondByte = registerAddress >> 16;
    thirdByte = registerAddress >> 8;
    fourthByte = registerAddress; // bottom byte

    Wire.write(byte(firstByte));
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));

    firstByte = Data >> 24; // top byte
    secondByte = Data >> 16;
    thirdByte = Data >> 8;
    fourthByte = Data; // bottom byte


    Wire.write(byte(firstByte)); // send 4 bytes of data
    Wire.write(byte(secondByte));
    Wire.write(byte(thirdByte));
    Wire.write(byte(fourthByte));
    Wire.endTransmission(true);

  }
  /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                  unsigned int newAddress - Address the shield should change to
  Parameters (OUT): None
  Return Value: None
  Description: This function will change the I2C address of the slave
  */

  void CHANGEADDRESS (unsigned int Address, unsigned int newAddress)
  {
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79; // First 5 bits 11110 and last bit '1' for a write

    Wire.beginTransmission(byte(upperSLAD)); // Red
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(0x70)); // Command to change address
    lowerSLAD = (unsigned int) (newAddress & 0x00FF);
    upperSLAD = newAddress >> 7; // Split address into 2 bytes
    upperSLAD |= 0xF0; // 10 bit addressing: First 5 bits have to be 11110.
    upperSLAD &= 0xFE;
    Wire.write(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.endTransmission(true);
  }

  /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
                  unsigned int Command - DMXON, DMXOFF
  Parameters (OUT): None
  Return Value: None
  Description: This function will enable or disable DMX512 control on shield
  */

  void I2CDMX (unsigned int Address, unsigned int Command) // Switch off / on the DMX
  {
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF); // Putting address into correct format
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;

    Wire.beginTransmission(byte(upperSLAD)); // Start I2C transmission
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(Command));
    Wire.endTransmission(true);

  }
  /*
  Parameters (IN): int Address - Address of RGB LED Shield, Default 0x15E
  Parameters (OUT): None
  Return Value: None
  Description: This function will request the shield to save configurations to flash memory
  */

  void I2CSAVEPARAM (unsigned int Address)
  {
    int i = 0;
    unsigned int lowerSLAD = (unsigned int) (Address & 0x00FF);
    unsigned int upperSLAD = Address >> 8;
    upperSLAD |= 0x79;

    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD));
    Wire.write(byte(SAVEPARAMETERS)); // write SAVEPARAMETERS command
    Wire.endTransmission(false); // false for Repeated Start

    Wire.beginTransmission(byte(upperSLAD));
    Wire.write(byte(lowerSLAD)); // write to address lower 8 bits of slave address
    Wire.requestFrom(upperSLAD, 2, true);  // send READ request with upper slave address
    unsigned int data = 0;

    while(Wire.available())    // slave may send less than requested. Print out received data byte
    {
      message = 1;
      c[i] = Wire.read(); // receive a byte as character
      i++;
    }
    Wire.endTransmission(true); // STOP condition

    data = c[1]; // print the data on serial monitor
    data = (data << 8) | c[0];
    Serial.print("0x");
    if (data < 0x1000)
        Serial.print("0");
    Serial.println(data, HEX);

  }








 

HC-06 Bluetooth Module : HC-06 is a commonly available and easy to use Bluetooth module which works with most of the microcontrollers which have serial communication, As the module transmits and receives Serial data to the microcontroller it is very easy to configure for different applications. I am using it to directly sent the name of the color as a string to arduino, when arduino gets a string and the name of the color is in the list of the pre-programmed colors, arduino sends data to the Infineon Shield.


About The App I am Using ( TxCOM ) :


I use windows phone, Nokia Lumia 720 to be more specific, so I was not sure that I will find a good app due to Windows Phone app store having only a few apps for this, But the app I found is amazing !, it has almost every thing i needed for the purpose Some Images Below.      

wp_ss_20150117_0001.png  wp_ss_20150117_0003.png  wp_ss_20150117_0002.pngwp_ss_20150117_0004.png

 

The App can send and receive serial data to the Bluetooth module, but the best features are the programmable keys and the voice recognition inbuilt on the app, it can also save many keys settings and can also transmit phones accelerometer and GPS data. I have made a small demo video which is Below :



                                              

 

In my next blog post I will use a IR remote control to select the color of the led strip....

Many thanks to all those who are participating in the Internet of Holiday Lights RoadTest Plus: the projects have been inspiring as well as illuminating, and have unleashed a flood of creativity which hopefully will inspire great IoT projects in 2015.
The Minion of the New Year
Dancing Dave
Dancing Dave steps into the New Year with style...
It was a difficult decision, but we are pleased to award the Dancing Dave Minion to Jan Cumps, in recognition for his prolific and interesting blogs, in particular the final summary. Congratulations!
Reminder: final submissions are due January 23rd, only completed projects will qualify for the Internet of Things with the Arduino Yún book.  Please note - we also will consider standard RoadTest reviews of the products used in the final submissions. We will announce the winner of the 3D printer within seven days of completion.
Thank you and Happy New Year!

Previous posts..

My IoT Holiday Lightings...#1: Introduction

My IoT Holiday Lightings...#2: First prototype

My IoT Holiday Lightings...#3 some more options Added

My IoT Holiday Lightings...#3: Second prototype with Music Controlled lightings and more options..

 

Dear All,

In this post and few upcoming post I will demonstrate my final build for "IoT Holiday Lighting Challenge".

I will explain step by step Android GUI Usage for My IoT Holiday Lighting here...

 

Main Funda for my project: Keep it Simple so all can do it without deep knowledge of embedded system and programming...

I have also kept BOM Limited... (Arduino yun, Infineon RGB LED Control Shield, RGB LED Strip, 12V 2AMP DC Supply, 5V 1AMP DC Supply and custom ckt for Music control lighting around TLV3402 Dual opamp and few passive components)


As I have used Rest style API for communication between App and Yun... There is no need for extra Hardware to setup broker and other stuff needed for Mqtt.

And by simple modification same application can be used with mqtt or CoAP...


So by using my simple setup LED lighting can be controlled from Local network or from Internet too...

 

Step By Step Demo Setup and Test

 

Here is my demo Setup..

IMG_20150116_105354536_HDR.jpg

 

And here are stp by step guide for Set up and run this Demo..

Step 1. Turn On Wifi Hot Spon on ur android phone (if You do not have WLAN Router near by.. like me)

Screenshot_2015-01-14-11-24-12.png

 

Step 2 : Turnon Arduino Yun and Infineon RGB LED Control Shield

IMG_20150116_105424905_HDR.jpg

Step 3: Wait for a minute to connect arduino Yun to hotspot and then Run Android App for IoT Holiday Lighting...

Screenshot_2015-01-14-11-16-20.png

Step4: Update Ip Address by touching Ip address field then touch connect... At this step Android app is connected to yun ..

Screenshot_2015-01-14-11-16-43.png

Step 6: move through options to see different LED Lighting Pattern... Play music for see music control lighting or Shake your phone to see gesture control lighting...

Screenshot_2015-01-14-11-16-58.png  Screenshot_2015-01-14-11-17-23.png  Screenshot_2015-01-14-11-17-13.png  Screenshot_2015-01-14-11-17-18.png

Screenshot_2015-01-14-11-17-10.png

Step 7: If you want to connect your IoT Holiday Lighting to Internet simply do port forwarding on android phone..open Port Forwarder.. Select Public interface (IP given by your network operator), forward 8080 port from public Interface to 80 port of your Yun.. and start port forwarder.. Cheers.. Ur Yun is now on Internet...

Screenshot_2015-01-14-11-25-33.png Screenshot_2015-01-14-11-25-44.png Screenshot_2015-01-14-11-25-57.png

Step 8: from Android phone with IoT Holiday Lighting App With internet configure Yun Address again and connect to yun...

Screenshot_2015-01-14-11-27-04.png Screenshot_2015-01-14-11-27-09.png

Step 9: All set move through options again to control LED Lightings...

You can use No-Ip or DDNS like Dns updater to give meaning ful name to ur arduino Yun remote URL...


Note : The same GUI App I have developed for PC (Windows)... Attached with this post... Gesture option will not work in PC.. But Remaining is same...

 

Here is Video of my Android phone screen recording for IoT Holiday Lighting App...


I Have attached PC application for my project Here...

Upcoming Post..

Final Build 2 : DIY GUIDE With complete Schematic and Codes..

Final Build 3 : Video Demo with android and PC Application

Today we will see how to run, on Arduino Yun, a webcam protocol compatible UVC (virtually every recent webcam supports this protocol).

 

First, install the sftp to read and write files into the Arduino Yun. From SSH do the following commands:

opkg update
opkg install openssh-sftp-server


Now we can access via SFTP with the same username and password that we used for the SSH to our Arduino Yun. For example I used FileZilla.

 

Then proceed with the installation of the driver to handle the webcam.

opkg update
opkg install kmod-video-uvc
opkg install fswebcam


 

Extract the files and place them with sftp in the annex for example in the /www/webcam/ . Position itself in this folder with cd /www/webcam/ and do the following command to install the mjpg-streamer :

opkg install mjpg-streamer_r148-4_ar71xx.ipk


 

Now you can connect the webcam with USB cable. If you have problems with the following commands reboot and try again with the following commands.

 

To view the current snapshot you must do:

mjpg_streamer -i "input_uvc.so -d /dev/video0 -y" -o "output_http.so"


It allow you to use the browser and, for example in my case, from http://192.168.1.10:8080/?action=snapshot you can view a snapshot in real time, if you refresh the page you can get a new snapshot. This method have the best image quality!

 

Another way to save an image is to use fswebcam. If you want to save on the /www/ you must do it:

fswebcam --device /dev/video0 --input 0 --resolution 640x480 --jpeg 95 --save /www/viewcam.jpg --palette MJPEG --no-banner


 

Another way to save images is to use a config file such as .fswebcam.conf with this content:

device /dev/video0
input 0
loop 15
skip 20
background
resolution 640x480
set brightness=60%
set contrast=13%
top-banner
font /usr/share/fonts/arial.ttf
title "ArduinoYunCAM"
timestamp "%d-%m-%Y %H:%M:%S (%Z)"
jpeg 95
save /www/viewcamC.jpg
palette MJPEG


And to use it go in the same directory and run:

fswebcam -c .fswebcam.conf


 

Other information are on:

- WebCam: Time-laps video

- WebCam: Using mjpeg streamer to stream video over HTTP

 

This is all for today...stay tuned to the next post, it will be about leds strips!

 

 

PS: If anyone have a problem with mjpg-straemer, my configuration file /etc/config/mjpg-streamer is:

config mjpg-streamer core
    option enabled        true
    option device        "/devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0/input/input1"
    option resolution    "640x480"
    option fps        "5"
    option www        "/www/webcam"
    option port        "8080"

Another tips is to do:

/etc/init.d/mjpg-streamer enable
/etc/init.d/mjpg-straemer start

In the previous days I have built the code for all my clients (the light spots): they receive TCP commands from the Yún and control the lights accordingly.

 

1. The 3W RGB LED.

 

The first one is an Arduino Uno connected to a custom, constant-current RGB LED driver that can handle 3-10W LEDs (maybe even 20W). Here's a picture of it (yes, bad soldering job):

 

HEy7tLe.jpg

 

This has 3 PWM inputs which are connected to 3 pins on the Arduino. It gets 12V from any power supply which then also goes to the VIN pin on the Arduino, powering it.

I then soldered an ESP8266 module on a protoboard, along with an LM1117 for bringing 5V down to 3.3V (the onboard regulator of the Arduino doesn't supply enough current) and a resistor circuit for level shifting.

 

Here it is:

 

IMG_20150105_141723.jpg

 

 

Here is the full Arduino code that controls the lights: there is still some work to do but the main functions are there and working. It has EEPROM saving so that the last value is automatically retrieved at boot. I got the ESP8266 control code from a website then tweaked it, but it was a couple of months ago so I don't remember where.

 

// TCP STRING SYNTAX
// Manual Mode - M,COLOR_R,COLOR_G,COLOR_B$ (e.g. M,255,128,0$ for orange)
// Strobe Mode - S,DELAY$ (e.g. S,200$ for a random color every 200ms)
// Fade Mode - F,R_START,G_START,B_START,R_END,G_END,B_END,DELAY_TIME$ (e.g. F,255,0,0,0,0,255,5$ fades from red to blue waiting 5ms between every fade "step")
// Options (0 or 1) - TODO


#include <EEPROM.h>
#include <AltSoftSerial.h>


#define BUFFER_SIZE 30
#define SSID "TP-LINK"
#define PASSWORD "topolottolo"
#define PORT 8080


AltSoftSerial debugSerial;


enum {WIFI_ERROR_NONE=0, WIFI_ERROR_AT, WIFI_ERROR_RST, WIFI_ERROR_SSIDPWD, WIFI_ERROR_SERVER, WIFI_ERROR_UNKNOWN};


char dataIn[BUFFER_SIZE];
char dataOut[BUFFER_SIZE];
char buff[BUFFER_SIZE];
char options[2];
char *dataPtr = dataIn;
char *data2Ptr, *mode, *word1, *word2, *word3, *word4, *word5, *word6, *word7;


int addr = 0, index = 0, red = 6, green = 3, blue = 11, debugLED = 13, strSize = sizeof(dataIn);




boolean dataComplete = false, newData = false, first = false, wifi = false;


byte setupWiFi() {
  digitalWrite(debugLED, HIGH);


  // reset WiFi module
  Serial.println("AT+RST");
  delay(500);
  if(!Serial.find("ready")) {
  return WIFI_ERROR_RST;
  }


  // set mode 3
  //Serial.println("AT+CWMODE=3");
  delay(500);
  Serial.print("AT+CWJAP=\"");
  Serial.print(SSID);
  Serial.print("\",\"");
  Serial.print(PASSWORD);
  Serial.println("\"");
  delay(2000);
  if(!Serial.find("OK")) {
  return WIFI_ERROR_SSIDPWD;
  }
  delay(500);


  // start server
  Serial.println("AT+CIPMUX=1");
  if(!Serial.find("OK")){
  return WIFI_ERROR_SERVER;
  }
  delay(500);


  Serial.print("AT+CIPSERVER=1,"); // turn on TCP service
  Serial.println(PORT);
  if(!Serial.find("OK")){
  return WIFI_ERROR_SERVER;
  }
  delay(500);






  return WIFI_ERROR_NONE;
}


char* getIP() {
  Serial.println("AT+CIFSR");
    Serial.readBytesUntil('\r', buff, 20);
    Serial.readBytesUntil('\r', buff, 20);
    Serial.readBytesUntil('\r', buff, 20);


    return buff;
}


void setup() {
  Serial.begin(115200);
  debugSerial.begin(9600);
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);
  pinMode(debugLED, OUTPUT);
  EEPROMReadString(addr, dataIn);
  first = false;
  delay(1000);
  //wifi setup
  if(wifi = true){
    debugSerial.println("Enabling WiFi...");


  while (byte err = setupWiFi()) {
  digitalWrite(debugLED, LOW);


    // error
    debugSerial.print("Setup error:");
    debugSerial.println((int)err);
    debugSerial.println("Retrying...");
    }


    // connected
    debugSerial.print("Connected to AP!");
    // char *ip = getIP();
    // debugSerial.print(" IP address is: ");
    // debugSerial.println(ip);
  }

}


void loop() {

  while(Serial.available() > 0 && first == false && Serial.find(":")){
  if (dataComplete == true || newData == true){


  debugSerial.println("New data found! Erasing array...");


  //erase data array
  for (int i=0; i<sizeof(dataIn); i++){
  dataIn[i] = NULL;
  }


  //erase eeprom
  for (int i = 0; i < BUFFER_SIZE; i++){
    EEPROM.write(i, 0);
  }


  dataComplete = false;
  newData = false;
  }


  // if(wifi == false){


  // char character = Serial.read();
  // dataIn[index] = character;
  // index++;


  // if (character == '$'){
  // dataIn[index-1] = 0;
  // index = 0;
  // } //old serial input mode
  // }



  Serial.readBytesUntil('$', dataIn, BUFFER_SIZE);
  dataComplete = true;
  debugSerial.print("New data received: ");
  debugSerial.println(dataIn);
  EEPROMWriteString(addr, dataPtr);
  data2Ptr = strdup(dataIn);
  splitSerialString();
  }


  if(strcmp(mode, "M") == 0){
  setRGB(atoi(word1), atoi(word2), atoi(word3));
  if(first == true){
  first = false;
  }
  }


  if(strcmp(mode, "S") == 0){
  strobe(atoi(word1));
  if(first == true){
  first = false;
  }
  }


  if(strcmp(mode, "F") == 0){
  fade(atoi(word1), atoi(word2), atoi(word3), atoi(word4), atoi(word5), atoi(word6), atoi(word7));
  if(first == true){
  first = false;
  }
  }


  if(first == true){
  first = false;
  }
}


void setRGB(int r, int g, int b){
  analogWrite(red, r);
  analogWrite(green, g);
  analogWrite(blue, b);
}


void strobe(int timeDelay){
  long r, g, b;
    r = random(0, 256);
    g = random(0, 256);
    b = random(0, 256);
    analogWrite(red, r);
    analogWrite(green, g);
    analogWrite(blue, b);
    delay(timeDelay);
}


void fade(int rstart, int gstart, int bstart, int rend, int gend, int bend, int delayTime){
  int r = rstart;
  int g = gstart;
  int b = bstart;


  int rSteps = calcSteps(rstart, rend);
  int gSteps = calcSteps(gstart, gend);
  int bSteps = calcSteps(bstart, bend);


  int redVal = calcSign(rSteps);
  int greenVal = calcSign(gSteps);
  int blueVal = calcSign(bSteps);


  for(int i=1; i<=1020; i++){
  if(checkSerial() == true){
  setZero();
  break;
  }
  if(i % rSteps == 0){
  rstart+=redVal;
  if(rstart >= 0){
  analogWrite(red, rstart);
  }
  }
  if(i % gSteps == 0){
  gstart+=greenVal;
  if(gstart >= 0){
  analogWrite(green, gstart);
  }


  }
  if(i % bSteps == 0){
  bstart+=blueVal;
  if(bstart >= 0){
  analogWrite(blue, bstart);
  }
  }
  delay(delayTime);
  }


  float aux;
  aux=rstart;
  rstart=rend;
  rend=aux;
  aux=gstart;
  gstart=gend;
  gend=aux;
  aux=bstart;
  bstart=bend;
  bend=aux;


  redVal = -redVal;
  greenVal = -greenVal;
  blueVal = -blueVal;


  for(int i=1; i<=1020; i++){
  if(checkSerial() == true){
  setZero();
  break;
  }
  if(i % rSteps == 0){
  rstart+=redVal;
  if(rstart >= 0){
  analogWrite(red, rstart);
  }
  }
  if(i % gSteps == 0){
  gstart+=greenVal;
  if(gstart >= 0){
  analogWrite(green, gstart);
  }


  }
  if(i % bSteps == 0){
  bstart+=blueVal;
  if(bstart >= 0){
  analogWrite(blue, bstart);
  }
  }
  delay(delayTime);
  }
}


int calcSign(int steps){
  int val;
  if(steps > 0){
  val = 1;
  }
  else if(steps == 0){
  val = 0;
  }
  else{
  val = -1;
  }
  return val;
}


int calcSteps(int startValue, int stopValue){
  if(stopValue-startValue != 0){
  return 1020/(stopValue-startValue);
  }
  else{
  return 0;
  }
}


void EEPROMWriteString(int startAddr, const char *string){


  debugSerial.print("Writing data to EEPROM... ");


  for (int i = 0; i < BUFFER_SIZE; i++) {
    EEPROM.write(startAddr + i, string[i]);
    if(string[i]  != NULL)
    debugSerial.print(string[i]);

  }
  debugSerial.println("");
}


void EEPROMReadString(int addr, char* string){


  debugSerial.println("Reading data from EEPROM...");


  for(int i=0; i<BUFFER_SIZE; i++){


  char character = EEPROM.read(addr);
  string[i] = character;
  if(string[i]  != NULL)
  debugSerial.print(string[i]);
  addr++;


  }
  //Serial.println();
  addr = 0;
  dataComplete = true;
  splitSerialString();
}


void splitSerialString(){
  debugSerial.print("\nSplitting string...");
  data2Ptr = strdup(dataIn);
  mode = strtok(data2Ptr, ",");
  word1 = strtok(NULL, ",");
  word2 = strtok(NULL, ",");
  word3 = strtok(NULL, ",");
  word4 = strtok(NULL, ",");
  word5 = strtok(NULL, ",");
  word6 = strtok(NULL, ",");
  word7 = strtok(NULL, ",");
  debugSerial.println("done!");
  first = true;
}


boolean checkSerial(){
  if (Serial.available() > 0){
  newData = true;
  return true;
  }
}


void setZero(){
  analogWrite(red, 0);
  analogWrite(green, 0);
  analogWrite(blue, 0);
}











 

 

 

2. The Infineon shield + RGB strips.

 

I have also installed and configured the Infineon RGB shield.

I immediately noticed that there were no "shield headers" included... and I only had standard male headers, so I soldered them on.

 

I then had to connect the ESP8266 module to the RX and TX pins (as well as to 5V and GND) so I had to do this ugly hack:

8XogENel.jpg

 

Sure enough, the Infineon shield expressed its disappointment by self-bending its pins! :O

 

IMG_20150102_185623.jpg

 

Everything is powered by an ATX breakout board (another nice summer project!).

 

One of the difficulties I encountered was converting 0-255 values into hex 0-4096 ones. Apart from that, the code is the same I posted a few lines before. This was my solution and it works, yet I'm not sure if I have done this right...

 

void setRGB(int r, int g, int b){
  //converts 0-255 values into i2c compatible values
  r = map(r, 0, 255, 0, 4095);
  g = map(g, 0, 255, 0, 4095);
  b = map(b, 0, 255, 0, 4095);
  char buffer[10];
  String red = String(r, HEX);
  String green = String(g, HEX);
  String blue = String(b, HEX);
  red = "0x" + red;
  green = "0x" + green;
  blue = "0x" + blue;
  red.toCharArray(buffer, 10);
  unsigned long r1 = strtoul(buffer, NULL, 16);
  green.toCharArray(buffer, 10);
  unsigned long g1 = strtoul(buffer, NULL, 16);
  blue.toCharArray(buffer, 10);
  unsigned long b1 = strtoul(buffer, NULL, 16);
  I2CWRITE6BYTES(ADDRESS, INTENSITY_RGB, r1, g1, b1);
}




 

Feels very redundant, maybe because I haven't fully understood int->hex conversions. Is there a better way of doing it apart from converting to strings?

 

I like the Infineon shield: it's packed of features and relatively easy to use, yet it seems to have this "hard-coded fade".

 

Right now, if I set the shield to be a single color (e.g. 255,0,0), the lights automatically fade from the previous color to red, according to the fade settings. I'm now working to integrate the fading in a better way with my web interface.

 

Thanks for reading! I will post a video in a few days, in the meanwhile I'm writing the review of the components!

Link to previous posts

 

Preface

 

My project for the Internet of Holoday lights was based around our living room which was not very livable. It was a mess and with the upcoming holidays I wanted to set the living room in such a way that it would be suitable for entertaining guests. Additionally I wanted to accomplish the above mentioned in such a way that the holiday lighting becomes part of the living room and I don't need to remove it after the holidays. Hence the concept of Dynamic Living-room Lighting.

 

In the previous posts, I have review the YUN and the infineon shield and have presented an overview of the project system. I also setup the place for the lighting with some homemade arts and crafts and give a preview of the system setup. I explained the Library I made for the Infineon Shield as well as the implementation for the MoodLights and made them Dynamic.

 

In this post I explain the placement of the Xmas Tree and how it fits into the living-room. The primary issue that plagues every holiday is that it goes away. I know a lot of people feel like the holidays just go away when you switch off the Xmas Tree. If only there was a way to keep the Xmas tree a part of the living room...

 

 

The tree that was... How to never leave Christmas behind!

 

I started with an artificial tree thats completely blank and had some bald spots. We bought some ornaments and stuff and made some of our own as well but the challenge was to light it up such that it can be reused. The whole concept of dynamic lighting is that you do not need to take down the lights completely. Trees seem awkward in the living room out of season and I needed a way to make the tree stay and become a permanent part of the living room. Now thats easier said than done and there is not much you can do to really make the tree look normal after the holidays BUT we can make the tree a little more dynamic. Once the lighting becomes part of the entire room and not just static lights that do nothing, we can take out the ornaments and make the tree as part of the home decor. That way the tree remains and the lighting change converts it into another living room decor or much much more. Lets see how we can do that.

Our tree initially looked like as shown in the image below.

d4f19e2701c44745c83a80daabcb94d5.jpg

 

Xmas Magic later....

I did an entire post about [Dynamic Living-Room Lights] Build Blog - Setting the stage and the result was a corner of the room which had a fireplace and a handsome tree.

745d407d79b54f52b0001f64d0cab059.jpg

The lights seen here are RGB LED strings and I used a total of 120 LEDs in this instance! They are the same as the NeoPixel from AdaFruit but I bought these from SeeedStudios. They have a single data signal connections along with a power and ground and that's it! The ornaments are a mix of bought outs and handmade ones. My wife makes some pretty cool santa minions The gift boxes are empty element14 and Wurth Electronic boxes which I have accumulated over some time. Controlling the 120 lights is a whole other ball game. Lets see what it takes.

 

Tree Controller

 

A lot of people would say that I can use the YUN to control the lights directly but instead I had to use an arduino UNO/NANO for this task. There are two reasons why we need a separate tree controller.

 

The First Reason is that the YUN is expected to control RGB LED lights in accordance with the music being played. This means if I do anything else, it will cause additional delays and the whole effect will loose it's glamor. I can use an analog circuit for the lights and equalizer but the Infineon Shield will be kicked out in that case.(DMX512- Next time baby!) Hence I need a dedicated controller for the tree lights.

The Second Reasons is that I have 120 LEDs which means that the neopixel library has to send a LOT of data on the wire which is a slow process. If I want to do something dynamic with the Lights then the code size will also be limited.

With that said, I resorted to making a individual controller for the Tree. The initial design used a wireless connection to send commands to the tree controller but I wanted to save some cost hence I resorted to using a wired USART connection. The image below shows my DIY Tree Controller in all its' glory.

1bc2e2381d987e14b955941b12def032.jpg

The circuit and code is almost the same as the one by @sciguy14 with the difference that the tree again has Three modes  at the time of this writing.

 

Connectivity

 

The arduino YUN has an AVR who's UART is connected to the Atheros Processor for communication which means no hardware UART. The UART on the USB is an enumerated type which means its only USB. The possible solution is to use a softserial which is to generate serial timing via software. The available libraries use timers and stuff which I don't need. Hence I wrote the TX part in software myself because I don't need the RX anyway. The communication is one way for now and my code uses no timers or interrupts and saves me some space too. I verified the timing using my tektronix scope which came in very handy!

33a12c3bc4484106fc5e8099065d0564.jpg

I also have a bus pirate which allows me to test some other serial stuff as well.

 

The YUN can hence transmit via Bit-Band UART and the NANO can receive it over it's hardware UART. The YUN gets all the commands for itself as well as the tree over MQTT. I wrote a small protocol for sending data. In my experiment, the frame is a follows.

1. : - Start of Frame

2. I - Infineon Settings OR T - Tree Settings OR S - Shelf Settings (More on this later)

3. A - Audio Mode OR M - Manual Mode OR P - Pattern Mode(More on this later

4. R2 - Red Hundred's Value

5. R1 - Red Tens Value.

6. R0 - Red Ones Value

7. G2 - Green Hundred's Value

8. G1

9. G0

10. B2

11. B1

12. B0

13. # End Of Frame

 

Hence if I want my tree to glow white, I would send

:TM255255255# and that would make the YUN send a command to the Tree controller automatically. And if I want the infineon RGB LEDs to turn off, I would send

:IM000000000# and that will make the YUN send an OFF Command to the Infineon Shield.

 

The static mode

In the static mode, the tree controller receives color information and command over the serial port which makes the entire tree of the same color. This is particularly effective if I want the tree and ambilights to be of the same color. The color is selected via the OpenHAB color Picker as shown in my previous post at [Dynamic Living-room Lights] The YUN talks to OpenHAB

 

These lights work quite well but I needed a separate power supply for these which I did and it did and we all did!

 

The Dynamic Mode

In the Dynamic Mode, the audio feed coming in which makes the colors on the tree lights change accordingly. The circuit and code for this part is the same by Jeremy Blum in his tutorial and allows the whole tree to act like a graphical equalizer. I did a small video to explain the system till this point and is given below.

 

 

Beware of Bugs

I got the whole thing to work like I wanted it to but after some minor hiccups. If you want to make one of these, I suggest not making the string longer than 60. I had to reduce the clock speed to 400KHz for it to reach the entire 120 LEDs and that too was not very fast. I would recommend giving shift registers a shot at this point for the desired 'wave' effect. I will experiment with DMX512 and this configuration and will have a post in the future.

 

What Next?

I will be presenting the video demo in the final summary post and will try to setup a live video feed for the project which I will keep live for as long as possible. The next post is going to have a mood light shelf which I prepared and I will go through controlling it as well. Till then...

 

Cheers,

IP

I've been hard at work on my IoT Christmas Ornaments project, specifically getting the software and firmware for my little lights working nicely.

 

As a first step toward that goal, I dove into the manual Infineon provides for the XMC1202 board in order to get a feel for how it works. In the end, I decided to follow Peter Oakes lead and produced a library for the board. While Peter's library focuses on using text-named colors, I wanted mine to act more as a simpler overlay for the actual control of the board, so mine is geared more toward being passed numerical values. Someone more ambitious than I may, someday, want to combine both functionalities into a single library. But for now, this works for me.

 

The library files, as well as a test program, are attached at the bottom of this post.

 

The Library - rgbshield

 

The library implements a number of functions which can be used to control the basic functions of the Infineon board.

 

There are four functions which can be used to set the intensity of each color channel:

 

setrgb(Red, Green, Blue) - Sets the intensities of all three color channels at once. This is probably the most common method of controlling color. It accepts three integers as inputs to set the values of the red, green, and blue channels respectively. The valid inputs range from 0 to 0xFFF (or 4095 if you prefer decimal).

 

setred(Red) - Sets the intensity of the red channel only. This accepts one integer as an input to set the red intensity, and the valid inputs again range from 0 to 0xFFF.

 

setgreen(Green) - Sets the intensity of the green channel only. It is otherwise the same as the setred function.

 

setblue(Blue) - Sets the intensity of the blue channel only. Again, it works the same as the previous two functions.

 

There are also three functions which can be used to set the other basic parameters of the board:

 

setbrightness(Bright) - Sets the maximum allowed brightness level of the board, from 0 to 0xFFF (or 4095 in decimal), with its single integer input. This doesn't simply set a cutoff point, above which any values will produce the same intensity of light, this acts more as a dimmer switch. If, for example, you passed a value of 0x800 to this function (so 2048 in decimal, or 50% brightness) it would cut all intensities in half. A pseudocode example may help illustrate this more clearly:

 

    setrgb(0xFFF,0xFFF,0xFFF); --> Full intensity white light

 

    setrgb(0x800,0x800,0x800); --> Half intensity white light

 

    setbrightness(0x800);

    setrgb(0xFFF,0xFFF,0xFFF); --> Half intensity white light

 

    setbrightness(0x800);

    setrgb(0x800,0x800,0x800); --> Quarter intensity white light, because the rgb intensity values are multiplied by the brightness level set

 

setwalktime(Walk) - Sets the time the board takes in transitioning from one color to the next. The single integer value passed here should be multiplied by 0.01024 seconds to determine what the actual walk time will be in seconds.

 

setfade(Fade) - Sets the time the board takes in going between brightness levels. This also accepts a single integer value as an input. The value set here isn't used linearly, because the board will follow a pseudo-exponential curve when changing brightness levels (in order to mirror the semi-logarithmic way our eyes perceive brightness) to create the appearance of a linear shift in brightness. This makes it difficult to give a quick and easy method of determining the actual time the board will take to transition from zero brightness to full brightness, so if this is a value that's important to your program you're just going to have to play with it until it looks good (and probably use the read function to determine when full brightness is reached rather than attempt to do it by absolute timing).

 

The library contains six functions which can be used to read the current state of the board's outputs. All six return an unsigned integer containing the current value of the requested parameter and require no arguments to function. There are three used to read rgb intensity values:

 

readred()

readgreen()

readblue()

 

As well as three used to read the other board parameters:

 

readbrightness()

readwalktime()

readfaderate()

 

I have also included two of the Infineon created functions for use with the more advanced parameters which are mainly set during setup (these parameters will be discussed later):

 

I2CWRITE2BYTES (int Address, int Command, unsigned int Data) - Allows two bytes to be written to the shield in order to perform whatever command value was passed.


I2CWRITE6BYTES (unsigned int Address, unsigned int Command, unsigned int DataOne, unsigned int DataTwo, unsigned int DataThree) - Allows six bytes to be written to the shield in order to perform whatever command value was passed.

 

The Library - a test program

 

To better demonstrate how the library is used, I have created a basic test program, aptly named rgbshield_test:

 

#include "rgbshield.h"
#include <Wire.h>


rgbshield RGB = rgbshield();


void setup()
{
    Serial.begin(9600);
    Wire.begin();

    while (RGB.on != 1) // Wait for shield to respond, keep setting the values till it does
    {
      RGB.setfade (0x0000); // Immediate fade
      RGB.setbrightness (0x0000); // 0% brightness level
      RGB.on = RGB.readbrightness(); // Request for brightness level
      if (RGB.message == 1 && RGB.on == 0) // If message received and dimming level = 0%, "message" is set in the I2CREAD function
      {
        RGB.message = 0;
        RGB.on = 1; // break out of loop
      }
    }

    RGB.I2CWRITE2BYTES (ADDRESS, OFFTIME_RED, 0x38); // Set off-time of red channel to 0x38 - good base value
    RGB.I2CWRITE2BYTES (ADDRESS, OFFTIME_GREEN, 0x39); // Set off-time of green channel to 0x39 - good base value
    RGB.I2CWRITE2BYTES (ADDRESS, OFFTIME_BLUE, 0x38); // Set off-time of blue channel to 0x38 - good base value
    RGB.I2CWRITE6BYTES (ADDRESS, CURRENT_RGB, 0x80, 0x80, 0x80); // Set current of red channel to 0x80 = 780mA - maximum safe current!
    RGB.setfade (0x002C); // Fade Rate between brightness levels
    RGB.setwalktime (250); // walk time between colors = (value)*0.01024 seconds = (here) ~2.5s
    RGB.setrgb (0x0555, 0x0555, 0x0555); // low level White Light - indicates initialization is finished
    RGB.setbrightness (0xFFF); //Maximum brightness means intensity levels are used directly


}


void loop()



{
    //Variables for storing color intensity reads
  unsigned int rout = 0;
  unsigned int gout = 0;
  unsigned int bout = 0;


    //Set full green
  RGB.setrgb(0x000,0xFFF,0x000);
    //Pause until green reaches desired level
  while(gout != 0xFFF)
  {
  gout = RGB.readgreen();
  }


    //Set half green half blue
  RGB.setrgb(0x000,0x800,0x800);
    //Pause until blue & green reach desired levels
  while(gout != 0x800 && bout != 0x800)
  {
  gout = RGB.readgreen();
  bout = RGB.readblue();
  }


    //Set full blue
  RGB.setrgb(0x000,0x000,0xFFF);
    //Pause until blue reaches desired level
  while(bout != 0xFFF)
  {
  bout = RGB.readblue();
  }


    //Set half blue half red
  RGB.setrgb(0x800,0x000,0x800);
    //Pause until blue and red reach desired levels
  while(rout != 0x800 && bout != 0x800)
  {
  rout = RGB.readred();
  bout = RGB.readblue();
  }


    //Set full red
  RGB.setrgb(0xFFF,0x000,0x000);
    //Pause until red reaches desired level
  while(rout != 0xFFF)
  {
  rout = RGB.readred();
  }


    //Set half red half green
  RGB.setrgb(0x800,0x800,0x000);
    //Pause until green and red reach desired levels
  while(gout != 0x800 && rout!=0x800)
  {
  gout = RGB.readgreen();
  rout = RGB.readred();
  }


}

 

Breaking down the program into its most relevant bits, we start with the initialization check for the shield. This code was adapted from Infineon's test program. As you can see, it attempts to set the brightness level to zero (i.e. turns the LEDs off), then reads back the current brightness level from the shield. It continues this process until the Arduino successfully sees the brightness set to zero at which point it knows the shield is fully responsive and ready to work:

 

while (RGB.on != 1) // Wait for shield to respond, keep setting the values till it does
    {
      RGB.setfade (0x0000); // Immediate fade
      RGB.setbrightness (0x0000); // 0% brightness level
      RGB.on = RGB.readbrightness(); // Request for brightness level
      if (RGB.message == 1 && RGB.on == 0) // If message received and dimming level = 0%, "message" is set in the I2CREAD function
      {
        RGB.message = 0;
        RGB.on = 1; // break out of loop
      }
    }

 

Next, we set some of the board's electrical and timing values. A deeper discussion of just what these do follows, but the values given here are good and safe base choices. I chose to leave these functions unimplemented in the library, because they aren't things that should be played with by the uninitiated. They're still easily accessible by using the I2CWRITE commands implemented in the library, but are not readily apparent to a user who hasn't spent some time digging into the workings of the board:

 

    RGB.I2CWRITE2BYTES (ADDRESS, OFFTIME_RED, 0x38); // Set off-time of red channel to 0x38 - good base value
    RGB.I2CWRITE2BYTES (ADDRESS, OFFTIME_GREEN, 0x39); // Set off-time of green channel to 0x39 - good base value
    RGB.I2CWRITE2BYTES (ADDRESS, OFFTIME_BLUE, 0x38); // Set off-time of blue channel to 0x38 - good base value
    RGB.I2CWRITE6BYTES (ADDRESS, CURRENT_RGB, 0x80, 0x80, 0x80); // Set current of red channel to 0x80 = 780mA - maximum safe current!

 

Finally, we have the main loop and its color changes. This basic pattern is repeated a few times, but essentially what it does is tell the board to set certain rgb intensity values, then continuously reads the actual intensity values until the desired level is reached before moving on to the next color change.

 

You could get the same behavior as this test program by replacing the while loop with a delay(2500) statement, and while that is simpler conceptually, it introduces additional problems if you decide to change your walktime value to anything other than 250. Say, for example, you changed walktime to 300 because you wanted slower changes. If you used the delay() method, you would then have to modify every delay() statement or else your color changes would run over each other. Instead of getting to full-green before starting the switch to full-red, you'd get about 70% of the way there, then immediately start transitioning from that color to full-red.

 

That may seem like a small hassle, but consider a less simple program: You use an input of some kind (whether a button, a rotary encoder, or some web-based input) to modify the walktime value to create different patterns. You would then have to use a variable as your delay value, and have that variable change in proportion to your walktime. It's certainly possible, but your simple solution has now become markedly more difficult, and that's still a relatively simple use case.

 

With this method, the problem works itself out. Walktime changed to 100? Ok! No problem! Oh, now it's 500? Wow, that's slow, but sure, we can do that... no other changes needed. Have I sold you on this method yet? Good!

 

    //Set full green
  RGB.setrgb(0x000,0xFFF,0x000);
    //Pause until green reaches desired level
  while(gout != 0xFFF)
  {
  gout = RGB.readgreen();
  }

 

Now... lets see how that program looks, shall we?

 

 

What you see here is everything going from a fully powered off state to the initialization check, then the very dim white light indicating the initialization has succeeded, and then on into the program itself for a few loops.

 

Now that you know how to use my library to control the Infineon shield, let's go into a few of those technical details I glossed over earlier. You can, of course, feel free to skip this section and simply use the commands discussed above. But we're hackers here, we care about more than just making it work, we care about knowing how it works.

 

Technical Nitty Gritty

 

The following commands aren't specifically implemented in my library. They're still accessible through use of the I2CWRITE2BYTES function, however, and can be accessed by using I2CWRITE2BYTES(ADDRESS, [command listed below], [value you want set]).

 

CURRENT_[COLOR]

 

This is the first of the "electrical and timing values" I mentioned before. Using this command, you can set the maximum current per given color channel (which are obviously red, green, or blue). It's normally something you would set in your setup() section, as shown in the test program, and then leave. There may be situations where you'd want to modify this during board operation... but I can't think of any offhand.

 

This command accepts a numerical value in the range of 0 to 128. Feeding it any value over 128 will just result in the setting being changed to 128, so you can't accidentally blow out your board with a funny setting. This maximum value also, unsurprisingly, corresponds to the maximum safe current for the board. Nine times out of ten you'll just set this to 0x80 (or 128) and leave it be.

 

OFFTIME_[COLOR]

 

This is the second, and more potentially dangerous, of the "electrical and timing values". The control circuit on the Infineon board uses a chopper style of pulse width modulation in order to achieve the required current for a given intensity level. This command sets the off-time of the chopper circuit.

 

To get a better understanding of what this means, picture a graph of the current flowing through your LEDs - because of the way circuits like this work, it won't actually be a straight line. Instead, it will be a series of peaks and valleys, because the power source is being constantly turned on and off ("chopped") in order to maintain an average correct level of current. By using this command to change the off-time value, we're either making those valleys wider or thinner, and in the process producing more or less ripple in the output current.

 

Because of propagation delays inherent in this kind of control, as well as delays introduced by components in use on the board, the peak level of current experienced by the LEDs and the driver board will always be slightly higher than the maximum we set with the previous command. That is, the board will sense that it has hit the maximum current value a short time after that value has actually been reached, and in the meantime the current has continued to go up, so by the time the chopper circuit goes into "off" mode we've already exceeded our desired maximum current.

 

The hardware can take this, briefly, but if we set the off-time to a value that's too short we can exceed that safety margin. And that's how you get catastrophic failure.

 

The default value here is 0x40 (or 64), and that's probably a good value to stick with. It results in an off-time of 1 microsecond. If you REALLY want to change it, the manual has equations you can use to try to estimate what is (and isn't) going to be a safe value when combined with your maximum current setting. But so far, the ripple with the default values seems low enough that I can't see its effects. Like the peak current setting, this is also a per-color setting, and something you'll usually handle in your setup() function.

 

Additional Commands

 

There are additional commands available for the Infineon RGB shield that are unimplemented in my library and which are actually inaccessible without creating additional functions. These are all very advanced commands, however, which allow you to do things like write directly to registers on the board (rather than reading commands stored in given registers and using them to set values), change the address of the board from the default 0x15EUL to something of your choosing (which would only ever be useful if you have multiple boards connected to a single Arduino), or save the current state of all settings on the board so it will produce the same output even without an Arduino or other microcontroller attached.

 

These are all very useful things in certain circumstances, and are all quite well documented in Infineon's manual for this board, but were things that I felt were best left out of my library. Because I'm releasing my library as public domain, however, you can add these in yourself if it's something you feel is necessary. If you do use my library as the basis for an expanded, improved, or otherwise optimized library of your own I would just ask that you leave mention of me in the comments of your file and link back to my original so the code can be traced back to its source should anyone ever need to.

 

Now... on to working out the IoT/Eclipse part of this project. We'll get these bright balls online yet!

graphic.PNGThe Internet of Holiday Lights RoadTest+ is running from December 8th to January 23rd 2015

Previous Activity:

Blog Summary #000 : Internet of Holiday Lights RoadTest Plus 2014

Blog Summary #001 : Internet of Holiday Lights RoadTest Plus 2014

Current Activity:

Blog Summary #003 : Internet of Holiday Lights RoadTest Plus 2014 - Post Final Day

NameSuper Awesome Blog Time
Viorel M. Alexe

The Santa monitor & lights - (T.I.O.H.L.)part-1

The Santa monitor & lights - (T.I.O.H.L.)part-2

Stephen BairdIoT Christmas Ornaments - The Hardware!
Jan Cumps

[Christmas Wreath of Things] Internet of Holiday Lights: part 2 - paper prototype

[Christmas Wreath of Things] Internet of Holiday Lights: part 3 - set up the Arduino Yún

[Christmas Wreath of Things] Internet of Holiday Lights: part 4 - I need Date and Time

[Christmas Wreath of Things] Internet of Holiday Lights: part 5 - Found a Stepper Motor

[Christmas Wreath of Things] Internet of Holiday Lights: part 6 - Stepper Motor works

[Christmas Wreath of Things] Internet of Holiday Lights: part 7 - Infineon LED shield works

[Christmas Wreath of Things] Internet of Holiday Lights: software side note - dodgy advent logic

[Christmas Wreath of Things] Internet of Holiday Lights: part 8 - Arts & Crafts

[Christmas Wreath of Things] Internet of Holiday Lights: part 9 - Time and Event Management

[Christmas Wreath of Things] Internet of Holiday Lights: part 10 - Secret IoT Team Up

Internet of Holiday Lights:  Join the secret IoT Service - open for all

[Christmas Wreath of Things] Internet of Holiday Lights - summary

[Christmas Wreath of Things] Internet of Holiday Lights : post Christmas blues

Massimiliano Dibitonto

No Updates

Jack Franklin

Internet of Holiday Lights - We meet at Last

Matteo Furlan

The smart entrance - My project for Internet of Holiday Lights RoadTest

Gurinder Singh GillNo Updates
Saurabh Gohe

Blog Post #1 : Introduction To My Project "Smartphone Controlled Lighting System" For Internet of Holiday Lights RoadTest Plus 2014...

Lukas Hornby

No Updates

Jordan Lui

RoadTest Internet of Holiday Lights: Apartment Lighting Extravaganza Post 2

RoadTest Internet of Holiday Lights: Apartment Lighting Extravaganza 3: LCD Screen Learning

Clem Martins

[IoT Christmas Sparkle Ball] The plans so far

Peter Oakes

BYOB Party #5, Mrs Yun gets her MQTT on

BYOB Party #6, Introducing Baby Trinket... Shhh she is sleeping

BYOB Party #7 - Mrs YUN gets chatty with iot.eclipse.org and NRF24L01

BYOB Party #8 - PI Matrix - Behind the scenes at the PI camp

BYOB Party #9 - Meet Minion Baby Bob, Trinket Evolves over night and learns a few tricks

BYOB Party #10 - Re-flow Soldering for Custom Neopixel displays

Mohan Palanisamy

Part X.3 Arduino Yun Extending the RAM with swap file

Part 2.3 Touche Minions

Part 3.1: Introducing Ponte, a M2M bridge for MQTT, CoAP and HTTP

Part 3.2: Reading a MQTT topic with HttpClient On Arduino Yun

Part 3.3: Arduino Uno + ESP8266 + Eclipse Ponte HTTP Bridge = MQTT Magic

Part 3.4 Behold the Color Catcher and Thrower

Aby Raj

No Updates

Inderpreet Singh

[Dynamic Living-Room Lights] The YUN review - When the Penguin Met The Arduino.

[Dynamic Living-Room Lights] The Infineon RGB LED Shield Review

[Dynamic Living-Room Lights] The Infineon RGB LED Shield -Library!

[Dynamic Living-Room Lights] The Lights Teaser Video

[Dynamic Living-Room Lights] Build Blog - Setting the stage

[Dynamic Living-room Lights] The YUN talks to OpenHAB

Francesco Truzzi

[Arduino light spots] Updates and WebUI preview!

Eric TsaiVoice controlled holiday lights w/ OpenHAB & Tasker
Madhuri Vaghasia

My IoT Holiday Lightings...#2: First prototype

My IoT Holiday Lightings...#3: Second prototype with Music Controlled lightings and more options..

My IoT Holiday Lightings...#3 some more options Added

Frederick Vandenbosch

[Christmas Tree] Internet of Holiday Lights - Getting Started

[Christmas Tree] Internet of Holiday Lights - Control from openHAB

[Christmas Tree] Internet of Holiday Lights - Special Feature

[Christmas Tree] Internet of Holiday Lights - NeoPixel Star

Darcy WalkerNo Updates
Robert WatersLight Shield Review Part 1

Hello everyone!


Here I am with the second step of my project. In previous point (http://www.element14.com/community/groups/arduino/blog/2014/12/23/the-smart-entrance--my-project-for-internet-of-holiday-lights-roadtest) I explained how to install mosquitto.

 

I go then to explain through a couple of pictures and code what I did to make it possible to write in the topic I chose updates of the data collected by the sensors.
Every 10 seconds my Arduino Yun reads data detected (humidity, temperature, air quality, fuel gases, flames and distance) from the sensors connected (see photo) and, through the MQTT protocol communicates them to the server.
To verify that everything happens correctly I installed in my smartphone "MyMQTT", a simple but powerful application to enroll in the topic, and also wanting to write messages on them. The configuration has only required the inclusion of IP of my server and the topic to which register.
Once started Arduino, as you can see from the screenshot, every 10 seconds, the topic is updated with the sensor data.


Below I leave you also also the code I used to be able to carry out the above and in the attached library for MQTT. Unfortunately this is not Paho as it is very greedy for space and occupied memory (about 92% against a 46% of this).


In the next post will address the issue in webcam and the one after that, hoping that the power pack, the pilot of the strip led according to the temperature received from the server using MQTT.

IMG_20150111_232113.jpgScreenshot_2015-01-11-23-32-23.png

 

#include <SPI.h>
#include <Bridge.h>
#include <YunClient.h>
#include <IPStack.h>
#include <Countdown.h>
#include <MQTTClient.h>
#include <Wire.h>
#include <dht11.h>
char printbuf[100];
// DHT11 sensor pins
dht11 DHT11;
#define DHT11_PIN 8 //pin number 8 of digital port
int pinSensoreFiamma = 7;
//HC RS04 ultrasound sensor
int triggerPort = 4;
int echoPort = 2;
YunClient yunClient;
IPStack ipstack(yunClient);
MQTT::Client<IPStack, Countdown> client = MQTT::Client<IPStack, Countdown>(ipstack);
byte mac[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // replace with your device's MAC
const char* topic = "/smart_entrance/toYun"; // replace with your topic

void connect() {
    char hostname[] = "0.0.0.0"; // replace with your server IP or domain
    int port = 1883;
    sprintf(printbuf, "Connecting to %s:%d\n", hostname, port);
    Serial.print(printbuf);
    int rc = ipstack.connect(hostname, port);
    if (rc != 1) {
        sprintf(printbuf, "rc from TCP connect is %d\n", rc);
        Serial.print(printbuf);
    }
    Serial.println("MQTT connecting");
    MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
    data.MQTTVersion = 3;
    data.clientID.cstring = (char*) "arduino-yun"; //name of arduino on mosquitto
    rc = client.connect(data);
    if (rc != 0) {
        sprintf(printbuf, "rc from MQTT connect is %d\n", rc);
        Serial.print(printbuf);
    }
}

void setup() {
    Wire.begin();
    Bridge.begin();
    Serial.begin(115200);
    // sets the digital pin 7 as input
    pinMode(pinSensoreFiamma, INPUT);
    //ultrasound sensor
    pinMode( triggerPort, OUTPUT );
    pinMode( echoPort, INPUT );
    connect();
}

void loop() {
    if (!client.isConnected()){
        connect();
    }
    MQTT::Message message;
    while (true){
        int chk;
        Serial.print("DHT11, ");
        chk = DHT11.read(DHT11_PIN);    // READ DATA //pin number 8 of digital
        switch (chk){
          case DHTLIB_ERROR_CHECKSUM:
                      Serial.print("Checksum error, ");
                      break;
          case DHTLIB_ERROR_TIMEOUT:
                      Serial.print("Time out error, ");
                      break;
          default:
                      Serial.print("Unknown error, ");
                      break;
        }

        //MQ135 Air Quality Control
        float RoRs;
        int airqValue   = analogRead(0);    // read air quality sensor
        if(DHT11.temperature >=20.0&&DHT11.temperature<=50.0){//adjust for dependency on temperature
          RoRs = -0.0034 * DHT11.temperature + 1.067;
        }
        else if(DHT11.temperature>=-10.0&&DHT11.temperature<=5.0){//adjust for dependency on temperature
          RoRs = -0.0300 * DHT11.temperature + 1.4;
        }
        else if (DHT11.temperature >= 5.0 && DHT11.temperature <= 20.0){//adjust for dependency on temperature
          RoRs = -0.0167 * DHT11.temperature + 1.333;
        }
        else {
          RoRs = 1;
        }
        RoRs= RoRs * (-0.001923 * DHT11.humidity + 1.0634); //adjust for dependency on humidity
        int adjAirQValue = airqValue * RoRs;

        //MQ-2 General combustible gas
        int mq2   = analogRead(2);    // read MQ-2 General combustible gas

         char fuocoAcceso[8]="";
        if(digitalRead(pinSensoreFiamma)==1){
          sprintf(fuocoAcceso, "%s","spento");
        }else{
          sprintf(fuocoAcceso, "%s","acceso");
        }

         // trigger
        digitalWrite( triggerPort, LOW );
  
        //impulse of 10microsec on trigger
        digitalWrite( triggerPort, HIGH );
        delayMicroseconds( 10 );
        digitalWrite( triggerPort, LOW );
  
        long duration = pulseIn( echoPort, HIGH );
        long centimetri = 0.034 * duration / 2;

        if( duration > 58000 ){
          duration=-1;
          centimetri=-1;
        }

        MQTT::Message message;
        message.qos = MQTT::QOS0;
        message.retained = false;
        char str[50] = "";
        sprintf(str, "%d,%d,%d,%d,%s,%d", DHT11.humidity, DHT11.temperature,adjAirQValue,mq2,fuocoAcceso,centimetri);
        message.payload = str;
        message.payloadlen = strlen(str);
        int rc = client.publish("/smart_entrance", message);
        if (rc != 0) {
          Serial.print("Message publish failed with return code : ");
          Serial.println(rc);
        }
        client.yield(10000);
    }
    delay(100);
}


I have been working with my Arduino Mega ADK and a nice little TO92 temp sensor, the TSIC 301. (Datasheet here) I have been playing with a very basic sketch, all it is doing at the moment is looping around "read value and display on serial"

const int IN_PIN = 0; // analogue input pin
const int DELAY = 1000; // a constant value for the delay.
int value = 0; // declare and initialise the variable for the value

void setup()
{
  Serial.begin(9600); // setup serial connection
}

void loop()
{
  value = analogRead(IN_PIN); // read the value of the sensor
  Serial.println(value); // display it in the serial monitor
  delay(DELAY); // wait 1 second then start the loop again although this can be altered easily
}

I am using this as the basis for a couple of ideas, one is to indicate high and low temperatures via LED display, maybe a "traffic light" systems that has different LEDs lit at certain temps or maybe a RGB LED would be best?(Suggestions please) Another idea is to tie this up with a stepper motor and use this sort of sketch to open and close a window in a greenhouse or similar.(All these ideas are being used as "proofs of concept" or should that be "proofs of concepts"?

I have been able to see the output value change from 78 in a normal run to 60 with an air duster blowing on it to 85 with a good  old fashioned "huff".I do not have a thermometer here to test the values, I will see if I can get hold of one to check.Apparently this can measure from -50C to +150C, (-58 to 302 to you Fahrenheit lovers :-) )

 

TO92 TSIC301 Temp Sensor_bb.png

The sensor in this Fritzing image is the correct form, TO-92, with the correct polarity with 1 being gnd, 3 being 3.0V to 5.5V and 2 being the actual sensor output.I am going to be using this sketch as the basis for a function, it is nice and small and won't take up a lot of memory.(4134 bytes)

Back to the primary blog BYOB Party #1, "Bring you own Bulbs" - The Internet of Holiday Lights

 

OK, so in the last post you where treated to my first attempt at re-flow soldering in an attempt to get my WS2812 LEDS ready for my Holiday Light decoration

 

Now I have completed a bit of the wiring and have the initial display code up and running, I would like to share some of the effects, i will include the code as you may find it handy for your own projects, I will update it once the NRF Radio software is added so you can issue remote commands and tie t into the MQTT subscription system

 

Step one is to break apart the strips along the v groves and adding the needed wiring prior to adding to their enclosure

 

I chose to award this display to another Arduino for now and so the next step was to add additional effects to the code to make this allot more interesting display.

 

Step two, find the enclosure (My personal favourite bit )

 

The enclosure for the project is simply a choc box (I'm all for re-cycling stuff where I can )

 

Start with a preferably full box of chocolates, Star shaped like this one

After eating all the stuff inside (Well we need the box empty for this project right ) you will see that the two halves of the box fit nicely into each other, well keep one part ccompletely intact and take the base out of the other leaving only the sides

P1010354.JPG

the now floppy sides will fit nicely into the inside of the other half with a little bit of cutting and glueing, leaving you with a nice partitioned enclosure for the lights

P1010355.JPG

The minions are helping out keep thins in place while glue dries (I personally think they just wanted a nap), make sure to include a big enough hole in the centre to pass wires through

Pre wire the strips ready to install into the case

P1010356.JPG

break apart the boards and install into the star passing the wires through the hole in the centre

P1010358.JPG

now on the back, connect all the power leads together  and connect the data in pins of the next strip to the previous data out connection, secure all the joints and were done the wiring

P1010359.JPG

Load up software into the uno, connect 5V to the lights, and a single data line to pin 6 of the uno and were all set to test.

 

Here is the test video

 

I hope you like it, I will follow up once the software is ready for the party radio

also here is the code so far in-case you would like to use it on your project

XMAS is over

 

On January 6, we remove our Christmas tree and lights in Belgium. So it's also time for my Christmas Wreath of Things to switch off.

But we still have our Secret IoT Service going on - and I want to enjoy that for a little longer.

 

So I switched over to a low profile design: an LCD that glows when one of my Secret IoT Service partners is alive,

and shows the name of the last person that sent me an I'm alive message.

In the picture below, it was peteroakes.

 

Photo 08-01-15 12 12 32.jpg

 

What's happening?

 

If no one but me is on-line, the display is blank, and the backlight off.

Once I receive a message from one of my friends, the Thing wakes up:

It sets a seconds counter to 120 seconds, and remembers the name of the sender.

 

The display lights up, and shows who was broadcasting:

 

lcd.jpg

 

 

Left upper corner shows my countdown timer. Each second the timer decreases.

Right lower corner shows the sender (in this case fvan).

 

If I receive no new message within 120 seconds, the backlight switches off, the display is blanked

and we go back to sleep.

 

Code:

 

 

// needed for MQTT and Process lib
#include <Bridge.h>








// MQTT  includes start




#include <SPI.h>
#include <YunClient.h>
#include <IPStack.h>
#include <Countdown.h>
#include <MQTTClient.h>


#include <string.h>
// MQTT includes end




// include the library code:
#include <LiquidCrystal.h>
#define PIN_LCDLIGHT 10




// start MQTT declarations
char printbuf[100];


YunClient c; // replace by a YunClient if running on a Yun
IPStack ipstack(c);
MQTT::Client<IPStack, Countdown> client = MQTT::Client<IPStack, Countdown>(ipstack);
char payLoadBuf[] = {'j', 'a', 'n', 'c', 'u', 'm', 'p', 's', 0};
const char* send_topic = "element14_IoT";
const char* subscribe_topic = "element14_IoT";
const char* _id = "1cfee8dd0afc_yun";
// end MQTT declarations




// start frederick declarations
unsigned int uFrederickIsAlive = 0;
// end frederick declarations


// initialize the library with the numbers of the interface pins
// LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);




char lastPayload[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};






// start timer functionality ============================================================
boolean bRunSeconds = false;
boolean bIsRunningSeconds = false;
boolean bRunMinutes = false;
boolean bIsRunningMinutes = false;
boolean bRunHours = false;
boolean bIsRunningHours = false;


void runSeconds() {
  bIsRunningSeconds = true;

  // // Serial.print("s"); // remove when confident


  // task: keep MQTT alive
  client.yield(30); // this takes 30 ms. May reduce the parameter // if you get duplicates, increase

  // task: handle frederick alive functionality
  // task: every minute; we take one live away from frederick
  if (uFrederickIsAlive) {
    uFrederickIsAlive--;
    sprintf(printbuf, "%3u%c", uFrederickIsAlive, 0);
    lcd.setCursor(0, 0);
    lcd.print(printbuf);
    lcd.setCursor(0, 1);
    lcd.print(lastPayload);
    pinMode(PIN_LCDLIGHT, INPUT);   // high impedance turns on light
  } else {
    pinMode(PIN_LCDLIGHT, OUTPUT);   // low impedance LOW turns off light
    sprintf(printbuf, "                %c", 0);
    lcd.setCursor(0, 0);
    lcd.print(printbuf);
    lcd.setCursor(0, 1);
    lcd.print(printbuf);
  }
  Serial.println(uFrederickIsAlive);



  bRunSeconds = false;
  bIsRunningSeconds = false;
}


void runMinutes() {
  bIsRunningMinutes = true;

  // // Serial.println("m"); // remove when confident

  // task: flag to Frederick that I'm alive
  sendAliveMessage();



  bRunMinutes = false;
  bIsRunningMinutes = false;
}


void runHours() {
  bIsRunningHours = true;

  // // Serial.println("h"); // remove when confident

  bRunHours = false;
  bIsRunningHours = false;
}


void timerInit() {
  // initialize timer1 for 1 second ticks; ISR(TIMER1_COMPA_vect) will be called as interrupt handler
  noInterrupts();           // disable all interrupts
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;


  OCR1A = 62500;            // compare match register 16MHz/256/1Hz
  TCCR1B |= (1 << WGM12);   // CTC mode
  TCCR1B |= (1 << CS12);    // 256 prescaler
  TIMSK1 |= (1 << OCIE1A);  // enable timer compare interrupt
  interrupts();             // enable all interrupts
}


ISR(TIMER1_COMPA_vect)          // timer compare interrupt service routine
{
  static unsigned int uSeconds = 0;
  uSeconds++; // every call is a second
  bRunSeconds = true; // so yes, flag that the seconds handler should be called
  bRunMinutes = ! (uSeconds % 60); // each 60th second, flag that the minutes handler should be called
  if (uSeconds > 3599) { // every hour
    bRunHours = true; // flag that the hours handler should be called
    uSeconds = 0; // and start over
  }
}


void timerTasks() {
  if (bRunSeconds && ! bIsRunningSeconds) { // timer interrupt flagged that seconds handler should be called
    runSeconds(); // but we only run it if it's not active
  }
  if (bRunMinutes && ! bIsRunningMinutes) { // timer interrupt flagged that minutes handler should be called
    runMinutes(); // but we only run it if it's not active
  }
  if (bRunHours && ! bIsRunningHours) { // timer interrupt flagged that hours handler should be called
    runHours(); // but we only run it if it's not active
  }
}


// end timer functionality =====================================




// start MQTT functionality ====================================




void mqttInit() {
//  Ethernet.begin(mac); // replace by Bridge.begin() if running on a Yun
  Bridge.begin();


  // // Serial.println("MQTT Internet of Holiday Lights example");
  connect();
}


void messageArrived(MQTT::MessageData& md) // this handler is called when a subscribed MQTT message arrives
{
  MQTT::Message &message = md.message;

  // debug code
  sprintf(printbuf, "Message arrived: qos %d, retained %d, dup %d, packetid %d\n",
  message.qos, message.retained, message.dup, message.id);
  Serial.print(printbuf);
  sprintf(printbuf, "Payload %s\n", (char*)message.payload);


  Serial.print(printbuf);

  /*
  // sprintf(printbuf, "Topic len %d\n", md.topicName.lenstring);
  int i;
  for (i = 0; i < (md.topicName.lenstring.len); i++) {
    printbuf[i] = md.topicName.lenstring.data[i];
  }
  printbuf[(md.topicName.lenstring.len)]=  '\n';
  printbuf[md.topicName.lenstring.len + 1]=  0;
  */
  int iPlCheck = strncmp(payLoadBuf, (char*)message.payload,8);

  if (iPlCheck) {
    Serial.print(printbuf);
    sprintf(lastPayload, "%16s", (char*)message.payload);
  
  
  
    uFrederickIsAlive = 120; // we give frederick two lives (minutes) to send an 'I am alive' live message.
  } else {
    Serial.println("it's my own message");
  }
}


void connect()  // connect to the MQTT broker
{
  char hostname[] = "iot.eclipse.org";
  int port = 1883;
  sprintf(printbuf, "Connecting to %s:%d\n", hostname, port);
  // // Serial.print(printbuf);
  int rc = ipstack.connect(hostname, port);
  if (rc != 1)
  {
    sprintf(printbuf, "rc from TCP connect is %d\n", rc);
    // // Serial.print(printbuf);
  }

  // // Serial.println("MQTT connecting");
  MQTTPacket_connectData data = MQTTPacket_connectData_initializer;     
  data.MQTTVersion = 3;
  data.clientID.cstring = (char*)_id;
  rc = client.connect(data);
  if (rc != 0)
  {
    sprintf(printbuf, "rc from MQTT connect is %d\n", rc);
    // // Serial.print(printbuf);
  }
  // // Serial.println("MQTT connected");

  rc = client.subscribe(subscribe_topic, MQTT::QOS1, messageArrived); 
  if (rc != 0)
  {
    sprintf(printbuf, "rc from MQTT subscribe is %d\n", rc);
    // // Serial.print(printbuf);
  }
  // // Serial.println("MQTT subscribed");
}


void sendAliveMessage() {
  if (!client.isConnected())
    connect();

  MQTT::Message message;



  char buf[100];
  int rc;
  // Send QoS 1 message
  // // Serial.println(payLoadBuf);
  message.qos = MQTT::QOS1;
  message.retained = false;
  message.dup = false;
  message.payload = (void*)payLoadBuf;
  message.payloadlen = strlen(payLoadBuf)+1;
  rc = client.publish(send_topic, message);
}


// end MQTT functionality ==============================


// start LCD functionality ===========================








void setupLCD() {

  pinMode(PIN_LCDLIGHT, OUTPUT);  //Set control pins to be outputs
  digitalWrite(PIN_LCDLIGHT, LOW);

  lcd.begin(16, 2);
//     lcd.setCursor(0, 0);
}


// end LCD functionality ===========================




void setup()
{


  Serial.begin(9600);
  delay(10000); // give me time to start the yun monitor


  // MQTT related tasks
  mqttInit();

  // initialise LCD
  setupLCD();


  // timer related tasks
  timerInit();
}


void loop()
{

  timerTasks();

  // non timer related functionality comes here





}


Ladies and gentlemen, engineers and hobbyists, welcome one and all to my first ever IoT project!

 

As you can probably guess, I am one of the lucky roadtesters for the Infineon RGB shield. Now this blog has been a long time coming, and I sincerely apologize for this delay, however unlike some other roadtesters this is my first ever electronics project(from home anyway) and so I was slightly unprepared. So I decided that it would be best to wait until I had pretty much everything that I needed for this project before blogging about it so that the blogs could be consistent and evenly spaced out but hey, better late than never as they say!

 

Now enough of the boring stuff, let's get down to business! So as you can probably see from my tag, I am going to create an interactive Christmas tree, which will be able to change it's lighting according to the mood of the room."How on earth will you find the 'mood' of a room?" I hear you cry! Well to be honest I'm not entirely sure however the plan is to use a small microphone(which will be hung from the Christmas tree itself) to listen to the sound in the room. The arduino yun will then change the colour, intensity and possibly even mode of the RGB strip according to what it hears. For example, if there is little noise the LEDs may be a dim red which will fade in and out, however if there is a lot of loud, high pitched noises the LEDs may be a bright flashing blue.

 

In terms of layout and setup etc., I will have the yun attached to the microphone, deciding on the mood of the room and then telling that to the uno which will control the Infineon board. Although i could possibly have this the other way round, I decided to use the yun to process the data as I also plan to possibly create an app for my phone using the android sdk which will allow me to change things like modes or intensity over wifi. My original thoughts were to connect the yun and arduino via usb, however this can produce some problems, such as the uno drawing power from the yun, and the fact that it looks extremely complicated! I will update you all on my final decision in my next blog.

 

Below is a picture showing all of the connections between the devices I will be using. It isn't too detailed, but it helps to show what on earth I'm rambling on about.

 

Communications.png

Join me again this time next week(hopefully) for my second blog, where i will working with the yun to turn the microphones outputs into moods and then send that to the uno.

Previous posts in this project:

 

 

Introduction

 

With the holiday period over, I finally have some time to focus on my projects again.

For this post, I worked on the star which will go on top of my digital Christmas tree.

 

NeoPixel Star

 

I originally intended to use an LED strip, which I would cut into pieces and place in a star shape, but I then came across the NeoPixel Sticks from Adafruit.

One stick has eight LEDs which are placed very close to each other. They seemed perfect for the job.

 

Based on some measurements, I created a simple 3D printed star to test the positioning of the sticks. You'll notice the different branches are a bit off center. That is to compensate for the fact that the pixels themselves are not centered on the stick either.


After that, I modified the star to be able to clip the sticks on and pass the wires for power and data.

IMG_5588.JPG

With the holder tested and fitting, I soldered the connections between the sticks, resulting in one strip consisting of five sticks.

To test the construction, I loaded the default "strandtest" sketch from the NeoPixel library and configured the proper number of pixels.

DSCN3158.JPG

 

 

You can find the final model I designed on thingiverse: http://www.thingiverse.com/thing:624811

I'm still waiting on my LED lights, which is making me nervous.  Perhaps I shouldn't have ordered from eBay

 

So, in the mean time, I've been working on some automation stuff with lights (when I get them).  I've always wanted voice control, but something that is continuous, and does not require pushing buttons prior to the voice command.  I found out about how Tasker can send HTTP Post/Get commands to OpenHAB.  Tasker also has a plugin called Autovoice, which can run in "continuous" mode, so it will always monitor your voice.  So here's an example of how to do this integration.

 

Here's the holiday lights screen.

 

holiday_lights.png

 

 

Video of a quick demo.

 

 

I have an item defined this way:

Switch itm_holiday_on "Lights Enable"

 

Under Tasker, define a new Task to turn off the switch.

New Task > Action > Net > HTTP Get

 

Server:Port

OpenHABuser:OpenHABpassword@192.168.x.x

Path

CMD

 

Attributes

itm_holiday_on = OFF

 

Do a similar task for turning it on, but just replace the attribute with "=ON".  You can test the task by using the play button at the bottom.  Executing these tasks should turn the switch off or on.

 

20150106_213329.jpg

 

 

Next, we use voice commands to activates profiles that run these tasks.

 

 

In the Profiles tab on Tasker, create a new profile.

Event > Plugin > Autovoice > Recognized

 

Edit the configuration for this event.  Set the "Command Filter" to whatever you want the voice command to be.  Then go down to pick a "Trigger Word".  In my case, the Trigger Word is "Computer", and the Command is "on" or "off".  Exit out of the profile creation and you'll be prompted to pick a task for this event.  Pick either the on task or the off task created previously.

 

Next, open up the Tasker plugin called Autovoice.  Set it to run continuously.  This will make it run voice recognition all the time, and act as the "computer" in Star Trek.

 

List of previous posts

 

Preface

 

My project for the Internet of Holoday lights was based around our living room which was not very livable. It was a mess and with the upcoming holidays I wanted to set the living room in such a way that it would be suitable for entertaining guests. Additionally I wanted to accomplish the above mentioned in such a way that the holiday lighting becomes part of the living room and I don't need to remove it after the holidays. Hence the concept of Dynamic Living-room Lighting.

 

In the previous posts, I have review the YUN and the infineon shield and have presented an overview of the project system. I also setup the place for the lighting with some homemade arts and crafts.

 

In this post, I will explain the control of the RGB LED strips attached to the arduino YUN and connected to an instance of OpenHAB. This instance of OpenHAB is running a raspberry Pi and an MQTT broker.

 

Installing OpenHAB and Mosquittoe

 

For the Forget Me Not Challenge, I used OpenHAB as the center piece and details can be found at

 

The "Forget_What ?" project - Index

 

I did various tutorials on installing and using OpenHAB and I suggest going through them if interested. Once you have installed it, you can install addons for such as MQTT etc. Additionally, I installed Mosquitto MQTT broker but you can use iot.eclipse.org:1883 . My reason for installing a local MQTT broker was the ability to work in the absence of an internet connection.

 

1.png

Configuring the YUN for MQTT

 

Benjamine Cabe did an excellent post at Controlling Holiday Lights using MQTT and the Arduino Yún and the code is available on github. For my experiment, I changed the subscribed topic according to my requirement. The rest of the code is more or less the same. The code can be downloaded at https://github.com/kartben/internet-of-holiday-lights

 

Once you have setup the YUN with the code and into your network, you can open up a serial monitor in the Arduino IDE by pressing Ctrl+Shift+M

 

You will also need a program to test MQTT off the bat. I choose MQTT Lens which is a Google Chrome Addon. Point it towards the MQTT Broker and you should be done.

 

1.png

The screenshot above shows how to control the YUN with the code supplied by Benjamine Cabe as is. Just send RGB values and you are good. If you send 000000 then the LEDs switch off and if you send ffffff then the LEDs turn on full brightness hence the white color.

 

Now you should be able to see the results almost instantaneously and if you don't try and see if the YUN is connected to the internet or not. The serial monitor can help you debug that.

 

Making OpenHAB talk to the YUN

 

It took me a little while to get this up and I am not completely happy with it, but its a goog start for the lazy man. The task is to format the MQTT messages just like Cabe Sir's application reads so we can use the YUN Code directly. Its actually quite easy.

 

The first thing we need to do is create an Item in the .Items file. This just creates a place to house the data for OpenHAB. I created a simple item as follows.

 

Color      Hue                      "IP Hues"                                      <colorwheel>      (All)
String            HueMqtt                  (All)            { mqtt=">[eclipse1:ip-led:command:*:default]"}







 

Note that I have a color wheel object that can store the RGB values and a string object that will store the string to be passed to the YUN. The '{' indicates that a binding has been employed which is mqtt. > specifies that the direction is outwards. eclipse1 is my name for the MQTT connection configuration stored in the openha.cfg file  and ip-led is the topic. You can change this to match your topic such as /IOTLights/LEDs1 etc. Please note these are case sensitive. Next it will send whatever (*) command this object gets. You can specifify conversions here using XLS but I choose to do all that in the rules segment.

 

The second thing we need to do is make it a part of the UI. You can see there is a segment in the above screenshot for the IOT Holiday Lights and is labeled YUN. To make that, we use the following code.

 

sitemap demo label= "Main Menu"
{


// All my other stuff//
// IOT Holiday Lights Frame
Frame label= "IOT Holiday Lights"{
            Text label= "YUN" icon= "yun "{
                  Frame label= "Yun Control"{
                        Colorpicker item= Hue icon="slider"
                  }
            }
      }
}







 

I downloaded the icon from the net and put it in the OpenHAB/webapps/images/yun.png . The resulting sub frame is shown below.

 

1.png

 

1.png

So now we have a color wheel. Brilliant!

 

The Third step is creating rules to connect the Color Wheel to the MQTT topic via the String. This is where all the fun stuff happens and for my instance my code is given below.

 

 

import org.openhab.core.library.types.*


// Stuff for the IOT Holiday Lights
var HSBType hsbValue
var int Brightness
var String redValue
var String greenValue
var String blueValue


// ********************* IOT Holiday Lights ****************************
rule "YUN Lights MQTT"
when
      Item Hue changed
then
      hsbValue = Hue.state as HSBType


      val Red1 = hsbValue.red.intValue
      val Green1 = hsbValue.green.intValue
      val Blue1 = hsbValue.blue.intValue

      redValue = Red1. toString(16 )
      greenValue = Green1. toString(16 )
      blueValue = Blue1. toString(16 )

      val Tmp = redValue + greenValue + blueValue

      sendCommand(HueMqtt, Tmp)
end







 

The rule can be named anything and I created some variables globally in case I want to use the values somewhere else as well. When the item Hue changes, we extract the color values after converting the object's state to HSBType. The color values are extracted as integers and I use local variables for some experiments later. Lastly, we convert them to strings but of base 16 since Cabe Sir's code reads hex values only. Club them together and send them across. Thats it!

 

It works as is and I tested it out with the same YUN code.

 

1.jpg

 

More to DO

 

At this point I am not very happy with the way messages are sent on MQTT. I am used to writing more lower level protocols but here I need to extend the use of MQTT to send elaborate commands to the YUN which will in turn control some other things. At the time of this writing, I have already made changes to the above code and only documentation remains. This post will complement kartben '  post and will use OpenHAB to control it out of the err.. github.

 

Comment if this helps you.

 

Cheers,

IP

The idea

 

I've been dragging my feet to enter this contest.  Working with light is not my forte.

But The Internet of Holiday Lights RoadTest Plus has a creative component. And  that's what pulled me in.

I was going to build an Electro Mechanical Xmas Wreath of Things!

 

 

 

 

This is the proposal I submitted:

 

Christmas Wreath of Things

...  my entry is an electro-mechanical wreath.

...

The wreath is a combination of mechanics, electronics and internet connectivity.

For each advent week, there will be a light. above the light is a filter that hides all four lights initialy, and will reveal a light each Sunday, 'candle wreath style'.

 

 

Microcontrollers are used to motor-drive the optical filter. The internet will be used 'IoT compliant', to check what date it is, and reveal the correct number of lights based on that.

The wreath will work every year without user input. Plug it in and it will adjust itself to the right state of advent.

My aim is to give this either a K'Nex or steampunk look and feel.


image.jpg

 

In fact I don't know anything about te design yet. It's just an idea at this moment.

You'll find out together with me how it materializes.

 

At that time, I really didn't know much. As it turned out, the only thing I've left from the original idea was the dumb lights and motorized filter.

All other things changed during the build.

In this post I will not go into technical details. There's a list with all blog posts about this gizmo at the end of this post.

 

What did I come up with?

 

3degrees_orig.jpg

 

I like to challenge the nature of the exercise.

 

The focus was on lights. I came up with the idea to make the lights an intrinsic part of the design - but a downplayed part.

It would have been obvious to switch on one light for each Sunday in the advent.

I inverted that thought process: what if the lights are static, but something else makes them go on and off.

The mechanically driven optical filter does that  job.

advent01.jpg

The Infineon RGB shield can handle high power leds easily. So I used it to drive standard low power leds.
It's perfectly capable of doing that, but you're playing at the very low edge of its range. It's a tricky balance because you can easier overdrive standard leds than the sturdy high power ones.

The shield did an excellent job. Even though I did not put advent intelligence in the lights, I did animate them.

peteroakes's (I bet he'll be mentioned by some other participants too ) Infineon library was instrumental for a painless exercise.

 

IMG_3575.JPG

 

 

 

The Eclipse IoT. What's the use of the internet of things if you only talk to yourself?

fvan and I have our gizmos connected to each other.

Our devices act differently when we're both on-line. How novel is that?

 

 

Frederick's gizmoJan's gizmo
photo+1+%281%29.JPGgzmo.jpg

 

We think we've used the internet as it's supposed to be used. To interact with others.

And we've used it as 'things'. There's no human interaction. Both things are happy when the counterpart is live, and they show it!

 

iot01.jpg

 

The Arduinos. The Yún drives the whole thing. It's filled up with more than 90%. It has a very down-to-earth duty.

The UNO is doing a more creative job. I've given it as a present to one of my kids that helped me build the wreath.

Maybe one day she ...



What changed during the build?

 

I started with virtually no ideas. And even then almost everything changed.

 

  • I was going to use the internet to get the current date. I'm a novice to IoT - this is my first experience - and thought that it was all about using on-line services and functionality.

When I was setting up the Yún, I found out it has linux running - and has time sync functionality.

So I changed my mind, stepped away from searching for an on-line time service, and used that linux part to get at the right date - with localization support.

 

  • That also meant that I had to come up with something else for the IoT part. The work with Frederick more than filled that gap. It was a blast working together - you get the warm fuzzy when the gizmo lights up when you're not paying attention.

 

  • The mechanical part went through several changes.

I started with a light dc motor, but that was a bit hard to control. I didn't have many options to provide position feedback - let alone brake the fast but weak motor. Ditched it.

Idea two was a servo motor that I have lying around. It does the job better, but it was looking dull. I wanted gears and shiny copper.

In came the final solution: a stepper motor from a defunct flatbed scanner.

 

IMG_3980.JPG

I struggled somewhat with driving the motor - and wrote about that in the blogs listed at the bottom of the blog. It turned out to be a perfect solution.

As an added bonus, the stepper does not run very smooth. That adds to the look and feel of my design.

From the start, I wanted it to look scabby. I'm quite pleased with how it behaves:

 

 

  • I was going to build it alone. One of my kids came to the rescue when I was about to cut off my fingers during the arts&crafts part.

That may have been the part that I enjoyed most.

 

IMG_3543.png

 

Wrap up:

 

'twas fun! I'm glad I participated - and I learned a few new things along the way.

My design is not going to be the brightest light around here (total current used for leds: < 150 ma, all Arduino Yún  leds included ).

But it moves. And it communicates. It's alive!

All the best for 2015 !

 

 

My Blog Posts:

 

The posts in this table tell the whole story from beginning till completion. They are listed - and  written - in sequence, so you can follow along with me.

 

Blogs


My entry for the Internet of Holiday Lights is an electro-mechanical wreath.

My first blog post was a brain dump of possibilities.

In my second post I made a paper prototype.

My third post was about getting the Arduino Yun up and running.

In the fourth post I used the Linux part of the Yun to get at the current date and time.

In the fifth post I scavenged a stepper motor from a flatbed scanner.

In post six that motor was running.

Post seven is covering the Infineon RGB LED shield.

My post number eight is an aside on programming the advent calendar logic.

In post nine I'm covering the creative 'Arts & Crafts" part.

Post number 10 covers Time and Event handling,

and post 11 reveals the IoT conspiracy that Frederick and I prepped.

Post-Christmas design: [Christmas Wreath of Things] Internet of Holiday Lights : post Christmas blues

And the bonus kicker: [Christmas Wreath of Things] Internet of Holiday Lights - Bonus kicker: the IoT talks (a spoken tribute to Science Fair kits)

Comparing the Infineon arduino libraries from our element14 team.

The Official Road Test Review©.

Bonus material

 

Frederick's post on our shared design: [Christmas Tree] Internet of Holiday Lights - Special Feature

You can join in. Topics are shared on this thread: Internet of Holiday Lights:  Join the secret IoT Service - open for all

 

After January 6, I switched over to a post-Christmas design: [Christmas Wreath of Things] Internet of Holiday Lights : post Christmas blues

Photo 08-01-15 12 12 32.jpg

 

Bonus Bonus:

The Internet of Things shouts out the names of my fellow road testers:

 

 

 

 

A playlist of 11 videos I've uploaded during the work. Some made it to the blog posts.

 

 

and some photos:

 

backside.jpg dark.jpg frederick ster.jpg IMG_3424.JPG

 

IMG_3503.JPG IMG_3984.JPG IMG_3986.JPG

 

IMG_3987.JPG IMG_3990.JPG

 

IMG_4006.JPG Photo 23-12-14 23 28 16.jpg wreath0001.jpg

tandy.jpg

Several of us are posting a 'secret' message to the eclipse broker.

You can subscribe to our topics and share the Xmas Light of Things.

 

If you post your MQTT payload here, I'll add them to the list.

 

whopayload
fvanfvan
jancumpsjancumps
peteroakespeteroakes
mcb1mcb1

 

 

MQTT broker info:

host: iot.eclipse.org

port: 1883

please post a keep-alive every minute

QoS: 1

Topic: element14_IoT

The internet is supposed to be a forum for collaboration and sharing. And the Internet of Holiday Lights contest asks for creative use of Eclipse's IoT offering.

 

So the two Belgian guys (Frederick and me) decided to team up and use the internet as our platform to work together.
We believe that having our two devices connected to each other - and make them change each other's behavior - ticks the creative use of the Eclipse IoT offering box in an inventive way .

Our gizmos work in isolation. But only when both devices are online they show their full colors.

 

 

Frederick's gizmoJan's gizmo
photo 1 (1).JPGIMG_3999_L.JPG

 

 

What have we done?

 

Both Frederick (fvan on element14) and me have reserved part of our Thing's look-and-feel for shared functionality.

And both of us publish an I-AM-ALIVE message to the Eclipse IoT broker every minute. We both subscribe to each other's message.

When we receive a message from the other, we animate some part of our design. When there's no new 'I-AM-ALIVE' arriving within a given period, that animation stops.

You can't get more Christmas compliant than that - and we don't use the internet to talk to ourselves; we use it to enrich the experience.

 

 

How did we test it?

 

You can use the Eclipse Paho MQTT Utility to view traffic, but also to submit test messages. So I can simulate that Frederick's device is online by submitting 'his' message via Paho.

We also use it to monitor if the other gizmo is emitting messages. Ideal to see if our designs are actually reacting on the broadcast.

The screen capture below is me simulating Frederick's broadcast. So the messages are not coming from his device this time:

 

paho.jpg

 

Here's a capture of both gizmos broadcasting. It's our devices that are generating the messages:

messages.jpg

... and what's the effect?

 

The visual effect when our designs are on-line together:

 

Frederick's gizmoJan's Gizmo
photo 2 (1).JPG

 

So that's our creative Internet of Things offer:

"Use the internet to influence, communicate and work together. And use it to let our Thing be More Than a Thing"

Fun.

 

The gizmo design

 

I got a bottle of after-shave for New Year, and used the old bottle as a special effects light filter. I fitted two strings with a random number of green and red LEDSs in the bottle (It's the Infineon RGB shield's duty to manage the current - and it handles that responsibility very well).

In the front of the bottle I made a cut-out of part of one of Frederick's design drawings (the big star from his drawing below). I glued that drawing over the cut-out hole, and gently tapped the inner part of the star with olive-oil to improve the transparency.

frederick ster.jpg gzmo.jpg

 

Frederick's post: [Christmas Tree] Internet of Holiday Lights - Special Feature

 

Update

 

The IoT Team Up is open to all.

Internet of Holiday Lights: Join the secret IoT Service - open for all

 

We've published the details on how to share your heartbeats. A few members are preparing to add something in their design.

The result will be more exciting than what we envisioned at the start.

Previous posts in this project:

 

 

Introduction

 

I was approached by jancumps some time ago, as he wanted to give the challenge an extra IoT twist.

 

After some messages going back and forth, the conclusion was that we would symbolise each other's project in our own design and have that component light up when the other design was online.

 

 

Heartbeat

 

Both our designs are making use of MQTT messages on the same broker (iot.eclipse.org).

 

We came up with the idea of having our designs send periodic messages (e.g. every minute) on a specific topic with a specific payload as a heartbeat mechanism.

Once a heartbeat is received, a timer is started and the symbol lit up. When a new heartbeat is received, the timer is reset, ensuring the symbol remains lit up.

However, if the timer expires because no heartbeat is received, the symbol is turned off as we assume the other design is offline.

 

Here's the code used to send my heartbeat (I removed the unrelated bits of code):

 

#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <Bridge.h>
#include <YunClient.h>
#include <Wire.h>
#include <Infineon.h>
#include <Console.h>

long isAlive = 0;

YunClient yunClient;
PubSubClient client("iot.eclipse.org", 1883, callback, yunClient);

void setup() {
  Bridge.begin();
  Console.begin();
  Console.println("Connected to console.");
  Wire.begin();

  // connect to MQTT broker and subscribe to topic
  if (client.connect("arduinoYunClient")) {
    client.publish("19e5983adc0f","fvan");
    isAlive = millis();
    delay(50);
  }
}

void loop() {
 client.loop();
  // send heartbeat
  sendHeartbeat();
}

void sendHeartbeat() {
if(millis() - isAlive >= 30000) {
  client.publish("19e5983adc0f","fvan");
  isAlive = millis();
}
}






 

And the code used to process Jan's heartbeat (unrelated bits removed as well):

 

#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <Bridge.h>
#include <YunClient.h>
#include <Wire.h>
#include <Infineon.h>
#include <Console.h>

long checkAlive = 0;

Adafruit_NeoPixel widget = Adafruit_NeoPixel(12, 7, NEO_GRB + NEO_KHZ800);
YunClient yunClient;
PubSubClient client("iot.eclipse.org", 1883, callback, yunClient);

void callback(char* topic, byte* payload, unsigned int length) {
  // Check for messages on subscribed topics
  Console.print("Topic: ");
  Console.println(String(topic));

  if(String(topic) == "1cfee8dd0afc") {
    String value = String((char*)payload);

    if(value == "jancumps"){
      checkAlive = millis();

      Console.println("Widget heartbeat received");
    }
  }
}

void setup() {
  Bridge.begin();
  Console.begin();
  Console.println("Connected to console.");
  Wire.begin();

  widget.begin();
  widget.show();

  // connect to MQTT broker and subscribe to topic
  if (client.connect("arduinoYunClient")) {
    client.subscribe("1cfee8dd0afc");
    delay(50);
  }
}

void loop() {
  client.loop();
  // check heartbeat
  receiveHeartbeat();
}

void receiveHeartbeat() {
  if(millis() - checkAlive >= 120000) {
    // turn widget off
    for(uint16_t i=0; i<widget.numPixels(); i++) {
      widget.setPixelColor(i, widget.Color(0, 0, 0));
    }
    widget.show();
  } else {
    //turn widget on
    for(uint16_t i=0; i<widget.numPixels(); i++) {
      if(i%3 == 0) {
        widget.setPixelColor(i, widget.Color(255, 0, 0));
      } else {
        widget.setPixelColor(i, widget.Color(0, 255, 0));
      }
    }
    widget.show();
  }
}










 

 

Symbol

 

Jan's design is a Christmas wreath. To symbolise that in my own design, I chose a NeoPixel ring lighting up in green and red.

photo 1 (1).JPGphoto 2 (1).JPG

 

Testing

 

To test this new feature, I used MQTT Lens and the Console output of the Yun.

 

MQTT Lens allowed me to confirm both Jan's and my heartbeats were "on air", with the expected payload. The console output on the Yun then confirmed I received and processed Jan's heartbeat as expected.

Screen Shot 2015-01-02 at 14.25.28.pngScreen Shot 2015-01-02 at 13.24.48.png

 

Demonstration

 

Here's a video of my widget being activated by Jan's MQTT heartbeat.

 

I shortened the timeout interval for demo purposes to 30 seconds, so the widget would turn off between heartbeats which are sent every minute. The timeout is otherwise configured to 120 seconds.

 

Back to primary BLOG BYOB Party #1, "Bring you own Bulbs" - The Internet of Holiday Lights

 

 

This is a quick blog to share my experience with trying to solder some WS2812 6pin LED chips onto my custom boards

 

I have about 14 strips to solder up and each strip contains 10 LED modules, the last time I tried to solder these, I had more fail than ended up on the board so I was determined to find a better way

 

So what I have is this

 

TEFAL Convection toaster oven I picked up new but on a big time sale at the local hardware store

Tubes of Solder paste

bunch of WS2812 LEDs to solder that are a PITB to solder by hand

NO Stencil for for the soldering

 

bunch of boards waiting for the LEDS

P1010322.JPG

 

So I have been meaning to give the Oven a try after I had converted the controller to something designed for re-flow, alas time was against me so I decided to see how easy it is without all the fancy controls

 

Well as it turned out and as you will see in the video, it was actually quite easy (Well the re-flow part anyway), the application of the solder paste was a pain without a solder mask and my first attempts with a small flat screwdriver ended up with loads of bridges I had to clean up with solder wick

 

Second attempy was using an old needle from an INK refill system I had long abandoned but happened to fit nicely onto the end of the syringe containing the solder, it took some strength to squeeze it out of he tube with it did allow much finer control of the application, more practice is needed though to get proficient at it.

 

At the end of the day, the effort was worth it and I now have six boards competed with seven more to do and only had a few bridges on the second attempt which was 5 strips at once

 

I have one faulty LED where the red led is not working, once im done with the remaining board, if i have spare LEDs i will replace it, till then it will have to stay

 

this is the heat profile I used, simply the timer on my camera and an Agilent DMM with a thermocouple, very easy and simple to repeat

 

 

here is the video

 

and thats all there is too it, now to get the next party goer kitted out for the pending bash

Here is short video of my IoT Holiday Lightings with Music controlled LEDs and more options of Random pattern and cool back ground...

Circuit diagrams, explenation and codes will be posted soon...

By mistakke I have uploaded the same content as document .... so now I am posting the same as blog post...

http://www.element14.com/community/docs/DOC-72746/l/my-iot-holiday-lightings3-second-prototype-with-music-controlled-lightings-and-more-options

 

Happy new year to all...


In the earlier posts here, here and here, i was leading up to this: The Color Catcher and Thrower. A glove that can capture colors and sends it out as MQTT message for my WiFi Christmas Tree and other light fixtures to consume.

 

LightGlove.png

 

 

 

 

The MQTT messages sent during the demo:

mqttcolorcatcher.jpg

 

Hardware Components Used:

 

1. Adafruit Pro Trinket (5v)

2. ESP8266

3. Adafruit TCS34735 5v Color sensor

4. Flex Sensor

5. RGB Led

6. Resistors

7. 28 Pin IC socket for Trinket

8. 2x4Pin female headers as socket for ESP8266

9. 5v usb battery charger (this one)

 

On the receiving end:

1. Arduino Yun

2. Infineon RGB Led Shield

3. RGB Led Strip from Amazon

 

Software Components used:

1. Arduino Ide 1.5.8

2. Eclipse Ponte MQTT HTTP Bridge

3. Adafruit TCS34725 Library

4. Software Serial Library

 

The Bread Board Proof of Concept

 

Almost all the software components were done using Arduino Uno and tested on the bread board. Didn't test it out with the Pro Trinket. Big mistake as i came to realize two days later. See below at the software section.

IMG_4437.png

 

The Perfboard Schematic:

This is the first time i put together something on a perfboard and ergo first time using Fritzing for laying out a perfboard. Bear with me on noob mistakes. But i think schematic can get you on the way to reproducing this if you like to.

 

Color Catcher - New Page.png

 

The Build :

Apart from wanting to make everything work, i also wanted to make sure my valuable Pro Trinket, ESP8266 and other components are removable. My skills at desoldering are next to none and didn't want to take the risk of losing anything. Initially i was planning to use conductive thread and sew the components directly on the glove. But after testing one part i realized that the conductive thread has too much resistance resulting in halving the input voltage. So i had to rip it all off and then take the plunge on designing  a proto board and solder everything. I am glad i did as I learnt so many things which i would never have otherwise.


I am a noob on electrical design. So i do not trust myself yet to create a voltage divider. ESP8266 needs a 3.3v input voltage. The Pro Trinket 5V doesn't have a 3.3v out. So i bought a NTE 956 voltage regulartor but i was running out of time for learning and applying proper voltage dividing techniques. So it was a pleasant surprise when i noticed that the Adafruit color sensor had a 3.3v pin out apart from the Vin. Checked the voltage on it and it was a good 3.3 v pin. Still was not sure whether the ESP8266 would work reliably as so many of the documentation out there was talking about the WiFi cheap being current hungry. I had no other choice. If the power was not enough, then i had plans to take the voltage from the VBus in Pro Trinket (direct from usb battery) and send it thru a voltage divider. Luckily for me ESP8266 worked with just the 3.3v from the the Color sensor.


The sockets for Pro Trinket and ESP8266:

IMG_4490.pngIMG_4491.png

 

The wire leads for Adafruit TCS34725 color sensor (5v Version).. On the right the backside of the protoboard with all the connections routed. Getting ready for soldering the wire leads for the LEDs and the Flux sensor.

IMG_4493.pngIMG_4502.png

 

All the connections for the LED and the Flux Sensor.

IMG_4503.pngIMG_4505.png

 

Preparing the LED and Flux Sensor mini protoboard that will go on the backside of the glove.

IMG_4506.pngIMG_4507.png

 

Finally done with all the soldering. Ready for sewing..

IMG_4509.png

 

After the sewing, the glove looked like this: (Palm/Inside Wrist and Back/finger with Flux sensor). Note that i have inserted the Pro Trinket and the ESP8266 on the respective sockets. The color sensor had male pins which i soldered for bread board testing which i didn't want to remove. So i just pushed it through the fabric and connected the wire on the inside which made a temporary lock. I also used a jumper to connect the LED Pin to the Interrupt Pin on the Color sensor.

IMG_4514.pngIMG_4515.png

 

The Software


As i mentioned earlier i tested everything on the bread board with Arduino Uno. I started moving the code to Pro Trinket. At first everything seemed to work correctly as i kept loading and testing software for each of the components. Once i started loading the MQTT part using the ESPRESTHelper library i created, i started noticing weird issues. For using the AT commands with ESP,  the code needs to send the size of the TCP packet first before sending the actual packet. My helper library was using Arduino Strings and it was constantly reading a 0 length packet when using string.length().  Also it kept working perfectly when only the MQTT code was on the board and nothing else. I was worried that something is wrong with the connections/voltage/current etc and i had no way of measuring any of this. I have a multimeter but don't have the confidence to measure current using it.


Then i started noticing the dynamic memory bytes during the compile time. The pro trinket is supposed to have the same 2Kb dynamic memory as that of Uno. But for some reason, i began to notice that whenever the size exceeded 1024 bytes, weird things happened with strings.


So two things i needed to do. Remove String from the code. Reduce dynamic memory size by using PROGMEM where possible. So i ended up removing my own ESP REST helper library and writing the ESP communication code directly in the sketch using Program. All these reduced the dynamic memory usage to under 1 Kb (When i get some time i will rewrite my ESP REST helper library to remove all references to String.)

 

Also i didn't have to include the ESP code to create a WiFi Connection. My ESP already has the fixed IP and automatically connects to my local network when ever its powered on. ( My library has the code for WiFI connection if you need it.)

 

I wanted to simulate the capture and throw effect. I was able to do this by using the flex sensors bent degrees. If its bent more than 80 degrees, i initiated the color capture. The LED will turn on with the right color. Throwing motion always results in the fingers being stretched fully. That would result in less 15 degrees. So i sent the MQTT message with the RGB payload at this time when the fingers are fully stretched.

 

(Digression: If some one wants to use this glove in some show, it will give them time to do a lengthy dialogue as long as they keep their fingers in a grab position. And at the right moment they can do a throwing motion resulting in the message being sent out and other subscribers to the message doing whatever effects they need to do. I can think of so many Star wars Jedi effects with this )

 

Here is the sketch: Githubhttps://github.com/mohankrr/IoT_holiday_lights/tree/master/ProTrinket/LightGlovelink is here: (note that gamm256.h is a gamma table to drive the gamma correction for the LED. The table is from Adafruit which has an excellent explanation on gamma correction. The file is available at my github repository.

 

/*******************************************************************************
* Sketch for Light Glove - A Color catching and throwing glove
* Built by: Mohan Palanisamy
* For: Element14.com 2014 Holiday Lights Road Test
* Uses parts of code from Adafruit
*******************************************************************************/
  #include <Wire.h>
  #include <Adafruit_TCS34725.h>
  #include <SoftwareSerial.h>
  #include <avr/pgmspace.h>
  #include "gamma256.h"


  #define FLEXPIN A0
  #define ESPRXPIN 4
  #define ESPTXPIN 5
  #define LEDPINR 9
  #define LEDPING 10
  #define LEDPINB 11
  #define _DEBUG
  #define ESP_RX_PIN 4
  #define ESP_TX_PIN 5


   extern const uint8_t gamma[];
  //Storing in PROGMEM to save dynamic memory space.
  //Note the topic name (uri after PUT) and the host name. Change it to your topic and hostname:port.
  PROGMEM  const  char  tcp_packet_template[] ="PUT /resources/FromLightGlove/RGB HTTP/1.1\r\n"
                                         "Host: 192.168.1.217:6000\r\n"
                                        "Accept: */*\r\n"
                                        "Content-Type: application/x-www-form-urlencoded\r\n" ;

//the server name should be surronded by double quote.. so pay attention to the escape charcter for double quote
  const char startTCPSession[] = "AT+CIPSTART=\"TCP\",\"192.168.1.217\",6000";


  Adafruit_TCS34725 colorSensor = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
  SoftwareSerial esp8266Serial(ESP_RX_PIN, ESP_TX_PIN);


  //Color Capture flags
  boolean colorCaptureStarted=false;
  boolean colorCaptureFinished=false;
  char capturedColorRGB[12];


  void setup() {

    Serial.begin(9600);
    colorSensor.begin();

    esp8266Serial.begin(9600);
    esp8266Serial.setTimeout(1000);
  
    pinMode(LEDPINR, OUTPUT);
    pinMode(LEDPING, OUTPUT);
    pinMode(LEDPINB, OUTPUT);

    captureColor();  //do it to turn off the LED and as a sanity check
  }


  void loop() {

    //Straight value 770
    //Bent 90 degree value 870
    int bentDegrees;
    int rawFlex=analogRead(FLEXPIN);
    bentDegrees=map(rawFlex,770,870,0,90);

    if(bentDegrees >80 && !colorCaptureStarted)
    {
      Serial.println("Bent..Initiate Color Capture");
      colorCaptureStarted=true;
      captureColor();
      colorCaptureFinished=true;
    }

    if(bentDegrees< 15) //throw color if captured
    {
      if(colorCaptureStarted && colorCaptureFinished)
      {
  
        SendMQTTMessage(capturedColorRGB);
        //reset after throwing
        colorCaptureStarted=false;
        colorCaptureFinished=false;

      }
    }
    delay(100);
  }


  void SendMQTTMessage(char* content)
  {
      //make sure you adjust this if the template stored in progmem changes depending on your
      //host name, port, topic etc.
     char tcpPacketTemplateBuffer[256];
     strcpy_P(tcpPacketTemplateBuffer,tcp_packet_template);

      int contentLength=strlen(content);

      sprintf(tcpPacketTemplateBuffer,"%sContent-Length: %d\r\n\r\n%s", tcpPacketTemplateBuffer,contentLength,content);

      esp8266Serial.println(startTCPSession);

      if (esp8266Serial.find("Linked"))
      {
          esp8266Serial.print("AT+CIPSEND=");
          esp8266Serial.println(strlen(tcpPacketTemplateBuffer));


          esp8266Serial.println(tcpPacketTemplateBuffer);

          if (esp8266Serial.find("SEND OK"))
          {
            //After reading close the connection. Do not want to reuse because the TCP stack on
            //ESP8266 might close the connection after a while.
            //So make sure the connection is closed by sending AT+CIPCLOSE
            esp8266Serial.println("AT+CIPCLOSE");
       
            Serial.println("Message Sent.");
          } else
          {

            Serial.println("Sending Packet Failed");
          }
    } else
    {
      Serial.println("Cannot Start TCP Session");
     }

     // Serial.println(tcpPacketTemplateBuffer);
     // Serial.println(strlen(tcpPacketTemplateBuffer));
  }


  void captureColor()
  {
    uint16_t clear, red, green, blue;
    memset(capturedColorRGB,0,12);

    colorSensor.setInterrupt(false);      // turn on LED

    delay(60);  // takes 50ms to read

    colorSensor.getRawData(&red, &green, &blue, &clear);

    colorSensor.setInterrupt(true);  // turn off LED


    uint32_t sum = red+green+blue;

    float r, g, b;
    r = red; r /= sum;
    g = green; g /= sum;
    b = blue; b /= sum;
    r *= 256; g *= 256; b *= 256;
     if (r > 255) r = 255;
    if (g > 255) g = 255;
    if (b > 255) b = 255;

    sprintf(capturedColorRGB,"%d,%d,%d", (int)r ,(int)g ,(int)b) ;
    setColor( (int)r ,(int)g ,(int)b);
  }


  void setColor(int red, int green, int blue)
  {
    analogWrite(LEDPINR, pgm_read_byte(&gamma[red]));
    analogWrite(LEDPING, pgm_read_byte(&gamma[green]));
    analogWrite(LEDPINB, pgm_read_byte(&gamma[blue]));
  }





 

 

This build proved to be the most challenging one i have ever done. From conceptualization to realization, my confidence grew as each obstacle was over come. I am glad and thankful that doctorcdf, kartben and  element14.com choose me as one of the participants in this road test. As we embark on a New Year, i wish every one a happy and prosperous new year. Here's to us for keep on Making things. Cheers.



Filter Blog

By date: By tag: