Thursday, December 25, 2014

XBee-fy the ESP8266 WiFi module

With the new ESP8266 module, adding WiFi to any Arduino project became a lot cheaper.
This module has a serial interface; therefore it only requires connecting 4 pins: Tx, Rx, 3V3 and Ground, as shown in this image.

A few peculiar facts about ESP8266:
  • default serial baud rate is 57600; since this rate is too high for SoftwareSerial library, a hardware port should be used;
  • requires 3V3 for power and level shifting for Rx signal (5V to 3V3);
  • physical interface is a 2x4 pin male header;
  • firmware can be upgraded to a version that allows 9600 baud rate;
  • can be used either as client or server.
The first two characteristics makes it a perfect candidate for a module with an XBee footprint, as is WiFly, for example.

It took me about half an hour to do it, following these steps.
  1. cut a piece of 2-mm perfboard to the XBee dimensions;
  2. solder two 10-pin the 2-mm-spaced male headers on the sides;
  3. desolder (using wick) the 2x4 header;
  4. mechanically attach the header-less ESP8266 module to the XBee perfbord, by soldering 4 pins into the corner holes, aligned with holes in the perfboard;
  5. wire the pins 1, 2, 3 and 10 of the Xbee-type module to pins Vcc, Tx, Rx and Gnd of the ESP8266 module respectively.

And now a few photos. Start with these (XBee shown for comparison purpose):


to make this:



Then plug it any Xbee socket, like one on Wise Clock 4:


or Adafruit XBee adapter:


Hopefully now more people can try adding new WiFi features to their Wise Clocks without breaking the bank (paying $35 for WiFly).

Sunday, December 14, 2014

M4 receiver backpack for reliable wireless remote control

My investigation into the failure of the M4 receiver remote controlling my Wise Clock 4 concluded with the need to add a step-up converter. The Sure 1632 display makes the input voltage drop sometimes below the absolute minimum of 4.5V required for the M4 module to work properly. It's not the noise (spikes) in the 5V power, nor the interference on 315MHz.

I designed a simple "M4 receiver backpack" that uses a DC-DC step-up converter to ensure a 5V power for the M4 receiver module. The board supports 2 different kinds of converters, one from ebay (red in the photo below), the other from tindie (made by BBtech, black in the photo).


The backpack can be used, by default, without the step-up converter if the voltage is steady at around 5V. (A trace-jumper must be cut when a converter is added.)

The wireless remote pair of 4-key fob transmitter and receiver module is sold by Adafruit or vendors on ebay.

The assembled board wired to Wise Clock 4 is shown in the photos below. Note that only 3 out of 4 buttons on the remote have a function on the clock. Each button press could light up a (optional) LED on the receiver board for visual confirmation.


A new design of the Wise Clock 4 board should probably feature a header for plugging in the receiver module, otherwise the back of the board will show a bunch of ugly wires.


This M4 receiver backpack could be used for adding remote control to other devices with buttons, especially when these buttons are hard to access (due to enclosure design constraints), or hidden (for aesthetic purpose). One example that comes to mind is an oscilloscope clock fully enclosed in transparent acrylic; drilling holes for the buttons would require some design stretches.

Schematic and board layout are shown below.



The M4 receiver backpack would be also suitable for hacking old commercial alarm clocks. Please let me know if anyone is interested :)

Sunday, November 30, 2014

It happened again

Once again, Sure Electronics modified their 32x16 3mm LED display, and this time not only cosmetically.
The two 16-pin shrouded male connectors have been replaced with 10-pin connectors. And the worst thing is that the display now requires 12V for power! Maybe these new displays are intended for use in vehicles powered by 12V batteries. Or maybe designers thought a 12V power source is easier to access than a 5V one. In any case, the display has an on-board DC-DC switching regulator (with XL4013) to make the required 5V.

For someone who needs to replace the older model with the new one, the immediate consequences are:
  • the connector between the driver board (e.g. Wise Clock 4) and the display won't work; connections must be re-wired, probably using an adapter cable;
  • either supply 12V to the board through the connector, or hack the display by soldering the 5V wire directly to the board (see the photos);
  • the holes won't align anymore.

The good news is that the display is electrically compatible with the old one. With the correct re-wiring, the display should work without any software changes.

The following photo shows the testing of the display with the Wise Clock 4 board (and it works just fine).


The display has a series of rail bars that can be used for soldering the 5V power wire, as shown below.


A new design based on this display should (or must) use a 12V power supply. Powering from the USB is not an option any more. This would require a re-design of the Wise Clock 4 board as well (USB connector would be useless now; the FTDI cable won't be able to power the display).

Saturday, November 29, 2014

From the mailbox (with software updates)

New software for the Bubble clock from MikeM:
I have the bubble LED shield working with the DS1337 RTC & LiPo shield.  I have it alternating the display with the battery voltage every 2 seconds right now.  I don't have a voltmeter handy, so I haven't verified what is displayed with actual voltage.  It started fully charged at 4.2v and has now dropped to 4.1v.  It should start blinking at 3.45v, and go to sleep at 3.3v.
I started with your original bubble sketch from the blog posting, but then had to remap all the display pins from the schematic.  The current version of the SevenSeg library doesn't match your code, so I had to make some adjustments.
I also changed the SevenSeg library code to even out the brightness.  It looped through all the segments and turned on each appropriate digit, then delayed and turned everything off.
I changed it to loop through all the digits, turning on each appropriate segment.  Once all the appropriate segments are lit, it turns on the current digit, delays, then turns everything off, then moves to the next digit.  With the previous method some segments were bright and some dim, depending on what was displayed on the other digits.
I also changed the SevenSeg library to not blank leading digits.  It now displays 01.36 for 1:36 AM.  I left it as a 24-hour clock.  I can only display a decimal point, not a colon.
Thanks again Mike!

From ScottH, another version (HDSP.ino only; the rest of the files are unchanged) of the HDSP clock sketch adds scrolling of the time and date and improved setting. Thanks Scott!

From DaveC [on the HDSP clock]:
Here are the pictures.  Hope you find it interesting, unique at least.   There is a slide switch in the back with selections Solar charge, USB charge, USB run (the default mode of the kit), and battery run where you press that button on the front to turn on and display the time.   I used a solar/USB  charge board from Adafruit as I am no EE to figure out how to charge a battery from solar and USB with all of the correct regulated voltages etc.  The case is made from corian and in the top view those speckles are a kind of metallic flake in the corian, the center band is pure black. 




From EricL [on the HDSP clock]:
We got the package last week and my 13 yr-old grandson and I soldered it together and powered it up. Works perfectly!! Then I got your Arduino code for it and programmed it with a flashing ':' between hours and minutes and between minutes and seconds. Then I set the date in the RTC and changed the code again. Now it shows the date for 2 seconds every minute. Nice! Thanks for a great project!

From GregoryK [on the HDSP clock]:
Your kit is fantastic. Simple but well thought out. Thanks for bringing it to the market!
I would like to use it in one of my classes at Stanford as an "intro to soldering" and "intro to Arduino hacking" (they already will be familiar with the Uno) project.

From IvanS [on Wise Clock 4]:
Thank you Florin for the very thoughtful and entertaining  gift. Anything based on electronics is always interesting to me. We have been reading the famous quotes all day. It was a pleasure to meet you [...]

"Double Bubble Clock" shield for ProMini

I could have added a second bubble LED display to my "bubble clock" by connecting the anodes for the 4 new 7-segment digits to the only 4 pins left available: D0, D1, A6 and A7.
Instead, I preferred to use the expensive ($8+) LED driver MAX7219. Luckily, I got mine a long time ago as free sample from Maxim, and this was my chance to use it. As one can expect, the "double bubble" clock can display the seconds, plus the date and day of the week.


Below are the 2 bubble clock versions side by side. Both are ProMini shields, so ProMinis get plugged on their backs. I designed them to stand by themselves with the electronics exposed and on the open, as shown in this post. I am not sure if this is a good idea, but designing (or finding) an enclosure seems even a bigger challenge.


The sketch, included below, uses the LedControl library (communicates with MAX7219 through SPI).

#include "LedControl.h"
#include "Wire.h"
#include "DS1307.h"

#define PIN_DIN          12
#define PIN_CLK          11
#define PIN_LOAD         10
#define PIN_BTN_SETHOUR  2
#define PIN_BTN_SETMIN   9

int hour, minute, second;

// read time from DS1307 at intervals;
#define MAX_TIME_READING_COUNTER  1000
long timeReadingCounter = MAX_TIME_READING_COUNTER;

LedControl lc = LedControl(PIN_DIN, PIN_CLK, PIN_LOAD, 1);

void setup()
{
  // MAX72XX is in power-saving mode on startup, we have to do a wakeup call;
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
  pinMode(PIN_BTN_SETHOUR, INPUT_PULLUP);
  pinMode(PIN_BTN_SETMIN,  INPUT_PULLUP);
}

void displayTime()
{
  // hours;
  lc.setDigit(0, 4, hour/10, false);
  lc.setDigit(0, 5, hour%10, false);
  // minutes;  
  lc.setDigit(0, 7, minute/10, false);
  lc.setDigit(0, 0, minute%10, false);
  // seconds;
  lc.setDigit(0, 2, second/10, false);
  lc.setDigit(0, 3, second%10, false);
  // delimiters (optional);
  lc.setChar(0, 1, ' ', true);
  lc.setChar(0, 6, ' ', true);
}

void loop()
{
  checkButtons();
  timeReadingCounter++;
  if (timeReadingCounter > MAX_TIME_READING_COUNTER)
  {
    getTimeFromRTC();
    displayTime();
    delay(5);
    timeReadingCounter = 0;
  }
}

void getTimeFromRTC()
{
  int rtc[7];
  RTC_DS1307.get(rtc, true);
  // check to avoid glitches;
  if (rtc[DS1307_MIN] < 60 && rtc[DS1307_HR] < 24 && rtc[DS1307_SEC] < 60)
  {
    second = rtc[DS1307_SEC];
    minute = rtc[DS1307_MIN];
    hour   = rtc[DS1307_HR];
  }
}

void setTime(int hh, int mm, int ss)
{
  getTimeFromRTC();
  RTC_DS1307.stop();
  RTC_DS1307.set(DS1307_SEC,  ss);
  RTC_DS1307.set(DS1307_MIN,  mm);
  RTC_DS1307.set(DS1307_HR,   hh);
  RTC_DS1307.start();
}

void checkButtons()
{
  // increment hours and minutes;
  if (LOW == digitalRead(PIN_BTN_SETHOUR))
  {
    hour++;
    if (hour>23) hour = 0;
    setTime(hour, minute, 0);
    delay(400);
  }
  if (LOW == digitalRead(PIN_BTN_SETMIN))
  {
    minute++;
    if (minute > 59) minute = 0;
    setTime(hour, minute, 0);
    delay(400);
  }
}

Since it's a shield, the board requires a ProMini. The device takes about 50mA.
Schematic and board are shown below.




I shared the PCB layout at OSH Park, so anyone can make their own.