Christmas Tree Automatic Watering System

Automate a pump to keep a tree well watered throughout the holiday season

Similar projects worth following
Keeping your tree watered is important for more the keeping those needles on. A dry tree can be quite a hazard ( But who wants to remember to crawl under those prickly boughs every so often to check the water level? This sounds like a job for automation. So I looked around the house and found all the materials I need to make it happen!

The provided code is simple. It just controls the pump based on the inputs. 

You may not want the pump to run at certain times of the day as it can be a bit noisy.  Also, there is no control over the pump or any status feedback (both the button and led are inaccessible in the enclosure).  Lastly, when the timeout expires on the filling cycle, the only way to reset it is to raise the water level to the top sensor, or reset the device (unplug, plug back in). You may want to connect the sonoff to your home wifi to accomplish all these things.

Instead, I just connected this to another sonoff wifi switch, which I already have at the tree to control the lights. It is connected to my wifi and has the stock software on it, which integrates with IFTTT to turn on and off the lights at specific times of the day. This will daily reset the water filling system, clearing the timeout timer. This also prevent it from running when the light are off, when we're asleep. 

Finally, I recommend gift wrapping an empty box to place everything within, both for aesthetics and to keep pets or children from tampering or knocking it over.

plain - 1.47 kB - 12/03/2018 at 16:40


  • 1 × Water Pick
  • 1 × Sonoff Smart Switch An inexpensive line powered ESP8266 with button, led, and relay on board!
  • 1 × DIY Level Sensor Just a paint stick and three 8-32 all-thread rods (w/Nuts & Washers)
  • 1 × Extension Cord Cut in half
  • 1 × TTL Cable Used for initial programming (

View all 10 components

  • 1
    Flash Sonoff with Micropython and connect

    Pry open case and solder on the 5 pin male header. Follow the offical docs to see details for most of the software stuff:

    On your computer, install and download the latest micropython build.

    Connect with ttl cable to the new header, see the pic for pinout. 

    To enter flash mode, hold the button when pluging in the usb. You may need to install drivers (

    Erase the flash ( -p COMX erase_flash). Unplug usb, hold button, plug back in.
    Flash firmware (esptool --p COMX  write_flash -fs 1MB -fm dout 0x0 esp8266-20XXXXXX-vX.X.X.bin).

    Install Putty and connect to the repl (select serial, enter your COM port, default baud rate is 115200)

    At the >>> prompt type "import webrepl_setup". Follow the prompts to turn on webrepl and set a password.

    Unplug the usb, plug it back in (no need to hold button)

    In your browser, to go

    Connect your computer's wifi to MicroPython-XXXXXX access point. On the website, click "connect". Enter your password when prompted. Upload your file under "Send a file".

    Good job, you're now connected via the webrepl, and you won't need the ttl cable anymore to make updates. Disconnect the webrepl and unplug the ttl cable.

  • 2
    Build out the system

    Cut  the extension cord in half and strip the ends. Install cord grip in box with reducers if needed.

    Solder wires to female header (see pic for pinout). Plug in header and feed wires out of Sonoff case. Make sure wires are marked on other end. 

    Close up Sonoff case and put in the box. Feed wires out box through cord grip, feed in output end of extension cord through same cord grip. Wire in these output wires on the output screw terminal.

    Feed in input end of extension cord through the other cord grip. Wire in these input wires on the input screw terminal.

    Tighten both cord grips and install the lid.

    Crip on the ring terminals on open end of the thin wires. You only need three wires (one ground, two inputs), but I ran four wires to have a spare input. I added some solder to make them more secure.

    Now make the level sensor. Cut all-thread to the appropriate lengths. Two pieces should reaching from the top of the tree stand to the lowest point you think the water should go. Add about 1" above the stand. Mine ended up being 5.5". One more piece reaching below stand screws, plus 1" above. Mine ended up being 3". 

    Drill holes in paint stick about 3/4" apart big enough for all-thread to go through. Feed the all-thread in holes, putting nut & washer on both sides. See pic.

    Test fit level sensor in tree stand to ensure levels are correct, adjust if needed.

    Place ring terminals on all thread, making sure the ground is on one of the long ones. Secure them with another nut on top.

    Test it. Plug it in and connect to the access point again. Connect to the webrepl as you did before.

  • 3
    Final install

    Once the tree is up, place this all at the base. Fill up water pick reservoir with water. Plug in the water pick to output end of the extension cord and place the pick in the tree stand. Place water level sensor on the tree stand. Plug in the device to the wall, and if there is no or low water in the tree stand it should start and run until it reaches the high level or times-out. Fill stand with water manually to ensure it shuts off properly.

View all 3 instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates