spotClock

Filled under: Electronics, Projects

Date posted: July 7, 2016

spotclock-contextual

spotClock is an Internet of Things type of device that displays live gold and silver spot prices.

Gold is the top row, where the current spot price is $1228 per ounce and the daily change is $2.20

Silver is the bottom row, where the current spot price is $17.05 per ounce and the daily change is $0.02

spotclock-front

The three buttons on the top changes the display to show the current time, alarm values, or error code.

When spot moves more than the alarm values provided, the display will flash and the LED will turn blue.

The alarm values are set by connecting the spotClock to a serial terminal via USB and entering the proper commands.

When the wifi or internet connectivity is dropped, the LED will turn red and pressing the error button will show the http error code.

spotclock-inside

Here you can see the spotClock is driven by an Arduino Nano and the LED 7-segment displays are modules connected via SPI.

The module to the right is the esp8266 wifi controller. Amazing little module for only a few dollars! It connects to the Arduino via UART.

To connect the esp8266 to my home wifi I had to enable the G network type as these modules are only 2.4GHz and also don’t support N.

The username and password are setup over the serial terminal and stored in EEPROM.


spotclock-wifi

Another issue with the esp8266 module is that it would not connect when I had the module mounted in the picture before the above.

I needed to the turn the module so the trace antenna was not directly next to the acrylic housing. An easy fix.

The spotClock uses the esp8266 to download a webpage that consists on only a single JSON string. Below is an example:

{“au”: “1229.17”,”auDelta”: “3.27”,”ag”: “17.04”,”agDelta”: “0.00”,”time”: “2016-11-16 20:33:02”}

The string is generated on my webserver using PHP by parsing another JSON string that is scraped on www.providentmetals.com.

http://www.providentmetals.com/services/spot/summary.USD.json

The reason for this extra step is due to the limited memory of the Arduino, the JSON parsing library could not handle the large JSON string provided directly from Provident.

 

Here’s the code, it’s a bit messy and I should of used sprintf and chunked the code more, but is still solid for a quick Summer project: