Home Blog Page 14

Adding AI Vision To A Robot Car Using A Huskylens

Today I’m going to be looking at adding AI line and object tracking to my previously built obstacle avoiding robot using a Huskylens.

A Huskylens is a standalone sensor with a couple of preconfigured recognition algorithms that allow you to easily add AI powered machine vision to your Raspberry Pi and Arduino projects.

Gravity Huskylens AI Vision Sensor

It’s got built in object tracking, face recognition, object recognition, line tracking, colour detection and tag recognition and the best part is that it doesn’t require any internet connection to run. All of the processing is done locally on the Huskylens.

Here’s a video of the modifications done to the robot car as well as the car following lines and tracking objects, read on for the write-up and code:

What You Need To Build Your Own AI Powered Robot Car

Unpacking The Huskylens

This Huskylens was sent to me by DF Robot to try out and share with you.

The Huskylens comes well packaged in a black bubble wrap sleeve within a two compartment box. Measuring just 52mm x 44.5mm, it’s smaller than an Arduino Uno or Raspberry Pi, it’s about the same size as a Micro:bit.

Huskylens Unboxed

The device has two primary inputs. A multifunction menu selector and then a learn button, which allows you to select and learn new objects, faces and tags directly on the built-in 2-inch display. So you don’t need a PC with you to change modes or select different tracking objects.

An OV2640 2.0 Megapixel Camera on the front is the Husklen’s “eye”.

Huskylens Camera

It uses a Kendryte K210 AI chip to run a neural network, which results in pretty impressively fast learning and recognition. Even with relatively fast-moving objects.

Kendryte K210 Neural Network Chip

In the second compartment in the box you’ve got a mounting bracket, some screws and the cable to connect it to a microcontroller.

One thing that’s worth noting is that the included cable has female Dupont/jumper connectors on it. This makes it directly usable with a Raspberry Pi, which has male GPIO pins, but you’ll need to make up an adaptor to use it with an Arduino Uno or LattePanda which typically have female pins.

Screws and Cables Supplied With The Huskylens

The Huskylens runs on 3.3-5V and consumes around 320mA at 3.3V or 230mA at 5V, so its perfect for battery powered projects as well.

Adding The Huskylens To The Robot Car

I’m going to be installing the Huskylens in place of the servo and ultrasonic sensor on the robot car which I built previously. Visit the previous build guide for the 3D print files for the car as well as assembly instructions, obviously leaving out the servo and ultrasonic sensor.

Ultrasonic Sensor On Robot

The car uses an Arduino Uno and a dual L293d motor driver shield to drive four wheels through some geared motors.

L293D Motor Driver Chips

I’ll be mounting the Huskylens onto the bracket which is supplied with it. The bracket is somewhat universal in that it’s got a mounting pattern which could be fixed with a single screw, two screws or mounted onto a servo arm.

Huskylens on Bracket

I’ve 3D printed a small adaptor block to fit into the servo holder on the robot car to screw the bracket into. I just glued this bracket into place using a glue gun.

Adaptor Block For Mounting Bracket

I secured the bracket using a single M3x8mm screw through the centre hole.

Secure Bracket In Place

The Huskylens can communicate using I2C or SPI communication, I’m going to be using I2C because these pins are still available on the motor driver shield. Just like any other I2C device, there are four connections to be made, two for power and two for communication.

I used the GND and 5V pins from one of the servo outputs and then connected the SDA and SCL wires to A4 and A5 respectively.

Huskylens Installed On Robot Car

Now that it’s installed, let’s power it up and have a look at the line and object tracking functions.

Experimenting With Line Tracking

We’ll start by powering up the Huskylens and switching it to line tracking mode.

I’ve drawn a black arrow on a piece of paper, so let’s see how well it is able to pick it up.

We first need to point the crosshair in the centre at the line and then press the learn button to tell the Huskylens that this is the type of line it needs to follow.

Align The Line With Crosshair

You’ll then see it recognise the line and overlay a blue arrow which follows the line around on the display.

Huskylens Line Tracking

The Huskylens is actually impressively fast when tracking a line and picking up direction changes, even when the line is removed and then brought back into the field of view.

I adapted the code from the obstacle avoiding robot to use the data from the Huskylens to follow a black line drawn on the floor using the Huskylens Line Tracking example by Angelo Qiao. There are some functions that have been carried over from the obstacle avoiding robot that are not used in this code but might be useful for future adaptations.

//The DIY Life
//Michael Klements
//16/04/2021
//Huskylens Line Tracking Robot
//Adapted from Huskylens Line Tracking example by By [Angelo qiao](Angelo.qiao@dfrobot.com)

#include "HUSKYLENS.h"                            //Import the required libraries
#include "SoftwareSerial.h"
#include "PIDLoop.h"
#include <AFMotor.h>

AF_DCMotor rightBack(1);                          //Create an object to control each motor
AF_DCMotor rightFront(2);
AF_DCMotor leftFront(3);
AF_DCMotor leftBack(4);

byte motorSpeed = 60;                             //The maximum motor speed
int motorOffset = 15;                             //Factor to account for one side being more powerful
int turnSpeed = 50;                               //Amount to add to motor speed when turning
int leftSpeed = 0;                                //Variables to keep current left and right motor speeds
int rightSpeed = 0;

PIDLoop headingLoop(120, 0, 0, false);            //Set up PID control for the heading, only P used for now
HUSKYLENS huskylens;                              //Create a Huskeylens object
int ID1 = 1;                                      //We're tracking recognised object 1

void printResult(HUSKYLENSResult result);

void setup() 
{
  Serial.begin(115200);                                         //Start serial communication
  Wire.begin();                                                 //Begin communication with the Huskeylens
  while (!huskylens.begin(Wire))
  {
      Serial.println(F("Begin failed!"));
      Serial.println(F("1.Please recheck the \"Protocol Type\" in HUSKYLENS (General Settings>>Protol Type>>I2C)"));
      Serial.println(F("2.Please recheck the connection."));
      delay(100);
  }
  huskylens.writeAlgorithm(ALGORITHM_LINE_TRACKING);            //Switch the algorithm to line tracking.
  rightBack.setSpeed(0);                                        //Set the motors to the motor speed, initially all 0
  rightFront.setSpeed(0);
  leftFront.setSpeed(0);
  leftBack.setSpeed(0);
  moveForward();                                                //Start the motors
  accelerate();                                                 //Accelerate to the set motor speed
}

void loop() 
{
  int32_t error;
  if (!huskylens.request(ID1))                                  //If a connection is not established
  {
    Serial.println(F("Check connection to Huskeylens"));
    leftSpeed = 0; 
    rightSpeed = 0;
  }
  else if(!huskylens.isLearned())                               //If an object has not been learned
  {
    Serial.println(F("No object has been learned"));
    leftSpeed = 0; 
    rightSpeed = 0;
  }
  else if(!huskylens.available())                               //If there is no arrow being shown on the screen yet
    Serial.println(F("No arrow on the screen yet"));
  else                                                          //Once a line is detected and an arrow shown
  {
    HUSKYLENSResult result = huskylens.read();                  //Read and display the result
    printResult(result);
    
    error = (int32_t)result.xTarget - (int32_t)160;             //Calculate the tracking error
    headingLoop.update(error);                                  //Perform PID control on the error
       
    leftSpeed = headingLoop.m_command;                          //Get the left side speed change
    rightSpeed = -headingLoop.m_command;                        //Get the right side speed change

    leftSpeed += motorSpeed;                                    //Calculate the total left side speed
    rightSpeed += (motorSpeed-motorOffset);                     //Calculate the total right side speed
  }
  Serial.println(String()+leftSpeed+","+rightSpeed);
  leftFront.setSpeed(leftSpeed);                                //Set the new motor speeds
  leftBack.setSpeed(leftSpeed); 
  rightFront.setSpeed(rightSpeed);
  rightBack.setSpeed(rightSpeed);
}

void accelerate()                                 //Function to accelerate the motors from 0 to full speed
{
  for (int i=0; i<motorSpeed; i++)                //Loop from 0 to full speed
  {
    rightBack.setSpeed(i);                        //Set the motors to the current loop speed
    rightFront.setSpeed(i);
    leftFront.setSpeed(i+motorOffset);
    leftBack.setSpeed(i+motorOffset);
    delay(10);
  }
}

void decelerate()                                 //Function to decelerate the motors from full speed to zero
{
  for (int i=motorSpeed; i!=0; i--)               //Loop from full speed to 0
  {
    rightBack.setSpeed(i);                        //Set the motors to the current loop speed
    rightFront.setSpeed(i);
    leftFront.setSpeed(i+motorOffset);
    leftBack.setSpeed(i+motorOffset); 
    delay(10);
  }
}

void moveForward()                                //Set all motors to run forward
{
  rightBack.run(FORWARD);
  rightFront.run(FORWARD);
  leftFront.run(FORWARD);
  leftBack.run(FORWARD);
}

void stopMove()                                   //Set all motors to stop
{
  rightBack.run(RELEASE);
  rightFront.run(RELEASE);
  leftFront.run(RELEASE);
  leftBack.run(RELEASE);
}

void turnLeft(int duration)                                 //Set motors to turn left for the specified duration then continue
{
  rightBack.setSpeed(motorSpeed+turnSpeed);                 //Set the motors to the motor speed
  rightFront.setSpeed(motorSpeed+turnSpeed);
  leftFront.setSpeed(motorSpeed+motorOffset+turnSpeed);
  leftBack.setSpeed(motorSpeed+motorOffset+turnSpeed);
  rightBack.run(FORWARD);
  rightFront.run(FORWARD);
  leftFront.run(BACKWARD);
  leftBack.run(BACKWARD);
  delay(duration);
  rightBack.setSpeed(motorSpeed);                           //Set the motors to the motor speed
  rightFront.setSpeed(motorSpeed);
  leftFront.setSpeed(motorSpeed+motorOffset);
  leftBack.setSpeed(motorSpeed+motorOffset);
  moveForward();
}

void turnRight(int duration)                                //Set motors to turn right for the specified duration then continue
{
  rightBack.setSpeed(motorSpeed+turnSpeed);                 //Set the motors to the motor speed
  rightFront.setSpeed(motorSpeed+turnSpeed);
  leftFront.setSpeed(motorSpeed+motorOffset+turnSpeed);
  leftBack.setSpeed(motorSpeed+motorOffset+turnSpeed);
  rightBack.run(BACKWARD);
  rightFront.run(BACKWARD);
  leftFront.run(FORWARD);
  leftBack.run(FORWARD);
  delay(duration);
  rightBack.setSpeed(motorSpeed);                           //Set the motors to the motor speed
  rightFront.setSpeed(motorSpeed);
  leftFront.setSpeed(motorSpeed+motorOffset);
  leftBack.setSpeed(motorSpeed+motorOffset);
  moveForward();
}

void printResult(HUSKYLENSResult result)                    //Display the results on the serial monitor
{
    if (result.command == COMMAND_RETURN_BLOCK)
    {
        Serial.println(String()+F("Block:xCenter=")+result.xCenter+F(",yCenter=")+result.yCenter+F(",width=")+result.width+F(",height=")+result.height+F(",ID=")+result.ID);
    }
    else if (result.command == COMMAND_RETURN_ARROW)
    {
        Serial.println(String()+F("Arrow:xOrigin=")+result.xOrigin+F(",yOrigin=")+result.yOrigin+F(",xTarget=")+result.xTarget+F(",yTarget=")+result.yTarget+F(",ID=")+result.ID);
    }
    else
    {
        Serial.println("Object unknown!");
    }
}

Let’s upload the code and see how well it works.

I’ll start by pointing the Huskylens on the front of the car downward so that it’s looking at the ground just ahead of the car.

Display Pointed Towards The Ground

I’ve drawn lines on the floor, trying to keep near the grout lines in the tiles so that it hopefully doesn’t get confused. I’ve also put some masking tape on the lines leading away from the turns so that it follows the turns and ignores the grout lines leading on from the turn.

Here are some images of the car following the line. It’s best to watch the video at the begining of the guide to see the line tracking feature running.

Robot Car Turning A Corner
Robot Car Following Line Using Huskylens
Car Following Line

Overall, the line tracking feature worked pretty well. The Huskylens is responsive enough that the car starts making adjustments to its direction as soon as the line starts drifting off centre or changes direction, so it’s able to track the line with a bit of speed as well. It only veered off course a couple of times during testing and these all occurred when the wheels slipped on the smooth tiled floor.

The limitation to the speed is probably more to do with the actual motors than with the Huskylens. These geared motors are really cheap and low quality, so the driver has a hard time controlling the speed accurately.

Experimenting With Object Tracking

Now that we’ve tried out line tracking, let’s try object tracking.

We use the selector to change over to Object Tracking mode. In this mode, the crosshair on the display is replaced by a yellow box. To start, you need to align the object you’re going to be tracking with this box and then press the learn button.

I’m going to try and use this Raspberry Pi logo cutout on a clear piece of acrylic as the object to track.

Aligning Tracking Object On Display

Once the object is learnt, it’ll receive an ID tag and it’ll then be followed around the display surrounded by the box. It also gets bigger or smaller if you move it closer and further away from the camera.

Learning The Object To Be Tracked

We’re going to use this box to control the car as well. When the box moves to the left or right of the display then we’ll move the car left or right and when it gets further away, the box gets smaller, and we’ll then move the car forward to follow the object.

I’ve adapted my old robot car code again, this time to follow the box around the screen.

//The DIY Life
//Michael Klements
//16/04/2021
//HuskyLens Object Tracking Robot

#include "HUSKYLENS.h"                            //Import the required libraries
#include "SoftwareSerial.h"
#include <AFMotor.h>

AF_DCMotor rightBack(1);                          //Create an object to control each motor
AF_DCMotor rightFront(2);
AF_DCMotor leftFront(3);
AF_DCMotor leftBack(4);

byte maxMotorSpeed = 50;                             //The normal motor speed
int motorOffset = 25;                             //Factor to account for one side being more powerful
int objectWidth = 50;
int turnGain = 12;
int offCentre = 20;
int distGain = 6;

int leftLimit = 160-offCentre;
int rightLimit = 160+offCentre;

int leftSp = 0;
int rightSp = 0;

bool isTurning = false;                           //Track when turning left and right
bool isTurningLeft = true;

HUSKYLENS huskylens;                              //Create a new Huskeylens object
int ID1 = 1;

void printResult(HUSKYLENSResult result);

void setup() 
{
  Serial.begin(115200);                                       //Start serial communication
  Wire.begin();                                               //Connect to Huskylens
  while (!huskylens.begin(Wire))
  {
      Serial.println(F("Begin failed!"));
      Serial.println(F("1.Please recheck the \"Protocol Type\" in HUSKYLENS (General Settings>>Protol Type>>I2C)"));
      Serial.println(F("2.Please recheck the connection."));
      delay(100);
  }
  huskylens.writeAlgorithm(ALGORITHM_OBJECT_TRACKING);        //Switch the algorithm to object tracking.
  rightBack.setSpeed(0);                                      //Set the motors to the motor speed
  rightFront.setSpeed(0);
  leftFront.setSpeed(0);
  leftBack.setSpeed(0);
  moveForward();                                              //Set motors to forward direction
}

void loop() 
{
  int32_t error;
  if (!huskylens.request())                                                 //If connection to Huskylens isn't available
    Serial.println(F("Fail to request objects from HUSKYLENS!"));
  else if(!huskylens.isLearned())                                           //If an object hasn't yet been learned
  {
    Serial.println(F("Object not learned!")); 
    setMotorSpeed (0,0);
  }
  else if(!huskylens.available())                                           //If the learned object isn't visible anymore
  {
    Serial.println(F("Object disappeared!"));
    setMotorSpeed (0,0);
  }
  else                                                                      //If object is being tracked
  {
     HUSKYLENSResult result = huskylens.read();                             //Get the results of the object being tracked
     if(result.xCenter < leftLimit)
     {
        leftSp = -turnGain*(leftLimit-result.xCenter);
        rightSp = turnGain*(leftLimit-result.xCenter);
     }
     else if(result.xCenter > rightLimit)
     {
        leftSp = turnGain*(result.xCenter-rightLimit);
        rightSp = -turnGain*(result.xCenter-rightLimit);
     }
     if(result.width < objectWidth)
     {
        leftSp = leftSp+(distGain*(objectWidth-result.width));
        rightSp = rightSp+(distGain*(objectWidth-result.width));
     }
     if(leftSp > maxMotorSpeed)
        leftSp = maxMotorSpeed;
     else if(leftSp < 0)
        leftSp = 0;
     if(rightSp > maxMotorSpeed)
        rightSp = maxMotorSpeed;
     else if(rightSp < 0)
        rightSp = 0;
     setMotorSpeed (leftSp, rightSp);
     leftSp = 0;
     rightSp = 0;
     printResult(result);
  }
}

void moveForward()                                //Set all motors to run forward
{
  rightBack.run(FORWARD);
  rightFront.run(FORWARD);
  leftFront.run(FORWARD);
  leftBack.run(FORWARD);
}

void stopMove()                                   //Set all motors to stop
{
  rightBack.run(RELEASE);
  rightFront.run(RELEASE);
  leftFront.run(RELEASE);
  leftBack.run(RELEASE);
}

void setMotorSpeed (int leftTempSp, int rightTempSp)
{
  rightBack.setSpeed(rightTempSp);                              //Set the motors to the motor speed
  rightFront.setSpeed(rightTempSp);
  leftFront.setSpeed(leftTempSp+motorOffset);
  leftBack.setSpeed(leftTempSp+motorOffset);
}

void printResult(HUSKYLENSResult result)                        //Display the results on the serial monitor
{
    if (result.command == COMMAND_RETURN_BLOCK)
    {
        Serial.println(String()+F("Block:xCenter=")+result.xCenter+F(",yCenter=")+result.yCenter+F(",width=")+result.width+F(",height=")+result.height+F(",ID=")+result.ID);
    }
    else if (result.command == COMMAND_RETURN_ARROW)
    {
        Serial.println(String()+F("Arrow:xOrigin=")+result.xOrigin+F(",yOrigin=")+result.yOrigin+F(",xTarget=")+result.xTarget+F(",yTarget=")+result.yTarget+F(",ID=")+result.ID);
    }
    else
    {
        Serial.println("Object unknown!");
    }
}

I uploaded the code to the robot and then tried the tracking out. This example took a bit more time to set up and get to a point where it was working reasonably reliably. Most of the time was spent adjusting the gains on the turning and distance tracking as it seemed to either not respond at all or respond too aggressively.

Robot Car Tracking Object

I eventually got it working reasonably well. The robot followed the Raspberry Pi logo around, moving forward when it was moved away and turning left and right to bring it back into the centre of the display.

You can watch the object tracking in the video at the beginning of this project as well.

Robot Car Following Object Being Tracked Using Huskylens

I probably need to spend a bit more time adjusting the gains, but you get a good idea of how the object tracking works.

I’d also like to try the object tracking mode on a two axis servo mount, as I think the results would be a bit more reliable and consistent than with the car.

Let me know what you think of the Huskylens and my robot car in the comments section below.

Build & Run Your Own Bitcoin Node On A Raspberry Pi

In this project, we’re going to be looking at how to run your own personal Bitcoin node on a Raspberry Pi. By running your own node, you can skip using a third party and directly make transactions on the Bitcoin network, without any additional fees.

If you don’t know how Bitcoin works, it’s essentially a network of thousands of nodes like the one we’re going to be building in this video. Each one has its own full copy of the Bitcoin blockchain, which is a record of every transaction which has ever occurred on the network. These nodes then work together to verify the transactions and maintain the blockchain. So you’ll essentially have a record of every Bitcoin transaction stored on your node and you’ll be helping to keep the Bitcoin network decentralized.

This is different to mining Bitcoin, which is a really bad idea on a Raspberry Pi as it would take you a couple of hundred years to mine a single dollar. Unlike Bitcoin mining, running a node doesn’t require any expensive hardware and can be done on a $35 Raspberry Pi and an external hard drive.

We’re going to be running a software package called Umbrel on our Bitcoin node. It’s really easy to use and their website literally guides you through the installation process step by step. The best part is that it’s free and all of its source code is available on GitHub.

Umbrel Software

Here’s my video of the build, read on as I take you through the project step by step so that you can build your own node:

What You Need To Build Your Own Bitcoin Node

  • Raspberry Pi 4B (8GB used) – Buy Here
  • 32GB MicroSD Card (16GB Min) – Buy Here
  • Low Profile Ice Tower (Black version used) – Buy Here
  • 1TB M.2 NVME SSD – Buy Here
  • External NVME Case (Not the one I used, but similar) – Buy Here
  • 1TB External SSD (Alternative to above) – Buy Here
  • Raspberry Pi Power Supply – Buy Here
  • Ethernet Cable – Buy Here
  • 4 x 3mm Yellow LEDs – Buy Here
  • 4 x 150ohm Resistors – Buy Here
  • M3 Screws & Nuts – Buy Here

Banggood Alternatives

In addition to the above, you’ll need to 3D print some parts for your case. I used a Creality Ender 3 V2 for this project. I used a K40 Laser Cutter to engrave and cut out the case lid.

The above parts are affiliate links. By purchasing products through the above links, you’ll be helping to support this blog, with no additional cost to you.

Designing & Making The Case

I started out by designing a case for the Bitcoin Node using Fusion 360. I designed the case to house the Raspberry Pi with the low profile Ice Tower installed and the SSD alongside it. I chose to used an M.2 NVME drive because it’s a bit more compact than a typical 2.5″ external one. SSDs produce quite a bit of heat, so I added a second fan onto the front of the case to push air into the case, which will then be exhausted from the vents on the side.

Designing A Case in Fusion 360

Print your own case – get the 3D print and laser cutting files

Note: The drive enclosure that I used is not all that common. I have provided an alternate case design for the linked Sabrent drive. This cutout is large enough to insert the entire Sabrent enclosure into the case (with the port sticking out a little).

Lastly, I designed a clear acrylic cover which I’m going to engrave a logo onto. I’m also going to install some yellow LEDs in the corners in to give the logo a gold glow while it’s running.

I enjoy designing and building my own cases for my Raspberry Pis, have a look at this mini desktop case I built to make my Pi look like a mini desktop computer.

3D Printing The Case

I 3D printed the case on my Ender 3, along with 4 legs and 4 corner clamps for the cover. The corner clamps are mainly there to stop the light from the LEDs from shining up and out of the case and keep it contained within the acrylic.

I printed the case in black PLA using an infill of 15%. The legs and corner clamps were printed solid using the same filament.

3D Printed Bitcoin Full Node Case

I then laser engraved and cut out the lid for the case from a sheet of 2mm clear acrylic. I designed the engraving and the cutout in Inkscape to the same dimensions as the sketch used in Fusion 360.

Laser Engraving The Case Lid

I engraved a mirror image of a Bitcoin logo into the back of the lid so that the top surface is still smooth, so it won’t trap dust and can easily be cleaned.

Peeling The Film Off The Cover of the Bitcoin Node

Assembling The Bitcoin Node

Now that we’ve got all of the components made up, let’s start assembling it.

First I’m going to install the legs, which are just held in place with an M3x8mm screw in each. In hindsight, it probably would have been easier to just glue these into place.

Screwing on the Legs

Next, let’s open up our Raspberry Pi. I used an 8GB version of the Raspberry Pi 4B, but you should be able to use the 2GB and 4GB versions as well.

Before I install the Pi in the case, I’m going to flash the SD card. I’ll do this using the method outlined on the Umbrel page. This involves downloading Balena Etcher and the Umbrel image and then flashing the image to the SD card.

Flashing Umbrel with Balena Etcher

Now that this is done, I’m going to put the SD card into the Pi and then assemble the Ice Tower as per the instruction booklet which came with it. Don’t add any of the brass standoffs yet, we’re going to use these in the next step.

Adding Legs to Ice Tower

To mount the Pi, we’re going to install one set of brass standoffs which came with the Ice Tower on the bottom of the case and hold the Pi in place with the second set. You’ll probably need to use a wrench or spanner to screw the standoffs into the base, they’ll be too tight to screw in with your fingers.

I missed a step here – I forgot to add the USB power cable through the slot near the USB cutout. You’ll see in the subsequent steps.

Installing Brass Standoffs

Next I’m going to add the cooling pad and install the Ice Tower on the CPU. The Ice Tower is held in place using some M2.5 screws which go into the brass standoffs. These also came with the Ice Tower.

Raspberry Pi Installed

Next, I’m going to install the second fan which came with the Ice Tower onto the front of the case. I pressed some M3 nuts into the pockets on the front and then secured the fan with some M3 screws. The fan should be mounted so that it pushes air into the case, although the airflow direction is not critical – it’ll work either way.

Install Fan onto Front of Case

Once this was done, I connected the wiring for the fans to the Pi’s GPIO pins.

Fan Wiring Connected To GPIO Pins

These just go onto two available 5V and GND pins near the end of the GPIO header.

GPIO-Pinout-Diagram-2

Now that the fans are done, we can install our SSD. As mentioned earlier, I’m using an M.2 NVME drive, so I needed a way to connect the drive to the Raspberry Pi. I bought a low profile USB C enclosure for it and I’m going to just be using the PCB inside it to mount the drive onto. We don’t need the rest of the enclosure for this project, the case will act as the new enclosure and we want to be able to get some airflow over the drive to keep it cool.

Putting SSD into Enclosure

I designed a cut-out in the case to mount the faceplate from the enclosure to hold it all in place.

Installing SSD into Case

It was at this stage that I noticed that I had designed a slot to run the power cable through and had forgotten to put it through the case before installing the Pi. I chose to put in a slot rather than add a large cutout to fit the connector through.

Forgotten Power Cable

So I had to remove the Pi to add the power cable and then re-install it.

Adding Power Cable To Case

I then made up a string of four 3mm yellow LEDs, one for each corner of the case. These are designed to fit into the holes I cut on the cover. I used a 150-ohm 1/4W current limiting resistor on each LED, then connected them in series and added some dupont connectors to the end to plug into the GPIO pins.

Soldering 3mm Yellow LEDs

I glued the LEDs into the cover with some clear epoxy. The top of the LEDs protrude a little from the surface of the cover.

LED String On Cover

I then plugged it in and closed it up using an M3 screw through each of the corner clamps. The corner clamps should align themselves as they go over the top of the protruding LEDs as well.

Screwing Top Cover On

Now that this is all done, the Bitcoin node is complete and ready to be powered up.

Powering Up the Bitcoin Node

Now that the Bitcoin node is assembled, lets plug in our cables and power it up. Umbrel says to allow the node 5 minutes to boot up before trying to access it.

Plugging In Cables

When I switched the node on for the first time, I found that the RGB lighting in the fan on the Ice Tower detracted from the yellow glow of the LEDs.

Top Cover of Bitcoin Node Illuminated, RGB Showing

I decided to replace the fan with another plain black fan which I had from another Ice Tower. You could probably also get away with just removing the fan on the Ice Tower altogether. The fan on the side of the case blows directly onto the heat sink as well.

Removing RGB Fan

This produced a much cleaner look. You can now only see the faint flashing LEDs on the Pi and the SSD under the cover.

Bitcoin Node on Raspberry Pi

Now let’s get back to Umbrel. You don’t need to connect a monitor to it to set up, once it’s booted up then you can access the dashboard by going to umbrel.local on any other computer or mobile device connected to the same network.

If you do plug in a monitor, you’ll be able to see some diagnostic information while it is booting up, but this is not necessary.

When you open up the dashboard you’re presented with a welcome screen and you’re then guided through the setup process.

Umbrella Welcome Screen

You’ll need to type in your name and choose a password. Then you’re asked to write down your seed words as a recovery mechanism if you forget your password. It’s quite important that you do this as there is no “I forgot my password” option when logging in. Lastly, you’ll need to accept a disclaimer.

You’ll then be taken to the main dashboard.

Umbrel Dashboard Running

Your node will begin downloading the Bitcoin blockchain. Depending on how fast or in my case, how slow your internet is, this could take a few hours or even a few days. At the time of making this video, the blockchain is around 327 gigabytes. Your node will also transfer a similar amount of data on a month to month basis, so you need to have a reasonably good internet service to maintain your Bitcoin node.

You’ll still be able to use your node while the blockchain is being downloaded, but you’ll have to wait to unlock the full functionality of your node.

You can also add apps and your wallets to your node to truly customise and get the most use out of it.

Let me know in the comments section if you do land up building your own node and what you think of this one.

Mini Sega Genesis Console Powered By A Raspberry Pi 4 Running RetroPie

In this project, I’m going to show you how I built a Mini Sega Genesis console lookalike, which is powered by Raspberry Pi 4 running RetroPie. The console has wireless controllers and can be used to play a number of arcade, console and classic PC games, all on one device. If you had a Nintendo, Sega and or Atari console back in the day then you’ll definitely want to give this project a try!

Here’s a video of the build and the console running some old games:

RetroPie is free software that runs on a few different devices. One of the best devices in terms of performance is a Raspberry Pi 4, so that’s the board that we’re going to be using for this project. The games being played on RetroPie are generally not very resource-intensive, so you should be fine with using the base model 2GB version. All of my 2gig Pi’s are in my water-cooled Pi cluster at the moment and I’ve got an 8gig Pi free, so I’m going to be using that. The emulation software mainly uses the CPU and GPU on the Pi, so RAM is not all that important.

I also chose to use wireless controllers for my console so that I didn’t have any additional cables protruding from the side of my console. The wireless receivers can be housed within the case, keeping it looking clean.

What You Need For This Project

  • Raspberry Pi 4 2GB – Buy Here
  • Power Adaptor – Buy Here
  • Aluminium Heatsink Set – Buy Here
  • Or Get The CanaKit (Includes Pi, Heatsinks and Power Adaptor) – Buy Here
  • Wireless Gamepad (or two) – Buy Here
  • 32GB MicroSD Card – Buy Here
  • Dcorn Monitor (Or Use Your Television) – Buy Here
Things Needed To Build A RetroPie Console

Keeping Your Pi Cool

To start off, we need to have a look at how to keep our Pi cool within the case. While most old console games are not really that intensive for the Pi to run, it’ll still be producing some heat which we need to remove. For most games, these small aluminium heat sinks will work just fine. You just need to peel off the backing and stick them into place.

Stick Your Heatsinks Onto The Raspberry Pi

We’ll have a look at some other cooling options a bit later when we’re designing the case.

Installing RetroPie

There are two parts to the software side of this project, the first is installing RetroPie, and the second is to add your ROMs. We’ll start by installing RetroPie and then have a look at how to load the ROMs a bit later on. ROMs are essentially images of the video games you’d like to play on your RetroPie.

To install RetroPie, I’m going to be using Raspberry Pi Imager. This utility makes it easy to format the SD card and write the image to the card without having to download any other apps or the operating system image first.

Raspberry Pi Imager

You simply select the operating system that you want to install, select the target drive, which is our SD card and then the utility does everything for you.

RetroPie on Raspberry Pi Imager

Make sure that you select the correct version of RetroPie for your particular Raspberry Pi. There are a couple of other versions for the Pi 2/3 and the Pi 1/Zero.

Once you’ve got your SD card prepared, you can plug it into your Pi. We’ll be loading the ROMs onto the Pi using an FTP client later.

Prepare The SD Card

Designing A Case For The Raspberry Pi

I wanted to make my own 3D printed case for the console, so I decided to design a case for the Raspberry Pi 4 which looks like a mini Sega Genesis console. I had a Sega console myself back in the day, so that was the obvious choice for me. Let me know if you like the case I came up with and what other options you’d like to see and I’ll have a look at putting these together as well.

The full set 3D print files, including all of the below versions of the case, can be downloaded here.

Designing The Sega Genesis Console Case

I designed the case in Fusion 360 and then shelled it out, sized it to fit the Pi and then added some cutouts for the ports. Some people have rerouted ports to the front or back of their cases, I just positioned the Pi sideways so that the primary cables would come out of the back of the console and I’m going to be using wireless controllers, so I don’t need the USB ports to be accessible with the case closed.

Fusion 360 Top Clear To See Pi

I’ve created a couple of variants of the case to suit different uses. One of them has the four USB ports accessible through a cutout in the side if you’d like to use wired controllers rather or if your controller’s receiver doesn’t fit within the allowed space.

Case With USB Port Cutouts

I’ve also created an option with the game slot and vents opened up to allow some of the heat to escape from the case if you’re running more resource intensive games.

Case With Better Ventilation

And lastly, I’ve created one which allows a 40mm fan to be mounted into the case to provide better cooling if your Pi is overheating. The fan is silver in the model, so is a bit more prominent. If you use a black fan and black screws then you’ll hardly notice it on top of the console.

Case With 40mm Fan

You can get the full set of 3D print files, which includes all versions of the case, through this link.

3D Printing The RetroPie Case

With the case design done, we now need to 3D print the components. I used black PLA for mine to keep with the original black console colour.

I printed the base of the case lying flat and the top vertically. This was done to reduce support material for the base and top cover, and also get some good detail on the top cover.

3D Printing The Case Top

I printed the components on a Creality Ender 3 V2 in black PLA with a nozzle temperature of 210°C and bed temperature of 55°C with a 100% infill.

I then cleaned up the support material and rafts by cutting them away with a craft knife.

Removing Print Support Material

Some people like to sand, fill and spray paint their 3D printed components to get a better surface finish.

Install Your Raspberry Pi In Your Case

You can then screw your Raspberry Pi to the base of your case using some M2.5 x 5mm screws, the standoffs are already printed in place. These are the same screws that are typically supplied with Raspberry Pi cases to hold the Pi in place and with an Ice Tower. Don’t overtighten the screws, they just need enough pressure to hold the Pi in place, if you tighten them too much then you might strip the holes in the standoffs.

Screw The Raspberry Pi Onto The Bottom Cover

Next we need to add the receiver from the gamepad. The gamepad I’m using has an internal battery with is charged using an included USB cable and has a small wireless receiver which needs to be plugged into on of the Pis USB ports.

This case design allows two receivers to be installed, one in each of the bottom ports. You should be able to just squeeze them past the bottom edge of the base with the Pi screwed onto the base. You won’t be able to use the top ports without the USB cutouts as the receivers stick out too much.

I wanted to make the case as compact as possible, so I didn’t scale the case up to fit receivers in the top ports as well. There are hardly any RetroPie games which support more than two players anyway.

Receiver Sits In Bottom Two Ports

I’m going to close up my case. You’ll want to keep your case open until you’ve finished the setup process as you might need to plug in a keyboard to type in your WiFi credentials or to change your Pi’s username and password.

Close Up The Case With M3 Screws

Connecting Your RetroPie To A Television Or Monitor

The console is now ready for its first boot up, we just need to plug it into a monitor. You can use any computer monitor with an HDMI input or even your television. To keep with the look of my mini console setup, I’m going to be using this 8″ monitor which Dcorn sent me.

HD Monitor From Dcorn

It’s got HDMI, VGA, AV and BNC inputs, so it will work with any Raspberry Pi, even way back to the first versions and it’s small and portable, with it’s own stand.

Range Of Input Options

It also runs on 12V, so it’s perfect to take along with a Pi in the car for your kids to play games on long drives or to use on camping and RV trips. It’s got a wide 178-degree viewing angle and has built-in speakers so you don’t have to worry about bringing headphones along or using external speakers for multiplayer games.

12V And Built In Speakers

If you’d like to get your own monitor, they’re available from Dcorn on Amazon.

Dcorn Monitor

Let’s plug in our cables and boot up our console. You’ll need to connect power and an HDMI cable to your monitor and then power and the micro-HDMI side of the cable to your Pi.

Plug Cables Into Monitor and Pi

Setting Up Your RetroPie

The first boot up takes a little longer than usual. Once the Pi has booted up, you’ll need to connect it to your network so that you can install your ROMs onto it. You’ll also be asked to push buttons on your gamepad so that your console knows how to manage the inputs.

RetroPie First Bootup

To connect your RetroPie to the internet, head to the options page and then select WiFi. You’ll then need to select your network and type in your network’s password.

If you are using an SD card which is larger than 4GB, you’ll need to expand it so that your Pi can use the remaining space for ROMs. To do this, open the raspi-config tool from the settings menu and then choose Expand Filesystem from the menu.

Lastly, head over to the configuration page and select show my IP. This will bring up your Pi’s IP address, which you’ll need in the next step to load ROMs onto it.

Show IP Address For Setup on RetroPie

Installing ROMs On Your RetroPie

You can download ROMs from a number of sources online, including a bunch of free arcade games and ones with expired copyrights. Just be aware that even though these games are often many years old, a lot of them are still protected by copyright laws. So downloading and distributing copies of these games is illegal.

Here are some resources for public domain ROMs:

I’ve downloaded a free version of Pacman for Super Nintendo which I’ll show you how to install.

Next you need to open up an FTP client on your computer, I used Filezilla, which is also free.

Filezilla Connectiong to RetroPie

Type in your Pi’s IP address which you found earlier and then the username and password, if you haven’t changed these they’ll still be the defaults, which are pi and raspberry. The port you’re accessing is port 22.

Click on connect and Filezilla should connect to your Pi and you’ll then have access to your Pi’s filesystem.

Copy ROMs into Relevant Platform Folder

Open the folder called RetroPie and then roms. This folder contains another folder for each platform that RetroPie supports. You’ll need to copy your unzipped roms into the relevant platform folder. As mentioned before, I’m using Pacman for Super Nintendo, so I’ll open the snes folder and then drag the contents of the unzipped rom onto the Pi.

Do this for all of your roms and then reboot your RetroPie.

Playing Games On Your New RetroPie

You should now see a menu item for each platform that you’ve got an available rom for. Open these up to see the games under each and select one to start it.

RetroPie Platform Options Once ROMs Loaded
RetroPie Running PacMan

You can add as many games as you’ve got space for on your SD card, but because these games were pretty small, you can literally fit thousands of games onto your RetroPie. I like to keep these down to a couple which we actually play so that we’re not scrolling through pages and pages of items each time we’re looking for a game though. It’s also pretty quick and easy to add or remove games as you’d like.

Platform Menu Showing Installed Games on RetroPie

Remember to shutdown your RetroPie properly before unplugging the power to prevent corrupting the SD card.

Shutdown RetroPie Properly After Use

Let me know what you think of my RetroPie console in the comments section. Are you going to try building your own one?

The M5 Paper, A Tablet Style Development Board With An E-ink Touch Display

Today we’re going to be looking at the M5 Paper development board, which is essentially an ESP32 tablet with a 4.7” e-ink touch display. The combination of a WiFi-enabled tablet with accessible IO as well as an ultra-low power consumption touch display really opens up a world of possibilities for home automation, dashboards, monitoring and data logging.

If you’re interested in some other boards in the M5 range, I had a look at the M5Stack Core 2 and M5StickC Plus last week.

M5 Paper Unboxing

Here’s my video of the unboxing and tinkering with the M5 Paper development board:

Where To Buy The M5 Paper

This board was sent to me by Banggood to share with you, you can get your own through the below link:

You can also have a look at some of the other boards in the M5 range:

The above links are affiliate links. By purchasing products through these links, you’ll be supporting my projects, with no additional cost to you.

Unboxing The M5 Paper

Let’s open up the M5 Paper and take a look at it.

The device is shipped with the pre-loaded demo program being displayed. This is one of the benefits of an e-ink display, the image can continue to be displayed even when the device is off or the battery is dead. The touch functionality obviously only comes back on when the device is powered up though.

M5 Paper E-ink Display

The 540 x 960 pixel e-ink display supports two touch points and 16 grey levels. The resolution is pretty good for a display of this size, the characters are crisp and clear and images look good as well.

On the right side we’ve got a microSD card slot for additional storage and a multifunction button – up, down and centre press.

Micro SD Slot and Multifunction Button

It is charged and programmed through a USB C port on the bottom alongside an IO expansion port.

USB C Port and Expansion Port

One the left side, we’ve got two additional expansion ports. Unlike the M5Stack and M5Stick boards, there are no accessible IO pins through a header pin arrangement, you’ve only got three IO expansion ports. But three ports seems like enough for what you’d be using on a device like this.

Second Two Expansion Ports

Like the other M5 boards, the M5 Paper has WiFi and dual-mode Bluetooth. It also has a realtime clock module and a built-in SH30 sensor that measures temperature and humidity.

M5 Paper Features

Specifications:

ESP32-D0WDQ6-V3240MHz dual-core, 600 DMIPS, 520KB SRAM, Wi-Fi, dual-mode Bluetooth
Flash16MB
PSRAM8MB
Input Voltage5V @ 500mA
Ports1 USB Type C, 3 x HY2.0-4P , TF-card (microSD) slot
E-Ink DisplayModel Number:EPD_ED047TC1 | 540*960@4.7″ | 
Grayscale : 16 Levels | Display area : 58.32*103.68mm | 
Display Driver : IT8951
Physical Button1 x Multi-function Button , 1 x Reset Button
RTCBM8563
Antenna2.4G 3D Antenna
PINSG25, G32, G26, G33, G18, G19
Battery1150mAh@3.7V
Working Temp32°F to 104°F ( 0°C to 40°C )
Net Weight86g
Gross Weight100g
Product Dimension118*66x*10mm
Packaging Dimension120*70x*14mm
Casing MaterialPlastic ( PC )

Preloaded Demo Program

The M5 Paper comes with a pre-loaded basic demo program, there’s a sample clip of this program included in my video at the beginning.

You turn it on by pressing the centre button on the side, the device then boots up and re-freshes the home screen we saw earlier.

The M5 Paper, A Tablet Style Development Board With An E-ink Touch Display

You can then open up a couple of mini-apps, one of which allows you to do a factory test of the sensors and IO. The system does a check on each device/sensor and reports the data back on the display. In our case there was no SD card plugged in and no WiFi connection, so those showed up as failed.

M5 Paper System Test

There are a few other mini-apps like this home automation dashboard. I’d definitely like to try and get this to drive my Phillips hue lights in future. This sort of app is one area where I think this device could really excel. I think a lot of people with various home automation devices would appreciate having a universal remote control for their system, which also lasts for a couple of weeks on a single charge.

M5 Paper Home Automation Control Panel

Using the text editor, I found that the display is amazingly responsive for e-ink technology and it does partial updates in well under a second. It’s still obviously a lot slower than an LCD or LED display, but if you’ve used an e-ink display before then you’ll really appreciate how well they’ve managed to get this one to work.

Typing on the M5 Paper

There are a few draw backs to the quick updates, you’ll see a bit of ghosting on more solid images, but you’ll hardly notice this through normal use. If you’re interacting with the display a lot, like during typing, then you’ll see that it partial updates small areas or it just does one refresh cycle at a time before waiting to see if you continue to interact with it. If you pause for one or two seconds then it’ll do another refresh to improve the image quality.

A Bit Of Ghosting On The M5 Paper

Overall, the image quality is crisp and clear, you can get quite a lot of detail out of it.

Display Details On M5 Paper

Pressing the power button on the back instantly turns it off, keeping whatever is currently displayed, but disabling the touch functionality.

You just push the middle button on the side to start it up again.

Programming The M5 Paper With Ui Flow

Now let’s try making and loading our own basic program onto the M5 Paper. It is compatible with the Arduino IDE, but we’re going to try and use Ui Flow to create a basic weather dashboard.

Ui Flow is a block coding and MicroPython IDE which allows you to drag and drop blocks to create basic programs in your browser and then wirelessly uploaded them to your M5 Paper device.

It’s got a reasonably long list of features and its really easy to use, so you can quickly and easily create your own programs with very little programming experience.  It’s definitely a bit limited for the M5 paper though, so you’ll probably want to use the Arduino IDE if you’ve got more ambitious plans for your programs.

To start, you’ll need to install a basic driver and then use M5 Burner to load the Ui Flow firmware onto the device.

M5 Burner For M5 Paper

M5 burner also allows you to burn a couple of other pre-made programs onto it, like this Microsoft ToDo list dashboard. The dashboard connects to your Microsoft account and pulls your to-do list onto your device.

Microsoft ToDo List On M5 Paper

Now let’s install Ui Flow to try and build our own dashboard. You simply click on download, wait for it to be downloaded onto your computer and then click on burn to burn it to your M5 Paper. You might also be asked to enter your WiFi network’s credentials to allow the device to access the internet in order to communicate with Ui Flow on your computer.

The Ui Flow firmware on your device then creates an API key which you’ll need to enter into Ui Flow in your browser to connect to your M5 Paper.

API Key For UI Flow

You then need to enter the API key into Ui Flow in your browser and then select the M5 Paper as your device.

Entering API Key Into Ui Flow

You’re then taken to the drag and drop block coding interface which allows you to start building your code.

I’m going to create a basic temperature and humidity dashboard that shows the date and time as well as a sun or moon depending on whether it is day time or night time.

Creating A Basic Block Code Program

This dashboard took around 15 minutes to make and upload to the device. Once you’re happy with the code, you just click on the run icon in the top right corner and the code is wirelessly sent to your M5 Paper device.

Block Code Dashboard
Weather Dashboard

Ui Flow for the M5 paper has a lot of room for improvement to make it easier to use the touch display. For example, it would be a lot easier to enable touch inputs on shapes, buttons or images to build control panels.

Programming The Device

Final Thoughts

The M5 Paper is a fantastic device in terms of hardware. It’s got a lot of built in features and I can definitely see a lot of potential in it, especially for home automation, universal remotes and creating longer term dashboards which don’t need to update very often.

I think the software packages and documentation for the M5 Paper need some work. Ui Flow is really easy to use to create basic dashboards, but it’s a mission to get anything meaningful from the touch display. It would have been a lot simpler to use if you could program images and shapes to function as buttons. You can obviously use the Arduino IDE as an alternative, but it’s going to take some time for the documentation, community and forums to catch up.

So if you’re up for the challenge, then consider getting one to start tinkering with.

Let me know what you think of the M5 Paper in the comments section.

M5 Paper In Packaging

Reimagine Your Home With Multipurpose Spaces

Many of us have probably wondered at some point about what it would be like to have some extra space to put away all our belongings that we simply have nowhere to store. While your first thought would probably be to extend your home or add an extra room or two to create that additional storage space, these are not always the optimal solutions.

Sometimes, making your space work for you will simply be a matter of changing the way your living space is used and making small tweaks to make it more functional. With that in mind, let’s take a look at some of the ways you can reimagine your home and turn it into a beautiful and practical one by creating multipurpose spaces that you will love.

Use room dividers to create a sense of privacy

Use room dividers to create a sense of privacy

Open floor plans are still quite dominant in the world of interior design. However, there are instances when homeowners crave privacy in their open concept spaces. That’s when room dividers come into play. You can either purchase a divider, build one, or improvise with what you already got.

For instance, a carefully positioned bookcase is a DIY room divider solution that has been around for decades and is still equally effective nowadays. The unit will need to be secured so that it doesn’t tip over, though, so keep that in mind, especially if you have small children running around. If you are feeling particularly crafty and want to take the DIY route, you can use virtually anything to build your own room divider, from pallet wood and repurposed doors to vinyl records and license plates.

Use multifunctional furnishings to transform a room

A simple and effective way to keep your home tidy and neat at all times, adding multifunctional furnishings is the perfect solution for a multipurpose living space. They allow you to quickly and easily change the room’s function and purpose while keeping other functions hidden until they’re needed again.

You can use Murphy beds to save space and turn a bedroom into a multifunctional room in just a couple of seconds. Rely on dining tables that double as working desks complete with hidden features for power and storage to quickly transform your dining room into an office. Ottomans and benches with hidden storage make it easy to keep clutter at bay, and other than functioning as extra seating, they can also be used as coffee tables and footrests.

Rely on rugs to break up space into distinct zones

Rely on rugs to break up space into distinct zones

When working with multipurpose spaces, it’s important to create visual zones. This will help you distinguish the transition between different areas of the home. This can be achieved by choosing some of the stylish Miss Amara rugs that will inject just the right amount of coziness into your living space. Other than feeling soft underfoot, the rugs will anchor the room and help you create distinct zones for playing, relaxing, and working.

When combined with effective furniture placement and area-specific lighting, rugs can help you completely transform your space, dictating how each area of your living space is used. To retain a sense of cohesiveness, make sure that you use the same color palette in those zones while allowing yourself to experiment with different textures, fabrics, and accent pieces.

Turn to visual tricks and decorate strategically

Less is definitely more when it comes to multipurpose spaces, and being careful with how you decorate your living space can go a long way in making your home feel more spacious and functional. Getting back to basics while retaining homely accents is key to achieving minimalism with personality and will make your space feel cozy without being cluttered.

Think upholstery with simple design, clear floors, floating shelves, and transparent, flexible furnishings. Taking such a strategic approach to decorating will help expand the space visually and make a smaller living space feel open and airy. Sticking to a restricted color palette is also a great way to create a sense of spaciousness in your home and ensure that all the rooms flow together perfectly.

Don’t let any space go unused

Don’t let any space go unused

Another way to improve the functionality of your living space is to make sure that every inch of the available space is serving a particular purpose. For instance, instead of using the space under the staircase for storing random items around the house, put it to good use by transforming it into a small workspace or a study nook. Make sure to match the colors and materials to the rest of the space so everything looks cohesive and intentional. Creating dedicated zones for activities like these is a great place to start building a conscious living space and making it more mindful.

Other than that, consider making upgrades that will help put your vertical spaces to good use. Rooms with high ceilings will benefit from creating a mezzanine space while the clever use of joinery can help you turn your home into a multi-use space so you can make the most of it.

Wrapping up

Instead of tackling costly renovations and extensions, making your home more functional and flexible can simply be a matter of rethinking the way you use your existing space and finding ways to make the most of it. Use these tips as an inspiration to reimagine your home, create your own multipurpose spaces, and ensure that it is as functional as it is beautiful.

Trying Out The M5Stack Core 2 and M5StickC Plus With Ui Flow

Today we’re going to be having a look at two members of the M5 range, the M5Stack Core 2 and the M5StickC Plus. These are feature-rich ESP32 based development boards that enable you to develop and prototype your own projects and IoT devices without a significant learning curve.

M5Stack and M5Stick

These devices both have colour displays, with the Core 2’s being a touch screen, as well as some additional buttons, built-in batteries, IO headers and a range of sensors, like microphones and IMUs built into them.

M5Stack Core 2 and M5StickC Plus

Here’s my video of the unboxing and tinkering with the two development boards:

Where To Buy The M5Stack Core 2 and M5StickC Plus

These two boards were sent to me by Banggood to share with you, you can get your own through the below links:

In addition to these boards, the following accessories were used here:

The above parts are affiliate links. By purchasing products through the above links, you’ll be supporting my projects, with no additional cost to you.

Unboxing The M5StickC Plus

Let’s open up the M5StickC Plus first and take a look at that.

M5StickC Plus

I’ll start off by saying that this device is really small for what it is able to do. It’s a little bit bigger than an Arduino Nano, and obviously a bit thicker to accommodate the sensors and battery, but it’s really compact for what they’ve managed to fit into it.

It’s got a 1.1 inch TFT display, with two customisable buttons and a separate power button.

Back of M5StickC Plus

It’s got an IO expansion port on the top which has a range of power supply and input options as well as access to four IO pins. It’s also got a grove connector on the bottom to add compatible devices and sensors.

This USB C port is used to charge and program it.

Grove and USB on M5StickC Plus

In addition to these features on the outside, the stick has a built in LED, buzzer, 6 axis MPU, IR transmitter, microphone and real time clock. It also has both dual-mode bluetooth and WiFi connectivity.

So this is a really powerful little device.

Specifications:

ESP32240MHz dual-core, 600 DMIPS, 520KB SRAM, Wi-Fi, dual-mode Bluetooth
Flash Memory4MB
Power Input5V @ 500mA
PortsUSB Type C x 1, GROVE (I2C+I/0+UART) x 1
LCD Screen1.14 inch, 135*240 Colorful TFT LCD, ST7789v2
Button2 x Custom Buttons
LEDRED LED
MEMSMPU6886
BuzzerBuilt-in Buzzer
IRInfrared Transmission
MICSPM1423
RTCBM8563
PMUAXP192
Battery120 mAh @ 3.7V
Antenna2.4G 3D Antenna
PIN PortsG0, G25/G36, G26, G32, G33
Operating Temperature32°F to 104°F ( 0°C to 40°C )
Net Weight15g
Gross Weight21g
Product Size48.2*25.5*13.7mm
Package Size65*25*15mm
Case MaterialPlastic ( PC )

Preloaded Demo Program

The M5StickC Plus comes with a pre-loaded basic demo program, there’s a sample clip of this program included in my video at the beginning. The program demonstrates the use of the MPU, real-time clock, microphone, IR transmitter and Bluetooth connectivity.

Internal IMU on M5StickC Plus

Unboxing The M5Stack Core 2

Next let’s open up the M5Stack Core 2 – this is an upgrade to the original M5Stack Core.

M5Stack Core 2 In Box

The Core 2 has a 2-inch display, which is also a touch screen. It also has three capacitive touch button below the display, which replace the physical buttons on the original core.

M5Stack Core 2 Unboxing

We have two buttons on the side, one for power and one to reset the device. And then we also have a USB C port, Grove connector and microSD card slot.

USB and Grove on M5Stack Core 2

Beneath the case, we’ve also got an LED, microphone, vibration motor, speaker, 6 axis MPU and real-time clock.

Back of M5Stack Core 2

This cover on the back hides the 30 header pin socket which allows you to access a range of IO and communication pins, which are detailed in the diagram alongside it.

Cover Removed on M5Stack Core 2

This port also allows you to plug in other M5Stack modules to build a stack, which is where the device get’s it’s name.

The M5Stack Core 2 has got magnetic feet, so you can easily stick it to a white-board or your fridge as a control pane or dashboard.

Magnetic Feet on M5Stack Core 2

Specifications:

ESP32-D0WD-V3240MHz dual-core, 600 DMIPS, 520KB SRAM, Wi-Fi, dual-mode Bluetooth
Flash16MB
PSRAM8MB
Input Voltage5V @ 500mA
InterfaceUSB Type C x 1, GROVE(I2C+I/0+UART) x 1
IPS LCD Screen2.0″@320*240 ILI9342C
Touch ScreenFT6336U
Speaker1W-0928
LEDGreen Power Indicator Light
ButtonPower Button, RST Button, Virtual Screen Buttons * 3
VibrationInternal Vibration Motor
MICSPM1423
I2S Power AmplifierNS4168
6-axis IMUMPU6886
RTCBM8563
PMUAXP192
USB ChipCP2104
DC-DC BoostSY7088
TF card slot16G Max.
Lithium Battery390mAh @ 3.7V
Antenna2.4G 3D Antenna
Operating Temperature32°F to 104°F ( 0°C to 40°C )
Net Weight52g
Gross Weight70g
Product Size54 x 54 x 16mm
Package Size75 x 60 x 20mm
Case MaterialPlastic ( PC )

Preloaded Demo Program

The Core 2 also comes with a basic pre-loaded program that allows you to explore some of the features and sensors on the device, there is a clip of this program included in the video at the beginning of this post.

Front Display on M5 Stack Core 2

The program allows you to explore the IMU, touchscreen, microphone, SD card access, timer, clock and WiFi.

Getting Started With Ui Flow on the M5 Range

Next, let’s have a look at how to program these development boards. The boards are compatible with the Arduino IDE, and there is quite a lot of information on installing the boards into the IDE’s boards manager as well as programming them, but they are a bit easier to work with using micro-python.

The developer’s preferred method is to use a web-based IDE called Ui Flow.

Ui Flow To Program M5 Stack

To make use of this application, we need to download and install a driver on a computer and then flash the Ui Flow firmware to the device using M5Burner to enable it to communicate with the web application. You can also burn a couple of other pre-made programs to each device directly from the M5Burner tool.

M5 Burner To Install Ui Flow

M5Burner is pretty intuitive, especially if you’ve worked with the Arduino IDE before, you simply select your board, the COM port, baudrate, and then choose the software that you’d like to install on the device.

We’re going to burn the latest version of Ui Flow to both the Core and Stick devices.

Ui Flow on M5 Stack Core 2

One of the best features of Ui Flow is that it is able to be used wirelessly. The device connects to your WiFi network and generates an API key, and you can then program the device from your browser without any cables, even from a remote location.

API Key For M5 Stack Core 2

This sounded to me like it had the potential to be buggy and slow, but I’ve been really impressed with how well this works. I’ve used it to load a number of programs and revisions and I’ve never had any communication problems with it. It also uploaded the code to the device in just a couple of seconds, usually well under 5 seconds.

Ui Flow is an intuitive drag and drop, block coding IDE, which makes it really easy to get basic programs up and running. You can also switch between block and python modes to add functionality or edit the actual code being generated.

Basic Program In Ui Flow

We can literally make a program and have it running on the device in a couple of minutes. Here I just made a button to drive the internal vibration motor when it’s pushed.

When you click on upload or run, the device receives the code from the IDE and then starts running it.

Vibrate Button For Internal vibration Motor

Making A Basic Home Automation Control Panel On The M5Stack Core 2

Next, I wanted to try making a program that used some of the IO pins, so I decided to try and make a basic home automation control panel using a relay board which I had lying around.

8 Channel Relay Module for M5 Stack Home Automation

I dropped in four slider switches to drive a relay for each room and then added some digital IO blocks to set each pin high or low depending on the state of the button.

Basic Home Automation on M5 Stack Core 2

Never having used Ui Flow before, I did have to do some searching through the menus/options for certain blocks, but this whole program took around 5 minutes to make and get ready to upload to the device. It really is easy to use, even for a beginner.

I then plugged the relay module into the IO pins (pins 2, 27, 32 and 13) and uploaded the code to the Core 2.

Connecting Relay Module To M5 Stack Core 2

It looks like it’s all working the way it should. You can turn multiple rooms on at once and the sliders indicate the status of each switch or relay.

Switching Relays on and off Using Display

I didn’t want to plug all 8 relays in at once as I’m not yet sure what the Core 2’s power supply capacity is and this was being driven straight from the Core 2’s 5V supply, not an external supply. If you’re using a large relay module like this then it’s a better idea to supply the relays using an external 5V supply.

Home Automation on M5Stack Core 2

Connecting Sensors To The M5StickC Plus

Next, let’s look at running a program on the M5StickC Plus which uses the analogue inputs. The whole process is pretty similar, it’s just a matter of selecting a different device in M5Burner and then in Ui Flow.

API Key On M5StickC Plus

We’ll start by creating a program to display the X and Y co-ordinates from an external joystick. I’ve connected a basic two axis joystick to the grove port on the bottom of the M5Stick.

Adding Joystick To M5StickC Plus

Our block code just takes a reading from each of the analogue inputs, maps these to a range between -200 and 200 and then displays this on the M5Stick’s display.

Basic Block Codeing Program For M5 Stick C Plus

It’s obviously not scaled properly, but it works pretty well for a first pass.

Joystick Connection

We can also replace the joystick with a sensor, like this soil moisture sensor and modify the program to display the soil moisture level.

Soil Moisture Sensor On M5StickC Plus

We’re now just going to be using a single analogue input and we’ll also add a battery voltage indicator on the display.

Basic Block Code Moisture Program

So we’ve now got a basic soil moisture level and our battery voltage being displayed on our M5Stick.

Soil Moisture Level Sensor

Final Thoughts

I think these are great all-in-one devices to get started with electronics and rapid-prototyping. I like that they’ve included a couple of built-in sensors and IO options. These, along with the physical buttons and colour display mean that you can already start building some basic programs right out of the box. I also like that you’re able to use the Arduino IDE if you’re already comfortable with it, but there are also easier options available, like Ui Flow.

If you’d like to build more complex projects, then you have the option of using plug-and-play grove sensors, or take it a step further and use the built-in header pins.

Ui Flow’s block coding makes programming the M5 devices really easy, but you’re still able to access some more powerful options through the micro-python editor as well. You also really need to try the remote programming over WiFi feature as well, it’s fast and convenient.

If you’re looking for a basic device for tinkering then the M5StickC Plus will do just fine. If you’d like to get a bit more functionality and be able to add a wide range of sensors and devices later, then have a look at the M5Stack Core 2.

Let me know what you think of these two devices and Ui Flow in the comments section below.

M5Stack Core 2 and M5StickC Plus Review

Making An Ultra Low Power Arduino Pro

This 3.3V Arduino Pro Mini uses over 600 times less power than a traditional Pro Mini, using a couple of simple, low power, changes that cost around $2 to make.

Making An Ultra Low Power Arduino

If you’ve followed some of my previous projects, then you may have seen that I have tried something similar before. Last year, we stripped down an Arduino Pro Mini by removing the power LED and the onboard voltage regulator until we were able to achieve a standby current draw of just 5 microamps at 3.7V.

Original Arduino Power Test

This method would work well for a range of applications, but not having a voltage regulator onboard has complications for voltage-sensitive devices and circuits, so we’re going to look at replacing it with a regulator which has a much better quiescent current.

Arduino Pro Mini Regulator and LED

If you don’t know what this means, the quiescent current is basically the current than a device consumes with no load or in a non-switching condition. So for a regulator, this would be the current being drawn by the regulator with no load connected to it.

Here’s a video of the modification process and results, read on for the write up:

What You Need For This Modification

How To Modify Your 3.3V Arduino Pro Mini

The standard regulator on an Arduino Pro Mini is typically a Micrel MIC5205.

Micrel MIC5205

This regulator is reasonably efficient under load, but is quite poor at low load. Meaning that it waste’s quite a lot of energy when the Arduino isn’t drawing much current from it. This is usually fine for general battery powered projects which run for a few minutes or even an hour or two, but it becomes a problem if you’re trying to build ultra low power projects which need to last a few months on a single charge of a battery.

So lets start by having a look at where we got to previously.

Unmodified Arduino Pro Mini

We started off by testing a standard 3.3V Arduino Pro Mini with no modifications and found that it drew 4.5 milliamps, or 4470 microamps, from the 3.7V battery when running the pre-installed blink sketch.

Power Consumption Before Any Changes

This isn’t much, but it means that a 3.3V Arduino Pro Mini would run for just under a month on a single 3000mAh battery.

Using Low Power Mode

We then used a low-power script to put the Arduino to sleep between blinking. This script makes use of a low-power library to put the Arduino’s Atmega chip to sleep between operations, which uses significantly less power than when it is awake.

Arduino Low Power Mode Sketch

If you’re building ultra-low-power projects then a key part of getting longer battery life is to look at how often information is measured and updated and to make use of the time between these operations to put the Arduino into a low power state. I’m not suggesting that you only take measurements once a day or once an hour, but even waking up to take measurements or check conditions for 1 second in every 10 seconds will make your batteries last almost 10 times longer than without sleeping.

I used this low-power library in my soil moisture monitoring stick project.

Battery Operated Devices Required To Be Low Power

This low power mode modification reduced the current draw to just 1.5 milliamps, or 1500 microamps, so we’ve got around a 3 fold improvement without doing anything to the hardware. Our single 3000mAh battery would now power our Arduino for a little under 3 months on a single charge.

Looking At The Hardware Under A Microscope

Next, we’re going to look at some hardware modifications which we can make to further reduce the power consumption. We’re going to be looking at the small surface mount components on the Arduino PCB, so I’m going to be using this 7″ LCD Digital Microscope which Dcorn have sent me to give you a closer look.

DCorn Microscope

If you enjoy tinkering with electronics and small PCBs then a microscope like this is a great workshop tool. Some of the close-up images and video footage has been recorded using this microscope.

Removing The Onboard Power LED

The next modification was to remove the onboard power LED. This little LED is on whenever the Arduino is powered, which is great when it’s on your bench, but just wastes power in an enclosure.

Arduino Pro Mini Power LED

Last time, we removed this LED by just clipping it off with some wire cutters, this time I’ll do it with a pencil heat gun.

Removing The Power LED With Heat Gun

This had a massive impact on the current draw, reducing it to 0.05 milliamps or 54 microamps. Which is a great result for something we probably wouldn’t have used anyway.

Power Consumption With Power LED Removed

So this was 25 times less power than in low-power mode. This translates to an additional 2900 days of run time on a 3000mAh battery, just by removing an LED which would have likely been covered anyway.

Removing The Voltage Regulator

We then found that removing the voltage regulator resulted in another significant improvement,

Arduino Pro Mini Power LED Removed

I removed the voltage regulator using the pencil heat gun again, taking care not to damage any of the surrounding components.

Removing Regulator With Heat Gun

The board now consumes just 6 microamps.

Power Consumption Without Regulator

So we can tell from this test that our regulator was using around 50 microamps by itself. So now we’re going to have a look at whether we can change this regulator for a more efficient one.

The regulator I’m going to be using is a Microchip MCP1700, which is a 3.3V 250mA regulator which is designed to have a low quiescent current.

MCP1700 Data

One thing to note with this regulator is that it is only rated for an input voltage of up to 6V, so you won’t be able to use it up to 12V like a standard Pro Mini. There is an alternative, the MCP1702, which has a slightly higher quiescent current but allows an input voltage of up to 13.2V. So if you need a higher input voltage then have a look at this as an alternative.

An issue with the onboard regulator on the Pro Mini is that it’s a bit of an uncommon form factor, having 5 legs. Most voltage regulators you’ll see look more like the MCP1700, having 3 legs. So we can’t just directly replace the one on board with a better one.

MCP1700 with MIC5205 Form Factor

But fortunately, there is an easy workaround. We’re just going to use a through-hole version of the MCP1700. It is a bit larger but has exactly the same characteristics as the smaller package.

Surface Mount and Through Hole Regulator

We still need to remove the surface mount one, which you can do with a pencil heat gun or just use clippers as I did previously.

We’re then going to connect the legs of the regulator to the VCC, GND and RAW pins on the Arduino.

Adding MCP1700 To The Arduino Pro Mini

Doing this takes the voltage supply being applied to RAW and GND and supplies the regulated 3.3V to the Arduino’s VCC circuit.

Now that we’ve done this, let’s have a look at whether our Arduino still works and how much power it now uses.

MCP1700 Installed On Arduino Pro Mini

So the blink sketch is still running and we’re now only using 7 microamps, which is substantially better than the 54 being used by the old regulator.

Power Consumption With MCP1700

So we’ve now got an Arduino that still has a regulated supply which is using 640 times less power than an original Arduino Pro Mini. This means that this Arduino would run for almost two years on a battery that would only power an original Pro Mini for a day, and it would run for almost 50 years on a single 3000mAh battery (if the battery would last this long)

Arduino Pro Mini Still Flashing

So you’ve now got more battery capacity available to power your other IO devices. You can also use batteries with a long shelf life, like non-rechargeable lithium batteries, to power your Arduino for 5-10 years without ever touching it.

Let me know in the comments section what you’d use one of these modified Arduinos to power.

DIY Motorised Camera Slider With Object Tracking

I’ve been wanting to build a motorised camera slider for a while now, so when some popped into my Amazon suggestions a week or two ago, it re-ignited the urge to build one.

So, in this guide, I’m going to be showing you how to build your own motorised camera slider which can pan, rotate and track objects for some really cool shots. It’s driven by an Arduino Pro Mini and some TMC2208 stepper motor drivers and can lift a mirrorless camera like the M50 vertically or in any other angle or orientation, even upside down.

Camera Slider Lift Camera Vertically

Here’s a video of the build and the slider in operation, read on for the step by step instructions:

What You Need To Build Your Own Camera Slider

There are quite a few parts to this build, but it isn’t actually that difficult to make. So don’t let the parts list intimidate you!

Parts From Amazon (Affiliate)

There are also a number of 3D Printed parts in this guide. I’ve used a Creality Ender 3 Pro to print my parts. If you don’t have a 3D printer, there are a number of online 3D printing services available to print and deliver your parts as well.

Parts from Banggood (Affiliate)

How To Make The Motorised Camera Slider

We’re going to build the camera slider in three stages. We’ll first assemble the extrusion mounted mechanical slider components and motors, then assemble the PCB and electronics case, and finally program the slider to perform our movements.

Assembling The Mechanical Slider

One of the cheapest and easiest ways to make sliding rigs is to use aluminium t-slot extrustions. These are widely used on 3D printers, laser cutters and other hobbiest CNC machines, so they’re pretty inexpensive and come in a range of sizes and lengths. They’re really useful for mounting components, you can buy special t-slot nuts which fit into the groves to clamp brackets and mounting plates onto.

Aluminium TSlot Extrusion

I picked out a 2040 extrusion and then a basic mount for the stepper motor, a sliding gantry, a belt tensioner and then the belt and pulley. I also picked up a ball joint camera mount so that I could position the camera at different angles.

Extrusion Components

If you don’t want to build a motorised slider and you’re happy to move your camera along the slider yourself, then you don’t even need the motor mount or the tensioner, just the extrusion and the gantry. An un-powered slider is just as useful to get some great footage, you just need a bit more effort and patience to get the shots.

I installed the components onto the extrusion, along with two stepper motors which I salvaged from an old 3D printer. These are just standard Nema 17 stepper motors with around 1-2A coils. I designed and 3D printed a basic housing for the motor as well as an adaptor for the camera mount and some belt clamps.

3D Printed Motor Mount & Adaptor

The motor mount is just screwed onto one end of the aluminium extrusion using some M5 button head screws and t-slot nuts and the pan motor is then mounted onto this mount with the motor shaft facing towards the extrusion and positioned in line with the top pair of side slots.

I then secured the pulley onto the motor shaft with the teeth lined up with the centre of the top slot.

Install Motor Onto Mount

Put the second motor into the 3D printed housing, securing it to the top cover plate with M3x8mm button head screws and close it up with some more M3x8mm button head screws.

Install Motors Into Housing

Screw the ball joint camera mount onto the 3D printed adaptor using some M4 button head screws and then secure this on the shaft with an M3x15mm cap screw.

Install Adaptor Onto Ball Joint Mount

You can then slide the rotation motor and gantry onto the aluminium extrusion and finish off the end by adding the belt tensioner, again using M5 button head screws and some t-slot nuts.

The “tightness” of the gantry can be adjusted using the nuts on the underside of one pair of wheels. These nuts move the wheel supports closer or further away from the slot, which tightens the grip on the slot. The gantry should be firm, without and rattling when moving, but shouldn’t be difficult to move along the guides.

Add Tensioner Onto TSlot Extrusion

Next I needed some legs to stand the slider onto, I also designed these along with a shoe for my tripod and then 3D printed them in black PLA to match the colour of the aluminium extrusion and the motor mount.

Designing Legs For Extrusion

I 3D printed all of my components using Black PLA with a 15% infill.

Once the legs were printed, I installed them on each end of the slider using two M5 button head screws and t-slot nuts on each.

Install Legs On Slider

Remember to put your tripod mount onto your extrusion (if necessary) before the second leg as this closes up the entry to the slot, so you won’t be able to get the nuts into place.

Add Tripod Mount To Underside Of Slider

Then add the second set of legs.

Add Second Set Of Legs

Once your legs have been added, you just need to add the belt from the motor to the gantry. Start on one side of the gantry, folding the belt over itself and securing it with a 3D printed clamp, then feed the belt around the motor, through the middle of the extrusion, around the tensioner and back to the opposite side of the gantry. The belt should be trimmed to length so that there is about 3-4cm of overlap near the gantry.

Install Belt Onto Motor And Tensioner

The belt needs to be pulled finger tight (with the tensioner completely loose) and you can then tension the belt by tightening the tensioning screw.

Adjust To Tension Belt

We’ve now got the basic slider together with our two stepper motors, so we need a way to get them moving.

Camera Motor Mount

Designing And Assembling The Electronics

To control the camera slider I’m going to use an Arduino pro mini. The Arduino will drive the motors using two silent TMC2208 stepper motor drivers. We also need a way to input the parameters for each movement, so I added an OLED display and a rotatary pushbutton.

Testing The Electronic Components

I set up a basic layout of my components on a breadboard first.

Electronic Components Layed Out On Breadboard

This was done to test that I had made the right connections and that the components all worked properly with the Arduino. I didn’t bother with both stepper motor drivers, if the one worked properly then the other one would too.

Wiring Connections Made On Breadboard
Temporary Wiring Connections

Designing The Circuit And PCB

Once I was happy with the connections to the electronic components, I drew up the circuit and a PCB to mount the components onto.

Camera Slider Schematic

You don’t have to use a PCB, you can mount your components onto a breadboard, but a PCB makes a stronger and more reliable build, especially for something that you’ll be moving around a lot.

Designing The PCB Layout

I got my PCBs made by PCB Way. They literally had them made and shipped out to me in 24 hours, which was quite impressive.

PCBs As Delivered From PCB Way

They did send me these PCBs for this project for free, but you can order your own PCBs from them from just $5 for 10 basic two layer boards. They’re really good quality and they also have a couple of different colour options, so you can really customize your projects.

Completed PCBs Brom PCB Way

Assembling The PCB

I then soldered the components and header pin connectors onto the PCB. I used a header pin connector for the display as well as I was planning on mounting it directly onto the case and having a short ribbon cable to the pins.

All Components Soldered Onto PCBs

I put the heat sinks onto both TMC2208 motor drivers, soldered the pins onto the display and Arduino and then pushed them into the sockets on the board.

You’ll also notice that there is a small jumper on the top right of the board, just above the motor drivers. This jumper selected between having the motors always energised (can be moved by hand) and energised on command by the Arduino i.e. the Arduino can enable or disable the motors. My code makes use of the drive enable function using the Arduino to control them.

Components Mounted

Making The Electronics Case

I then sketched the PCB into my CAD model and designed a case to house it and mount onto my slider.

Designing A Case To House The PCB

I 3D printed the case components again using Black PLA and a 15% infill.

3D Printed Case From Black PLA With 15% Infill
3D Printed Case Components

I installed the PCB into the case, holding it in place with some M3x3mm button head screws. My display is still shown plugged into the header pins here, it was removed for the next steps.

Installed PCB Into Case

I then made up a short power lead to a 5.5mm barrel plug socket (the same one used on the Arduino UNO) to mount onto the side.

I mounted to case onto the slider using some M5 button head screws and t-slot nuts.

Add Power Cable And Mount To Slider

I put a switch onto the PCB to use if you’d like to, but I prefer just having it on when its plugged in and off when its not. A switch is useful if you’re powering it from a battery pack or your’ve got it set up somewhere permanently. If you want to use the switch then you’ll need to modify the case so that it’s accessible through the side.

I connected my motors to the PCB ports alongside each driver and put the wires into some braided sleeving to keep it neat.

Programming The Camera Slider

With that all done, it was time to tackle the programming, which was a bit more of a project than I had anticipated.

Making menus with these rotary pushbuttons is a really neat way to input information with a single device, but you land up having to do quite a lot of coding to make up for it.

Rotary Pushbutton To Input Data

I got the pan and rotate functions working quite quickly and then came the object tracking. I simplistically, or rather stupidly, initially thought this was easy. The camera moves from A to B and rotates through a bit less than 120 degrees, so just divide up the movement and rotation and it’ll work perfectly.

Except that thats not how it works at all.

In order for the camera to stay fixed on an object, it needs to move slowly in the begining, quite quickly in the middle and then slow down at the end again. There’s a bit of trigonometry involved in getting the camera to follow the object properly.

Object Tracking Code

At least I had now realised what I had done wrong and could fix it, so after another few hours of coding, it was finally working.

Here’s my final version of the code. I usually go through the code in some detail for each project, but this project’s code is quite lengthy. I have added quite a few comments in the code to help you follow through it.

I have started a GitHub repository for the code if you’d like to share your adaptations and improvements. Some adaptations have been shared below as well.

Code Variations

Our community has also helped out with some useful additions to the code. Here are some of the modified versions. Note that I haven’t tested these versions of the code.

Limit Switch Inclusions by Paul Bartlett

Paul has added micro-switches to the two ends of the rail to act as limit switches to stop the motor. He has also added a short routine to move the motor back a little at the ends of travel to release the switches and added a routine to automatically home the gantry after running a movement.

Use A 1.3″ Display by Tony Tren

Tony has modified the code to work with the 1.3″ OLED display.

Closing Up The Case

Once I had programmed the Arduino, I closed up the case using four M3x8mm screws and then pushed the knob onto the rotary encoder.

Install Cover Onto Case

The motorised camera slider was now ready to be used.

Completed Camera Slider Ca

Using The Camera Slider

When you first put power onto the Arduino, a splash screen is briefly displayed.

Startup Splash Screen

You’re then presented with the main menu, which allows you to choose from four options – pan, rotate, pan and rotate and object tracking mode.

Camera Slider Main Menu

The options are selected by rotating the encoder and are selected by pressing the encoder. Once a mode is selected, a parameter input screen allows you to input the distance, angles, timing and directions for each movement.

Camera Slider Input Menu

Once all of the parameters have been input, you push the encoder button to start the movement and it then enables the motors and runs. The drivers then remain enabled at the end of the movement until you push the button again to release them. This is to ensure that the camera isn’t suddenly dropped once the movement is complete.

Camera Slider Object Tracking

The camera slider works pretty well, staying fixed on the object from one side to the other. There is one limitation in that you need to know the pan distance and the distance to the object quite accurately, otherwise you land up slightly over or under rotating the camera. This isn’t a big issue but it does mean that its difficult to keep the object exactly in the centre of the frame without getting a ruler out each time. I’ll probably look at designing an interface to a Raspberry Pi in future so that I can run TensorFlow to do real-time object tracking. This should give more reliable results without any measurements.

Camera Slider Mounted Onto Tripod To Work In Any Orientation

The TMC motor drivers were a great choice for this build as they are really smooth and quiet, so you bearly notice them running.

Opposite End Of Camera Slider

As always, let me know what you think of this motorised camera slider in the comments section and let me know what you would do differently. But most importantly, enjoy building your own!

Community Builds

Andrew Campbell has shared his camera slider build with some neat modifications, including adding the limit switches by Paul. Have a look in the comments section for his feedback and thoughts on the project.

Andrew Campbell Camera Slider
Andrew Campbell Camera Slider 2
Andrew Campbell Camera Slider 3

Thermal Testing My Water Cooled Raspberry Pi Cluster – Does Loop Order Matter?

Today I’m going to be thermal testing my water-cooled Raspberry Pi cluster to see if the water cooling system is effective with all of the Pi’s overclocked and running at full load, and to see if there is any significant temperature difference between the first and last nodes since they’re all connected in series.

The comments section on the build video was quite divided. Some suggested that the last Pi would start thermal throttling, some questioned having the radiator positioned first in the loop and others said that it doesn’t make any difference in what order the components are connected and mentioned a video done by JayzTwoCents on the loop order of PC components.

The only way to really be sure that the same is true for the cluster is to test it, so that’s what we’re going to do.

Here’s my video of the thermal testing, read on for the write-up:

Setting Up The Thermal Test

To test the Raspberry Pi Cluster, I’m going to connect a monitor, keyboard and mouse to the first node, which I’ll then use to control the other nodes in the cluster an I’ll use the onboard CPU temperature and a thermal camera to measure the temperatures of each node.

Pi Cluster Test Setup

The first thing we need is a means to get the Pis to all run at full load and produce as much heat as possible. For this, I’m going to be using a utility called CPU burn. Out of all of the CPU stress testing utilities I’ve used, this one seems to be the most intense and generates the most heat.

So I’m going to install this on each of the Pi’s and then run the utility along with a printout of the CPU clock frequency and temperature every 10 seconds. I’ll then leave this running until it looks like the temperatures have levelled off and aren’t increasing anymore and we can then compare the temperatures logged by each and see if there was any significant difference between the first and last nodes in the loop.

To install the CPU burn utility, we need to open a new terminal window and enter the following:

wget https://raw.githubusercontent.com/ssvb/cpuburn-arm/master/cpuburn-a53.S
gcc -o cpuburn-a53 cpuburn-a53.S
Installing CPU Burn

We’ll need to use SSH to install the utility on each of the 7 other nodes as well.

One thing to remember is that the nodes are numbered differently to their position in the loop. The nodes are numbered from top to bottom, left to right and the cooling water loop runs from the bottom right to the bottom left.

Cluster Node Layout

So the cooling loop order is actually 8,7,6,5,1,2,3,4. So if the loop order does matter, then we should have Node 8 being the coolest and Node 4 being the hottest at the end of the test.

To run the test, I’ll open up a new terminal window for each Pi and prepare the command line on each so that we can just hit enter in each window to start running. I’m doing it this way so that all of the node temperatures are being displayed on a single screen so that they’re visible for this video.

Preparing The Command Prompts For The Test

With that all prepared, it looks like the Pis have warmed up a bit when booting up, and we have a surface temperature of about 27 degrees on each Pi, and the room temperature is about 24 degrees.

Looking a bit closer at an individual Pi, we can see there’s definitely a cool spot where the cooling block is, so thats doing it’s job. The RAM, USB and Ethernet chips have warmed up quite a bit.

Running The Thermal Testing On The Cluster

Now let’s start the thermal testing and see how it goes. You can see each Pi started off with a CPU temperature of around 30 to 31 degrees, and this spiked quite quickly to 40 degrees once the test got running.

Running The Thermal Test

After around 8 minutes, you can see that the individual Pis and the combined cluster is quite a bit warmer than when we first started the test.

After running the test for about 10 minutes, there doesn’t look like there has been much increase in temperature over the last two minutes. So, let’s put the results onto a graph and have a look at the temperature of each Pi.

Cluster Thermal Test

I’ve renamed each node to the order that it sits in the loop to make it easier to follow. I didn’t think that there would be much difference across the loop, but I also didn’t expect there to be such a wide variance between each Pi.

From the graph, it looks like the Pi in loop position 4, which is node 5, ran the coolest and the Pi in loop position 1, which is node 8, ran the warmest.

This is what the results look like if we average out the last 4 minutes of the test.

Average Temperature Test

So there really doesn’t seem to be any correlation between the Pi’s position in the loop and its temperature. You can see here that the order in the loop and the average temperature of the node is pretty much random.

Average Re-ordered

If the loop order was significant, then we would have seen a descending pattern starting with 7 or 8 and ending with 1 or 2.

The 4 degree temperature variation between them is more likely caused by conductivity differences between the cooling blocks, thermal paste and CPUs and manufacturing differences between the Pis. The CPUs might also generate slightly different amounts of heat.

Running The Thermal Test Without The Cooling Water Circulating

There were also a couple of comments which suggested that Raspberry Pi’s are so underpowered that they don’t need any active cooling and that a simple heat sink on each would do. So next I’m going to try turning the pump off and leaving the CPU burn utility running to see if we even need the water flow through the heat sinks. Each cooling block is effectively a 30x30x10mm heat sink, so they do increase the surface area of the CPU and should help with cooling by themselves.

After 5 minutes of running, these were the results:

Cooling Water Power Off Test

So it’s pretty obvious that the cooling blocks heat up quite a lot without the water being circulated through them.

You can see from the thermal image that the circuit is much hotter than it was with the water flowing through it.

I turned the loop back on when the hottest Pi reached 65 degrees, and this was only a little over 5 minutes in. The individual Pis also look pretty cool under the thermal camera now, the emissivity difference between the acrylic and cooling blocks makes the Pi logo show up

It looks like the temperature would have levelled off somewhere around 72 degrees. So you could probably get away with running the Pis without the cooling water on without them thermal throttling, but it’s getting close, and they probably wouldn’t last very long if they’re frequenctly running at over 70 degrees.

Does Loop Order Matter?

So, from the thermal testing, it looks like the loop order has very little effect on the temperature of each component. And while this might seem like it doesn’t make sense, it’s actually got to do with the flow rate through the loop.

Single Water Cooled Raspberry Pi

If the loop were running at a really low flow rate, saying taking eight minutes for a millilitre of water to get from one end to the other, then the water would have almost a minute in each node to heat up – which it obviously would. This would have an additive effect, where each Pi would increase the temperature of the water by a couple of degrees and you’d land up with a pretty significant difference in temperature between the first and last nodes.

