High availability Pi-hole cluster with Nginx load balancing

This is a quick write up for the hardware and software config for the high availability Pi-hole cluster with Nginx load balancing.


List of components used:

Name Part Number Quantity Link
raspbery pi single board computers (with cases and SD card) 3
USB A male to micro usb cables 3 https://amzn.to/2x9OdK6
6″ Ethernet patch cables 4 https://amzn.to/2KCi7K4
gigabit switch that has 5V input AM-SG205 1 https://amzn.to/2VGYGGy
5V 10A amp power supply Mean Well LRS-50-5 1 https://amzn.to/3aFPkic
Wire https://amzn.to/2Y2wv6q
Crimp ferrules https://amzn.to/3aH4a8c
Double Stick tape https://amzn.to/35eHUSg
panel mount Ethernet connector 1 https://amzn.to/2VGYMOq
usb to power PCB 2 Order from OSH Park
dupont female to female connector (for display) 18 https://amzn.to/3cPOkKa
PiOLED 0.91inch 3 https://amzn.to/2zyjJlV
1U rack mount case

Setup notes:

To configure the load balancer:

Add this to nginx.conf (make sure to change IPs to match your two pihole pi)

stream {
upstream dns_servers {
server fail_timeout=60s;
server fail_timeout=60s;
server {
listen 53 udp;
listen 53; #tcp
proxy_pass dns_servers;
error_log /var/log/nginx/dns.log info;
proxy_responses 1;
proxy_timeout 1s;

to restart nginix run this:

sudo /etc/init.d/nginx restart

See this page for details https://www.nginx.com/blog/load-balancing-dns-traffic-nginx-plus/

WS2812b Led Ring Christmas Tree

This tree design is based on the tree featured here: https://hackaday.io/project/18821-ws2812-christmas-tree

My plan was to cut the tree out on my CNC machine using a single fluted endmill. After shattering a couple of sheets of acrylic this idea was abandoned. The design file was sent to https://www.ponoko.com/ for laser cutting. The design fits into a P1 sheet and was cut using 0.118 inch clear acrylic. Here is the design file that can be uploaded to be cut: https://github.com/mdunakin/Ws2812bChristmasTree/blob/master/Design/tree5.svg

The code is just a configured version of the FastLED DemoReel1000 example code. It can be found here: https://github.com/mdunakin/Ws2812bChristmasTree

Construction was not super complex. The two tree pieces were hot glued together. The led rings were attached from smallest to largest. When the ring was attached it was wired with 30 awg wire wrap wires. The ground and vcc on the rings were connected together. The data out on the rings was connected to the next rings data in. As a small side note these wire strippers are amazing if you want to strip wire wrap wire https://amzn.to/2SaPNAG

Here is a picture of the constructed tree:


Here is a video. The tree looks much better in real life.


Solar Powered ESP8266 Wemos D1 WIFI sensor node for Domoticz using ESPEasy

This post will cover building a low power solar WIFI sensor node using a Wemos D1 module. The module is loaded with ESPEasy firmware and reports sensor data to a Domoticz server.

The sensor nodes can be used with any of the sensors the ESPEasy firmware can support. This includes temperature, moisture and a host of other physical and environmental inputs and outputs. A full list is located here: https://www.letscontrolit.com/wiki/index.php/Devices


Bill of materials:

Description Notes Qty
JST-XH 2 Pin Header Male 2
JST-XH 2 Pin Pigtail Female 3
1N4004 Diode 1
.1″ Header Female (8 Pin) 2
.1″ Header Male (8 Pin) 2
.1″ Header Male (2 Pin) For Sleep 1
.1″ Header Male to Female (8 Pin) 2
TP4056 DW01A Charger Board Module 1
Mini 12-cell Polycrystalline Solar Panel 6V 1
18650 or other lithium ion Battery 1
Wemos D1 1
Wemos D1 Mini LiPo Battery Shield 1
Heatshrink for battery wires 1
Dry Box 135*80mm*40mm 1
Optional PCB Gerber Link Below 1
Optional Target Sensor 1

The first two versions of this sensor node were built by hooking  .1″ headers together and fixing all the components inside a large dry box with double stick tape. Here is a photo of the first two versions:

These versions were somewhat time consuming to reproduce so a PCB was spun to help speed up build times.


Here is a link to the gerbers: https://github.com/mdunakin/PCB/tree/master/WemosD1Plate

This PCB takes power in from a solar cell on the left JST-XH connector. This is fed through a 1N400X diode that is acting as a bypass diode. This then feeds into the Blue PCB shown at the top. This PCB acts as a charge controller. Ideally the charge controller on the Wemos D1 mini LiPo battery shield could be used but it lacks over discharge protection. This is the reason for the secondary charge controller. The left JST-XH connector is used to attach the LIPO battery and the red and black wire are fitted with a female JST-XH connector that plugs into and powers the Wemos D1 mini LiPo battery shield.

JP2 and JP3 are used to break out the IO pins on the Wemos D1 mini. The sleep jumper allows for the Wemos D1 to be put into a deep sleep mode conserving battery power. The sleep function is documented here: here: https://www.letscontrolit.com/wiki/index.php/Devices



Before getting sensor readings you will need to get a copy of Domoticz from here: https://domoticz.com/ I recommend running this on a computer that will be on all the time and also running it as a Windows service.

You will also need to flash your Wemos D1 with the ESPEasy firmware https://www.letscontrolit.com/wiki/index.php/ESPEasy This was a simple process. You just grab the installer from the link above. Run the executable and point it at the correct serial port.


Hardware Configuration:

The hardware configuration can be broken down into two main parts. Configuring the ESP8266 to send the data and configuring the Domoticz server to receive the data.

Before configuring the sensor it needs to be created in Domoticz to get the IDX number so the ESP8266 knows where to send the data.

This is done by adding “dummy” hardware in Domoticz and then selecting the “create virtual sensors”  button.


After that create a “Temp+Hum” sensor:


Here is the configuration for the ESP8266 using ESPEasy firmware:


Make sure that the Domoticz server is configured on the ESP8266:


Battery Monitor:

Battery voltage monitoring is described here:


Here is a setup screen on ESPEasy:


Here is the corresponding Domoticz setup:

Create a dummy Hardware device:


Click the create virtual sensors button


Add a voltage sensor




To get ESPEasy to sleep, configure each configured device to take readings at the interval you desire on the devices tab. Then under the config tab set the interval.


After that cut power by disconnecting the battery and solar cell and set the sleep jumper on the PCB and re-power up the system. If everything is configured correctly the device will now sleep between readings. Note, when first powered up the ESP8266 will have a responsive web server for 30 seconds before going to sleep.

Here is some data that was collected from a previous sensor deployed during summer:


The PCB assembly and battery are packaged in a small dry box with a solar cell mounted to the lid. The DHT 22 will be placed into a Stevenson Screen that was purchased from: http://www.misolie.net/plastic-outer-shield-for-thermo-hygro-sensor-spare-part-for-weather-station-transmitter-thermo-hygro-sensor-p-515.html



Binary Compare Game

As a kid one of my favorite book series were Forrest Mims Circuit Scrapbooks. They were interesting to read and build the circuits out of. One of the projects that was in my opinion the most fun to play with is a binary guessing game from The Forrest Mims Circuit Scrapbook, Vol 1 page 121. Since prototype PCB prices have dropped recently due to competition in China this was a project that seemed interesting to convert to a PCB.



Changes to above schematic:

  • A 10K pullup was added to the 74193 side of S1 to prevent noise from loading new numbers to guess.
  • A .1 μF bypass cap was added to the 555 timer to prevent ringing in the output.
  • The circuit is powered by a 9V battery. This battery goes to a switch. After the switch a LM2596 buck module is used to drop the voltage down to 5V



Photo of finished PCBA:




Door Ajar Sensor

This project was created to address an issue with the layout of my house. The door from the garage into the house overlaps with another door. If this door is left open it could get hit by the overlapping door. To prevent this from happening a visual indicator was installed to show if the overlapping door is left open.



VCC is supplied by four AA batteries. The circuit is broken down into two parts. On the left is a circuit that shows if the door is open. On the right is a low battery indicator.  LED2 is a flashing led. This part was selected to lower current draw versus an always on led. U1 is an open collector voltage sensing chip that triggers at 3.6V.

Gerbers and BOM for the PCB can be found at:


Photos of completed and installed circuit:

Garden Time lapse with Security Camera

The goal of this was to get a long term time lapse of my garden growing each season using off the shelf hardware. The camera used for this is a SV3C SV-B01-1080PL bullet camera powered with POE.  The camera is mounted outside with a fixed view of the garden. At the start of this project a new gmail account was acquired to be used with only this camera. The email section of the camera was configured and tested. Then then camera was configured to send an image every hour to the above mentioned gmail account.


To date this has resulted in eleven thousand plus emails with photos. Manually downloading and extracting the photos seemed like a tedious and boring  process so a different route was found using the Thunderbird mail client. The client was installed and configured to use the gmail account. Then the attachment extractor extension was added.


This extracted all the attachments to a folder. The extracted images had varying degrees of brightness so the output folder was batch processed using  PhotoScape.


After the batch processing was done the group still contained images that happened during night times or photos with excessive shadows. Luckily the output files had a similar file nameing structure so a simple C# program was written to move and re-name photos shot during specific times of day. The paths will need to be tweaked to run it on a different system. Here is the code:

using System;
using System.IO;

namespace PhotoCleaner
    class Program
        static void Main(string[] args)
                var folderLoc = @"C:\Users\media2\Desktop\New folder";
                var destFolderLoc = @"C:\Users\media2\Desktop\Output";
                var directoyInfo = new DirectoryInfo(folderLoc);
                var Files = directoyInfo.GetFiles("*.jpg");
                var counter = 1;
                foreach (FileInfo file in Files)
                    //file.Name = "IMG_chn0_TIMER_MNG_20170522164542_001.jpg"
                    var fileName = file.Name.Trim();
                    fileName = fileName.Replace("IMG_chn0_TIMER_MNG_", "");
                    var year = fileName.Substring(0, 4);
                    var splitFileName = fileName.Split('_');
                    if(splitFileName.Length == 2)
                        var rawDate = splitFileName[0];
                        var hour = rawDate.Substring(8, 2);
                        var hourInt = int.Parse(hour);
                        if(hourInt = 16 && year == "2018")
                            File.Copy(Path.Combine(folderLoc, file.Name), Path.Combine(destFolderLoc, $"frame{counter.ToString().PadLeft(4, '0')}.jpg"));
                            counter = counter + 1;

            catch (Exception ex)


After running the above code a folder with files named frame0001.jpg, frame0002.jpg… should be generated. To stitch the files together FFMPEG was used. After installing FFMPEG it was added to the system path. This blog helped figure out the different flags that needed to be set in FFMPEG http://notes.theorbis.net/2010/05/creating-time-lapse-with-ffmpeg.html The parameters suggested in the blog post were tweaked slightly to end up with this:

ffmpeg -r 12 -i frame%04d.jpg -qscale 0 -s hd720 -vcodec libx264 -preset fast -crf 25 OUTPUT.MP4

Here are the results:

2018 (short):

2017-2018 (long):


The above C# code could be improved by accounting for sunrise and sunset values in the time calculations. This should account for the sun shifting in other seasons and make the video have less of a strobe like occurrence from shadows.

Using ke5fx HP 7470 plotter emulator with a 54659B module on a 54600B oscilloscope

This write up will talk about modifying the ke5fx HP 7470 plotter emulation software to work with a 54600B oscilloscope using Microsoft Windows.

NOTE: make sure to use a null modem cable

Steps to setup computer:

      1. Get a working serial port on your computer with a USB to serial converter or a native serial port.
      2. Download the ke5fx software from: http://www.ke5fx.com/gpib/7470.htm
      3. Modify default_connect.ini Comment out the top line and add the second line (Make sure your com port is correct):
        ;interface_settings GPIB0
        interface_settings com3:baud=19200 parity=N data=8 stop=1

        also modify:
        is_Prologix 1
        is_Prologix 0
      4. On the 54600B go to the print menu and make sure the scope is in DTR mode, also make sure the scope is set to 19200 baud.

Steps to print image to computer:

  1. Make sure that the com port your device is on matches the default_connect.ini file. If it does not then edit the file or use the device manager to change the assigned to serial port mappings.
  2. In the ke5fx 7470.exe software choose this option:scope1
  3. Press print screen on plotscope

Hydroponics Update Part 3


To understand the context of this post you may want to read updates one and two.

The half gallon mason jars worked well as shown with the romaine growing in the photo above. The jars started developing hairline cracks in the bottoms that started leaking.  This was more than likely due to routine handling during weekly water changes. This lead to attempting to find a plastic substitute for the mason jars.  The jars that were selected were a 96 ounce petg plastic container with a handle. These were prepared with a net cup similar to the process in post two. After a few months of growing an algae problem occurred in the jars. This is probably due to the high nutrient levels and bright lights the plants are grown under. A test is being conducted to see if painting the jars black will help combat this problem. Below is a photo of basil grown in the garden vs hydroponic basil grown in the new containers. The basil was started by cloning a basil plant purchased in the supermarket. The grow medium was rock wool.



Rack Mounting RTL-SDR


This post talks about rack mounting a RTL-SDR reciever attached to a raspberry pi into a 1U case. The donor case used was a used kramer broadcast 1110 balanced audio distributor, but any 1U case should work.

Parts Needed:

    • 1U Case
    • 5V 3A power supply (Mean Well RS-15-5)
    • Raspberry Pi
    • Class 10 SD Card
    • rtl-sdr receiver with antenna
    • Short 6″ ethernet patch cable
    • panel mount ethernet jack (“search ebay for “ip68 ethernet”)
    • Screws, wire, fuses, switches, etc…


Configuring the Raspberry PI:

    1. Get the Raspbian “lite” image from  https://www.raspberrypi.org/downloads/raspbian/
    2. Install the image based on this guide: https://www.raspberrypi.org/documentation/installation/installing-images/README.md
    3. Find the SD card on the computer and add an empty file to it with the file name “ssh” (no extension). This will enable ssh on boot
    4. Power up the raspberry pi with ethernet connected.
    5. Find the address of the pi by port scanning with a tool like Nmap or looking at your routers DHCP allocation table.
    6. Use a tool like Putty to ssh into the pi on port 23. User name “pi” Password: “raspberry”
    7. Its a good idea to change the password when you log in using the passwd utility
    8. Optional: since this is going to be a headless install it would be a good idea to lower the video memory using  raspi-config.
    9. Now run these commands to get Osmocom rtl-sdr up and running on the pi:
      sudo apt-get update
      sudo apt-get install git cmake build-essential libusb-1.0 libpulse-dev libx11-dev
      git clone git://git.osmocom.org/rtl-sdr.git
      cd rtl-sdr
      mkdir build
      cd build
      cmake ../ -DINSTALL_UDEV_RULES=ON
      sudo make install
      sudo ldconfig
  1. Now you should be able to run rtl_tcp -a IpAddressOfPiGoesHere If an error pop up like Failed to open rtlsdr device #0. run sudo rmmod dvb_usb_rtl28xxu rtl2832 This will prevent the pi from loading the stock drivers for the dongle.
  2. The pi now can be used as a remote rtl-sdr server