Home Blog Page 16

Make A YouTube Subscriber Counter Using An E-Ink Display And A Raspberry Pi Zero W

I’ve seen a couple of different designs for YouTube subscriber counters and social media follower counters and I had a Raspberry Pi Zero W lying around which I wanted to put to use. I didn’t want the distraction of a bright LCD display at night, so an e-ink or e-paper display seemed like the best option. So, in this project, I’ll show you how to make your own Youtube Subscriber Counter using a 7.5” Waveshare E-Ink display and a Raspberry Pi Zero W to update it.

E-Ink Youtube Subscriber Counter

The Raspberry Pi uses a Python script to query the YouTube API a couple of times a day and then refreshes the e-ink display to update the counter. It’s really simple to make as it just uses the Waveshare Hat for Raspberry Pis, so there is no soldering required and you don’t have to worry about tinkering with any other electronics to get it working.

The e-ink display provides great visibility during the day, even in bright light, and only uses power when it’s being refreshed, so the counter uses very little power to run. The updates take about 40 seconds to complete and between updates the Pi uses around 0.5W while at idle.

Here’s a video of the build and the display updating, read on for the step by step instructions to build your own.

What You Need To Make Your Own Youtube Subscriber Counter

  • Raspberry Pi Zero W – Buy Here
  • Micro SD Card – Buy Here
  • Waveshare 7.5” HD E-Ink Display (B) With Controller – Buy Here
  • 6×8” Shadow Box Frame – Buy Here (The one linked to is not exactly the same as used in the project, but the most similar I could find on Amazon)
  • Keyboard, Mouse & Monitor For Setup (Or Connect Through SSH)
What You Need For This Project

All you need for this project is a Raspberry Pi Zero W, an SD card, and a Waveshare E-Ink Display, make sure that you order the display which includes the hat display controller for the Raspberry Pi. You’ll also need a suitable frame to put it in, you may even have one lying around your home.

Connect & Prepare The Electronics For Your YouTube Subscriber Counter

Let’s start by preparing the Raspberry Pi Zero W. You’ll need the header pins to be soldered to your Pi Zero, so if yours didn’t come with them already installed, then you’ll need to install them before starting. Also, attach the heat sink to the CPU, this project isn’t particularly strenuous on the CPU, but it’s a good idea to install it anyway.

Fit The Header Pins & Heat Sink

Once your Pi is prepared, you can connect the display. I’ve used the 7.5” HD 3 colour version, the three colours being white, black and red. You also get a two colour version which is just black and white and another 3 colour version which had yellow instead of red. The red just works better for the YouTube play button.

Display Comes With Hat And Adapter

In the box, you get the SPI e-paper display controller, which is designed as a Raspberry Pi hat, to plug directly onto the GPIO pins. It also includes a plug and a set of leads to connect the controller to another SPI capable device, such as an Arduino or ESP32.

E-Paper Display

The actual display is really thin and has a thin ribbon cable at the bottom which plugs into the controller.

Display Is Really Thin

To connect the electronics together, you simply lift the black tab on the back of the connector, plug the display’s ribbon cable into the connector and then push the black tab down to lock it into place. Make sure that you get the orientation of the plug correct, the components are all face-up when laid on a flat surface.

Plug Display Into Hat

You’ll need to prepare your SD card with an installation of Raspberry Pi OS, which can now be easily done using the Raspberry Pi utility for Windows and Mac computers. You just choose the operating system you’d like, then the target SD card, and the utility does the rest for you.

Choose Raspberry Pi OS

For this project, you can use the full version of Raspberry Pi OS or the Lite version which doesn’t have the GUI (graphical user interface) if you’re comfortable using the terminal (command line prompts) to set it up. If you’re planning on setting it up using SSH then you’re better off just using the Lite version.

Insert The SD Card

Plug your formatted SD card into your Pi and then plug the hat onto the GPIO pins.

Plug In The E-Paper Driver Hat

You can now get started testing the display. I’d suggest that you get it working like this before building it into the frame if this is your first project using one of these e-ink displays.

The Waveshare Wiki for the 7.5″HD e-Paper Hat (B) is a great place to start. It walks you through the exact steps required to get the example code working and the display running through some example images and text. The Python script used for this project is based on this Waveshare example script.

If you’re not comfortable tinkering with the display and working through this Wiki then just follow the steps I’ve outlined in the subsequent sections to get it working for this specific project.

Build The Electronics Into The Frame Or Display Box

Now let’s build the display into the frame or display box. I found this cheap 6×8 inch box frame which will work quite well. You should be able to pick up a shadow box or deep photo frame around this size from a local discount store for a few dollars.

Next You Need A Frame

I started by removing the back layer to get to the white frame panel.

Remove The Back From The Frame

This is likely sized for a 4×6 inch photo like mine, so you’ll need to open it up a bit using a craft knife and a ruler so that it fits your display.

Measure the size of the display area and then mark it out on your frame insert.

Measure The E-Paper Display To Cut The Card Bigger

Use a sharp craft knife and a ruler to cut along the new lines to open the frame up to fit the display.

Cut The Frame Insert Larger To Fit The New Display

You could also just adjust the display content size to fit within the frame area if you don’t want to modify yours.

Peel off the protective film from the display.

Remove The Display Film

Then carefully glue the back of the display to the frame, making sure that it’s centred and straight. I used a drop of hot glue on the corners to hold it in place.

Glue The Four Corners To The Display

Next, mark out and cut a slot in the back layer to pull the display’s ribbon cable through.

Measure A Slot For The Ribbon Cable

I also made the holes to mount the Raspberry Pi onto the stand.

Cut Out The Slot And Holes For The Pi

Now re-assemble the frame and clamp the back layer back into place. If you don’t want a glossy finish to your frame, you could remove the glass panel from the front or use a matt finish panel instead.

Pull The Ribbon Cable Through The Slot

Plug the display back into the controller and glue the connector in place so that it doesn’t put any stress onto the display’s ribbon cable.

Glue The Adapter Plug Into Place

Now lets add some plastic standoff mounts to mount the Raspberry Pi and the Hat.

Add Standoffs For The Raspberry Pi Zero W
Mount The Pi Zero W And The Hat

Your frame is now complete and ready for programming.

The Youtube Subscriber Counter Is Now Complete & Ready To Program

Setting Up & Programming Your Raspberry Pi Zero W

The first time you boot up the pi, it will take a while to set up the Operating System, get connected to your WiFi network, and do any updates. Most of this is done automatically and you should be guided through prompts until you get to your Desktop view and your Pi is ready for programming.

Before you start with the Python script, there are a couple of libraries to install and setup steps to work through.

Please also remember that software changes quite often with these devices, these steps work as of 6 October 2020, but you may encounter errors in the future as packages are updated and pieces of software become obsolete.

Setup & Library Installation

These initial setup steps are as per the display’s wiki from the Waveshare Wiki for the 7.5″HD e-Paper Hat (B)

Enable The SPI Interface

The Raspberry Pi communicates to the display controller using the SPI interface, so you’ll need to enable it on your Pi.

Open the terminal window and enter the following command:

sudo raspi-config

Choose Interfacing Options -> SPI -> Yes

You may need to reboot your Pi for the changes to take effect.

sudo reboot

Once you’ve restarted your Pi, open a new terminal window again and enter the following to install the libraries:

Install the BCM2835 libraries:

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz
tar zxvf bcm2835-1.60.tar.gz 
cd bcm2835-1.60/
sudo ./configure
sudo make
sudo make check
sudo make install

Install the WiringPi libraries:

sudo apt-get install wiringpi
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v

Install the Python2 libraries:

sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install python-pil
sudo apt-get install python-numpy
sudo pip install RPi.GPIO
sudo pip install spidev

Install the Python3 libraries:

sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-pil
sudo apt-get install python3-numpy
sudo pip3 install RPi.GPIO
sudo pip3 install spidev

Get Your YouTube API Key

In order for the Python script to retrieve your current subscriber count and number of views, you’ll need to add your Channel ID and your YouTube API key.

Here’s how to generate your API key:

Go to the Google API web page while signed in to your google account associated with your YouTube channel – https://console.developers.google.com

Go to your Dashboard and the click on “Create Project”, choose a name for your project and click “Create”.

Next, click on “Enable APIs and Services” and type – Youtube Data API v3 – into the search box. Enable it and click “Create Credentials”.

On the next page, you should see a link to create an API key in small letters, click on this link.

Next click “API Restrictions” and select “YouTube Data API v3”.

Click “Create” and you should then be given your API key which you’ll need to copy into the main Python script below.

You’ll also need to get your Channel ID. You can find this under “Advanced Settings” for your channel account. Click on your profile picture in the top right, then go to “Settings”, wait for the page to load and then click on “Advanced Settings” from the menu on the left.

You can test your API Key and Channel ID by going to the following address in your broswer, replacing YourChannelID and YourAPIKey with the ones you’ve just got:

https://www.googleapis.com/youtube/v3/channels?part=statistics&id=YourChannelID&key=YourAPIKey

Load The Python Script

This script is largely based on the Waveshare example script, with a couple of additions and changes to get the information from Youtube:

#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import os
import requests
picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic')
libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib')
if os.path.exists(libdir):
    sys.path.append(libdir)

import logging
from waveshare_epd import epd7in5b_HD
import time
from PIL import Image,ImageDraw,ImageFont
import traceback

from datetime import date
today = str(date.today())

logging.basicConfig(level=logging.DEBUG)

# Set up the structure of the API request URL

URL = "https://www.googleapis.com/youtube/v3/channels"
type = "statistics"
channelid = "******"
apikey = "******"
PARAMS = {('part', type), ('id',channelid), ('key',apikey)}

#Get API results

r = requests.get(url = URL, params = PARAMS)
data = r.json()
subscribers = int(data['items'][0]['statistics']['subscriberCount'])
totalviews = int(data['items'][0]['statistics']['viewCount'])

#Convert results to a string and format numbers with commas

noViews = 'Views:   ' + f"{totalviews:,d}"
noSubs = 'Subscribers:   ' + f"{subscribers:,d}"

#Update the display

try:
    logging.info("Updating display")

    epd = epd7in5b_HD.EPD()
    logging.info("initialising and clearing display")
    epd.init()
    epd.Clear()

    font12 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 12)
    font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24)
    font32 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 32)

    logging.info("Drawing new image")
    blackImage = Image.new('1', (epd.width, epd.height), 255)
    redImage = Image.new('1', (epd.width, epd.height), 255)
    draw_blackImage = ImageDraw.Draw(blackImage)
    draw_redImage = ImageDraw.Draw(redImage)
    draw_blackImage.text((312, 360), 'Michael Klements', font = font32, fill = 0)
    draw_blackImage.text((200, 435), noViews, font = font24, fill = 0)
    draw_blackImage.text((475, 435), noSubs, font = font24, fill = 0)
    draw_blackImage.text((800, 500), today, font = font12, fill = 0)
    bmp = Image.open(os.path.join(picdir, 'youtubeIcon.bmp'))
    redImage.paste(bmp, (265,80))
    epd.display(epd.getbuffer(blackImage),epd.getbuffer(redImage))
    
    #To delay before clearing, if used
    
    #time.sleep(20)

    #To clear the display afterwards
    
    #logging.info("Clear...")
    #epd.init()
    #epd.Clear()

    logging.info("Putting display to sleep")
    epd.sleep()
    epd.Dev_exit()
    
except IOError as e:
    logging.info(e)
    
except KeyboardInterrupt:    
    logging.info("ctrl + c:")
    epd7in5b_HD.epdconfig.module_exit()
    exit()

Copy the root folder into your home/pi/ directory so that your script is in /home/pi/SubCount/SubCount/subCount.py

You may also need to include the Font used from the Waveshare example, paste this font into the pic folder along with youtubeIcon.bmp

We start by importing the libraries, functions and directories needed as well as getting the current date.

We then use the Youtube API to get the subscriber count and number of views. Remember to update these in your script before running it, just replace the ****** with your own ID and Key.

We then format the returned numbers with commas and finally connect to the display to update it. You’ll also need to update your channel name to your own channel name by replacing the “Michael Klements” with your own channel name in this portion of the code.

The script then puts the display into a low power sleep again until the next update.

If you’d like to play around with the layout of the display, try adjusting the numbers in the display portion.

draw_blackImage.text((200, 435), noViews, font = font24, fill = 0)

The first number is the X position and the second number is the Y position of each object to be displayed.

You’ll also need to run the setup.py script, included with the above code download, once before you run the actual script:

import sys
from setuptools import setup
setup(
    name='waveshare-epd',
    description='Waveshare e-Paper Display',
    author='Waveshare',
    package_dir={'': 'lib'},
    packages=['waveshare_epd'],
)

Try to run the script and after a few seconds, you should see your display start to refresh. The full refresh of the display does take quite a while, somewhere around 30 seconds on the Raspberry Pi Zero. It is a bit faster on a Raspberry Pi 4.

Display Refreshing
Waveshare E-Paper Display Refreshing

The flickering is normal for these controllers and is done to prevent burn-in on the display. It’ll first flicker black and white to clear the display, then load a black and white version of the image and finally replace some of the black with red as instructed.

Schedule The Python Script To Run Automatically

Once you’ve got the script working, you’ll just need to schedule the script to run automatically using crontab, mine updates the YouTube subscriber counter display every 8 hours, running three times a day. You could probably just refresh the display once a day, but Waveshare recommends updating the display at least once every 24 hours to prevent burn-in. So I just went with every 8 hours to be safe.

I followed this guide by scottkildall to get crontab to automatically run the script at 6AM, 2PM and 10PM.

You essentially need to create a launcher.sh script in the same folder as your Python script:

#!/bin/sh
# launcher.sh
# navigate to home, then script directory, then execute, then back home

cd /
cd home/pi/SubCount/SubCount/
sudo python3 subCount.py
cd /

This script tells the Raspberry Pi to change directory to the home directory, then navigate to your script, then run the script using python3 and then go back to the home directory.

Once you’ve got your launcher script created, open crontab by opening a terminal window and entering:

crontab -e

You’ll then edit crontab to run the launcher.sh script by adding lines:

0 22 * * * /home/pi/SubCount/SubCount/launcher.sh
0 6 * * * /home/pi/SubCount/SubCount/launcher.sh
0 14 * * * /home/pi/SubCount/SubCount/launcher.sh

Save the changes and your Raspberry Pi should now be all set to update automatically at 06:00, 14:00 and 22:00. You can edit the minutes and hours in the above lines to set the times you’d prefer. The first is the minutes and the second the hours, in 24 hour format.

Using Your YouTube Subscriber Counter

Once you’ve got the scripts set up and scheduled to run automatically, your Youtube Subscriber Counter is complete. Just plug it into a USB power supply and place it on your desk or shelf.

E-Paper Display Viewing Angle And Contrast

The date in the bottom right corner is updated to reflect the last time the stats were updated, so you’ll be able to see if anything goes wrong and the Pi stops updating the display regularly by checking this date as well.

Youtube Subscriber Counter E-Ink Display

I wanted to build this particular YouTube Subscriber Counter using a Raspberry Pi Zero W, but you could also use an ESP32 to use even less power by putting the controller to sleep between updates to the display, something that’s difficult to do on a Raspberry Pi.

Let me know what you think of it in the comments section and let me know if you try building your own!

Share This Guide

YouTube Subscriber Counter Using An E-Ink Display And A Raspberry Pi Zero W Social

DIY Smart Indoor Plant Base – Know When Your Plant Needs Watering

A while ago, I made a soil moisture monitoring stick that gives you some useful information about the soil moisture level for your indoor plants.

Soil Moisture Monitoring Stick

It does a great job, providing indication LEDs and giving you a numerical readout of the moisture content of the soil, but it looks quite ugly stuck into your pots and it’s not easy to see the flashing LEDs from far away. This got me thinking of a way to make a better-looking moisture level indicator which could give you all of the basic information you need at a glance, a smart indoor plant base.

After throwing around a couple of ideas, I thought of making a round base for the pot to stand on, similar to a coaster, with an indicator layer which could be lit up in different colours to indicate whether your plant needs some attention.

Sketch of New Soil Moisture Monitor

The indicator layer would be lit up in green when the plant had enough water and red when it needed more water. I could also create a colour fade between these two limits as a sort of level indicator. So a greeny-yellow would mean that there’s still a fair amount of water, while an orangy-yellow would mean that you’d need to water the plant soon.

I didn’t want the base to become bulky and unattractive as well, so I wanted to keep it as thin as possible.

Here’s a video of the build and the smart indoor plant base in use, read on for the full step by step instructions.

What You Need To Make A Smart Indoor Plant Base

Gather Electronic Components Together

Building The Smart Indoor Plant Base

Get Your Components Together

I decided to use a layer of 3mm acrylic wedged between two layers of 3mm MDF. An RGB LED on the back would illuminate the edges of the acrylic to be green when the plant was healthy and red when it needed some attention, with the levels in between being varying shades of yellow.

Capacitive Soil Moisture Sensor

I’ll still be using the same soil moisture sensor that I used previously, only now it won’t have any other electronics attached to it, all of the processing will be done in the base by the small microcontroller.

Seeeduino XIAO

The microcontroller I decided to use was this Seeeduino XIAO. It’s really small, has an ARM Cortex CPU, and is Arduino compatible, so it’s easy to program and interface with the components. The best part is that they cost just $5 from Seeed Studio.

Designing The Smart Indoor Plant Base

Measure Plant Base

I started out by measuring the base of the pot so that I could design the new base to be slightly larger. I designed the three circular layers of the base and the small enclosure at the back to house the Arduino.

Measure Components

The Arduino has a built-in USB C port for power, so it’s easy to just plug the base into a USB outlet using a USB C cable to power it once it’s built.

The components were designed in Inkscape so that they can be exported for laser cutting.

Components To Be Cut

Assembling The Base Components

Once the components were designed, I cut them out on my laser cutter.

Laser Cutting Components

If you don’t have a laser cutter, you can also easily cut MDF and acrylic with a hand saw. Just print out the PDF template supplied with the laser cutting files and trace them out onto your MDF and acrylic.

Laser Cut Components

In order for the edges of the acrylic to light up evenly, you need to roughen them with some sandpaper so that they’re opaque. The rough edges diffuse the light and make the acrylic layer look as if it is lit up entirely.

Roughen The Edges Of The Acrylic
Roughen The Edges Of The Acrylic To White

I used some 240 grit sandpaper until they had an even white appearance all around.

Use Epoxy To Glue Components Together

Next, I glued the three layers together using some epoxy adhesive.

Glue Components Together

Use a small amount of epoxy, you don’t want it to seep out of the edges and onto the areas you’ve just sanded or you’ll need to sand them again.

Clamp The Pieces Together

I used some small tool clamps to hold the layers in place while it cured.

Allow Epoxy To Cure

Solder The Electronic Components Together

While the epoxy was curing, solder the electronic components together.

Gather Electronic Components Together

The circuit is not very complex as you’ve only got two components to interface with the Arduino, the sensor and the LED:

Smart Indoor Plant Base Schematic

You need a current limiting resistor on each leg of the LED, 100Ω on the red leg and 220Ω on the green leg, and some header pins to plug the moisture sensor into. The green light from the LED tends to be more intense and washes out the other colours, so I used a higher resistance on the green leg than the red leg to balance it out.

Solder Components Together

I connected my soil moisture sensor the 3.3V output on the Arduino. I have noticed that some of these sensors don’t run reliably (or some even at all) on 3.3V, although they are supposed to be able to accept 3.3V to 5V. If yours is not working correctly, try powering it from the 5V supply on the Arduino – VCC. The sensor steps the voltage down in any case, so you’ll still only be supplying 3.3V back to the analogue input. Be careful if you’re using a different sensor as this Arduino’s analogue inputs can only accept a maximum of 3.3V.

Soldered Components

Install The Electronics Into The Base

Next, you’ll need to install your soldered electronics into the housing at the back of the base.

When I tried to assemble my electronic components I saw that I had been a bit optimistic in thinking I’d get all of the components into the two-layer space. So I cut an additional spacer to create a bit more headroom. This spacer is included in the cutting file download and should be glued to the underside of the top cover.

Install Components Into Housing

Push your LED into the hole in the acrylic, not too far as you want the brightest part to be in the acrylic layer. Then glue your Arduino into the housing and glue the pins into the cover layer. It’s a good idea to cover up the soldered joints on the header pins so that they don’t short out on the LED legs when you assemble it.

Close Up Component Housing

Lastly, close the housing up. I used a glue gun as it’s quicker to work with, but you can use your epoxy adhesive as well.

That’s it for the assembly, now we just need to program and calibrate it.

Base Is Now Complete

Programming The Arduino

The sketch is quite simple, it just takes analogue readings from the moisture sensor and then adjusts the LEDs proportionally between two limits.

You’ll need to calibrate and set the two limits up according to your own plant as some plants need more water and some can survive in dryer soil. Essentially you want the LED to be red when you need to water it and go green once you’ve given it enough water, you shouldn’t need to over-water the plant to get the base to turn green. There’s more about this setup step later on.

In my first revision of the sketch I just updated the LEDs with the value read from the sensor. I noticed that there was some variation between measurements and every so often there was a value significantly higher or lower which caused weird colour flicker to occur.

Change To Moving Average

So I switched to a moving average system where the average of the past ten readings is taken and this produces much more consistent results and a slow fade when you water the plant. This is why the code looks a bit more complex than it should have been.

Here is the final version of the sketch:

//The DIY Life
//Michael Klements
//26 September 2020

#define greenLED 3                                        //Define the IO pin numbers
#define redLED 5
#define moisturePin 9

#define wetCal 750                                        //Wet and dry calibration limits
#define dryCal 1023

int measurements [10];                                    //Array to store the last 10 measurements
int counter = 0;                                          //Counter to keep track of the current array position

void setup() 
{
  pinMode(greenLED, OUTPUT);                              //Define the pin modes
  pinMode(redLED, OUTPUT);
  for (int i=0; i<=9 ; i++)                               //Populate the array with starting readings from the sensor
    measurements [i] = analogRead(moisturePin);
}

void loop() 
{
  addData(analogRead(moisturePin));                                       //Take a new reading and add it to the array
  int moistureLevel = getAverage();                                       //Get the new average of array readings
  if(moistureLevel > dryCal)                                              //Constrain reading between the high and low limits
    moistureLevel = dryCal;
  else if(moistureLevel < wetCal)
    moistureLevel = wetCal;
  int greenBrightness = map(moistureLevel, dryCal, wetCal, 0, 255);       //Calculate the green and red LED brightness according to the reading
  int redBrightness = map(moistureLevel, wetCal, dryCal, 0, 255);
  analogWrite(greenLED, greenBrightness);                                 //Set the green and red LED brightness
  analogWrite(redLED, redBrightness);
  delay(2000);
}

void addData(int num)                                                     //Function to add a reading to the array and increment the counter
{
  measurements [counter] = num;
  if (counter < 9)
    counter++;
  else
    counter = 0;
}

int getAverage()                                                          //Function to return the average of all readings in the array
{
  int ave = 0;
  for(int i=0; i<=9 ; i++)
    ave = ave + measurements [i];
  ave = ave/10;
  return ave;
}

We start by defining the IO pin numbers and the calibration limits, we then have an array to store the last ten readings and a counter to keep track of the array position being updated.

In the setup function, we define the pin modes and then populate the array with ten initial readings from the sensor as a starting point.

In the loop function, we take a new reading and call the addData function to add the reading to the array in the current position. We then get a new average value for the array before checking that the value is within the wet and dry limits. If it is not, it is limited to a maximum and minimum, being the two limits.

We then map the average moisture level to a corresponding green and red led brightness and then set the LED brightness accordingly using a PWM output. We then wait 2 seconds before repeating the loop.

We then have two functions, addData and getAverage which manage the data in the array. The addData function just adds the latest measurement to the array at the current position and then increments the counter. The getAverage function returns the average of all of the values in the array.

Calibrate the Sensor

As mentioned previously, you’ll need to calibrate your sensor in order to get meaningful results from the base. The best thing to do is to start when your plant soil is “dry” or at a level where you’d expect to need to water your plant again.

Replace Pot Plant Base

Place your plant onto the base, push the sensor into the soil, and plug it into the header pin socket.

Plug In Soil Moisture Sensor

Connect the Arduino to your computer using a USB C cable, and open up your Serial monitor on your Arduino IDE. Output the soil moisture readings to the monitor, one every second or two, and note the average of around 10-20 readings once they’ve stabilised (aren’t varying significantly). This will be your dry setpoint.

Once you’re happy with your dry readings, you’ll need to water the plant. Water your plant as you would normally, giving it enough to be fully absorbed into the soil, but not over watered. Now do the same as you did before and take the average of around 10-20 readings on your serial monitor. This will be your wet setpoint.

Update the two setpoints in your code and then re-upload the sketch to start using the base properly.

Since you’ve just watered your plant to calibrate it, the indicator layer should now be green. It will slowly go red again over the next few days as the soil dries out.

Using The Smart Indoor Plant Base

You’ve now got a smart base for your indoor plants which shows you at a glance when your plant needs to be watered.

The Smart Indoor Plant Base when your plant needs more water:

Base When Red

Give your plant some water:

Watering Indoor Plant

After a minute or so, the water should be absorbed into the soil and the sensor base should indicate that the plant has been watered:

Base When Green

The base after a day or two when the water is drying up:

Base In Between

If you’re going to use yours in a really sunny room then you’ll probably want to add two or three LEDs and possibly another layer of acrylic to brighten the display a bit. Else you’ll only be reminded to water your plant at night.

Plant Monitor On A Shelf

Let me know what you think of this smart indoor plant base in the comments section. Are you going to try building one?

Share This Guide

Smart Indoor Plant Base Pinterest

How To Start A Bullet Journal

Are you stressed by your schedule and struggling to stay organized?  Then a bullet journal may be just what you need!  The bullet journal, also called a “BuJo” for short, was created by Ryder Carroll and has become a huge help for people to take control of their lives.  As a beginner, it is easy for you to start a bullet journal to organize your work, home, hobbies, and any other areas that matter to you.  One journal can be used for everything!  Stay flexible and customize the journal to fit your unique needs. 

Starting a bullet journal will help you to be organized in every part of your life.  It will serve as your planner and your journal.  Having a bullet journal will reduce your stress and anxiety and help you to create achievable goals with action steps to reach them.  It also provides you a creative outlet, as you can decorate your journal as much as you like, and it can become a pretty keepsake for years to come.  The best part is that it does not take much to get started, just a notebook and pen!

The Notebook

You can use any notebook or journal, but I would suggest a larger notebook with heavier paper to avoid bleeding and ghosting.  You also will want one that is easy to open and write in.  The good thing is that almost anything will work, depending on your preferences!  One popular journal is the Lechtturn 1917 which has numbered pages, a built-in index, two ribbons, excellent paper to use with watercolors, brush pens, and fountain pens, and a variety of colors and grid versions (plain, ruled, graph paper or dot grid). 

The Pen

Like the notebook, any type of pens or markers will work to begin your bullet journal depending on what works for you.   You should strive to find a good nice quality pen or set of pens that you can write with comfortably on a daily basis.  It is also nice to have a variety of colors.  A favorite option of many is using a fountain pen.  There are many great fountain pens that are extremely fun to write with as the ink glides effortlessly over the page with less pressure.  Fountain pens provide a more unique writing style that can be changed by the type of nib, hold, and angle of the pen.  A good pen can be the motivation you need to start writing in your journal every day!

Getting Started With Your Bullet Journal

Now that you have all that you need to get going, here are a few basic things to consider when getting started.

  1. Create an index where you can keep track of all of your pages.  You can use any format, but an easy one is just to have two columns: one for the page content and one for the page numbers.  Remember to keep your index updated as you create new pages.
  2. Create a key for all of the symbols that you want to use in your bullet journal, making it easier to keep your entries and to-do lists brief.  You can be as creative or as simple as you want.  For example, you can use happy and sad faces to represent your mood on that day, checkmarks for accomplished tasks, and stars for very important events. 
  3. Create your first monthly page.  This is a wide view of the month.  Typical formats include some sort of calendar or lists of dates.  I also suggest having a place to write out your monthly goals.
  4. Create your weekly and daily logs.  These sections are where you put all of your regular daily notes, your schedule and to-do lists of tasks to be accomplished.
  5. Decide on additional sections (collection) that you want to have in your bullet journal that are important to you.  Some examples include future goals, finances, savings plan, diet and fitness, meal planning, date night ideas, a mood tracker, and a gratitude log.  There are endless possibilities for what you can include.
  6. Decorate your bullet journal and make it your own.  Let your creative side show by jazzing up your journal with watercolors, hand lettering, modern or traditional calligraphy, original artwork, doodles, stamps, and stickers.

Now it is time to start your own bullet journal.  Remember to have fun and make it your own! 

Elegoo Uno Project Super Starter Kit Unboxing & Review

Elegoo is one of the popular names in the Arduino starter kit spaces, making great value starter kits with a good instruction set to get you started tinkering with Arduinos and electronics. They sent me their Uno project super starter kit to try out and share with you. So, I’ll be doing just that and sharing two small projects which I built using the kit as well.

The kits are available through their Amazon storefronts in a number of different countries.

Elegoo Uno Project Super Starter Kit – Buy Here

Elegoo Amazon Store

You can watch my video of the unboxing and projects here, or read on for the write-up.

Unboxing The Elegoo Uno Project Super Starter Kit

As expected from Amazon, the kit arrived really quickly and was well packaged and protected. The kit arrived in the usual bubble-sleeve Amazon-branded package and inside it was this yellow package, which Elegoo themselves have wrapped up as well.

Elegoo Project Package

Inside this yellow package, the kit is packaged into a plastic storage case, which is great for keeping all your components together after you’ve started using them.

Project Starter Kit Case

The super starter kit case is pretty tightly packed when you get it, but once you’ve removed the plastic packaging and foam pieces for shipping, you shouldn’t have a problem getting the components back into the box again once you’re done with a project.

Included with the kit is a CD which contains a detailed tutorial guide as well as the code or sketches and the libraries used in the tutorials. We’ll have a look at this in more detail later on.

Project Kit Contents

Let’s get the kit unpacked and see what’s included.

Elegoo Project Super Starter Kit

You’ve got a pretty good range of electronic components to get started with, here is what’s included in the Elegoo Uno Project Super Starter Kit:

  • 1pcs Elegoo Uno R3 Controller Board (Arduino-Compatible)
  • 1pcs LCD1602 Module
  • 1pcs Prototype Shield With Mini Breadboard
  • 1pcs Power Supply Module
  • 1pcs ULN2003 Stepper Motor Driver
  • 1pcs Stepper Motor
  • 1pcs Servo Motor (SG90)
  • 1pcs 5V Relay
  • 1pcs IR Receiver
  • 1pcs Joystick Module
  • 1pcs DHT11 Temperature and Humidity Module
  • 1pcs Ultrasonic Sensor
  • 1pcs DC Motor and Fan
  • 1pcs Active Buzzer
  • 1pcs Passive Buzzer
  • 1pcs IC 74HC595
  • 1pcs IC L293D
  • 5pcs Push Button
  • 1pcs Potentiometer
  • 1pcs 1 digit 7-segment Display
  • 1pcs 4 digit 7-segment Display
  • 1pcs Tilt Switch
  • 1pcs IR Remote
  • 1pcs Breadboard
  • 1pcs USB Cable
  • 10pcs Female-to-male DuPont Wire
  • 65pcs Breadboard Jumpers
  • 1pcs 9V Battery
  • 30pcs Various Resistors
  • 5pcs Yellow LED
  • 5pcs Blue LED
  • 5pcs Green LED
  • 5pcs Red LED
  • 5pcs White LED
  • 2pcs RGB LED
  • 1pcs Thermistor
  • 2pcs Diode Rectifier (1N4007)
  • 2pcs Photoresistor
  • 2pcs NPN Transistor (PN2222)

As with any starter kits, there are probably components that you’re interested in and some which you may never use, but you really can’t beat the value you get with a kit like this. You’d easily pay two to three times what this kit costs if you try and buy the components separately, so it’s a great way to start out.

The Arduino you get with this kit is Elegoo’s copy of the Uno. It’s a great starter board, compatible with a wide range of shields and accessories, and is probably one of the most widely used as well. So you shouldn’t have any trouble trying out different projects and new sensors once you’ve worked through their tutorials.

Elegoo Uno R3

They’ve included both a full-sized breadboard along with a prototype expansion shield with a mini breadboard on the top so that you can build more compact projects as well.

Prototype Shield and Mini Breadboard

I do like that they’ve labelled the sides of the header pin strips with the port numbers. This is really useful if you’ve got a shield plugged in or you can’t see the top of the Arduino because it’s tucked into a tight case or container for a project.

Pin Numbers On The Sides Of The Arduino

Some other nice inclusions are a dedicated breadboard power supply with a 5V and 3.3V regulator, an LCD display and a stepper motor and driver.

Breadboard Power Supply
LCD Display
Stepper Motor & Driver

Tutorial Guide & Included Code

Now let’s have a look at what is included on the CD with the Elegoo Uno Project Super Starter Kit.

As mentioned before, the CD contains a detailed tutorial guide as well as the code or sketches and the libraries used in the tutorials in a number of different languages.

CD Directory

This is quite useful as a few kits I’ve seen leave it up to you to find the libraries they’ve used, which can be a problem for new users. You can also download the contents of the CD along with up to date libraries through the Elegoo website, the download is around 250MB.

The tutorial guide starts out by explaining the Arduino IDE as well as how to connect and program your Arduino and how to install the included libraries.

Elegoo Uno Project Super Starter Kit Manual

They also detail how to install the drivers for the board. Both my Windows PC and mac picked the board up as an Arduino Uno right away and I didn’t need to install any additional drivers.

You’re then guided through 24 Lessons in total, which show you how to connect and program the Arduino to use all of the components supplied in the kit. Once you’ve worked through all of these, you should have a really good understanding of how any Arduino works and you’ll be able to build some pretty cool projects.

Code For Each Lesson

The lessons are quite details and tell you exactly what you need and how to connect them. They also give you a bit of background information for the components and give you a photograph of what the final setup should look like. You shouldn’t have any trouble getting each lesson up and running using the included components and the included sketches.

Example Photograph

The only issue I could point out with the lessons is that they don’t go into much detail on how the code works. Some lessons have more details than others and they do point out any areas which you may get stuck or need to change for your specific project, but you probably won’t learn too much about the code if you don’t already have a basic understanding of the Arduino programming language or C++. But there is enough information to help you get by and get through each of the lessons.

Code Descriptions

Rather than go through one of the lessons which have already been done, I’ve put together two basic projects which use the included components and just combine sections of the included example code to make, so are really easy to get running.

Sample Project 1 – DC Motor Throttle

The first project I tried with the super starter kit is a simple throttle for the DC motor and fan. It uses one axis of the joystick to control the speed and direction of the motor using the included L293D motor driver chip. This project uses Lesson 12 for the analog joystick module input and Lesson 21 for the DC motor and driver. I assembled the components onto the prototyping shield and mini breadboard.

Motor Throttle Project

For this project, you’ll need:

  • Elegoo Uno R3
  • Prototyping Shield & Mini Breadboard
  • 9V Battery & Lead
  • L293D Motor Driver
  • DC Motor & Fan
  • Joystick Module
  • Power Supply Module
  • Jumpers

I’ve connected the motor and driver as well as the analog joystick to the Arduino as outlined in the two Lessons in the tutorial.

For the joystick, we’ll only need one axis, I used the one to A1:

Analog Joystick Connection

For the L293D DC Motor driver, I’ve used the circuit as shown, but with the mini breadboard. The power connections will need to be made directly onto the 5V header pins on the power supply module.

L293D Motor Driver Connection

Once you’ve made the connections, your breadboard should look like this:

Motor Throttle Project Wired Up

You’ll then need to program your Arduino.

I’ve also just copied sections of code from both lessons to make a really simple sketch to drive the motor.

//DC Motor Throttle Example Project

#define ENABLE 5                    //Define the motor driver pins
#define DIRA 3
#define DIRB 4

const int X_pin = A1;               //Define joystick input pin

int motSpeed = 512;                 //Variable to store the motor speed

void setup() 
{
  pinMode(ENABLE,OUTPUT);           //Set the motor driver pin functions
  pinMode(DIRA,OUTPUT);
  pinMode(DIRB,OUTPUT);
}

void loop() 
{
  motSpeed = analogRead(X_pin);                 //Read in the joystick position
  if (motSpeed>=532)
  {
    motSpeed = map(motSpeed,532,1023,0,255);    //Map the motor speed to the driver range
    analogWrite(ENABLE,motSpeed);               //Set motor speed
    digitalWrite(DIRA,HIGH);                    //Set motor direction
    digitalWrite(DIRB,LOW);
  }
  else if (motSpeed<=492)
  {
    motSpeed = map(motSpeed,492,0,0,255);       //Map the motor speed to the driver range
    analogWrite(ENABLE,motSpeed);               //Set motor speed
    digitalWrite(DIRA,LOW);                     //Set motor direction
    digitalWrite(DIRB,HIGH);
  }
}
Motor Throttle Project Wired Up 2

I found the included battery to be a bit sluggish, for the motor, so I replaced it with a power supply to give it a bit more speed.

Push the joystick forward to drive the fan in one direction and backwards to reverse the fan.

Motor Running Forward
Motor Running Reverse

The fan’s speed is also proportional to how far the joystick is pushed, so you can slow it down or speed it up in either direction. Have a look at the video at the beginning of this review to see some clips of the motor running.

Sample Project 2 – Parking Assistant

The next project is a bit more complex, but all of the components and lessons used are included with the Elegoo Uno Project Super Starter Kit. It’s a parking assistant, which can be mounted onto a wall in front of your parking bay or garage to indicate when your car is in the right spot.

This parking assistant measures the distance to your car and guides you to park it in the correct spot using an LCD display readout and an LED, which progressively changes from green to red. The red LED starts flashing if you get too close. A button on the assistant lets you set a new parking position as well.

For this project, you’ll need:

  • Elegoo Uno R3
  • Breadboard & Jumpers
  • Ultrasonic Sensor
  • LCD Display
  • Tactile Pushbutton
  • 5mm RGB LED
  • 2 x 200ohm Resistors
  • 10K Potentiometer

This project uses the following lessons from the tutorial:

  • Lesson 4 – RGB LED
  • Lesson 5 – Digital Inputs
  • Lesson 10 – Ultrasonic Sensor Module
  • Lesson 14 – LCD Display

I’ve kept the connections for the LCD display the same as in the tutorial. The other components have been adjusted for the available IO.

Start off by plugging your components into your breadboard. Try to separate them as much as possible, so that you’ve got lots of space to connect your jumpers.

Parking Assistant Layout

There are three components which you should position in certain places to avoid additional jumpers:

  • Plug a 220ohm resistor onto a track connected to each of the positive (anode) legs of the LED. You’ll only need the red and green legs, you can leave the blue leg disconnected.
  • Plug the wiper (center leg) of the pot onto the same track as V0 on the LCD. This pot will be used to adjust the contrast of the LCD.

​I’ve tried to keep this project as close to the ​example lessons in the Elegoo kit as possible so that it’s pretty easy to use the same connection diagrams and just copy and paste parts of the code to get it working.

​Start off by connecting power to the components as shown in the below image, or follow the connections outlined in the lessons. You need a GND and 5V supply to the ultrasonic sensor, GND to the LED, GND to the pushbutton, and then a number of GND and 5V connections to the LCD and pot.

Wire Up Power To Components

The connections to the LCD are done as per Lesson 14:

LCD Connection To Arduino

Once this is done, you can connect the remaining components to your Arduino’s IO:

  • Pushbutton – D2
  • Ultraonic Sensor Echo – D3
  • Ultrasonic Sensor Trigger – D4
  • RGB LED Green Leg – D5
  • RGB LED Red Leg – D6
  • LCD RS – D7
  • LCD EN – D8
  • LCD D4 – D9
  • LCD D5 – D10
  • LCD D6 – D11
  • LCD D7 – D12
Connect All IO To Arduino
LED & LCD
Pushbutton To Reset

Once you’ve made all of the connections, you can upload the sketch to your Arduino. This sketch has also been mostly constructed from parts of the four lessons, so it should be fairly easy to follow:

//Parking Assistant Example Project

#include "SR04.h"                             //Import Ultrasonic Sensor Library
#include <LiquidCrystal.h>                    //Import LCD Library

#define TRIG_PIN 4                            //Define sensor pins
#define ECHO_PIN 3

SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);          //Create sensor object
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);       //Create LCD object

int greenLedPin = 5;                          //Define IO pins
int redLedPin = 6;
int buttonPin = 2;

int maxDist = 80;                             //Define parking assistant parameters
long dist;
long parkDist = 20;

void setup() 
{
  lcd.begin(16, 2);                           //Start the display and display startup text
  lcd.print("Parking");
  lcd.setCursor(0,1);
  lcd.print("Assistant");
  pinMode(greenLedPin, OUTPUT);               //Define IO pin functions
  pinMode(redLedPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP); 
  delay(2000);
  lcd.clear();                                //Clear the startup text
}

void loop() 
{
  boolean tooClose = false;
  dist = sr04.Distance();                                       //Measure the distance to an object
  lcd.print("Distance");                                        //Display the measurement
  lcd.setCursor(0,1);
  lcd.print(dist);
  lcd.print("cm");
  if(dist >= maxDist)                                           //Define the parking distance limits for the LED
    dist = maxDist;
  else if(dist <= parkDist)
  {
    dist = parkDist;
    tooClose = true;
  }
  analogWrite(greenLedPin, map(dist,parkDist,maxDist,0,255));   //Display the object distance on the RGB LED
  analogWrite(redLedPin, map(dist,parkDist,maxDist,255,0));
  if (tooClose)
  {
    digitalWrite(redLedPin, HIGH);
    delay(250);
    digitalWrite(redLedPin, LOW);
    delay(250);
  }
  if (digitalRead(buttonPin) == LOW)                            //Set the new parking distance if the button is pushed
  {
    parkDist = dist;
    digitalWrite(greenLedPin, HIGH);                            //Flash LED to indicate new distance has been set
    delay(500);
    digitalWrite(greenLedPin, LOW);
    digitalWrite(redLedPin, HIGH);
    delay(500);
    digitalWrite(redLedPin, LOW);
  }
  delay(500);
  lcd.clear();                                                  //Clear the display
}

When you power the parking assistant up, it shows a brief Parking Assistant splash screen and then starts taking distance measurements to the object in front of the ultrasonic sensor, to a maximum of 80cm – this can be changed in the code to suit your parking spot/garage.

Startup Screen

The distance is displayed on the LCD and the RGB LED will light up according to the distance to the object. If the object is at the maximum distance, the LED will be completely green and if it is at the minimum distance (the correct parking spot) then it will be completely red.

Green LED When Far Away
Red When Closer

The LED will change colour proportionally in between these two limits, with a yellow colour in the middle. If the object comes closer than the minimum distance, the LED will flash red.

Red Flash When Closer Than The Minimum

The LCD will continue to display the actual measured distance while the LED is flashing.

Trying moving your body or hand in front of the ultrasonic sensor and check that the measurements on the LCD change and that the RGB LED changes from green when you’re far away to red when you’re close by. Have a look at the video at the beginning of the review to see some clips of the parking assistant in operation.

To set a new parking position, make sure that the car is parked in the new position to be set and that the display is showing the correct distance to the car, then push the button to update the parking position. Note that this doesn’t change the maximum distance, so if you need to park your car further than this distance, then you’ll need to update this in the code, this adjustment is meant to be used for fine adjustment.

Press Button To Reset Minimum Parking Distance

Try placing an object or your hand at a certain distance, say around 40cm from the ultrasonic sensor and push the button. The LED should flash green and then red and the new distance will then be set. You should now notice that the RGB LED turns completely red by 40cm instead of 20cm and starts flashing when the distance is less than 40cm.

To reset the distance, set the object to 20cm from the sensor and press the button again.

The correct spot being 20cm and the maximum distance being 80cm are just arbitrary numbers used for this example. You’ll need to set up your own limits for your own garage and car before you use it.

That’s it, your parking assistant can now be installed into an enclosure and mounted onto the wall in your garage. You might also want to position the LCD and LED a bit further up the wall than the ultrasonic sensor so that it’s easier to see.

Conclusion

Overall I think this is a great value kit and an excellent way to get started tinkering with Arduinos and electronics. There’s a good selection of components and unlike some other starter kits, Elegoo includes loads of jumpers, resistors and LEDs for more complex projects.

If you’re interested in buying one of these kits, head over to Amazon to pick one up. Elegoo have given me a discount code to share with you too, use the code DWZRAUL5 to get a discount on the kit from their Amazon store until 27/09/2020 11:59 PM AEST

Building an 8x8x8 LED Cube from an Amazon Kit – Arduino Compatible

I bought this kit a while ago when I was looking at building an Arduino based 8x8x8 LED cube. This one was listed on Amazon as Arduino compatible, meaning that I should be able to re-program it using the Arduino IDE after assembling it to display what I want.

LED Cube Kit As It Arrived

The kit was delivered quite quickly, but there was one pretty obvious thing missing, the assembly manual. I had a look on the product page on Amazon, emailed the supplier, and Googled the supplier and other 8x8x8 cube kits to try and find the manual. The supplier never got back to me and although I found a few similar cubes, I never found an assembly manual for this particular cube, so I packed the kit away and forgot about it for a few months.

A week ago, I found the kit again and decided to try assembling it. At worst, I’d have a cube that didn’t work and would just be a dead shelf decoration.

Here’s a video of the build and the 8x8x8 LED cube working, read on for the detailed assembly.

Buy Your Own 8x8x8 LED Cube Kit

  • 8x8x8 LED Cube Kit (Like The One In The Video, Probably Has No Instructions Either) – Buy Here
  • 8x8x8 LED Cube Kit (Better Quality, Not Arduino Compatible) – Buy Here

Assembling The 8x8x8 LED Cube

So let’s get started with putting the cube together.

The kit arrived quite quickly and this is what was delivered.

LED Cube Kit, What Was Delivered

There was a bag of LEDs, they said that 550 LEDs are supplied in case some are faulty, the PCB to mount the components, and then a small case with the chips and other electronic components.

The product page said that the cube was Arduino compatible, although the chip supplied is a STC12C5A60S2 micro-controller. You’ll need a USB-2-TTL programming module to re-flash this micro-controller. There is guide a good guide and software to re-programming the STC micro-controller on GitHub.

Soldering The LED Layers

I started out by testing all of the LEDs. I’ve never found a new LED to be dead, but since they said that they included 550 LEDs in case some were faulty, I decided to test them all first to avoid have to replace LEDs once it was all assembled. I set up a simple 5V power supply and 220 ohm resistor on a breadboard and got testing.

Testing The LEDs

I didn’t find any faulty LEDs, but I still think it was worthwhile to save the frustration if I had.

All LEDs Tested

Next, I laser cut a template to lay out the LEDs. Rather than trying to get the placing right for each individual LEDs, having an MDF board which I could press the LEDs into and then connect up while they’re held in place would dramatically speed up the process and hopefully result in nice straight and evenly spaced grids of LEDs.

Laser Cutting A Template

I cut two layers, one with 3mm holes to hold the LEDs and one with 5mm holes to be the bottom spacer layer so that the LEDs don’t touch the table underneath them when they’re pushed into the template.

I then layed out the 64 LEDs on the template, making sure that the LEDs were all facing the same direction.

Laying Out LEDs In Grid

So with the longer positive leg or anode on the right side and the negative leg, or cathode on the left side.

LED Cube LEDs Positioned On Template

Next, the idea is to connect all of the positive legs together in each column and all of the negative legs together in each row, making sure that they don’t touch each other. I started with the negatives, bending them all down so that there was some overlap between them.

Bending Legs Down

I then soldered them together.

LED Cube Soldering LED Legs
LEDs All Cathodes Soldered

Once all of the negatives were done, I did the positives. I used a pair of pliers to space the bend a little away from the back of the LED so that the positive connections were spaced about a millimeters away from the negative connections. In hindsight, these legs should have been bent in the opposite direction in order to keep the connections on the back side of the cube when it’s on display, but this isn’t particularly noticeable in the end.

Bend All Anodes To Make Rows

I continued this until all of the columns and rows on this layer were connected.

Completing Rows and Columns of LEDs

I then tested the LEDs again, this time testing the soldered connections. I used a small battery pack for this and just ran the leads over the columns and rows, checking that each LED lit up. I was glad I did this as I found two bad connections on my first layer.

Testing The LEDs Once Assembled Into Grid

I then carefully removed the layer of LEDs from the template, trying not to bend the legs of the LEDs.

Removing LED Grid From Template

I was worried that I might have damaged some of the joints when removing the LEDs, so I tested this layer again once I removed it from the template.

Testing LEDs Again

I tested the subsequent layers only after removing them from the template. The next few went a lot better, but I did still find one or two bad connections, and one LED installed the wrong way around.

Creating these layers is the most time-consuming part of the build, but time spent here will result in a much neater looking cube down the line. It’s also definitely worth taking the extra minute or two between layers to test all of the connections. Even fixing a single bad joint once the cube is assembled will be near impossible without damaging it when taking it apart again.

Soldering The PCB Components

Once all of the layers of LEDs were made, I got started with soldering the components into place.

This was where some guesswork came in. It was pretty obvious when making the layers that the LEDs had to be connected in a particular way, but it’s less obvious which capacitors and resistors go in which places on the PCB when it isn’t labeled.

The two electrolytic capacitors were the same value, despite the markings on the PCB being different sizes, so I just installed those in the two available spots. The ceramic capacitors were all the same size, although there were three supplied and only two spots on the PCB for them. I also noticed that there were two different value resistors supplied, 2 of one resistance and 8 of another. I noticed that the PCB had two resistors on one side and 8 on the other, so I decided to install them with two of the same on one side and the 8 others on the other side and hope for the best.

Soldering Front Components

There are three different size chips. The ones that are the same size are all the same, so those are quite easy to figure out and the remaining components could be figured out based on the PCB holes.

Soldering Back Components
Adding IC Chips

The final part of the PCB assembly is to mount these LED leg holders onto the board to plug the LEDs into. I cut the strips up into individual pins and then broke the plastic off of them. I then installed one on each of the holes on the PCB. Luckily these could be installed from the component side of the PCB as the back side of some of these pins were covered by the IC sockets, something which I hadn’t thought about earlier.

Adding The LED Holders

I also noticed that on the PCB there are laocations for some header pins and two pushbuttons, but the components weren’t supplied. I assumed that the header pins are for programming the chip and the pushbuttons could be used to change the display currently being run on the cube, but this probably wasn’t preloaded onto the chip either. I decided to install these components as I had some pushbuttons and pins lying around and I wanted to be able to re-program the chip later as well.

Adding Pushbuttons and Header Pins

Assembling The Cube Layers

Now that the components are all in place, I could plug the LED layers in.

From other cubes I’ve seen online, I assumed that the positive legs of the LEDs went into the holes directly underneath the cube for the columns and that the negative legs would get joined in layers and connected to the holders alongside the cube. It turned out that the negative legs on my LED layers should have been on the other side, as that was the back side of the cube, but this doesn’t really make much difference.

First LED layer in place.

Installing First LED Layer

I then installed them remaining LED layers.

Installing Additional Layers
Completing The Installation Of The Layers

Once the layers were installed, I bent the negative legs at 90 degrees to join each layer together and soldered them together.

Joining The LED Layers Together

The next mystery was to decide which layer to connect to which numbered holder. I wasn’t sure if pin 8 was to go to the bottom layer or top layer? One diagram in another cube’s manual had the layers labelled with 1 being the top layer and the image alongside clearly showing the bottom layer being wired to 1.

All LED Layers Joined

I decided to temporarily connect these are there was a good chance my guess would be wrong.

Connecting The Layers To The Pins on the 8x8x8 LED Cube

Another issue was that the red insulated wire supplied to connect the layers to the holders was too short by 2-3cm. I didn’t waste any of it with incorrect lengths or stripping too much wire, so I’m not sure why it was too short. I made a plan for the shortest connection and was then ready to power up the cube.

Powering Up the Cube

I plugged the power supply into a USB charger and pushed the switch to turn it on.

Pattern Displayed When First Turned On 8x8x8 LED Cube

The built-in program is a bit odd in the beginning and its not really clear if the of the layers are working or not working correctly. I would have thought that a good initial test would be to light up all LEDs or at least the layers sequentially.

8x8x8 LED Cube Assembled Flashing

I left it running and eventually some recognizable patterns started emerging and it looked like I had guessed the layers correctly. There was a typical “rain” type animation where the LEDs drop from the lit-up top layer, and the top layer was actually at the top of the cube, so I assume that I’ve got the layer numbers correct. If they were the wrong way around then the rain would fall upwards.

8x8x8 LED Cube Rain Animation

As expected, the buttons don’t seem to do anything, but I’ll be looking to program them to change what is being displayed on the cube once I figure out how to program it. It also seems like the resistors are correctly installed, there aren’t any obvious bright or dim rows or columns.

8x8x8 LED Cube Working

Next I’m going to try and figure out how to program it and I’ll be making a clear acrylic case for it as well.

8x8x8 LED Cube Revolving Lights

Have you tried building your own 8x8x8 LED Cube? How did it go and did you build it from scratch or use a kit? Let me know in the comments section below.

How To Make A Raspberry Pi Zero WiFi Security Camera

In this project, I’ll be showing you how to assemble and configure a Raspberry Pi Zero W to be used as a WiFi security camera, which is also accessible over the internet.

We’ll be using an operating system called MotionEyeOS on the Raspberry Pi, which is a web-based, mobile and tablet friendly surveillance system. It can be used with both the Raspberry Pi camera or any USB web camera plugged into the Raspberry Pi. You can also set up motion detection with email notifications, take still images and time-lapse movies, and even configure it to upload media files to network storage locations or to cloud storage services.

Here’s a video of the build and the camera in operation, read on for the full step by step instructions.

What You Need To Build Your Camera

Optional Alternative (You’ll still need to buy the camera):

  • Pi Zero W Kit (Includes Pi Zero W, Case, SD Card, Power Supply & Camera Ribbon Cable) – Buy Here
What You Need To Build Your Pi Zero WiFi Security Camera

Assembling The Raspberry Pi Zero WiFi Security Camera

I’ve used a Raspberry Pi Zero W for this project because they’re relatively cheap and compact, making them perfect to mount discretely around your home. You can set up a couple of cameras around your home for less than $100. The W version has built-in WiFi, so there’s no need for an external WiFi or Ethernet adaptor to connect it to your home network.

Raspberry Pi Zero W

Let’s start by assembling the components into the Raspberry Pi Zero case.

If your Pi Zero came with a heat-sink, attach it to the board using the adhesive tape on the heat-sink.

Stick The Heatsink To Your Raspberry Pi Zero W

Once you’ve done that, you’ll need to connect the camera to the Pi.

The ribbon cable just slides into the connector with the contacts facing towards the board.

Clip The Ribbon Cable Into The Camera

Make sure that the black clip is pulled away from the connector to open it. Then push the black clip back into place to grip the ribbon cable once it is seated correctly in the connector.

Secure The Ribbon Cable Connector

Now do the same on the connector on the Raspberry Pi to connect the camera module to the Pi.

Plug The Camera Into The Raspberry Pi

Next open up the case and push the Pi into the back of the case. There are small pegs on the case which align with the screw holes on the Pi and the ports should all be aligned with the cutouts on the side of the case.

Install The Pi Into The Case

Next, clip the camera into place on the top cover and then close up the case to check that it all fits correctly.

Close Up Of The Case

We can now move on to preparing the SD card with the MotionEyeOS operating system.

Loading The Operating System Onto The SD Card

Use a card reader to plug the card into your computer.

Now you’ll need to download the MotionEyeOS software.

If you’re not using a Raspberry Pi Zero, or you’d like to use a different board, have a look at the list of Supported Devices to see which version of the operating system you should download.

MotionEyeOS Supported Devices

Go to the list of latest releases and make sure that you download the latest version of the software which is compatible with your board.

We’ll be using the Raspberry Pi version which was released on the 6th of June.

Latest Release For MotionEyeOS

Once you’ve downloaded the software, you’ll need to unzip it to a folder on your computer. I used Easy 7-Zip for this. Don’t try to flash the zipped image to your SD card, it won’t work.

You’ll then need to use an image flasher to flash the disk image to your SD card. The one recommended in the installation instructions on GitHub is Balena Etcher. Once you’ve downloaded and installed the software, you can flash the disk image.

You’ll need to first select the source file, which is the disk image that you unzipped in the previous step.

Download & Use Balena Etcher

Then select your destination target, which is your SD card.

Then click on Flash and wait for the software to write the disk image to your SD card.

Flashing The Image To The SD Card

Finally, you’ll need to tell your Raspberry Pi how to connect to your WiFi network.

To do this, use the template below. It’s a basic text file in which you’ll need to add your country code and then your Network name or ID and the network password.

You can find a list of country codes on Wikipedia.

Rename the file to wpa_supplicant.conf, making sure to change the extension as well and then put it into the 30MB settings partition which you’re able to write to on your SD card.

Once you’ve done this, your SD card is ready to be installed into your Pi for the first boot up.

Booting & Configuring Your Pi Zero Security Camera

You don’t need to attach a monitor for this next step, but it is helpful to check that you don’t get any error messages and to make sure that the Pi has finished booting up.

Boot Up Pi For The First Time

The first boot up takes about a minute or two to complete, it’ll boot up much faster than this after the first boot.

Boot Up Log

If you haven’t used a monitor then you’ll need to find the IP address of the Pi using a network analysing tool on your computer.

Once you’ve found the address, type it into your browser to access the Pi and it’s video feed.

MotionEyeOS Running

If everything is working correctly, the video feed from your camera should show up after a few seconds.

Test Camera Loading

If you open up the settings menu, you can also shutdown or restart your Pi, which you’ll need to do if you’re going to be disconnecting it to install elsewhere. If you’re asked for login details, the default username is admin, with no password.

Mounting Your Camera

I 3D printed a small GoPro adaptor to stick onto the back of the Pi case so that it can be mounted onto any standard GoPro mounts.

GoPro Mount For Back Of Pi Camera
GoPro Mount On Back Of Raspberry Pi Zero

I’m going to be using a suction cup mount to mount the Pi onto an outside window. It’s under cover, so it’s protected from direct sunlight and rain.

This mount also enables the camera to be positioned so that it’s pointing in the right direction.

Mount Raspberry Pi Zero WiFi Camera Onto Window Outside

You’ll need to power it using a USB power supply. You can also use a power bank to temporarily power it for a mobile surveillance system.

Raspberry Pi Zero WiFi Security Camera

Let’s have a look at the video feed outside.

MotionEyeOS Video Feed Outside
MotionEyeOs Camera Feed

You can also access the camera using your mobile phone or tablet by typing the same IP address into your device’s browser.

Configuring Port Forwarding To Access Your Camera Over The Internet

The last step is to configure port forwarding on your router, so that you can access the camera from the internet.

You’ll need to start by assigning a fixed IP address to your camera, so that it doesn’t change every time it re-connects to the network. This can be done in the MotionEyeOS settings menu. Set the IP configuration to manual and then change the IP address to the address you want to always assign to the camera. This should be out of the range that your router typically assigns addresses to otherwise you’ll land up with a conflict it that address has already been used.

For example, if your router typically assigns IP addresses in the 192.168.10.1 to 192.168.10.20 range then you should pick an address higher than 20, so something like 192.168.10.21 and onward for your cameras.

You might also need to change your Default Gateway to your Router’s address.

Next, you’ll need to set up port forwarding on your router. This is something I can’t really show you how to do because it’s very different for each router make and model. But you essentially need to login to your routers configuration page and then add a port forwarding instruction so that requests from outside your local network on a specific port are forwarded to a particular device, in this case, your Raspberry Pi camera.

Setting Up Port Forwarding On NetComm Router

Here’s the general idea of what you need to do:

  • You’ve got your Raspberry Pi’s local IP address (this is what you’ve been using to access the camera through your browser), you now need to know what port number it is communicating on. This is usually Port 80 by default. Since this is the default, it’s a good idea to change it to a port number that is unused by any other services as a security measure.
  • Next, you’ll need to find your router’s external IP address. This can be done by googling – “What’s My IP” from any device connected to the same internet-connected network.
    • This is the IP address you’ll need to type in over the internet in order to access your camera while you’re away from home. It is the IP address which your provider has assigned to your router. So this might change if you don’t have a fixed IP address arrangement with them.
  • Lastly, you need to choose an external port to forward. Again, you can choose any unused port. You’ll use the combination of your router’s IP address and this port number in your mobile device’s browser in order to access the camera.

Now that you have an external IP address and port as well as your internal IP address and port, you should have all of the information that you need to configure the port forwarding instruction on your router. This is the part that is very different for each router manufacturer and model, so you’ll need to figure out how to do this on your own router.

Essentially what you’re doing is telling the router that when an external request is sent to it on the particular port you’ve chosen, the router should forward the “web page” which is served to it when it calls the local IP address and port number so that you’re able to see it from outside the network.

Once this is done, you should be able to access your camera over the internet in the same way you could do it locally. If you’re still unsure how to do this, try searching for setting up Port Forwarding on your specific router make and model.

Let me know if you’ve built your own Raspberry Pi Zero WiFi Security Camera in the comments section. What are you using it for?

Share This Guide

Raspberry Pi Zero WiFi Security Camera Social

How Fast Can An Arduino React? Tested Using My Reaction Timer Game

Last month, I built an Arduino based reaction timer game, which allows you to challenge your friends and family to see who has the fastest reaction time. We managed to get our times down to around 160 milliseconds and I’ve seen videos of people who can get down to 120 milliseconds, but now I want to know – How fast can an Arduino react to the same game?

Here’s a video of the test, have a look at it to see the Arduino react to the reaction timer’s LED, otherwise read on for the full write-up and details.

What You Need For This Test

Components Required

Setting Up The Test Rig

In order to test the Arduino’s reaction time, we’d need a sensor to detect the light coming from the LED on the game and then an actuator to push the button to stop the timer.

Arduino Reaction Time Reactor Schematic

I built a simple setup with an LDR to detect the LED’s light and a micro-servo to push the button. I also included an LED so that we can see if there is any delay between the Arduino telling the servo to move and the servo actually pushing the button since there is a motor to spin up and a number of gears between the motor and the servo arm.

Solder Components Together To Make A Wiring Harness

I soldered the components together using a few strips of ribbon cable and some header pins.

Glued The Servo To A Box

I then found a plastic base which was the right height to mount the servo on so that it could be positioned just above the button.

Placed The Reaction Timer Under The Servo

Next you’ll need to position the LDR as close to the LED as possible. I glued the resistor onto the side of the game using a glue gun and could then adjust the legs of the LDR to position it directly over the LED.

Set Up The LDR On The LED

Now let’s have a look at the code.

//Michael Klements
//The DIY Life
//7 May 2020

#include <Servo.h>

Servo react;        //Create a servo object to control the reaction servo
int lightOn = 0;    //Variable to read in LDR value

void setup()
{
  //Serial.begin(9600);
  react.attach(6);    //Set the servo pin to pin 9
  pinMode(7, OUTPUT);   //Output pin for LED
  react.write(80);    //Set the servo to an initial position just above the button
}

void loop()
{
  lightOn = analogRead(A0);   //Read the output from the LDR
  //Serial.println(lightOn);
  if (lightOn > 800)
  {
    digitalWrite(7, HIGH);            //Light up the LED
    react.write(65);                  //Move the servo to push the reaction button
    delay(600);                       //Wait 400 milliseconds
    react.write(80);                  //Move the servo back to the initial position
    digitalWrite(7, LOW);             //Turn the LED off
  }
}

We start by including the servo library to control the servo.

We then create a servo object called react to control the servo and create a variable to store the value read from the LDR.