But in this case, as is the case with pretty much all PC water cooling loops, the flow rate through the loop is quite high. Water circulates from the first to last node in this loop in under 10 seconds. So there is very little time for the water to be heated up by each node.

This doesn’t mean that the water isn’t heated up, it just means that the difference between the first and last nodes is much smaller, so much so that it’s pretty much negligible. This basically means that the temperature of the whole loop remains fairly uniform and that the order of components within the loop doesn’t really matter.

As long as you’ve got a radiator which is removing more heat than what is being put into the loop, the loop will work effectively.

Running a loop in this way is actually more efficient as well, because the greater the difference in temperature between the cooling block and the liguid running through it, the more effective it is at removing heat.

Let me know your thoughts on my thermal testing of the cluster in the comments section. Have you tried different loop orders on your computer’s cooling circuit?

Water Cooled Raspberry Pi Cluster Being Tested

HT-02 Thermal Camera Unboxing & Review

Today I’m going to be unboxing and reviewing the HT-02 Thermal Camera, which Banggood have sent me to share with you. They’re currently selling for $200, which is really cheap for a thermal camera. If you’re not familiar with thermal cameras, entry-level ones from well-known brands typically start around the $1,000 mark and they easily go up to the $10,000 to $20,000 mark. So we’ll have a look at some of the features of this camera as well as what you can and can’t do with it.

Here’s my video review of the camera, read on for the written review.

Where To Get One?

If you’d like to get your own HT-02 thermal camera, you can get one from Banggood through this link – HT-02 Thermal Camera. They’ve got US and China shipping options, so you should get yours in a couple of days.

HT-02 Thermal Camera

Unboxing The HT-02 Thermal Camera

The camera comes in this black and yellow box which has a magnetic flap on the front.

HT-02 Thermal Camera Box

There isn’t much else to the box, it doesn’t give you much information on the specifications of the camera itself, but you can get all of that online on the product page. We’ll also have a look at some of the more important ones in the next section.

Side Of HT-02 Thermal Camera Box

Inside the box, you’ve got a nice hard shell carry case with the camera inside it.

HT-02 Thermal Camera Case In Box

The case zips closed and inside that we’ve got the manual right on top. So let’s have a look at that first.

Camera In Bag With Plastic

The Manual & Specifications

The manual is only in English, and it’s actually not that bad. There are one or two settings or sentences which don’t really make sense, but overall it’s pretty understandable and will get you through setting up and using the camera quite quickly.

Looking At Camera Manual, Specifications

Here are some of the main specifications for the HT-02 thermal camera:

  • Display: 2.4inch colour display
  • Thermal Image Resolution: 60 x 60 (3600 pixels)
  • Thermal Sensitivity: 0.15℃
  • Temperature Range: -20℃ – 300℃ (-4o℉ – 572℉)
  • Measuring Accuracy: ±2℃
  • Wavelength Range: 8-14μm
  • Image Frequency: 8HZ
  • Emissivity: 0.1-1.0 / Adjustable
  • Focus Mode: Fixed
  • Image Storage: SD card(MAX 32G)
  • Power Supply: 4 x AA batteries (NOT included)
  • Operating temperature: 0℃ – 50℃
  • Drop Resistance: 2m
  • Size: 230 × 80 × 52mm
  • Weight: 410g

It has an infrared image resolution of 60×60, which is a total of 3600 pixels. This is on the lower end for thermal cameras, but should still be good enough to get a fair amount of detail for objects when you’re not too far away. It also has a regular camera, with a resolution of 0.3 megapixels. The focal distance is 0.5m, this is the optimal distance between the camera and the subject. It has a temperature range of -20C to 300C, which is pretty good, it’s actually better than most other entry level thermal cameras. Its accuracy is claimed to be within 2% or 2C. It’s also got a range of colour palettes and includes an 8GB SD card. It is powered by 4 AA batteries, which give it a total run time of around 6 hours.

The manual runs you through all of the components, features and buttons.

Manual Menu Options And Settings

It also shows you the menu functions and how to replace the batteries.

Camera Menu Options

We then have a section on how to take measurements and change colour palettes.

Thermal Camera Palette Options

There is also a guide on how to mix images. This feature is quite useful, it enables you to overlay the thermal image and camera image so that you can better locate warm or cold spots on objects. You’re given 5 different levels of mixing from a complete camera image to a complete thermal image and 3 levels in between.

Image Mixing Settings

They also include a small guide on the emissivity of common materials. Different materials emit infrared energy at varying levels and this is the means to calibrate the thermal imaging on the camera to get more accurate results. The default is 0.95, which is a good starting point for most materials and for when you’re measuring a variety of materials in one image, but this is something to keep in mind when you’re taking measurements of certain materials, particularly with metals.

Emissivity Of Materials

That’s pretty much it for the manual. We’ll go over some of the features and operation of the camera while we try it out.

A Close Up Look At The Camera

The HT-02 thermal camera is packaged in a sealed plastic bag and is held in place with an elastic strap on the inside of the case.

Camera In Plastic Bag

The camera actually feels quite solid. It’s got a wrist strap which is tied to the bottom of the handle and there’s also a 3/8” thread on the handle which is useful to mount it onto a tripod or stand.

Threaded Tripod Mount

On the back we have the colour display and 6 buttons for navigating through the settings and menus.

Back Of Camera

The screws are all covered on the sides with small rubberized plugs. On the front we’ve got the thermal camera at the top, then the visual camera underneath it and lastly an LED light. We’ve also got a red trigger button on the handle which is used to take photos.

Front Of Camera

At the top of the camera is the micro SD card slot, which is again covered with a rubberised flap and you’ve given an 8GB micro SD card, which should be plenty of space for the resolution that the camera runs at.

SD Card Slot On HT-02 Thermal Camera

I’ve mentioned before that it feels quite solid and pretty well built. The yellow material on the outside has a rubbery feel to it, so it feels like something you could use around a workshop.

Rubberised Coating On Sides of HT-02 Thermal Camera

I wouldn’t chance dropping it from more than a meter or so, although the manual says it’s safe to drop up to 2m, but it feels like it would survive being bumped around a bit or thrown into a bag with some other measurement equipment.

Testing The Camera

Now that we’ve got the HT-02 thermal camera unpacked, let’s try it out.

We’ll need to put 4 AA batteries into the handle to power it. The battery compartment is in the handle of the camera and the cover just slides into place.

4 AA Batteries In Handle Of Camera

We then need to push and hold the menu button to turn it on. It takes a few seconds to power up and it then goes straight into the thermal camera mode.

Turning The Camera On

Navigating the Menus

Let’s take a look at the menu and some of the settings. To access the menu, you just press the menu button. You can then scroll up and down through the menu options using the up and down arrows and select menu options with the select button. You push the menu button again to exit the menu.

Thermal Camera Menu Options

The menu is pretty simple and is quite intuitive, for the most part.

There’s an option to switch between degrees Celsius and Fahrenheit.

Then there’s a setting called BG. I’m not really sure what this setting is for. The manual just describes it as Default Setting, it might be some sort of calibration offset value. I just left it alone for the test.

We’ve then got the storage space on the card, colour pallet options, emissivity settings, single or multi point measurement, ambient temperature, the time, the number of pictures taken and the display brightness.

The Thermal Imaging Screen

Outside of the menus, and when you turn the camera on, you’re taken to the measurement screen, which is where the thermal image and measurement values are shown.

Measurement Display Screen

You’ve got the thermal image in the centre, with the centre point temperature (defined by the crosshairs in the centre of the display) on the top left and then a battery level indicator along with the emissivity setting on the right. At the bottom you’ve got the colour pallete setting, the current time and then the minimum and maximum temperature in the current image.

The LED on the front is turned on by pressing and holding the trigger button and is turned off in the same way.

HT-02 Thermal Camera Sensor

Taking Measurements & Images

Let’s start off by looking at a Raspberry Pi.

This Pi hasn’t been turned on in a while, so it should be the same temperature as the rest of the room. So you can’t see anything on the thermal camera.

Looking At Raspberry Pi Thermal Image

If we switch to the visual camera you can see that the Pi is in the shot, it’s just not emitting any heat yet.

Looking At Raspberry Pi

Now let’s try plugging it in and watch it heat up a bit. After a few minutes, you can see we’re now getting a warm spot on the bottom of the Ice Tower.

Raspberry Pi Heating Up

If we try the multi-point mode we can see the points on the display where the highest and lowest temperatures are being measured. The highest temperature looks like it is on the bottom of the heat sink in the area in contact with the CPU, as expected, and the lowest temperature is on the desk around it.

The HT-02 thermal camera seems to take a screenshot of the display, so you get all of the information around the image saved with each photo as well. It doesn’t look like you can turn this on or off, but it is pretty important to have with each picture anyway.

Thermal and Visual Image Blending Options

There are 5 blending options for the thermal and visual camera images. 0%, 25%, 50%, 75% and the 100% thermal image and you can easily switch between them using the side arrows. This is useful to locate specific areas in your picture which are generating heat.

Thermal Image Mixing

You’ll notice that the thermal image of the Pi is slightly higher than the visual image. This is because the two cameras obviously have to be spaced slightly apart, and the camera’s alignment is set up for the 0.5m focus distance. So if you’re closer than this then you get a slightly misaligned image. This is going to happen on any camera though because you can’t have both cameras in the same position. Some other cameras do have a means to adjust the focus point, either optically or digitally to correct this and some even do it automatically

Thermal Signature On Objects

Let’s try looking at my hand placed on the desk through the camera. The colour display is bright and produces nice vibrant colours according to the colour palette you’ve got selected.

Looking At Hand Print On Desk

Even with the fairly low resolution of the thermal sensor, you still get pretty good definition and you can make out objects fairly well, as long as they’re not really small.

Hand Print Stays On Desk For A Few Seconds

You can see my hand’s thermal signature stays around for a while after I’ve removed my hand from the desk.

Comparing Hot And Cold Measurements

Lastly, let’s have a look at these two cups of water. The one is cold and the other is hot, which you can’t really tell from my camera unless you notice the thin wisps of steam above the one cup.

Cups Of Water Test Thermal Camera

Here’s what they look like from the thermal camera.

Looking At Cups Of Water Test On Thermal Camera

Here’s a look at the different pallet options available:

Colour Palette Options

You can also use this camera around your house or workshop to find gaps between doors and windows, or to see if equipment has been running or is still on.

Checking Electronics Around The House

Drawbacks and Suggestions

There are three main things I would have liked to have had on this camera, which all would have been relatively easy to add.

The first is that I would have liked to have a video option. It would be useful to see how objects heat up or cool down, like my 3D printer, and with the tripod mount already there, this would be a great tool for monitoring an object for a couple of minutes. You could also add a simple alarm which triggers if the temperature exceeds a certain high or low limit.

Video Of 3D Printer Heating Up

The next would be to be able to digitally adjust the alignment of the two overlaid images. It’s not always possible to get your object at exactly 0.5m and you’re then left with a slightly mismatched image. This doesn’t make the feature unusable, as you can still generally see where the overlay is supposed to be, but this would be pretty simple to do right on the camera and would give you much better quality images. Here’s an example of an image that I’ve fixed up, compared to the original image.

Digitally Aligned Image

Lastly, it would have been nice to have a rechargeable battery. People just don’t use AA batteries as often as they used to and it’s a bit of a mission to have to get to a store to get some more if they die while you’re busy using the camera. Obviously, an internal battery and charger would push the price up a bit, but I think the extra ten to twenty dollars would be worth it for the convenience. If you do use rechargeable AA batteries in the camera then it shows up a low battery warning and shuts down prematurely because rechargeable AA batteries are only 1.2V each and not the usual 1.5V.

Conclusion

Overall, I think the HT-02 thermal camera is a great value for money camera and I’d definitely recommend getting one to try out if you’re unsure about spending thousands of dollars on a more well-known brand. It has a few drawbacks, but none of them are serious. It’s still a perfectly functional camera and is great for getting started with thermal imaging. If you’re interested in getting one for yourself, here’s a link to the product page.