Category Archives: Guides

Using INA219 (GY-219) with the Raspberry Pi

Hi everyone,

I’ve just setup an INA219B Voltage/Current sensor on my RaspberryPi. Just thought I’d link the tutorials and libraries I used – there’s a lot of really useful info out there.

Install the following library via git:
sudo pip3 install pi-ina219

Follow this tutorial:

Misc Notes

  • Common ground is required
  • Vin – and Vin+ are attached to +, neither goes to ground

Custom Sensor Address
na = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS, address=0x41)

Can be configured via the following:

Enable Low Power Between Reads
while True:
print "Voltage : %.3f V" % ina.voltage()

Mini-360 DC-DC Buck Converter – Incorrect Voltage 10v Instead of 5v

Hi everyone,

I’ve been playing around with a few DC-DC buck converters similar to these ones:

I had expected 5v output from my 12v supply but when I hooked it up to a multimeter I found I was getting just over 10v. This would fry pretty much everything in my circuit so I was pretty worried.

After a bit of research, I came across a thread on eevblog that mentioned a screw for adjustment. Looking closely you can see that there is a small screw on the side of the chip. Turning this quarter of a rotation anti-clockwise put mine at exactly 5.04 volts.

A few other small tips:

  • The thread seems to indicate that some models require a lot more turning (up to 30 seconds for one poster).
  • I had to push down fairly hard to get it to actually turn the part underneath instead of just the metal cover

Hopefully this helps someone else out!



Duinotech Hall Effect Sensor with RaspberryPi

Hi everyone,

This is just a quick post to cover how the Duinotech hall effect sensor module (XC-4434) can be hooked up to a RaspberryPi.

Sample Code

The code below will output a zero when the sensor is activated by a magnet, otherwise a zero.

import time
import datetime
import RPi.GPIO as GPIO

# Define constants

