Wednesday, April 12, 2023

Haiku Display Console

My next project started out as a standalone unit (ie. battery powered) for displaying haikus.  These are poetic forms of Japanese origin that consist of three lines that follow a five-seven-five format (five syllables in the first line, seven in the second and five in the third).  Since I wanted it to be battery driven, I chose an e-Paper display. These displays are ultra-thin, low power units that will hold an image or text for long periods of time without power.  Perfect for my needs. I chose an ESP32 board for my controller because of its Wi-Fi capability and its large memory capacity for holding potentially dozens of haikus.

Initially I planned to incorporate the sleep functionality of the ESP32 to minimize battery drain.  The controller would select a haiku at random and display it, go to sleep for two hours, wake up, display another haiku, go to sleep again,  and so on.  Also, since this type of display needs ambient light to work, it didn't make much sense to keep it running 24hrs a day since the room it was going to be placed in would be dark in the evenings.  Therefore, I planned to put the unit to sleep during the evening and early morning hours (again, to save the battery). 

After writing the code and using a public domain library to interface with the display, I ran some tests to see how long it would work on a fully charged battery.  After about four months it finally stopped running.  I didn't count on the fact that periodically checking the time online would drain the battery so quickly.  Ultimately, I made the decision to scrap the battery idea and use a wall mounted unit for my power source.  This had the added benefit of eliminating the hassle involved in having to keep recharging the battery 3-4 times a year.

To complete the project, I made a custom enclosure out of maple and wormy chestnut to hold the display upright while keeping the electronics hidden underneath.  A few weeks after finishing up, my wife and I both got inspired to write a few of our own haikus while hiking around the Blue Ridge Parkway.  I uploaded these into the controller chip and we now look forward to seeing one of our poems randomly "popup" on the screen from time to time.

A "traditional" Japanese haiku

A haiku written by my wife











Side view showing display thickness

Sunday, August 29, 2021

Programmable Timer Using an ATtiny45

I've been wanting to be build a simple timer ever since I got my amateur radio license a few years back.  FCC regulations state that your call sign must be transmitted at the start and end of each transmission and at least once every ten minutes during a call.  My original idea was to use a simple 555 timer to drive a binary counter which would activate an LED upon timeout.  I toyed around with it for a couple of years and had a circuit sketched out but never followed through with it for various reasons.  Fast forward to 2021 when I came across a project someone had created using an ATtiny85 microcontroller.  I'd never heard about these devices before but immediately thought it would be a perfect solution for my timer.

The ATtiny series of chips are 8-bit microcontrollers that fit within an 8-pin DIP footprint.  The ATtiny45 is the one I decided upon using. It has 4096 bytes of flash memory for holding a small program, 256 bytes of EEPROM, 5 useable I/O pins, interrupt capability, etc., etc.  In other words, a very powerful little device contained in a very small package. Another nice feature is its ability to work down to 2.7v.  This allowed me to use a single, 3v coin cell battery as my power source.

Because of its capabilities I decided to expand on my original idea of having a fixed timing function.  The result is a timer that can be programmed from 1 to 255 minutes while driving 2 LEDS.  The countdown function begins when the "timer" button is momentarily pressed.  A green LED then comes on briefly at the top of every minute to indicate countdown activity.  When the elapsed time gets down to 30 seconds the green LED starts flashing on and off.  If, during the countdown period the "timer" button is pushed again, the countdown event starts over.  Otherwise, upon timeout, the red LED comes on.

To set the time, the "timer" button is pushed and held in.  The green LED will then flash on and off representing the number of minutes to countdown for future timing events.  When the button is released, the minute value is then stored in nonvolatile memory (EEPROM) for future reference.

The entire program only occupies 802 bytes of memory.  One other nice feature I included was a clever power on/delayed off circuit I discovered on a YouTube video (Power On Off Shutdown).  It uses a momentary pushbutton, and two MOSFET transistors (along with the ATtiny45).  Push the button once and power is immediately applied to the chip.  Push it again and power is removed after a short delay to allow for processing of any internal housekeeping tasks.  In my case, when I detect a power down request, I flash the red LED twice as an acknowledgement then shut down.

I used EasyEDA software for laying out the circuit board and had the board manufactured by JLCPCB. The board arrived in about a week.  I built the enclosure from pine which I hollowed out to hold and secure the battery.


The "brains" of the timer




Friday, May 21, 2021

Nixie Tube Clock (or Revisiting the 70s)

I built my first digital clock back in the mid 70s.  It was a Heathkit of course (one of many I built as a teen) and it had a cool looking Nixie-like display.  Fast forward to today when I recently came across a YouTube video featuring a clock with real Nixie tubes.  Most of the tubes available today were manufactured back in the 70s and 80s for instrumentation, test equipment, etc. but apparently there has been a revival of these devices for digital clocks in particular so I thought why not go for it.  The first challenge was locating the tubes but that actually proved easier than I thought thanks to eBay.  I found four tubes from a Russian seller (type IN-8) which were labeled as NOS (new old stock) for $75.00.  These are high voltage devices (upwards of 170VDC or more needed for activating the internals).   To avoid having to scratch build a supply, I decided to purchase one (again from eBay).  A detailed description of the boost converter kit I bought can be found at Threeneuron's Pile o'Poo.  Below is the finished board:

Pretty nifty little device and it only takes up a bit more than one square inch of space.

Next came the components needed to control the clock functions and drive the displays.  I chose an ESP8266 based WiFi module for the controller (ESP8266DevKitC-02D).  The controller periodically retrieves the time from an NTP server, then converts it into four bytes (32 bits) and outputs it via an SPI interface to a serial to parallel logic converter (HV5530).  This particular converter has 32 channels, each capable of handling up to 300V, so it worked perfectly for my application.  

To the right is the controller and voltage regulator along with the various wiring harnesses needed to connect with the display circuit board.  The blue section to the right of the controller is the WiFi antenna.

One minor issue cropped up when using this particular controller and driver and that involved their respective supply voltages.  The ESP8266 is a 3.3v device while the HV5530 uses 12v.  Therefore, to connect the two a level shifter is required.  This was easily solved by using an N-channel MOSFET and two pullup resistors for each control line (shown below):

Level shifter

One issue that all Nixie tubes have in common is something called "cathode poisoning".  As the individual digits (cathodes) are turned on, they emit microscopic particles which can coat the unlit elements.  Over time, enough material can coat the other cathodes to the point that they start to go dim.  To reduce this effect, an anti-poisoning routine is needed in software.  By turning on each digit in rapid succession over a given period of time, the poisoning process can be minimized.  So, prior to turning the tubes off for good each night, I run my routine for sixty seconds, then shut down (I decided to turn off the tubes at 11:00p to help lengthen their useful life which is stated to be in the neighborhood of 10,000 hours.  I have read, however, that the posted numbers for these tubes is very much on the conservative side but why take any chances?).

A circuit with this many components required a custom printed circuit board so instead of rolling my own,  I used EasyEDA software to create the schematic and then layout the components.  The gerber/drill files generated by the software were then emailed to JLCPCB, a PCB fab house in HongKong.  I received my board in less than 2 weeks (actually, the minimum number of boards that can be ordered is five but total cost including shipping was only $15.00 so no complaints from me).  Here is an image of an early board created by the PCB software after I made an initial component placement:

Early PC board prototype

For comparison, here is the actual board I received from the fab house along with a few components I soldered on:

Bottom view - partially populated PC board

A couple of minor changes noted between the blue and green board images are due to updates I made to the schematic later on.  I decided to add a neon tube between the hour and minute Nixie tubes to act as a colon and I also realized I didn't need one of the voltage level shifters after all.  For what its worth, the 44-pin chip was a real bear to solder in.  Not my best soldering job but it works.  The finished board is seen below (I left off one tube to show the backlight LED found under each tube:

Top view - showing a backlight LED
To wrap things up I decided to make my own enclosure and chose maple and walnut because I thought  the contrasting colors would look nice.  All pieces came from 1/4" stock.

I used double sided carpet tape to attach the top piece and screws for the bottom piece.  A clear finish of linseed oil was then applied to protect and beautify the wood.

Time (designated by colon off)

Date (designated by colon on)

Display elements highlighting differences in depth

Rear view



Update (Sep 2023)
Currently, the display is only on between the hours of 8:00a and 11:00p to prolong tube life.  This is true regardless of whether the room its located in is occupied or not.  I decided to go one step further in my quest to improve tube longevity by adding a light sensor.  This was easily achieved by adding a photo detector and resistor combination connected to the controller's ADC input.  A low light condition results in a low voltage reading (ie. counts) on the analog input while a high light condition results in a high voltage reading.  Now, whenever the room light is turned off (indicating the absence of a person) the display will also turn off.  Conversely, when someone enters the room and turns on the light the display will turn on.

Tuesday, March 16, 2021

Bird Cam

One of my wife's hobbies is watching and sketching birds.  We even installed a bird feeder outside of our bedroom window so that she could periodically look for any bird activity.  I eventually realized that she could accomplish the same thing if we had a camera trained on the feeder and then watch the live stream on her iPad.  I had been reading about the ESP32-Cam modules lately and thought this might be a good opportunity (ie. excuse) to build something for her.

To power the unit I used a 6v solar panel I happened to have lying around and hooked that to a solar powered battery charger (Lipo charger).  The charger connects to two parallel configured 3.7v Lipo batteries which in turn provide the input voltage needed to drive a 3.3v LDO voltage regulator.  A simplified schematic is shown below:


I used an onboard ADC channel to continually monitor the battery voltage.  Since the maximum allowed ADC input level of an ESP32 is 3.3v and the maximum expected battery voltage is 4.2v, I had to add a simple voltage divider to scale down the voltage level.   When or if the battery voltage ever drops below a preset level (3.7v in this case), the unit will shut down to conserve power.  In shut down mode (actually called "deep sleep mode"), the module draws ~4mA whereas when fully active the current draw can exceed 250mA.  After a specified number of hours the unit will "wake up", hopefully under conditions suitable for battery charging.  The electronics along with both batteries are installed in a waterproof enclosure with a clear cover (shown on the right minus the cover).

The location of the feeder I'm using this camera with is quite a distance from our router, so I'm having some issues right now with signal strength.  Therefore, I will probably be adding an external WiFi antenna in the near future to boost signal levels.

Here is a recent visitor enjoying a snack:










Update (June 2021)
Two changes were incorporated:

1) After putting up with slow and intermittent browser response times I finally decided to add the aforementioned external antenna.  This seems to have done the trick and browser interaction is now much more robust.

2) The Lipo battery power system I was using was not able to reliably supply the camera module with enough power to operate.  We get a lot of cloudy and rainy weather during parts of the year and when that occurs the batteries never seem to reach a fully charged state.  Couple that with the high current demands of the camera and well, things just kept shutting down.  I solved this by replacing the batteries and charging system with a 5v wall unit.  This eliminated the unit's portability (unfortunately) but definitely improved its reliability. 

Sunday, September 27, 2020

Weather Station - Finale

For several months I've been exploring various ways of gathering and displaying all of my environmental sensor data.  Well I'm now ready to wrap this project up.  The final two pieces are a wind speed monitor and a rain gauge.  I chose an ESP32 module for processing the incoming data and hooked it up to a .96" OLED display.  The image below shows the completed unit w/o the clear top installed.  The pushbutton on the left allows me to switch between metric and English units of measure.  An external, four channel analog to digital converter sits to the right of the ESP32.

I purchased the anemometer from Adafruit (anemometer).  It outputs a voltage that's proportional to the wind speed and connects to one of the  analog inputs of the ESP32.  However, after several attempts I finally gave up on using the internal ADC.  I didn't know at the time but it turns out that problems with this feature were well documented on the internet so I decided to go with an external ADC (ADS1115) instead.  This seemed to solve all of my problems and I'm happy with the results.

