Friday, April 20, 2018

PiJuice - Mobile Power for the Raspberry Pi (First Impressions)

Ever since the Raspberry Pi came out I've had an idea to make a time lapse camera that would take pictures over weeks, months, or even a whole year. For this purpose I needed a mobile power management solution for the Raspberry Pi.

Over two years ago I supported a Kickstarter campaign for the PiJuice. The PiJuice was delayed multiple times for various technical and non-technical reasons that are nicely outlined in this review. After all that time my PiJuice has finally arrived and now I'll outline my first impressions!

Top View with Raspberry Pi Zero W connected

Bottom View with Raspberry Pi Zero W connected
The PiJuice is designed for the Raspberry Pi A+, B+, 2B, 3B, and is compatible with the Zero, and Zero Wireless. I am testing it with the Zero Wireless and 3B right now. Documentation is somewhat lacking right now. Your best bet is to look at the PiJuice's GitHub Page. I found the hardware page the most useful to get an overview of how it works.

The PiJuice product page touts many features. The features I think most people will care about are the following:

  • Charging from weak sources:
    • Batteries can be charged from weak and unreliable sources such as solar and wind because of a feature called Dynamic Power Management (DPM)
  • Low power mode
    • Real Time Clock
    • Low power deep-sleep state with wake on interrupt/calendar event
    • Hardware watchdog timer
  • Software
    • Python based API
    • Python based system daemon
  • Nice to have
    • Programmable multi-colored RGB led (x2) and buttons (x3)
I bolded the first feature because I feel like this is what sets the PiJuice apart from other competitors.

I will have many more reactions regarding the PiJuice in future posts. However I'll leave you with this graph which shows the discharge curve of the BP7X 1820mAh battery provided with the PiJuice. I was able to get nearly 7 hours of usable time from it on the Pi 3B! I had to make sure to throttle down the Pi to achieve this but it is possible.

To get the Pi 3B to use less power I performed the following:

echo 0 | sudo tee /sys/devices/platform/soc/3f980000.usb/buspower >/dev/null
sudo tvservice --off
echo gpio | sudo tee /sys/class/leds/led1/trigger
echo 0 | sudo tee /sys/class/leds/led1/brightness

The first line powers off the USB/LAN expansion chip. The second line powers off HDMI, and the last lines turn off the power indication LED. Doing all of these things I can reduce current consumption from 500-600mA to 200-300mA!

I'll be posting more about how to use it with the Solar Panel, as well as my reactions to the available software API including using the real time clock and more!

Friday, July 19, 2013

Raspberry Pi Camera Module HD Time-lapse

So a bunch of camera modules were made available last week and so I finally went ahead and ordered one for my Raspberry Pi. It arrived in less than a week! However the shipping and tax brought the cost up to $36 Canadian from $25 retail. Oh well, at least I have it now!

The obvious first project for the camera module was wireless, battery powered timelapse! I did a similar project last summer with a webcam. However, the camera module is a million times better! It does 1080p video at 30FPS. The quality of the stills is also much better, and its all hardware accelerated!

I used this guide for making the time-lapse. The result is beautiful:

 I was able to capture the sun setting over my cul-de-sac. I think the moving shadows are really cool.

The setup is very ghetto. I used a makeshift lego case, and a cheap 11200mAh battery from eBay.

In my next post I will post how to capture live streaming HD video from the Raspberry Pi. Until then keep tinkering!

Wednesday, August 8, 2012

Wireless, Battery Powered, Time-lapse Video with a Raspberry Pi

I was looking for cool projects for my Raspberry Pi and came across a really cool project by Jeremy Blythe: Battery powered, Wireless, Motion detecting Raspberry Pi.

It inspired me to build something similar, but instead of using the Pi as a security camera, I wanted to do some outdoor time-lapse photography. Here is an animated GIF that the Pi produced. I'm working on longer and higher resolution versions.

And here is the device itself, the "Lapse-Pi":

I used the following hardware to build it:

1. Microsoft Lifecam Show 2.0MP - $13 from NCIX
2. Power Bank 12000mAh External Battery Charger USB - $25 from eBay
3. Ultra Mini USB Wireless LAN Adapter 802.11n - $7 from
4. Lego Bricks, Raspberry Pi, SD Card etc.

Below is a close-up of the battery. I've let my Raspberry Pi idle on it for around 24 hours before the juice runs out.

I've had lots of trouble getting webcams working on Linux, fortunately, the Microsoft Lifecam Show 2.0MP is UVC compatible. It was basically plug and play. I highly recommend getting a UVC compatible webcam. It will be almost guaranteed to work with your Raspberry Pi. See the Linux UVC driver webpage for compatible webcams.

On the software side I am using:

1. Official Raspbian Wheezy Image, ""
2. Streamer
3. Imagemagick Convert
4. sshfs

Step by step instructions:

1. Install Streamer and SSHFS

sudo apt-get install streamer
sudo apt-get install sshfs

2. Mount your network share to store the time lapse images wirelessly. I use SSHFS, however you can use SAMBA, NFS, or whatever else you want.

mkdir server_mount
sshfs username@server:/home/username /home/pi/server_mount

3. Run streamer to capture the frames.

mkdir -p server_mount/timelapse
cd server_mount/timelapse/
streamer -o 0000.jpeg -s 352x248 -j 100 -t 00:20:00 -r 0.1 -c /dev/video0

Some notes on the command line parameters:

  • "-o 0000.jpeg" specifies the filename format for the individual frames
  • "-s 352x248" specifies the resolution. I think the Pi can handle much higher than this.
  • "-j 100" is the JPEG quality"
  • "-t 00:20:00" instructs it to capture for 20 minutes
  • "-r 0.1" indicates the frame rate of 0.1 frames/second
  • "-c /dev/video0" specifies the video device. It should be the same for you.

4. On the server, convert the captured frames to an animated GIF using Imagemagick's "convert" utility

convert -delay 5 *.jpeg -loop 0 animated.gif

Future Plans:

I have recently purchased a 4.5V OCV / 450mA SCC solar panel from eBay for about $20. I am in the process of figuring out how to charge the battery with it. If that happens then I can take time-lapses over multiple weeks and months rather than just 1 day.

I also will be trying higher resolution time-lapses. The Lifecam Show is capable of 2MP or 1600x1200. And hopefully in October the official Raspberry Pi camera module will come out that will be capable of 5MP or 1080p at 30fps!

Thursday, July 19, 2012

Raspberry Pi Camera Module Information

I am very excited about the Raspberry Pi Camera module. So excited that I've compiled the latest information I could find on the camera module.

  • The camera will be available in 3-4 months (October, 2012) [1]
  • The camera will cost $20-$25 USD [1]
  • Specifications [2]: 
    • Rolling shutter, 1/4" lens
    • Resolution 2592x1944
    • Frame rates: (sensor specs, not necessarily possible on Raspi)
      • QSVGA 15fps
      • 1080p 30fps
      • 720p 60fps
      • VGA 90fps
    • Can support 8-/10 bit raw RGB
    • Power : approx 100mA at 1.5v
[1] Interview with Eben Upton

Small and Cheap USB Wi-fi Adapter for the Raspberry Pi

I wanted to write this for the benefit of Raspberry Pi owners who are still looking for an appropriate and economical Wi-Fi adapter. The cheapest one I could find is based on the Realtek 8188CUS Chipset. There are a number of devices that use this chipset. The cheapest as of writing this entry is $5.05 US, the SANOXY Mini 150M USB2.0 WiFi Wireless LAN 802.11 n/g/b Adapter.

One that seems popular on the Raspberry Pi forums is the Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter with EZmax Setup Wizard

The one I have I got from is the Ultra-Mini USB Wireless Lan 802.11N Adapter - 1T1R (150Mbps). To give you a idea of how tiny it is, here is a picture next to a penny.

There are two issues with these Wi-Fi adapters. First, the RTL8188CUS driver that comes with the official Raspberry Pi image does not work. You will need to install the driver manually. There are a number of users who have already written excellent how-to's to accomplish this.

* Compile on the Raspberry Pi itself

* Cross Compile driver on your desktop

After you have the driver compiled and working, the Debian wiki has some great info on how to get it up and running.

The second issue is with power. Sometimes the adapter will stop working (especially when transmitting). To solve this issue you can either use a powered USB hub or try a hack to boost the current provided to the USB ports on the Raspberry Pi.

Wednesday, July 18, 2012

Raspberry Pi USB Power Issues - Ultimate Solution

Update: This modification will probably void your warranty and comes with no guarantees. Use at your own risk.
I have been struggling with USB power issues with my Raspberry Pi for weeks now. I had issues getting USB Wi-Fi adapters and Bluetooth Adapters working. I would have issues when using non-powered USB hubs. The Wi-fi adapter would freeze and start producing USB errors when trying to download files.
The recommended solution from the Raspberry Pi foundation is to use a powered USB Hub. So I ended up buying the Gear Head 4-Port Powered USB Hub. It solved all my problems. This solution was frustrating because of its price ($20 = 50% of the Raspberry Pi price!), and how large it was. Here is a picture of my make-shift Lego Raspberry Pi case with powered USB Hub:
Eventually I stumbled upon a thread on the Raspberry Pi forums discussing USB power issues. There are a number of proposed solutions, but the the one that worked best for me was suggested by user mahjongg. The solution is to solder a 1 ohm 1/4Watt resistor in parallel to each of the F1 and F2 fuses.
To understand why this works, one must understand what causes the USB power issues. The Raspberry Pi has 2 fuses (F1, F2 on the board) which are used to limit the current supplied to the 2 USB ports on the board. The fuse resistance increases linearly with applied current up to a maximum of about 7 ohms. A 7 ohm resistance at 100mA causes a 0.7V drop. This will cause the voltage being supplied on the USB port to be 4.3V which is too low for most USB devices. The fuse is designed to limit USB current to 100mA. This is much less than what is needed by a Wi-fi adapter.
By attaching a 1Ohm resistor in parallel, we reduce the maximum voltage drop at 100mA to 0.1V only, and at 300mA to 0.3V. This will allow a voltage of 4.9V and 4.7V respectively to be seen by the USB device at those 2 currents. These voltages are okay for most USB devices. Below are a couple pictures of my modification.
After performing this mod, I no longer have any USB power issues. I can use a non-powered USB hub, wi-fi adapters, and bluetooth adapters with no problems. I can also hot-swap USB devices without reboots. I no longer require the powered USB hub. As a result, I re-configured my Lego case to be much smaller.
Please note that if you are using high power USB peripherals, your power supply for the Raspberry Pi itself should be up to snuff. The Raspbery Pi on its own uses 500mA. So if your USB peripheral is using 300mA, I would suggest using a 1A power supply at a minimum.
Thanks to mahjongg on the Raspberry Pi forums for this great tip!

Friday, June 29, 2012

First Post

This is a content-less first post just so that I can figure out what my blog will look like.