# Setup GPIO pins
GPIO.setup(BUCKET_HALL_EFFECT_SIG_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Important

while True:



When near a magnetic field the light on the sensor will turn on. If you’re using the sample code above, a zero will be shown when close to a magnet, otherwise a 1.


Purchased from:

Spec Sheet: Z7275

Updating to Python 3.5.1 on RaspberryPi

Hi everyone,

Just a quick post on how to update to Python 3.5.1 the normal upgrade process isn’t working for you:

cd ~
tar -zxvf Python-3.5.1.tgz
cd Python-3.5.1
./configure && make && sudo make install

You may need to restart once this is complete. Run the following to confirm that the version is 3.5.1:

pi@raspberrypi:~ $ python3 --version
Python 3.5.1

Check out the following link for more info:

Check Tensorflow Version – Raspbian

Hey everyone,

Just a quick post on how to check the Tensorflow version on Raspbian with a one-liner (assumes Python 3.x):

python3 -c 'import tensorflow as tf; print(tf.__version__)'

Check out this Stackoverflow post for more info:

Check if String Contains a Substring – Python

Hey everyone,

Just a quick post on how to check if a string contains a string in python:

if "STRINGTOFIND" in "testtesttestSTRINGTOFINDtestesttest":
# continue

Thanks to this stackoverflow post:

Arduino GPS – Ublox NEO-M8N Flight Controller GPS w/Protective Shell for PIX PX4 Pixhawk

Hey everyone,

I recently purchased this GPS unit on ebay:

Unfortunately, I didn’t do a lot of research before getting it and had a bit of trouble finding any spec sheets or documentation. Just in case anyone else has the same problem I’ve listed out everything I needed to get it running below.

This is the wiring info you’ll need for an Arduino:
– VCC: red
– GND: black
– TXD: yellow
– RXD: white
– SCL: green
– SDA: blue

And while this post is mostly targetting Arduino, the following wiring can be used for a RaspberryPi3:
– VCC: red => pi 3.3v
– GND: black => pi gnd
– TXD: yellow => pi rx (GPIO15/Pin #10)
– RXD: white => pi tx (GPIO14/Pin #08)
– SCL: green => pi scl (GPIO3/Pin #5)
– SDA: blue => pi sda (GPIO4/Pin #7)

The default baud rate was 38400.

This is the example I ended up using to get a quick test up and running. Ensure that you map the rx and tx pins correctly (arduino tx to gps rx, arduino rx to gps tx).

This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
static const int RXPin = 11, TXPin = 10;
static const uint32_t GPSBaud = 38400;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup()

Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F("by Mikal Hart"));

void loop()
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0)
if (gps.encode(

if (millis() > 5000 && gps.charsProcessed() < 10) { Serial.println(F("No GPS detected: check wiring.")); while(true); } } void displayInfo() { Serial.print(F("Location: ")); if (gps.location.isValid()) { Serial.print(, 6); Serial.print(F(",")); Serial.print(gps.location.lng(), 6); } else { Serial.print(F("INVALID")); } Serial.print(F(" Date/Time: ")); if ( { Serial.print(; Serial.print(F("/")); Serial.print(; Serial.print(F("/")); Serial.print(; } else { Serial.print(F("INVALID")); } Serial.print(F(" ")); if (gps.time.isValid()) { if (gps.time.hour() < 10) Serial.print(F("0")); Serial.print(gps.time.hour()); Serial.print(F(":")); if (gps.time.minute() < 10) Serial.print(F("0")); Serial.print(gps.time.minute()); Serial.print(F(":")); if (gps.time.second() < 10) Serial.print(F("0")); Serial.print(gps.time.second()); Serial.print(F(".")); if (gps.time.centisecond() < 10) Serial.print(F("0")); Serial.print(gps.time.centisecond()); } else { Serial.print(F("INVALID")); } Serial.println(); }

Output should be something like this:

A simple demonstration of TinyGPS++ with an attached GPS module
Testing TinyGPS++ library v. 0.92
by Mikal Hart

Location: -27.427371,153.028945 Date/Time: 9/10/2017 06:04:21.40
Location: -27.427371,153.028945 Date/Time: 9/10/2017 06:04:21.40
LocatiaonfTGS+wh atahdSmlesiTiGS+bay .2b a at
ain Da/ie/ ai .Da/Te 1tion: -27.427371,153.028945 Date/Time: 9/10/2017 06:04:21.60
Location: -27.427371,153.028945 Date/Time: 9/10/2017 06:04:21.60
LocaS+bay .2b a at
ain Da/ie/ ai .Da/Te 1tion: -.aeTm1.
ti:.atTm:7cation: -27.427370,153.028945 Date/Time: 9/10/2017 06:04:21.80
Location: -27.427370,153.028945 Date/Time: 9/10/2017 06:04:21.80
Location: -27.427370,153.028945 Date/Time: 9/10/2017 06:04:22.00
Location: -27.427370,153.028945 Date/Time: 9/10/2017 06:04:22.00
Location: -27.427370,153.028945 Date/Time: 9/10/2017 06:04:22.20
Location: -27.427370,153.028945 Date/Time: 9/10/2017 06:04:22.20
Location: -27.427370,153.028945 Date/Time: 9/10/2017 06:04:22.40
Locat/Te:/ an:3aTi: /1ain.atTm:7atn 3Dtie 1.cto.3teim 1.
ti: .aTim1aton: -27.427370,153.028945 Date/Time: 9/10/2017 06:04:22.40
Location: -27.427368,153.028945 Date/Time: 9/10/2017 06:04:22.60
Location: -27.427368,153.028945 Datn 3Dtie 1.cto.3teim 1.

One final thing to note is that the blue light will start to flash once the GPS has a lock. You'll need a pretty open space, mine didn't work inside but got a lock within 60 seconds outside.

Let me know if you have any questions or links to better doco!

Rename all files in a directory with Sequential Numbers

Hey guys,

Just a batch script I came across that allows you to rename all files in a directory with sequential numbers. Really handy for things like tensorflow. All you need to do is create a batch file in the directory containing the following:

@echo off
setlocal EnableDelayedExpansion
set i=0
for %%a in (*.jpg) do (
    set /a i+=1
    ren "%%a" "!i!.new"
ren *.new *.jpg


Thanks to this stackoverflow post:

Using FFMPEG to create an image for every second of a video

Hey guys,

Just a quick command I found on stackoverflow to take a still image/thumbnail out of a video every second:

ffmpeg -i video.avi -r 0.01979 -f image2 output_%05d.jpg

Thanks to this stackoverflow post: