Introduction
This project is to create a WiFi Connected lamp from a Transformer themed lamp. The original lamp was plain white in colour and not very interesting. The idea was to add a microcontroller with WiFi capabilities and a number of RGB LEDs. This is to be controlled via a simple web page running on the microcontroller. There are a number of micros that could have been chosen such as a Raspberry Pi, ESP8266 module, mbed or any of the other Arduino boards and an addon WiFi module.
The board chosen is the Arduino Yún. The Yún consists to two parts, the first being a Linux based module providing the WiFi connectivity and Webserver. This also provides a management interface that allows the Yún WiFi to be configured remotely from a web browser. The second part being the Arduino part based on the Atmel 32u4 microcontroller and is the part that is programmed via the Arduino IDE and sketches. It is possible to run code on the Linux part but this is not covered here. Once the Arduino Yún has been connected to your WiFi it is then able to have sketches uploaded over to it remotely without a serial connection.
The finished lamp showing a rainbow effect.
Parts
The main parts for the project are:
- Autobot USB Lamp
- Arduino Yún, available from Farnell
- Individually addressable RGB LED strip WS2801 LED Strip or Adafruit NeoPixel strip
- Micro SD card for storing web pages
Other parts, usually found in your parts box include hookup wire, header connectors and heatshrink tubing. Tools required include a soldering iron, solder, screwdrivers, snips, wire stripper, hot glue gun and heat gun.
Hardware Build
The photographs below show the steps in building the WiFi Autobot lamp.
Software
Before starting to write any code the Arduino Yún was initially setup as per the instructions in the Getting started guide. The examples were tried to ensure the Yún was functioning properly and able to connect to my WiFi without problems.
The software for the lamp consists of an Arduino sketch running on the Atmel 32u4 microcontroller and a simple web page and images being served by the Linux portion of the Yún. The web pages are kept in a folder/directory called www within the Arduino sketch folder. This will then be sent to the Yún when the sketch is uploaded over WiFi. It doesn’t appear to do this if the sketch is uploaded via the serial port, presumably this is because over WiFi the portion is handling the files and able to access the micro SD card.
The sketch is based on the Yún Bridge example with extensions to interpret the rgb command. Example command URLs are: (If you have problems using the .local domain, for instance if using Microsoft Windows, then you would need to use the IP address for the lamp.
- http://lamp.local/arduino/TransformerLamp/rgb/off – Turn off the lamp
- http://lamp.local/arduino/TransformerLamp/rgb/ff0000 – Set lamp colour to red
- http://lamp.local/arduino/TransformerLamp/rgb/random – Set random colour mode
- http://lamp.local/arduino/TransformerLamp/rgb/rainbow – set rainbow mode
The web page is accessible http://lamp.local/sd/TransformerLamp where lamp is the name I’ve assigned to the lamp and TransformerLamp is the name of the sketch. The actual html, css and images for the web page were downloaded from an Ajax colour picker I found and was based on http://www.w3schools.com/tags/ref_colorpicker.asp.
Example of the web page controlling the lamp
The code is available on GitHub