Introduction: WIFI Controlled LED Hat
Here you learn to use an Intel Edison Microcontroller Board to connect to LEDs as output and to use WIFI as an input method to change colors or animations of the LEDs.
I also is a step by step guide how to setup the Edison and how to avoid mistakes.
Step 1: Unboxing
The Intel Edison comes in a card board, with is not easy to open with bare fingers without destroying the box.
You need to find three transparent, round stickers.
Cut the stickers to slide the blue outer part of the box sideways. I do not know why the box is sealed with three stickers. The box is well designed and would not open accidentally without them.
After opening the box you will see the small Edison Compute Module as in the above picture.
As you can see it is placed in another clear plastic enclosure.
Pull it gently.
Step 2: The Intel® Edison Board for Arduino
Hidden underneath in the box of the Intel® Edison Kit for Arduino, you will find the Edison Board for Arduino.
Before touching it or the small Edison module itself, make sure that you are not electrostatic charged, which could harm sensitive electronics. Therefore the Edison Board for Arduino is protected in a metallic shielded bag. The small Edison itself is not protected like that.
In another small bag are four metal screws and four standoffs. Use these standoffs to avoid direct contact between the electronic board and your table or anything else, which might be lying around.
Be careful in the that bag are also two very small screw nuts, you will need them soon.
The Edison Board for Arduino has six screw holes, but we only have four screws. So choose the four outer ones.
You put a screw from above though a hole and hold it with one finger. Fix the standoff from the bottom side by turning it with your finger. I did not use a screwdriver, because there was none in the box.
The two other screw holes could be used to fix an Arduino Shield. But we do not have screws or standoffs for that.
Step 3: Connecting the Edison Board With the Arduino Board
After fixing all for standoffs open the enclosure of the small Edison and put it on to the Edison Board for Arduino.
The mounting holes of the small Edison board should be aligned with metal standoff on the big board. The tiny 70 pin connector on the bottom side of the small board should also aligned with its counterpart on the big board.
If everything looks OK, then gently press the two boards together. You should feel a slight click, when the connectors snap together.
Now comes the fun part. Get the first of the two screw nuts out of the bag, without losing it. And then screw it on one the metal standoffs to fix the Edison board.
A tool for that would be very useful, but it is not in the box, so use your fingers again. If your fingers are to big for that, then ask someone with smaller fingers, to do it. Shake hands with the other person, before letting her touch the fragile electronics, just to avoid harmful static electricity. If you do not want to shake hands, one kiss is also sufficient to discharge high static voltages. Now comes the second screw nut and a second opportunity to find someone pleasant to help you.
Step 4: Connecting the Edison to Your Computer Via USB
Now you have assembled your Edison Kit for Arduino, you need to connect it to your computer via USB.
To confuse you, the Edison board for Arduino has three different USB ports.
One USB type A and two different Micro USB ports.
As you might guessed or not, the right one is in the middle.
(I have a Mac, if you have for example Windows, things could be more complicated, for example you should first install the right Drivers before connecting this USB Device. Because I have no experience with that, I will not further talk about those details here. No drivers are needed with a Mac.)
So use the middle USB connector with a suitable cable to connect to your computer.
This connection is used for three things:
- To give 5V power from your computer to the board.
- To mount a drive provided by the Edison, to copy files from your computer to the Edison.
- To upload programs written with the Edision Arduino IDE from your computer to the Edison.
If the Edison board has power, at least one tiny green LED hidden somewhere in the middle on the board should light up. And on your Desktop should appear a new Icon named "EDISON", which takes you to an initially empty drive.
Step 5: Use the Edison As an Arduino
To use the Edison like an Arduino, you need the Arduino Software. But I used not the usual software from arduino.cc but I got all the Software on an USB-Stick from Intel at the Intel® IoT Roadshow. And finding something yourself on an Intel Website could be difficult
Maybe the link on the Arduino Website will help you.
After starting the Edison Arduino Software version 1.6.0 there came a message that a newer version 1.6.3 is available, which I did not install, because I thought, that it would not support the Edison. But apparently it will. But I have not tested it.
Every time you want to use an Arduino for the first time or a different one, you have to select the Board and the port where you connected it, via the tools menu of the Arduino Software. Unfortunately there is no autodetection of the right board and port in the Arduino Software. So you must decide it right. Otherwise it will not work and you will get very weird error messages.
So choose "Edison" as board.
Step 6: Selecting the Right Arduino USB Port
If you have problems to find out the right name of the USB port, you could compare the of USB ports when the device is connected, with the list, when it is not connected. In my case the port name starts with "/dev/cu.usbmodem".
Now use the menu "File -> Examples -> 01 Basics -> Blink". A new window will open containing the source code of the Blink Programm. You can compile and upload it to your Arduino or Edison by using the (second) upload icon in the toolbar of that window.
Step 7: Successful Blinking LED
There should be a success message "Transfer complete" in the bottom part of your window. And another tiny green LED somewhere in the middle of the big Edison board should be blinking for one second on and for one second off.
Step 8: Using the Serial Port
Connect a secondUSB Cable to the small USB port on the left with another free USB Port of your computer.
Open a Terminal Window on your Computer.
To open Terminal.app on your Mac just use the search icon in near the top right corner of your screen. Klick on the magnifier symbol and type: Terminal
And then press the Return key on your keyboard.
The Terminal.app will open a window.
Find the name of the newly connected port by typing into the Terminal window:
All letters in the above command are lowercase.
The result should be something like that, where XXXXXXXX would be probably different for different devices:
Now you know the device name to connect to. Type a command like this, but using your device name and not XXXXXXXX:
screen /dev/cu.usbserial-XXXXXXXX 115200 -l
115200 is the connection speed of the Edision and the -l stands for "login".
After pressing the Return key, you should see a "login:" prompt.
Enter the following username:
You will not be asked for a password at this time.
The Root user has all rights on a Unix system, so be careful.
Step 9: FAT32 Is Needed for Upgrading the Firmware
The firmware is the software of the Edison, which is stored in its built-in memory. It includes the Linux operating system of the Edison and some additional tools for configuring the Edison.
The preinstalled software of my Edison hat some strange errors, like ignoring each first letter that was typed into the Terminal window.
First you have find out which filesystem is used on your EDISON drive. Click on the icon of the EDISON drive on your desktop. And press command-i to its information. If you see "MS-DOS-Filesystem (FAT32)", you are lucky. But if you see "MS-DOS-Filesystem (FAT16)", then you have to do an additional step to change FAT16 to FAT32.
Step 10: FAT16 Will Not Work
I did not check if the EDISON drive was formatted with FAT32.
I copied all the needed files to the EDISON drive and tried to upgrade the Edison. But nothing changed. The version was still 1.6 .
I thought, if I can copy files onto it, the Edison should be able to read its own drive.
But that was wrong.
Step 11: Reformatting FAT16 to FAT32
I had to reformat the EDISON drive with the "disk utility.app", which you can find and start again via the search symbol in the menubar of your Mac.
Make sure to delete only the EDISON and not any other value data.
(Do you have a recent backup of all your data?)
After reformatting the EDISON drive as MS-DOS it should now have the FAT32 format.
Step 12: Upgrading the Firmware of the Edison
I got the new firmware on an USB stick from Intel as a zip file named:
I double clicked the icon of this zip file to extract all of its content to a folder with the name:
I opened that folder by double clicking its icon. I marked all files contained in it by pressing command-a.
And I copied those files via Drag & Drop to the EDISON drive.
To install the new firmware type in your Terminal window:
While the Edison is rebooting you will see a lot of messages and after that, you can login as root.
The version should be changed from 1.6 to 1.6.1 . And in my case all the configuration changes I had already done on the Edison where lost.
Step 13: Configuring Name, Password and WIFI
Intel has provided one useful tool for configuring your Edison.
To use it type in Terminal window:
If you successfully had updated the firmware in the previous step, the tool will show you how to use it:
usage: configure_edison [-h] [--server]
[[--setup | --name | --password | --wifi]
[--showWiFiIP | --version | --latest-version | --upgrade | --disableOneTimeSetup | --enableOneTimeSetup | --flash [ ...]
| --flashFile | --showNames]
-h, --help show this help message and exit
--server Starts the server (testing only)
--setup Goes through changing the device name, password, and
--name Changes the device name
--password Changes the device password
--wifi Changes the wifi options
--showWiFiIP IP address associated with the wireless interface
--version Gets the current firmware version
--latest-version Gets the latest firmware version
--upgrade Downloads the latest firmware
Disable one-time setup and WiFi access point
--enableOneTimeSetup Enable one-time setup and WiFi access point
--flash [ ...]
Downloads and flashes an image
Flashes the given image (.zip).
--showNames Show device name and SSID
So type this, for changing password, name and WIFI:
And follow the instructions, that will be shown by the above command.
On success two URLs will be shown how you can access the Edison via WIFI from any web browser in your local WIFI network. Both URLs should work.
Step 14: Using Ssh
After configuring the Edison to use your local WIFI network, you have a second way to login into your Edison.
The first way was via USB cable using the screen command.
The second way is remotely without cable using the ssh command from your computer.
To do so open a new Terminal window.
Type, where xxxxxxxx should be replaced by the name you gave the Edison:
ssh xxxxxxxx.local -l root
Step 15: Connection the Edison Via SPI to the LEDs
Serial Peripheral Interface (SPI) is way to connect different hardware devices and sending information over the connection.
To connect LEDs of the type WS2801 to the Edison, two wires for signal and two wires for power are needed.
- + 5 Volt (5V)
- Ground (GND)
- Data (MOSI = Master Out Slave In)
- Clock (SCK = Serial Clock)
The corresponding pins on the Arduino connectors of the Edison are:
- Pin 11 (MOSI)
- Pin 13 (SCK)
II used four jumper wires to connect the Edison to the LEDs, which have a four pin JST SM connector at both ends of the string. One connector at the LEDs is for input and the other for output. The output is needed, if you want to connect more than 50 LEDs. Using many LEDs might draw too much power.
Each LED is marked with an arrow symbol showing the direction from input to output. I only connected the input.
Step 16: Isolating the Power Wires of the LEDs
In addition to the JST connectors there are two loose wires for power at each end of the LED strings. These are additional power wires are indented for large installations with many LED strings, where you definitely need to supply power at more than one point. Otherwise the last LEDs will get a lower voltage and light up darker and more reddish.
I connected the power wires of the same color from both ends, which each other. Otherwise blank wires would be laying around and would be sooner or later cause a short circuit, which might damage a lot.
So a cut two 2 cm pieces with scissors from a roll of a heat shrink tube with 2 mm diameter. Then pushed one wire end trough the tube and soldered the wire together with the other wire of the same color. After this I pulled the tube to the middle of the connection to isolate it. A temperature around 90°C will shrink the tube to fix it. If you do not have a hot air gun with that regulated temperature, a hot air hair dryer could also work, but not so easy.
Step 17: Using SPI
There comes a standard SPI library with the Arduino Software.
To use this library in an Arduino Sketch, just add the following line in the beginning of your source code:
As we have seen in the Arduino Blink example code (Blink.ino), an Arduino Sketch has to function:
The setup function will run once, every time when your program on the Arduino is restarted again, which happens after connecting to power, and after uploading a new Sketch and after reset.
Then the loop() function will run repeatedly until disconnecting the power, uploading or reset.
To use initialize the SPI library, put the rolling line into your setup function, which then could look like this:
And then you can use a function which I have been successfully used on the Intel Galileo and the Intel Edison, but it is not documented on the official Arduino website.
SPI.transferBuffer(bytes, NULL, size);
Where "size" is the number of Bytes to transfer. For 50 LEDs with 3 Bytes for 24 Bit RGB Color per LED this would be 150 Bytes.
You will find the my original code, which I used to use the SPI interface of the Edison for the first time, in my GitHub repository. I made this code originally for the Arduino Nano, Arduino Uno and Arduino Pro Micro. Then I modified it to run with the faster Intel Galileo. And the same code runs now without modification on the Intel Edison.
Step 18: Running a Web Server on the Intel Edison
After configuring the Edison to use WIFI a web server is already started on it and it show page where you can see the name and the IP address of your Edison.
I stopped and disabled that web server to run my own web server inside an Arduino Sketch.
But I think you just can change the standard port number 80 in the Arduino Sketch to have it run on a different unused port number.
I used the an Ardunio example code, which I found in the Arduino software in the menu:
File -> Examples -> WIFI -> SimpleWebServerWiFi
You have to change at least two lines of code, to make use of it:
char ssid = "yourNetwork"; // your network SSID (name)
char pass = "secretPassword"; // your network password
To see the small web page which is produced by that sketch, you need have a computer or a phone with browser. I that browser you enter the name or the IP address of your Edison.
Instead of toggling one LED on or off, I modified the code so, that all 50 LEDs could be switched Red or Green.
Step 19: Changing the Animation of the LEDs Wirelessly Via Phone
I the above picture you see, how the screen of the phone looks like, when connecting wirelessly to Edison.
I made five links. One to switch all LEDs off and four other links to switch between four different animations.
As mobile power supply for the Edison and all LEDs I used one rechargeable USB battery. I measured a power consumption of about 300 mA, so it can run for hours.
For practical uses of this WIFI enabled LED Hat I see some problems:
- The Edison with the Arduino Kit is much too big to be a truly wearable device. Even the too big Arduino Uno is much smaller.
- The Edison gets hot. You do not want that near your head.
- You have to wait for the operating system of the Edison to boot and to connect to the WIFI, before you can use it. A usual Arduino starts without noticeable delay.
- You are limited to the area of one WIFI network to control it via phone. This makes it difficult for the use on bicycles.
- Booting the Edison into the Arduino Sketch did not work reliable. If it did not work, I hat to upload the Arduino Sketch again.
Step 20: …
- Intel Edison Ardunio Kit
- 2x male USB A to male USB micro cable
- 4x jumper wire male to female
- String of 50 RGB LEDs with WS2801 ICs from Trafo Pop
- a white hat
- a rechargeable USB battery
- 2x Heat Shrink Tube, diameter: 2mm, shrink factor 2:1, transparent, length: 2 cm
- a Computer with the Arduino software
- a Phone with a browser
- a Soldering Iron
- a Hot Air Gun for shrinking the heat shrink tube
- Scissors to cut two 2 cm pieces of the heat shrink tube
to be continued:
- combining webserver and LED animations