The rain gauge came from a source off of eBay and is mechanical in operation.  As water enters the unit it causes a collector to fill with water.  When the collector is full it tips over (tilts) and empties its contents.  Each tilt forces a reed switch to momentarily close via a magnet attached to the collector arm.  This switch closure is easily monitored by a GPIO pin on my Raspberry Pi.  The number of tilts are counted and converted to an equivalent depth.  The ESP32 then polls the RPi every 15 minutes to get an updated rain fall amount via an MQTT connection.

Since OLEDs are known to have a limited lifespan, I decided to shut off the entire display at midnight and then re-enable everything at 8:00am.  The ESP32 "knows" the time because it periodically retrieves the actual time via an NTP (network time protocol) server.  I also chose to leave the sensor display readings blank if there was no wind or rainfall to report, just to keep the display uncluttered.

All in all, a pretty fun little project.

Monday, December 30, 2019

Making a Magnetic Loop Antenna

I've been using my recently acquired SDR for a while now hooked to a simple wire antenna, but as you might expect the results were far from ideal.  So, I made the decision to build (not buy) my own magnetic loop antenna.  The big advantages of this type of antenna over others are their small size, portability and decent bandwidth.

The antenna consists of a large, outer resonant loop for picking up the RF signals and a smaller, magnetically coupled, inner loop that connects to the radio.  See diagram below left:

(Source: http://www.aa5tb.com/loop.html)
For the large loop I used 10' of 1/4" copper tubing inserted inside an identical length of 1/2" PEX tubing to aid in stiffness and durability.  Pigtails were soldered to either end of the copper and then connected to an air variable capacitor I had in my junk box (thanks Bob, WA1EDJ), creating a parallel resonant circuit. The measured inductance of the copper loop was ~3.25uH and the variable cap I had selected had a range of ~10-200pF.  This gave me a calculated tuneable bandwidth of ~6.2MHz to 27.9MHz.

A 2' length of copper tubing was then formed into a smaller loop with one end connected to the center conductor of a length of RG-58 coax while the other end was connected to the outer braid.  The other end of the coax was mated with a BNC connector to hook up with the receiver. This inner loop was then positioned in close proximity to the outer loop and secured in place with zip ties.

Some close ups of the various construction details:

Copper tubing inside PEX (large loop)
with a soldered pigtail on one end

Coax connected to ends of small
copper (inner) loop

Inner loop positioned closely to outer tube

Vertical support strut added
Tee connector at bottom of large loop




Completed antenna minus tuning capacitor

After assembly, I hooked it up to the radio to see if reception had improved.  Definitely!!  I also took measurements to determine the actual tuneable bandwidth.  It seemed to show signal peaks at ~6MHz on the low end and ~18.5MHz on the high end.  This corresponds roughly to the 40-17m amateur bands.  I can only attribute the difference in high end response (27.9MHz calculated vs 18.5MHz actual) to additional parasitic capacitance of ~13pF.

I'm not worried about weather proofing the variable cap since the entire antenna unit can easily be moved indoors at a moments notice in case of rain or snow.  The next task at hand will be to make additional antennas to cover different bands.

Thursday, December 19, 2019

Software Defined Radio

This Christmas I thought I'd splurge on a Software Defined Radio (SDR) from SDRPlay (SDRplay.com).  I chose the RSP1A model for ~$100.00 that includes the software to setup and run the user interface.  It covers the radio spectrum from 1kHz to 2GHz with a displayable bandwidth of  up to 10MHz.  All that's needed is a PC to run the software and an external antenna and its ready to go. I plan on making my own antenna soon (probably a magnetic loop), but for now I'll just string a wire from the unit and hope for the best.

Here is the unit showing the USB interface on the right along with a length of wire attached to the antenna port on the left.  That's it!...The PC does all the data and display processing.

RSP1A

This image is a screenshot of the SDRuno software user interface.  This can be customized by each user to meet their particular needs (filter selection, spectrum bandwidth, band/mode of interest, etc).

Here I'm listening in on a CW signal on the 40m band (7.044.5MHz).

Looking forward to hours of experimenting (aka playing) and exploring the rich feature set available.