Monday, May 18, 2015

Ideas

First off, a new adapter for the WiFiChron or HDSP clock. The 8-LED Neopixel stick from adafruit has the perfect dimensions to fit them. Naturally, the time is displayed in color code. The best definitions for the 10 colors I could come up with are these:

byte color[10][3] =
{
  {0,0,0}      /*black*/,
  {30,9,0}     /*brown*/,
  {100,0,0}    /*red*/,
  {128,60,0}   /*orange*/,
  {110,120,0}  /*yellow*/,
  {0,64,0}     /*green*/,
  {0,0,111}    /*blue*/,
  {64,0,63}    /*violet*/,
  {15,15,15}   /*grey*/,
  {127,127,127}/*white*/
};

The clock code is trivial, especially because it's using the great Neopixel library. Below is the most important function:

void displayTime()
{
  byte digit1 = hour/10;
  byte digit2 = hour%10;
  
  strip.setPixelColor(0, strip.Color(color[digit1][0], color[digit1][1], color[digit1][2]));
  strip.setPixelColor(1, strip.Color(color[digit2][0], color[digit2][1], color[digit2][2]));

  digit1 = minute/10;
  digit2 = minute%10;

  strip.setPixelColor(3, strip.Color(color[digit1][0], color[digit1][1], color[digit1][2]));
  strip.setPixelColor(4, strip.Color(color[digit2][0], color[digit2][1], color[digit2][2]));

  digit1 = second/10;
  digit2 = second%10;
  
  strip.setPixelColor(6, strip.Color(color[digit1][0], color[digit1][1], color[digit1][2]));
  strip.setPixelColor(7, strip.Color(color[digit2][0], color[digit2][1], color[digit2][2]));
    
  strip.show();
}

The video I took of the clock in action is, for the lack of a better word, of too little value :), mainly because my camera doesn't seem to distinguish the colors as well as my eyes.

Even though this photo sucks, I added it only as proof :)


The time is shown as "HH MM SS", with spaces between hours, minutes and seconds. 0 is represented by an unlit (off) pixel. It is easy to get used to the colors, with help from the changing seconds.

Note that the 595 shift register on the board is not used (could even be removed, or not mounted at all).

Secondly, here is how one can save $20 on WiFiChron with GPS: use the $12 ublox instead of the $32 GPSBee. Some minimal wiring is required though, to connect 3 lines (5V, Gnd and Rx) to the module. Luckily, the GPS module has the right dimensions to fit in the spot for XBee (without the 2 headers mounted, nor the 74HC125, which is not needed in this case anyway).


If you really want everything to fit in the Serpac A20 box, you need to replace the original antenna with a smaller one (but working just fine), as shown in the next photo.


Thirdly, Craig (thanks very much!) published on thingiverse the plans for a 3D-printed enclosure he designed for Wise Clock 4:



Saturday, April 4, 2015

"Home-made", Wise Clock-based, Alpha Clock Five

I saw Justin's recent post on Alpha Clock Five and I just couldn't resist not to try it myself too. Since I didn't have that clock, I thought of improvising one by making a 5-character display that would plug into my Wise Clock 4 board. The idea was easy, the implementation not so. After many hours of hand-wiring, this is how it looks like.


The displays are 1" single digit alphanumeric (common anode) from sparkfun, now retired. They came with non-functional dots, probably the reason they were less than $2 each.
The spacing between the individual displays is forced by the protoboard.


The 2 boards are connected through the pairs of 2x8 headers. All pins used by Alpha Clock 5 to drive the displays are wired to the unused header on the Wise Clock 4 board.


Not to mention  that the software compilation and upload worked without any glitch (after downloading the very nice DS1307RTC library)

The only regret is that this clock lacks seconds. One extra display would have added lots of extra value, but probably lacked the cool factor (the "6-letter clock" requires a lot more memory to store all 6-letter words than the approx 50k required by the 5-letter-word collection).

You should try this at home :)

Sunday, March 29, 2015

Modding WiFiChron with GPS or Bluetooth

The latest revision of WiFiChron has an XBee socket (beside the ESP8266 8-pin socket), which allows the addition of a few individual features:
  1. GPS-based time synchronization, by using the GPSBee;
  2. displaying messages sent from a Bluetooth device, by using the BTBee/BLEBee;
  3. displaying data acquired from an XBee/ZigBee network of sensors (not implemented yet);


Things did not go smoothly, without some drama though. Naively (I always seem to forget that there is a difference between theory and practice), I designed the XBee/ESP to connect to the serial port, with the expectation that once the development (including testing with debug statements to the serial monitor) is done, I will just plug in the serial module (either XBee of ESP8266) and things will work properly. Well, I had to re-consider this approach once again. Luckily, I had two pins left available (D7 and D17), which I could use for software serial. I re-wired those to the XBee/ESP and used the hardware serial for console communication. Until the next board revision, anyone wanting to follow will need to re-route a couple of traces manually, as shown in the photos below (cuts are red-circled).


A few details on my implementation of the GPS time sync (so that one doesn't need to look at the code to figure it out):
  • user can set a timezone (stored in eeprom, default is -1); there is no (easy) way to determine if the timezone was set or not, since -1 (eeprom byte being 255) is a valid value;
  • estimate the timezone from the longitude, assuming that a every 15 degrees is an hour difference;
  • a difference between GPS estimated timezone and the user-set timezone of more than 2 hours would mean that the time is way off and the user did not set the timezone; in this case, blink the display; a difference of 2 hours or less would be acceptable (for many reasons, including summer-time, or variations from the "15-degrees-longitude-per-hour" approximation);
  • in any case, the minutes and seconds are set from the GPS data;
  • date and day are not set/synchronized at all (currently);
  • the GPS sync is scheduled to happen every 10 hours (and also after a reset);
  • a successful sync is indicated by an up arrow at the end of the scrolling date (e.g. March 29, 2015 ^).
I will publish the code as soon as I have a chance to polish it (and also test it with BTBee).

As you can see in the photo below, the GPS antenna fits well in the case. It also works well: the GPS has good reception inside the house, 5 meters from the closest window.


Tuesday, March 17, 2015

How to assemble the 2-servo mini pan-tilt kit

Mystery solved!

This is somehow embarrassing, but I post it anyway, hoping that it may help others.

Although it looks easy, I had trouble assembling the mini pan-tilt kit from adafruit, specifically the bottom servo. I just couldn't figure out how to fix the servo with screws to the main arm, since there are no holes for screws (unless I drill them myself). Also, there is no guide anywhere to be found (uncharacteristic for adafruit), nor explicit photos of the assembled parts. I thought that there must be a trick, so I bought the assembled version as well. Guess what? The "trick" is obvious, and I missed it because I was focused on using the screws! The bottom servo must be inserted in the 2 tracks on each side of the two symmetrical parts that make the arm, no screws needed!

When assembling the kit, the easiest way is to start by attaching together the 2 symmetrical parts of the arm, with the servo between them. (In the photo below, i was too lazy to completely dis-assemble the 2 halves of the arm, I only pulled them apart enough to fit the servo in between, with servo's bracket in one of the tracks.) Notice the servo's bracket snug in the groove.


See? No screws on either side of the servo! Because they are not needed!



I hope these photos will bring some light and spare the frustration to (probably very few) people like me.

Friday, March 13, 2015

WiFiChron with software support for ESP8266

Another great software update from MikeM (download here)! This one has support for the ESP8266 module, allowing the WiFiChron clock to:
Before getting excited and jumping to compile and upload the new sketch, there are a few steps to be done on the ESP8266 module:

1. pull the CHPD pin high with a 10k resistor to Vcc;

2. make sure you can communicate with the module using a serial port; this could also include checking the version of the installed firmware (AT+GMR);

3. upgrade the firmware on ESP8266 to version 0.9.6.

After you download the bin files, the next step is to find a tool that would upload those bin files onto the chip. There are many tutorials on how to do this, some sketchy and ambiguous, some detailed and very helpful. In my search, I found references to a few different tools: XTCOM (old MFC Windows app), "NODEMCU Firmware Programmer", ESP flash downloader, ESPtool (python).

The easiest one to use for me seemed XTCOM, with my only complaint being that COM port selection was limited to COM1-6. Luckily, on Windows XP I am using, I was able to change the serial port from the default (assigned by the OS) COM9 to COM2 (the only one available in the range COM1 - COM6). I used this tutorial to load this firmware.

4. Change the baud rate from the default (after firmware upgrade) 115200 to 38400, for the following reason: according to the datasheet (table 20-6, page 189), ATmega328 running at 8MHz has an error rate of approx. 8% communicating on serial port at 115200.

Now, with the ESP8266 module prepared and plugged in, to connect to your wireless network, you will need to configure the module by providing the SSID and the password. To start this process, select "Init" for the "Wifi" menu item. There is an additional "init y/n" option to confirm the init. Once in "init" mode, the ESP8266 module starts acting as access point (another wireless network), using the SSID "WiFiChron". Connect to it using the key "WiFiChron" (*).


The clock will display (scrolling) an IP address, something like "192.168.4.1". Connect to the WiFiChron's access point with your computer/laptop/tablet/phone and web-browse to that IP address, as shown in the screenshot below.


Use that page to configure your local access-point SSID and key.  You can also configure an optional SNTP host for synchronizing time and an optional RSS URL.  Fill in something like pool.ntp.org for the SNTP host or http://w1.weather.gov/xml/current_obs/KNYC.rss for the RSS URL.

Clicking on the "Submit" button will send the configuration to the WiFiChron system, which will write it into its eeprom. If you check "Activate" before submitting, the WiFiChron will immediately switch out of access-point mode and attempt to connect to the SSID/key that you've entered.  If you have problems, you can power-cycle the WiFiChron.  It will use whatever settings it has stored in eeprom.

(*) Although the "WiFiChron" network was detected, I could not connect to it from my Windows XP machine (acquiring network address takes forever and eventually fails). It worked much better with my Android tablet. This is the reason why the first screenshot above is from my XP machine and the second is from my tablet.

NOTE: The ESP8266 module must be taken out of the socket while uploading the sketch (since it's connected to Rx/Tx as well).