Introduction: Steampunk ESP8266 Internet Connected Clock Using the Arduino IDE
What to you get when a NeoPixel ring, an inexpensive Arduino Wifi board, and a laser cutter walk into a Steam Punk Saloon?
A fashionable Steampunk designed Internet connected Clock using the ESP8266 chip and the Arduino IDE of course!
Here is an evening or easy weekend project to get familiar with the ESP8266 and end up with a great steampunk clock.
Step 1: ESP8266 Primer - the Arduino Advantage
The ESP8266 is one of the newer entrants into the world of "Internet of Things" or "IoT" (Not to be confused with "GOT", where everything dies). Wikipedia describes IoT as "...the network of physical objects or "things" embedded with electronics, software, sensors, and connectivity to enable objects to exchange data with..." other "things". Essentially the idea that everything becomes connected to the internet and exchanges data or commands with everything else. Historians of the future will undoubtedly mark the ESP8266 as the beginning of Skynet.
Leaving Skynet aside, the ESP8266 is a very small (Postage Stamp) sized micro processor with built in WiFi abilities available for ~$3. It operates "as shipped" as a sort of "AT" command set driven modem that can be attached to an Arduino or other similar microprocessor. Alternatively it can be directly programmed using LUA, MicroPython or the newer Arduino IDE. The chip also sports nine GPIO (3.3V logic) pins, which can also be used for I2C or SPI applications and two UART pins to allow the easy addition of accessories like LCD screens, switches, knobs and other controls.
The ESP is a 3.3v device which can be problematic, however using a logic level shifter solves many issues. So does purchasing one of the specialized ESP8266 breakout boards from Adafruit or SparkFun which have some voltage regulation built in to assist with easier and fun making.
The real advantage here is if you are familiar with the Arduino, then you should consider programming the ESP8266 in the Arduino IDE format...nothing much new to learn! The rest of this Instructable will walk through getting set up and building a Steampunk ESP8266 Internet connected Clock using the Arduino IDE.
Step 2: Parts List
HOWEVER many types of ESP8266 modules can be purchased on-line for $3-$6.
This project uses the Adafruit HUZZAH and matching FTDI cable, but any of the units can be used to complete this project.
- NeoPixel Ring - 12 x WS2812 5050 RGB LED with Integrated Drivers
- 3.3 V Voltage regulator - LD1117-3.3
- Wires, solder, glue
- Cabinet or case for the clock (Laser cut instructions included at the end of this Instructable for the one I made)
- 300-500ohm Resistor
- 1000uF Capacitor
- USB Breakout
Laser Cut Case requires:
- 20 x M3 20 socket head
- 20 x M3 Nut
- Steampunk-y decorations
Step 3: Install the Arduino IDE and Update the Boards Manager
Arduino IDE versions from 1.6.2 and later can be used to program boards other then the Arduino. This is done via a "Boards Manager". Its easy - Lets get started!
These instructions where developed on a Windows PC. If you try this on Unix or Mac, please let me know of any major differences - Thank you!
- Download the latest Arduino IDE from here. At the time of this writing its version 1.6.5 that is available
- Run the installer and accept all the defaults
- Start the Arduino IDE
- Choose File->Preferences
- In the text field for "Additional Boards Manager URL's" and paste this URL:
- Click OK
- Choose Tools->Board->Boards Manager
- Scroll down the options until you see "esp8266 by ESP8266 Community"
- Click install
- Let the install Click and Whirrrr for a few (10-15) minutes
- When its done click "Close"
- From the Tools menu choose Tools->Board->Generic ESP8266 Module
- Typically the other defaults are fine:
- Flash Mode "DIO"
- Flash Frequency "40Mhz"
- Upload using "Serial"
- CPU Frequency "80Mhz"
- Flash rate "512K"
- Upload Speed "115200"
- Select under Tools->Programmer->AVRISP mkII
- Choose the Tools->Port that matches port the ESP8266 is plugged into on your machine. This is the most likely thing to go wrong...fix it and try again. Go to the next step and I'll show you how to test the install on your ESP8266
That should be it! We'll test programming in the next step
Step 4: Connect the ESP8266 to Your Computer
Connect the ESP board to your computer using an ESP8266 to an TTL-USB.
The **EASIEST** way is to connect the ESP8266 is to purchase a breakout board from Adafruit or Sparkfun and also purchase the matching FTDI cable to go with it. In the "Parts List" I have created links to a matched and functioning set. OTHERWISE You may need to find a USB-to-Serial cable and match the pins
- Connect the RX/TX pins in a 3v3 FTDI cable to the TX/RX pins in the ESP module.
- Connect a 3v3 power supply to the VCC/GND pins. Note that it is possible to use an Arduino 3v3 supply for this. Connect the CH_PID pin to VCC as well.
- The rest of the pins should be floating. However, be prepared to occasionally ground the RST pin. This would help if the board is stuck on some command.
Step 5: Programming the ESP8266 to Blink
To program the ESP8266, the unit must be placed into program (Bootloader) mode.
To put various ESP8266 boards into program mode:
Generic Modules - Hold the GPIO0 pin low. Ground and release the reset pin. Then release GPO0 pin.
Adafruit Huzzah - hold the GPIO0 button down and press and release the Reset button. Then release the GPIO0 button.
Sparkfun Thing - (Anyone with one? I couldn't find information on how to put it in bootloader mode)
Once the ESP8266 is in bootloader mode, open the Arduino IDE.
On the Arduino IDE interface, choose File Upload (CTRL - U) or the Right Arrow at the top of the window.
After much flashing of lights and such, the Arduino IDE should say "Done Uploading". If not you may need to hunt down the issue - however the 2 most likely situations are that the ESP8266 was not in bootloader mode or that the COM port (Under the Tools Menu) was not correct for the device.
Most ESP boards have an LED and it should now be flashing on a one second on, two seconds off cadence.
On to the Electronics build...
Step 6: Building the Clock
A USB breakout board was chosen as the easiest power source to obtain - a cable and wall wart are inexpensive and also allows the clock to be powered by other USB capable devices. The breakout board has convenient screw holes to attach the board to the case. The USB standard delivers 4.75v and 5.25v which is a touch high for both devices (Although the Huzzah can handle unto 16V). Both the standard ESP8266 boards and the NeoPixel rings are 3.3 volt devices.
Wire the USB breakout GND to the GND of the LD1117-3.3 and VBUS to Vin. You may decide to place a 1000uF Capacitor across GND-Vin to help reduce voltage spikes, which the NeoPixel ring is quite sensitive to. From the LD1117-3.3 GND and Vout you can wire the ESP8266 GND and Vbat. Again, you may decide to place a 1000uF Capacitor across GND and Vbat to help reduce voltage spikes.
Next wire the LD1117-3.3 GND and Vout to the NeoPixel Vin and GND.
Lastly wire the ESP8266 pin #5 to the DATA IN on the NeoPixel. Best practices calls for a 300-500 Ohm resistor between the ESP8266 pin #5 and the input to the first NeoPixel (DATA IN). This resistor must be at the NeoPixel end of the wire to be effective!
That should be the electronics part - Download the Clock Code to your computer.
Change the WiFi Name and password.
Change the variable hours_Offset_From_GMT to reflect your locale. Here in Vancouver, Canada, we are -7 from GMT.
The timeServer variable can be changed if you would like to use a different time server - this is the one that can programmed in the Arduino library example. No authorization is required.
Upload the clock code to the ESP8266. The router name name is the ssid variable and the password is the pass variable.
Step 7: Lasercut Case
Use the attached SVG and/or DXF file to laser cut the case for the clock - This is designed for 6mm Birch. The T-Slots are set for 20mm M3 bolts and nuts. If you don't have access to those and design something new, please let me know! I can add it here as an option for others.
Stain and Varathane the wooden parts.
Note that I retained the inner circle to fill in the middle of the NeoPixel ring. Drill holes for the Esp8266 and USB Breakout and use hot glue to attach the NeoPixel ring and the adornments. MAKE SURE YOU GET PIXEL ZERO (the first one to light, the #12 position on the clock) at the top. Otherwise the time will be hard to read indeed. Perhaps you want that? A clock only you know how to read...hmmm.
Note I used some old typewriter keys to spell "TIME" - you may not want to do that, in which case perhaps don't laser cut the 4 holes I made for the back of the typewriter keys to fit into.
Stain and bolt together.
Plug it IN!
Step 8: How It Works - Telling the Time.
The NeoPixel ring has 12 lights - from numbered from 0 to 11 in the code, but they can be considered 1-12 like in a clock with the "12" at the topmost position.
The clock is reasonably easy to read - Its essentially a blue background with a purple "12" light at the top. The other lights are virtually numbered 1-11 just like a real clock face.
The NeoPixels light up as different colours to indicate the location of each "hand" on the clock.
Lets say its 4:57.
The hour hand is green - you should be able to read it right off the clock face. At 4:57 the fourth light is green indicating its Four-Something O'clock
The minute hand is red - it moves every 5 minutes...4:05, 4:10, 4:15 and so on. In this case the "10" O'clock light will be on...On the real clock the minute hand would point at the "10" at 4:55.
The Minutes hand is Yellow and tracks any additional minutes. In this case the Green and Red hands say 4:55 - so there will be 2 "Minutes" lit up - on light "1" and "2" - to indicate the 2 additional minutes to add to 4:55 - which makes it 4:57!
The second hand is Orange and moves every 5 seconds around the clock - from 1 to 12.
Step 9: How It Works - Code Breakdown
High Level - The clock get the time from a global timeserver, using the Network Time Protocol (NTP) and updates the NeoPixels.
The code starts by defining 5 colours - please feel free to change these and post into the comments if you have good design skilzs.
The Setup initializes the NeoPixel library, draws the background on the clock, tries to connect to the local network and starts the UDP Client. While waiting to connect to the Local network, the NeoPixel ring changes to random colours every few seconds.
The Loop 's job is to update the NeoPixel ring to the correct time on a regular basis, and to get the NTP time on occasion. It has a small amount of code to track the time in between calls to the NTP server.
Participated in the
Epilog Contest VII