In the setup function we set the servo pin number, then set the LED pin as an output and set the servo position slightly above the reaction button.

In the loop function, we read in the LDR sensor level, then compare it to the light set point. If the measured level is greater than the set point, then we turn the LED on and then move the servo downwards to push the button. We then wait 400 milliseconds for the servo to move and then move the servo back up for the next push and turn the LED off again..

I’ve also included a serial monitor printout of the sensor value which is used initially to measure the game’s LED set point. You’ll need to run the game and see what value is measured by the sensor when the reaction timer’s LED is on and then update this value in the code accordingly. Once you’ve done this, then remove or comment out this code so that it is now slowing down the loop for the actual test. We’ll look at this in the next step.

Calibrating The Light Sensor

If we upload the code and then open the Serial Monitor, we get a stream of input values read from the sensor, detecting the ambient light. Now press the button on the reaction timer to start a game and look out for the change in values when the LED comes on.

Results When Calibrating The Arduino

You can see that we get a reading of around 775 when the LED is off and it goes up to around 830 when the LED is on.

We can now go change the setpoint value to a value just above the off value so that it triggers the servo movement as soon as the LDR starts to register the change in light. You want it to trigger as the LDR starts detecting the light change as the LDR will “slowly” ramp up to the maximum value over a couple of milliseconds.

Remember to comment out the Serial communication for the final version as you want the code to be as quick as possible.

Let’s upload the code and see how it quick it is.

Testing The Reaction Time Of The Arduino

Press the button once to start the game and then quickly position it under the reaction servo.

Reaction Time of 54 Milliseconds

For the first run, we get a reaction time of 54 milliseconds, which is pretty quick considering we have to wait for the servo to move to push the button as well.

I tested it a couple of times like this and consistently got around 50 to 60 millisecond reaction times.

Some Delay In The Movement Time On The Servo

Watching one in slow motion (included in the video at the beginning), you can see that the LED comes on really quickly after the reaction timer’s LED turns on, but there is a bit of a delay in getting the servo to move. By looking at the individual frames, I calculated that it takes around 8 milliseconds LED to come on after the reaction timer’s LED is turned on, the servo then takes around 50 milliseconds to press the button after this.

I Tried Taping Over The LDR To Make It Darker

I then tried to see if making it darker around the LDR with some tape would result in a faster response time. It didn’t really make much of a difference, although there was a very slight improvement of around 1-3 milliseconds.

Turning Off The Reaction LED As Well

I also tried disabling the LED so that the Arduino just had to move the servo, this improved the reaction time by almost 10 milliseconds, so I got times around the mid-forties.

Conclusion

So from this test, we can see an Arduino react to an external light source in under 10 milliseconds, the servo movement takes up most of the reaction time from there. With the movement of a servo, the response time is just less than 50 milliseconds.

Arduino Reacting To Reaction Timer

There are ways to further improve an Arduino’s response time by using Direct Port Manipulation, but this is probably not going to make a significant difference in this example, as the delays in the LED lighting up, the LDR responding to the light and the second LED lighting up is much more significant than the amount of time the Arduino takes to respond to the input.

Have you tried building any projects which required your Arduino to react quickly? What have you built? Let me know in the comments section below.

Can I Get An Arduino To Run For A Year On A Single 18650 Battery?

I recently looked at how much power some common Arduino boards consume and how long we’d be able to power them using one or two 18650 batteries. I found that I could power a 3.3V Arduino Pro Mini using a single 3.7V lithium-ion 18650 battery for 117 days in lower power mode. This got me thinking. What else could be done to make the Arduino Pro Mini even more power-efficient? How long could I get it to last? So I did some research and testing to find out.

For each test, I’ve included two battery capacities in my calculations, one for the 4200mAh claimed on the test batteries and one for the more commonly available 3500mAh batteries. I’ve then calculated the number of hours, days and years of run time for each modification and each battery. I’ve put these results into a table at the end.

Here’s the video of the modifications and the results, otherwise read on for the full write-up.

Testing The Standard Board With A Single 18650 Battery

Let’s start with the standard board with no power-saving or sleep mode active and no hardware modifications to use as a baseline.

I loaded a basic sketch onto the Arduino which simply waits 8 seconds, then flashes the onboard LED for 100 milliseconds.

Arduino-Power-Consumption-Sketch-Delay

I then connected the single lithium-ion 18650 battery to the GND and RAW pins with the multimeter hooked up on the GND lead to measure the current being supplied to the Arduino.

Arduino Pro Mini Normal Operation

So with no modifications, a 3.3V Arduino Pro Mini uses around 5.4 milliamps. Meaning that it could run for around a month on either the 4200mAh or the 3500mAh battery, the difference is only a couple of days.

Testing Low-Power Sleep Mode

The Atmega chips on the Arduino Pro Mini supports a number of different sleep modes that turn off any unused peripherals in order to conserve power when the Arduino is running on batteries. So let’s try putting the Arduino into a low power sleep mode between flashing the LED, using the following sketch and the LowPower library.

Arduino-Power-Consumption-Sketch-Low-Power-Mode

We’ll keep all of the connections and hardware the same the same for this test.

Arduino Pro Mini Low Power Sleep Mode 18650 Battery

So this mode has decreased the current draw to around 1.5 milliamps, which means that the Arduino will last almost 4 months on the 4200mAh battery and a little over 3 months on the 3500mAh battery.

Remove The Built-In Power LED

Now let’s try making some physical modifications to the board in order to conserve more power.

The first and probably most obvious thing to do is to get rid of the on-board power LED. These small LEDs don’t draw much power, but when we’re trying to power the board for over a month using a single battery then even small consumption items like these can become significant. It’s also not particularly useful to have an onboard power LED if the board is going to be in a housing or box.

Remove Power LED From Arduino

Because its a surface-mounted component and there are components alongside it, the easiest way to disable it is to break it off of the board with pliers or some wire cutters. You could also cut through one of the supply traces on the PCB.

Power LED Removed From Arduino Pro Mini

Now let’s see what improvement we’ve made.

Here’s the current draw shown in milliamps.

No Power LED Current Draw In mA On 18650 Battery

Let’s try switching the multimeter to microamps to get better resolution.

No Power LED Current Draw uA On 18650 Battery

So the supply current has reduced from 1.5 milliamps to 0.058 milliamps or 58 microamps, which is a substantial saving. We’re now using 25 times less power than with just the power-saving mode activated, and all we’ve done is remove an LED which we probably wouldn’t have seen anyway.

So we’ve got an extra 2900 days of run-time by removing the LED. Your Arduino should now last for 8 years on a single charge on the 4200mAh battery and 7 years on the 3500mAh battery.

In practice, this will obviously be less, because your Arduino will also be doing some more complicated processing between sleep cycles, not just flashing an LED, but depending on how often and for how long it wakes up, this is what is possible.

You’ll also need to consider that an 18650 battery has a charge life of around 1 year, meaning that it slowly loses its charge over about a year to a year and a half. So your battery is actually losing its charge faster than the Arduino is using the power. If you’re going to be building really long term projects then you’ll probably want to use non-rechargeable batteries as these typically have a longer shelf life. Non-rechargeable lithium batteries generally have a shelf life of around 10-12 years.

For most projects, 8 years is more than enough and your components will likely pack up before the battery is empty. But why stop there? Let’s see if there is any other way we can further improve battery life.

Remove The Onboard Voltage Regulator

The next thing I’m going to try is to remove the voltage regulator. The 3.3V regulators which are typically used on these boards are not very efficient at very low currents, you usually only get around 10-20% efficiency on the low end of thecurve. Replacing the regulator with a linear regulator, such as an MCP1700 will dramatically improve the battery life of your Arduino as well. This is a bit more complicated to do, you’ll need a steady hand and some patience to remove the surface mount voltage regulator from the board and replace it with a new one.

The other option is to remove the voltage regulator altogether. The ATmega328P chip can actually support input voltage levels between 2.7V and 5.5V, however the voltage on the IO pins will vary with the input voltage as well. This may not be a problem if your IO devices can handle the fluctuating voltages, as is often the case with LEDs, pushbuttons and relatively simple OLED displays. We’re going to try this method and see if the Arduino will still run and flash the onboard LED while using less power during sleep.

In order to remove the voltage regulator, I also just used some wire cutters and pulled the regulator off of the PCB.

Removing The Voltage Regulator From An Arduino Pro Mini
Voltage Regulator Removed From Arduino Pro Mini

You’ll also need to make a slight modification on your breadboard. With the voltage regulator removed, you’ll now need to power your board by connecting the 18650 battery to the GND and VCC pins. Connecting the battery to the GND and RAW pins will do nothing.

With the multimeter in milliamps, it doesn’t even register the current draw, but the LED is flashing, so the Arduino is still working.

Arduino Pro Mini Without A Voltage Regulator In Milliamps

Let’s try switch it to microamps.

With the voltage regulator removed, our board is now drawing 5 microamps in sleep mode.

At 5 microamps we’re now up to 35,000 days on a single 4200mAh 18650 battery. This is also now pretty close to what the ATmega datasheet claims for power down sleep mode, so it’s unlikely that we’ll be able to reduce this much further.

You’ll notice a brief spike in the current reading when the LED flashes as the Arduino wakes up and supplies power to the LED.

Current Spike When Arduino Wakes Up And Powers LED

So we now have an Arduino which will theoretically run for 96 years on a single 18650 battery. That’s way better than I thought we’d be able to do!

Let me know in the comments section what low power projects you’ve built using an Arduino and how long your batteries typically last.

Sustainable Home Perks to Use on Your Own House

With environmental consciousness rising globally, many homeowners are starting to recognize the importance of building a sustainable home. Even the Hollywood stars are seeing the impact of their lavish lifestyles and realizing how they can sometimes be unsustainable. While some are putting effort into creating energy-neutral homes, others are becoming green activists. While us, regular folks, may not change the homes we live in entirely, we may improve our ecological footprint by borrowing some ideas from sustainable homes. And the best part – most of these ideas involve DIY in one way or another.

Food

The first thing that comes to mind is food. Organic, locally grown food is your aim. Every patch of land around your home can be used to grow your own food. Even the inside of your home can serve this purpose. While you may not be able to make this the only source of your food, you can reduce your costs a lot. Investing in a greenhouse will provide you with vegetables throughout the year. More ambitious people can consider building a DIY fishpond or even growing a couple of chickens. It doesn’t take that much work. Of course, these are the options for those that have the space for this.

Sustainable Home Perks

Energy

First, keep the energy and heat lost that you already spend to the lowest. This is achieved by insulation, responsible consumption and eco-friendly appliances. These are the things that every sustainable household has. The next steps are the solar panels and wind turbines. Needless to say, investing in these energy sources pays off in many ways. A lot of people choose to install these systems themselves, especially when it comes to home insulation. Making and installing your own home insulation can save you a lot of money, and the best part is that it can be done in an eco-friendly way by using cellulose fiber.

Solar power

One of the cleanest, greenest, and most sustainable ways to power your home is by relying on solar energy. The best place to start would be to learn more about your home’s energy efficiency. Next, you want to assess your home’s solar potential and estimate how much solar electricity your home will need. After that, you can proceed to obtain bids from solar installers. In order for your home solar power system to perform at an optimal level, you’ll also need to invest in high-quality components such as a high-powered solar inverter while keeping in mind the size, capacity, input voltage, and the type of inverter. Installing a home solar power system can also earn you rebates and tax credits, not to mention the giant favor you’ll be doing to Mother Nature by switching to renewable energy sources.

Solar Power

Water

Water is recycled and harvested from the rain. The water that you use for showering and washing your clothes and dishes is cleared and used to water the plants in your greenhouse. A rainwater harvesting system can provide you with the majority of the water you need. This will cut down the yearly bills for water significantly. For this system to work, you need to make sure you have all the filters needed to avoid polluting the greenhouse with cleaning products you use. Perhaps you don’t have a garden to water or but you can build the system that will reuse that water for flushing. You can even build it yourself.

Comfort

Some people have prejudice when it comes to sustainable living. Regardless of their thinking, it doesn’t have to be basic and cave-like. All the perks of modern life are still there for you to use. You use energy and water in a smart way and get hold of it in a way that doesn’t involve paying for it. This is true for fully sustainable households. Yours doesn’t have to be that way, but it will definitely benefit from some of these things.

Living free from bills, costs and credit rates in your own solar home is a dream come true for many people. Some of them even managed to pull this off and now they live fully sustainable lives. However, this kind of life means changing all your habits entirely. For the time being, using the experience of sustainable living to save some money and improve your home will be enough.

Sustainable Home Comfort

How Long Can An Arduino Run On Batteries? I Tested 6 Of The Most Common Boards

I recently built a soil moisture monitor, which relies on a 18650 lithium-ion battery to power it. This got me wondering which Arduino would be best to use for a battery-based project and what can be done to improve the battery life. So, in this test, we’re going to be looking at the power consumption of a number of different Arduino boards with the aim being to try and power them for as long as possible using two 18650 lithium-ion batteries.

Here’s a video of the test, read on for the test write-up:

Setting Up The Test Rig

Let’s get started by showing you what I’m going to be using for the test and how I’m going to be testing each Arduino using the batteries.

These 18650 batteries are 3.7 voltage each and come in a range of capacities from around 1800 to 4500mAh. The ones used for this test are on the higher end, at 4200mAh, meaning that they can supply 4.2mA for 1000 hours or 420mA for ten hours or any combination of current and time for which the product is 4200.

Two 18650 Lithium Ion Batteries

Most Arduino boards require a minimum input voltage of around 6V, so we’ll be powering each Arduino using two batteries connected in series, with an input voltage of 7.4V to power these boards. I’ve also included a 3.3V Pro Mini, which is able to run on a single battery as a comparison.

4000mAh 18650 Lithium Ion Batteries – Buy Here

We’re going to be testing the power consumption of 6 different Arduino boards:

Arduino Power Consumption On 6 Boards

I’m going to be loading a basic sketch onto each Arduino which has has an 8 second delay and then flashes the onboard LED for 100milliseconds just to tell us that the sketch running and this will just loop repeatedly.

Arduino Power Consumption Sketch - Delay

The Atmega chips on these boards support a number of different sleep modes that turn off any unused peripherals in order to conserve power when the Arduino is running on batteries.

Atmega Chip Sleep Mode

I’m not going to go into too much detail on how this works, but we’ll be using a low power library that enables you to put the Arduino to sleep for a certain amount of time or until an interrupt is triggered.

So, I’ll include two tests for each board, one without sleep mode and one in which the Arduino is put to sleep for the 8 seconds between flashes instead of running a delay. I’ll discuss this option a bit later when we look at the difference in power consumption.

Arduino Power Consumption Sketch - Low Power Mode

I’ve connected the two batteries in series and then connected them to my multimeter to measure the current draw. The multimeter is going to be showing the current drawn in milliamps.

Arduino Power Consumption Test Rig

Fluke 17B+ Multimeter – Buy Here

Testing The Arduino’s Current Draw

Now that the test rig and sketches are ready, let’s start testing the Arduinos.

We’ll start off with the Arduino Uno, since it’s one of the most common boards available. This board is designed to be robust and easy to use rather than power efficient or compact, so I doubt it’s going to do very well in the power test, but let’s try it out as a starting point.

Arduino Uno Normal Mode

In each test, I’ll allow the current to stabilise for a bit and then record the average current drawn during the delay time. We’ll ignore the peak current drawn while the led flashes as this only happens for 100 milliseconds every 8 seconds, which is only around 1% of the time.

On the Uno in normal mode, we get a current draw of 54.4mA, which means it would run for about 77 hours or three days on the two 18650 batteries.

Now let’s load the sleep sketch and see if there is any difference.

Arduino Uno Low Power Mode

If you watch the video, you’ll notice the current spike briefly when the LED flashes and then return to the low power mode current draw.

So if we use the sleep mode between flashes, the current consumption goes down to 38.2mA. So we expect it to be able to run for around 110 hours or 5 days.

Now let’s try an Arduino Mega. We’d expect the Mega to be the worst performer as it’s the largest board, has the most IO and the most complex chip on it.

Arduino Mega Normal Mode

As expected, this board draws a bit more power than the Uno, it draws around 77.7mA, so it would only last for 54 hours or 2 days.

Now let’s look at the Mega in low power mode.

Arduino Mega Low Power Mode

So in low power mode, an Arduino Mega draws around 31.7mA and would run for about 132 hours or 6 days.

Next we have a Nano. I’d expect the Nano to be the most efficient board so far as it’s designed for smaller, more portable projects and is a lot more compact than the Uno or Mega.

Arduino-Nano-Normal-Mode

The Nano seems to be a lot more efficient than the Uno or the Mega. The Nano draws 25.5 milliamps, so we’d expect it to run for 165 hours or 7 days.

Now let’s try the Nano in low power mode.

Arduino Nano Low Power Mode

Using the sleep mode sketch, the Nano draws only 6.4 milliamps, so it would run for around 656 hours or 27 days. So we’re almost at a month. Let’s see if the Pro Micro can get to a month.

Next let’s try a Pro Micro in normal mode.

Arduino Pro Micro Normal Mode

The Pro Micro actually did a lot worse than the Nano, which I didn’t expect. I thought that it would be similar, if not better, than the Nano. It drew around 43.4mA, so it would last for only 97 hours or 4 days.

Now let’s try low power mode.

Arduino Pro Micro Low Power Mode

In low power mode, the Pro Micro drew 9.25mA, so it’s much better than the Mega and Uno but the Nano is still the most efficient.

Next, we’re going to try powering a Pro Mini. This is a very similar form factor to the Pro Micro but it has a different chip and the onboard USB host has been removed, so you need an external programmer to connect it to your computer.

First we’ll try the 5V Pro Mini in normal mode.

Arduino Pro Mini 5V Normal Mode

The Pro Mini uses just 19.1mA, which is a little less than the Nano, and means that it will last around 220 hours or 9 days.

Now let’s try the 5V Pro Mini in low power mode.

If we put the Pro Mini to sleep between flashes, it uses just 3.2mA, which means that it will run for 1313 hours or 55 days, we’re now getting closer to 2 months.

Lastly, let’s try the 3.3V Arduino Pro Mini and see if it does better than the 5V version. We’ll still be powering the 3.3V Pro Mini using the two 18650 batteries for this first test.

Arduino Pro Mini 3.3V Normal Mode

The 3.3V Pro Mini draws substantially less current than the 5V version, just 5.5mA, which is even better than the Nano in low power mode. So it will run for a month in normal mode, let’s see how long it will run in low power mode.

Arduino Pro Mini 3.3V Low Power Mode

The 3.3V Pro Mini uses just 1.6mA in low power mode, so it will run for around 109 days, which is a bit over 3 months.

Let’s see if that changes if we power it with just one battery. Remember that if we’re halving the input voltage, we’d expect the current to increase to supply the same amount of power to the Arduino.

Arduino Pro Mini 3.3V at 3.7V Low Power Mode

Strangely, there was actually a slight decrease in input current. This is probably due to the onboard voltage regulator being more efficient at voltages closer to the operating voltage. So you’ll actually get better battery life by powering a 3.3V pro mini with a single 18650 battery. You’ll get almost 4 months.

The Results, How Long Can Each Arduino Run On Batteries?

Now that we’ve completed the test for each board, lets look at how long each Arduino can run on batteries.

Arduino Boards Current Draw Comparison Table - Arduino Running on Batteries

The most power-efficient board in both modes is the 3.3V Pro Mini, lasting almost 4 months on a single 18650 battery.

There’s also a significant decrease in power consumption when using sleep mode, so you should definitely consider using it if you’re designing battery-based projects.

Now you obviously can’t have the Arduino sleeping the whole time, it’s actually expected to do something if it’s connected up to a project. But, on most projects where you’d be looking to power the Arduino using batteries, you’re only using the Arduino for a fraction of the time that the system is powered up.

Soil Moisture Monitor

For example, if we look at a soil moisture monitor, the soil doesn’t suddenly dry up in a couple of milliseconds, and even watering the plant takes a minute or two for the water to be evenly soaked up into all of the soil. Also, your plant isn’t going to die if its roots are dry for 2 seconds. So, you really only need to take soil moisture readings in minute intervals rather than every couple of hundred milliseconds. You could, therefore, have your Arudino sleep for a minute, then take the measurements over a few hundred milliseconds and then sleep again, so your Arduino would be sleeping for most of it’s “on” time.

Weather Station

Similarly, for weather stations, even rapid outdoor temperature changes only change over a number of minutes. So, you can set your Arduino to wake up every 5 minutes and take a new temperature and humidity measurements, rather than take measurements on every loop cycle.

It’s also important to note that there’s a difference between putting the Arduino to sleep and simply putting delays into your code. Delays don’t stop the Arduino from processing operations, they just tell the Arduino not to proceed until an amount of time has passed.

You can think of the two like this; putting a delay into your code is like having a child asking “are we there yet”, “are we there yet”, “are we there yet” over and over until the answer is yes and it’s able to proceed. Putting the Arduino to sleep is like setting an alarm and allowing the Arduino to do nothing until the alarm rings and wakes it up again. You’ll get much longer battery life by allowing your Arduino to do nothing between readings rather than constantly checking if the amount of time has elapsed.

Look out for the next test, in which I’m going to try and further reduce the power consumption of a 3.3V Arduino Pro Mini and see if we can get it to run for over a year on a single 18650 battery.

Let me know in the comments section what battery based Arduino projects you’ve built.