Tag : Hardware

IR LEDs for a Pi NoIR Camera

For a while now I’ve been meaning to put together a board with a few IR LEDs for a Pi NoIR Camera…

The Pi NoIR camera is an add on for the Raspberry Pi that uses the CSI-2 camera interface on the Pi. It’s just like a normal camera except it has no IR filter (hence NoIR).
This means it can capture in the IR range as well as the visible light range of the spectrum. This is good for dark or nighttime shots where you can ‘light up’ the scene with IR light (that is not visible to the human eye) instead of ‘normal’ visible (white) light.

The Pi NoIR Camera itself does not come with any IR light source. So for nighttime photography is pretty useless on it’s own.

The IR LEDs for a Pi NoIR Camera circuit is pretty simple to build. A few IR LEDs (I got some from Amazon that draw about 20mA and drop somewhere between 1.2 to 1.4 volts) and some resistors. Each LED needs it’s own current limiting resistor (this question gives a good explanation of why). You could just run the LEDs and resistors from a +5v and ground connection directly. However I wanted the LEDs to be switchable by a GPIO pin. As I planned to use 4 LEDs I’d need to be switching ~80mA so I’d need a transistor. The transistor would be driven from a GPIO pin so I’d need a resistor there too.

The circuit I put together look like this:

IR LEDs for a Pi NoIR Camera - Circuit

Calculating the resistor values was pretty easy.

IR LED current limiting resistors

We know the LEDs draw up to 20mA (0.02 A) and drop between 1.2 and 1.4 volts. We want to drive them close to 20mA to get maximum brightness from them.

5v – 1.3v (average) = 3.7v / 0.02 A = 185 Ohms. So I selected 220 Ohms to be on the safe side.

Transistor base resistor

We want the current on the base to be limited to a reasonable value so that we’re not pulling too much from the GPIO pin.
With an HFE of around 100, a 2N2222 only needs about 1mA to drive 100mA through the load. I may add more LEDs in the future, so I opted for something that would give me ~4mA at the base.

3.3v – 0.6v = 2.7v / 0.004 A = 675 Ohms. So I opted for 560 Ohms which will give around 4.8mA.

I soldered this all up on some veroboard with 3 header pins to connect up the +5v, Gnd and GPIO pin:

IR LEDs for a Pi NoIR Camera - Veroboard

Next, I connected it up to my Raspberry Pi (GPIO pin 23) and set that GPIO to an output and high. Switched off the lights. Took a raspistill image on my other Pi (with the NoIR camera connected) and you can see it works :

IR LEDs for a Pi NoIR Camera - Result

So, the little IR LEDs for a Pi NoIR Camera project was completed in an hour or so. Next up will be something a bit more complex (for me) – trying some outdoor, nighttime photography…

Raspberry Pi with a RDA5708 FM Radio Module

I’ve been playing around with getting a Raspberry Pi with a RDA5708 FM Radio module working.

Raspberry Pi with a RDA5708 FM Radio

I bought 2 of them from ebay for around £7. They took around 2 weeks to arrive (from China).
Wiring them up is pretty simple. They are controlled via I2C, so only need SDA, SCL and power (3v3 and Gnd). Audio out is via a standard 3.5mm headphone socket and it has pin holes for a 3 pin header providing Left, Right and Ground.

It took me a little while to get things going and working out the correct command sequences to send it. When that was cracked it was pretty much plain sailing. The resulting audio is fine (for a small radio). The headphones also act as a decent antenna for radio reception, so no need for connecting an antenna for testing.

Raspberry Pi with a RDA5708 FM Radio : Getting it working

I will post a fuller tutorial later but getting it working boiled down to 3 steps:

  1. Send the correct initialisation commands (0x00, 0xC0, 0x02, 0x00, 0x00, 0x04, 0x00, 0xC3, 0xA7, 0x60, 0x00, wait 500mS then send 0x00, 0xC0, 0x01)
  2. Set the desired frequency and set the tune bit (there is a specific algorithm for it, but it is pretty simple to implement).
  3. Set the desired volume (least significant nibble of one of the registers)

There is a bunch more to do in terms of measuring signal strength, scanning frequencies etc. That said, for quickness, the 3 steps above will get you listening to your favourite station. Some of these modules also have RDS capabilitiy but I do not think the particular version I got has this. It may have and I just don’t yet know how to turn it on – more experimenting required.

Sample code will be posted to GitHub in the next few days is on GitHub

I have a project in progress where I’m replacing the ‘guts’ of a vintage Roberts Rambler II Radio (from the 70’s) with this module.

How To Make A Raspberry Pi Shutdown Button

After one too many times of forgetting to shutdown my (headless) Raspberry Pi before shutting down my PC/laptop (and resorting to just pulling the power plug), I decided I needed a button to shut it down gracefully – a ‘Raspberry Pi Shutdown Button’…

There’s lots of solutions around for this, but I decided to re-invent the wheel (as usual)…

Making a Raspberry Pi Shutdown Button

This is a fairly simple project, with a little bit of easy soldering required. I had all the bits I needed laying around in various component boxes. It’s not a lot and is likely to cost less than £1 for one. However, typically, you can’t buy these items in ones, they come in quantities of twenty or fifty. Even so the total cost should be much less than £10 and you’ll have a bunch of useful parts left over.
Here’s the list of what you’ll need (with links to buy the components if you don’t have them):

Raspberry Pi Shutdown Button - Parts

Step 1 – The Button.

First we work out which legs of the button are shorted when the button is pushed. Using the multi-meter determine which two pins get shorted together when the button is pushed. There will be two sets of 2 pins that get shorted (as the button has four legs). We only need one set, so the other two legs we simply break off (bending them back and forward multiple times works well).

Step 2 – The Jumper Wire.

The jumper wire gets folded in half and cut in two at the middle point, so that we have two bits of similar lengths, each with the female connector on one end. The other end we strip two or three millimeters of insulation from. As an aside, I like to use yellow or white for these kind of things as Red, Green, Black all make me think ‘power supply lines’.

Step 3 – The Heat Shrink Tubing.

For the thinner piece (2mm diameter) of tubing, we cut it in half (so each piece is around 20mm long). For the thicker piece (6mm diameter), we cut it into two lengths, one is 1/3 and the other is 2/3 (so for a 40mm long piece, one of the cut pieces would be about 13mm long and the other 27mm long). Lengths do not have to be accurate – these figures are just a guide (we can be a bit ‘rustic’).

Now we should have something like the image below.

Raspberry Pi Shutdown Button - Cutting

Step 4 – Placing the Heat Shrink Tubing.

I usually find myself staring at some left heat shrink after I’ve finished soldering. Then realize that I forgot to put it on, and have to redo it all. So, make sure you put the heat shrink on first. You want to (in order):

  • Hold both wire lengths together and slip the thicker tubing over both (from the end with no connectors).
  • Now slip each thin bit of tubing over a different one of the wires.
  • All you should have left is the shorter, thicker bit of heat shrink tubing.

Raspberry Pi Shutdown Button - Wire Prep

Step 5 – Soldering Time.

The soldering involved is really easy. Essentially you want one wire connected to each leg of the button. It doesn’t matter which way around it is.

  • ‘Tin’ the ends of both wires.
  • ‘Tin’ both the button legs.
  • Solder a wire to each leg.

Step 6 – Shrinking.

All that is left on the hardware side is to shrink the tubing. You need to push the two thinner pieces (one on each wire) as far as possible towards the button legs. Try to ensure that there is no bare wire or bare leg visible. Now shrink both of those so that they hold tight. Next push the thicker tubing over the two bits you just shrunk. It doesn’t have to go all the way. It is more just to hold the wires together. Now shrink that too.

Now the final shorter, thicker bit of tubing I push over the two connectors (it should be a fairly tight fit). This just makes it easier to insert the connector as one unit rather than as two separate wires.

Raspberry Pi Shutdown Button - Wiring Done

Great the hardware is now done. You can place the connector onto P1 connector pins 20 (Ground) and 22 (GPIO 25) and we can write the software that monitors the button and does the shutdown.

Raspberry Pi Shutdown Button - Plugged In 1Raspberry Pi Shutdown Button - Plugged In 2

Step 7 – The Software.

So, our button is connected between GPIO 25 and ground. We’ll want our software to:

  • Set up GPIO 25 as an input.
  • Set up GPIO 25 as pulled high by default
  • Wait for GPIO 25 to go low (button pressed)
  • Make sure GPIO 25 stays low for a set time (to avoid shutdowns on accidental presses)

I’m going to do this in a simple bash script. I’m also going to make sure the script runs when the Raspberry Pi boots.

To set and monitor the GPIO pins we’re going to use the ‘gpio’ utility that ships with Raspbian Jesse.
We’re going to check every second to see if the pin is low. If it is we’re going to check again in another 5 seconds that it is still low. If that is the case then we are going to shutdown (and halt).
We’ll keep it user friendly by issuing a terminal message to all users when the shutdown happens.

Here is the code for the script (shutdown.sh)

#!/bin/bash

# Raspberry Pi Shutdown Button Script

# Wait for a minute – to let everything settle.
sleep(60)

# Set up GPIO pin 25 as input and pull-up
gpio -g mode 25 in
gpio -g mode 25 up
sleep(5)

# wait for pin to go low
while [ true ]
do
if [ “$(gpio -g read 25)” == ‘0’ ]
then
echo “Hold button to shutdown Pi…”
sleep 5
if [ “$(gpio -g read 25)” == “0” ]
then
echo “Raspberry Pi Shutting Down!”
sudo halt &
exit 0
fi
fi
sleep 1
done

When you have written the script make sure you make it executable:

chmod +x shutdown.sh

To ensure it runs on every boot you need to edit your /etc/rc.local file, so in terminal type:

sudo nano /etc/rc.local

and add the following to the end of the file, but before the final ‘exit 0’ line:

# Raspberry Pi Shutdown Button Monitor Script
printf “Starting Raspberry Pi Shutdown Button Monitor Script”
sudo /home/pi/shutdown.sh &

That’s us done. You now have a button that you can hold for ~5 seconds and it will cleanly shutdown your Raspberry Pi.

If you want to make things a little neater you can use some hot glue to secure your button to the case you are using. I glued mine to the end of the case, above the micro USB power connector. All it needed was a small dab for the base of the button and a small dab for the wires to hold it straight. There is less chance of it being mistakenly pressed when glued there, and it’s out the way. It looks pretty clean there too.

Raspberry Pi Shutdown Button - Finished

Raspberry Pi Outdoor Music Player Project

This project, a Raspberry Pi Outdoor Music Player had been germinating in my mind for a while. We’d had a few BBQs and found that running an extension outside to plug the iPod and speaker system into was a bit of a pain.

Requirements

I had seen a whole bunch of MP3 players housed in old / up-cycled ammo boxes, and I wanted something similar. The thing I wasn’t too keen on was most of them only had play/pause and fwd/back buttons. I wanted something that I could play music on, have playlists and stream internet radio on. So the requirements list was shaping up a bit like this:

  • 6 to 8 hours battery life (and batteries that could be easily swapped / recharged).
  • Internet access (for streaming radio stations).
  • Web front end (for control, generating playlists etc.)
  • Reasonable volume (enough to be heard at a family BBQ, and but not enough to annoy the neighbours).
  • Rugged enclosure, that can handle itself outside.

The Parts

IMG_20160704_194517

Enclosure

Whilst an ammo box is rugged and cool, I wasn’t too sure how a Wi-Fi adapter would fare trying to get a decent signal from inside a metal box. So, something else was needed, something rugged and non metal. Looking around the garage I spied some old plastic boxes that housed power tools. One of those would be ideal. I chose a Bosch Cordless Drill/Driver box that was empty anyway. If I hacked it about, it wouldn’t be a big loss if anything went wrong and I had to bin it.

Brain

This was a ‘no brainer’ (pun intended) – I would use a Raspberry Pi. I had a spare Model B+ (with 2 USB ports), so I could attach a Wi-Fi USB dongle and a USB memory stick to hold a local music library. That also allows me to change / improve the software as needed, and it can play from the local library, stream from the garage server, or Google Play Music, and the GPIO pins would allow me to drive a LCD display to show track information etc. if I chose to do that in the future. The Raspberry Pi also has an audio out jack, so driving the amp / speakers wouldn’t be an issue.

For software I decided to go with MPD (Music Player Daemon). This is fairly ubiquitous in Raspberry Pi Music Systems, and rightly so. It gets the job done well, has a ton of clients across all platforms and is easy to get installed working. For the front end I found ympd which is a great application, single file, self contained that you run and it acts as a web server (so no apache, nginx, lighttp needed) listening on a port of your choice. The UI has a nice clean functional look too.The only issue is that it doesn’t (yet) do playlist management/creation (I’ll be looking into adding that later).

Amplifier

The audio output from the Raspberry Pi itself is fine for headphones, but is not really good enough to drive a set of speakers directly. So, I wanted to feed a stereo audio amplifier from the Pi and have the amplifier drive the speakers. Initially I went with a 12 volt 15watt amplifier module, but after a few problems with this (see below), I swapped to one of these 5 volt stereo 3W=3W watt amplifier modules.

Speakers

For the speakers I needed something that fitted into the space available in the plastic case, and that would fit into a flat area on the outer part of the case. I found some 4 inch 4 Ohm speakers from Maplin, for the princely sum of £2.99 each. They were a perfect fit for the space I had available in the box. If you can’t get them from Maplin they you can try these from Amazon.

Battery

I originally planned to use some spare LiPo batteries that I had laying around. I had 2200mAh 3S batteries available that would provide around 11-13 volts. After having audio noise problems (see build below) trying to use a DC-DC (buck) converter to get this down to 5 volts for the Raspberry Pi, I abandoned this and reverted to an Anker 20,600mAh portable battery pack that I had anyway. I normally carry this portable charger around with me, and when needed in the Raspberry Pi Outdoor Music Player I just plug it in and we’re ready to go. I may have to buy one to keep in the box rather than swapping it around every time.

The Raspberry Pi Outdoor Music Player Build

I put this project together in 3 stages, each of around 1 hour.

Stage 1 – Case Mods

The first part of this was to cut out cardboard templates for the speakers – this allowed me to place them on the case and see where the best fit was. When I was happy with the position I then marked it and cut the holes. For the cutting I started each with a holes drilled all the way around, then did the rest with a Stanley knife / box cutter.

IMG_20160704_194603IMG_20160704_194627IMG_20160704_195944IMG_20160704_201928IMG_20160704_201945

Next was the internal case mods. This will vary depending on the case you use. For me the plastic risers and dividers inside were thin enough to cut with the Stanley knife, so it was a quick job. Just find suitable spaces for the Raspberry Pi, the amp, the battery and cut those to the size required. You’ll also want to cut out some routing for the power and audio cables. I routed these around the outside of the box, but whatever suits you best.
Note: Initially I mounted the 15W amp on it’s side, screwed into one of the dividers (see image below), but the 3W+3W (smaller) amp had an adjustable pot on it and was designed to be mount through the chassis.

raspberry pi outdoor music player

15W 12v Amp mounted

raspberry pi outdoor music player

6W 5v Amp mounted

 

The final product looked like this:

IMG_20160724_102922

Stage 2 – Connecting Everything

This stage required a little soldering. Basically I took a 3.5mm audio cable I had laying around and cut off one end. I then found the right connections for Ground, Left Audio and Right Audio and soldered those to a 3 pin header socket I had. This was then connected to the 3 pin header on the amp board. The output of the amp board is a + and – audio signal for each channel. I used 2 pin cables to plug into the headers on the board, cut off the other ends and soldered the cables directly to the speaker + and – tabs.

For Raspberry Pi power I ran a USB to micro USB cable from the battery to the Raspberry Pi (just as you normally would). For the power to the amp board, I first considered hacking about another USB to micro USB cable. Then I remembered I had some little micro USB socket boards that I’d bought in bulk some time ago. I plugged in the second USB to micro USB cable to that board and soldered the +5V and Ground connections from that board to the amp board.

IMG_20160913_131031

Everything was now connected  – time to start on the software side.

Stage 3 – The Software

This is still a (kind of) work in progress stage. To get the first version working I installed mpd and the command line client (mpc) on the Raspberry Pi:

sudo apt-get install mpd mpc

Next I used the command line client to add a stream (Heart Radio) and told it to play:

mpc add http://media-ice.musicradio.com/HeartBerkshireMP3
mpc play

Not much happened at first, but I turned up the volume on the amp board (using the on board potentiometer) and then it worked well, so I knew I had things connected and working correctly.

So far so good, but I didn’t want to be SSHing into the Raspberry Pi to add or change songs. I also wanted to get a local cache of all my music on there. A 64GB USB stick would easily hold my music collection with room to grow. So, I copied all music from my home server to the USB stick and inserted it into a USB socket. You could also simply copy all your music onto the Raspberry Pi SD card itself (assuming you have enough spare storage). The default location that MPD looks for music files is /var/lib/mpd/music so best to copy your files there.
If you go the USB route then you have to tell mpd where the base folder is for your music. This is done in the config file, so a few more commands at the terminal:

sudo nano /etc/mpd.conf

Now find the line with the setting music_directory and edit the path to your USB drive. On my machine that was /mnt/usb/music. You may have to restart the mpd daemon after this, to do so:

sudo service mpd restart

That sorts out the playing of music, now we just need a simple way for a user to interact with it. For that I wanted a web interface, so that anyone (of my family or guests) could connect and chose songs to add to the queue. Initially I thought that would mean a full blown web server, database, PHP stack, however a google around found me ympd. This a self contained app that uses web sockets to serve up web pages dynamically. The author has done a really neat job of using bootstrap and JavaScript to provide a clean and functional user interface.

ympd_ss

There are simple instructions on the website to get this installed and running. Essentially, download it, extract it and run it.
I wanted it to be run automatically so I moved the app :

mv ympd /usr/bin

… and the made it automatically start with :

sudo crontab –e

… then added

@reboot /usr/bin/ympd –webport 90

to a new line at the end of the file and saved/exited.

With all that set up you should be able to use a browser to navigate to your Raspberry Pi. I gave mine a hostname of musicpi, so I simply browse to http://musicpi.local. From the web interface you can control everything you need to. Of course, there are a ton of other clients available for mpd if you would rather control it directly from your mobile etc.

Aside – Audio Problems

It is probably worth noting that initially (with the 15W audio amp) I had a lot of noise and distortion. The amp I had chosen needed a 12v source, so I had used a 12v power supply and fed the amp as well as a DC-DC (buck) convertor to step the voltage down to 5V for the Raspberry Pi. I believe the buck converter is very noisy (switching) and this was causing the problem. As soon as I switched to the 5v amp the noise vanished. Bonus for only having a single supply voltage too.

Conclusion

IMG_20160721_230216

Overall, I’m really happy with the Raspberry Pi Outdoor Music Player Project result. A few spare (laying around) parts, combined with a cheap amp and speakers and a few hours of integrating it all together and I have a pretty cool music box. There are a few enhancements in the works for this too:

  • Change the case for an old 80s style ‘ghetto blaster’ radio cassette player.
  • [Possibly] Better working with playlists (creation, editing)
  • Some controls on the case for skipping forward/back or loading a specific playlist.
  • LCD display showing the current playlist/song/time remaining etc.

 

If you build one, or found this useful please comment below and leave a link for me to check out your project.

Raspberry Pi Zero USB Hub Hack

As much as we all love the Pi Zero, the connectivity options are very limited. With only one (micro) USB port (for peripherals) it means you need a micro <=> ‘normal’ USB adapter to get any of the usual accessories (keyboard, Wi-Fi dongle etc.) plugged in, and when you have that’s it – nothing else can be plugged in. Also, those little USB adapters just look a little bit to precarious for my liking. So, what I needed was a ‘Raspberry Pi Zero USB Hub Hack’.

I’d seen that the USB power and data lines are presented as pads on the board itself. I wasn’t alone in noticing this, and seemingly a bunch of people had success soldering on USB hubs directly. So I though I’d give it a go. I bought myself this little ‘no name’ 4 port USB2 hub from eBay for the princely sum of £2.09 (including delivery) – how they make any profit on these is beyond me.

IMG_20160705_201003IMG_20160705_201035

As soon as it arrived, I pulled the case apart exposing the board itself and cut the USB cable off. (NOTE: I probably should have tested it on the laptop, or Pi first, but I was a bit too eager).

IMG_20160705_201158IMG_20160705_201530

A simple soldering job had the 4 individual cables soldered to their respective pads on the Pi Zero. It wasn’t a great success to start with, as it was ‘hit and miss’ whether it showed up on the Pi after booting.

IMG_20160706_201802IMG_20160706_201856

I guessed that it was likely that not enough power was being delivered, to the hub, by the super thin cables. I decided to remove those completely and replace themwith some thicker cable to make sure there was enough power to the hub. I also used some thicker signal wire for the Data + and –.

IMG_20160707_134138IMG_20160707_134146

However, now it never showed up, not even for a short time.

lsusb

lsusb_no_hub

It looked like it was recognising that a hub was plugged in, but it saw it as a ‘new low-speed USB device’. The seller on eBay had advertised this as a high-speed hub, so the ‘low-speed’ was odd. I would also get a lot of ‘device descriptor read/64, error -71’ errors in dmesg when the hub did not show up.

dmesg | grep usb

dmesg_usb

Googling around suggested trying out a bunch of dwc_otg settings in cmdline.txt, but none of those seemed to work. I also switched it to low speed (dwc_otg.speed=1) and that didn’t help. I knew all the connects were good and there were not shorts, so I began to think I had killed the IC on the hub somehow.
A last ditch attempt was to swap around the Data + – wires. I didn’t expect this to work as it was being ‘seen’ by the Pi, just not working. I figured, how could it ‘see’ the hub without being able to read ‘something’ from it). WRONG….

Swapping round the Data + – wires brought it to life, every time I powered on the Pi. Excellent. So now a little tidying things up, getting some anti-static foam between the boards and squishing them together with and elastic band (temporary) got me to the finish line.

lsusb

lsusb_with_hub

dmesg | grep usb

dmesg_with_hub

Here are some pictures of the finished Raspberry Pi Zero USB Hack project (although it still needs tidying and a case etc.)…

IMG_20160707_134618IMG_20160707_134629IMG_20160707_134645IMG_20160707_134715IMG_20160707_134725

Next up is to replace one of the hub ports with a directly soldered Wi-Fi dongle. Watch this space…

Raspberry Pi Music Player Project–Stage 1

I had a couple of hours free this evening, and so began to do work on the first stage of the Raspberry Pi Music Player project. This was mostly the modifications to the plastic power tool case which is going to serve as the ‘enclosure’ for the Music Player project.
Here’s a few pictures of the work…

First thing to do was to cut out a template for the speakers to make the marking easier.

raspberry pi music player - template drawing 1raspberry pi music player - template drawing 2

I then used that template to mark out where I needed to cut on the plastic box. I used the Dremel (fantastic piece of kit) to drill round the edge of the speaker hole.

raspberry pi music player - cutting 1raspberry pi music player - cutting 2

The speaker was a good snug fit, with none of the rough edges showing. This probably needs a little tidying up of that edge up before the final version.

raspberry pi music player - speaker fitting

Same again for the second speaker. Next, I started on a hole for the On/Off switch which I wanted on the side of the box. This is a green, 12v rocker switch that illuminates when on.

raspberry pi music player - switch 1raspberry pi music player - switch 2

With that done, I moved on to a few internal cuts to make sure there was room for the Pi (Model B+). The stereo amplifier board needed some holes drilled in the case to mount it in. That was pretty much the first stage complete. Looks quite neat so far.

raspberry pi music player - cutting complete

Next, will be the internal wiring and setting up the software for the Raspberry Pi Music Player. For this I’ll be using MPD. Watch this space for the next update…

Update (Sept 2016): The full project write up can be found here.

Raspberry Pi Versions

To date (July 2016), there have been 8 versions of the Raspberry Pi. Below is an outline of each.

Raspberry Pi Model A

pi_a

The Model A sported the ARMv6 architecture (700MHz, single core ARM11) with a Broadcom BCM2835 SoC. It had 256MB of RAM and a 26 pin version of the header. Power was provided by the micro USB connector, video by the HDMI connector (supporting HDMI v1.3), a single USB port, composite video out RCA jack and a 3.5mm audio out connector. There is also a slot for a camera module and on board storage was via a slot for a full size SD Card. There was no Ethernet (RJ45) port on this model.

 

 

 

Raspberry Pi Model B

pi_b

The Model B also used the same ARMv6 architecture (700MHz, single core ARM11) with a Broadcom BCM2835 SoC as the Model A. It had increased memory to 512MB of RAM. The header is the same 26 pins as the Model A, but it had an additional 4 GPIO pins available via the P5 header (if you user was willing to solder the pins). HDMI, composite video, audio and SD card slot all remain the same, but the USB ports are increased to 2 and there is now a Ethernet (RJ45) connector on-board also.

 

 

 

Raspberry Pi Compute Module

pi_compute

The Compute Module is a full system on a device with only a 200 pin DDR2 SO-DIMM. This uses the same ARMv6 architecture (700MHz, single core ARM11) with a Broadcom BCM2835 SoC as the Model A and B, has 512MB RAM on-board as well as an on-board 4GB eMMC flash chip for storage. There are no on-board ports, but all the usual inputs and outputs (and more) are exposed as pins on the 200 SO-DIMM connector.

 

 

 

pi_b_plus

The Model B+ sported the same ARMv6 architecture (700MHz, single core ARM11) with a Broadcom BCM2835 SoC as the Model A and B. It had the increased memory of 512MB of RAM same as the Model B. Now has a 40 pin version of the header which exposed 9 more GPIO pins and support for the HAT ID bus. It now has 4 on-board USB ports, and the composite video out (RCA) plug had been removed and the composite video combined with the audio out in the 3.5 jack . There is also a slot for a camera module and on board storage was via a smaller slot for a micro size SD Card. There was an on-board Ethernet (RJ45) port on this model. Power consumption has been improved as has audio quality.

 

 

 

Raspberry Pi Model A+

pi_a_plus

The Model A+ sported the same ARMv6 architecture (700MHz, single core ARM11) with a Broadcom BCM2835 SoC as the Model A and B. It had the increased memory of 512MB of RAM same as the Model B, the same 40 pin version of the header as the Model B (exposing 9 more GPIO pins and support for the HAT ID bus). It retains the single USB port of the Model A, and the composite video out (RCA) plug had been removed and the composite video combined with the audio out in the 3.5 jack . There is also a slot for a camera module and on board storage was via a smaller slot for a micro size SD Card. There was no still Ethernet (RJ45) port on this model. Power consumption has been improved as has audio quality.

 

 

 

Raspberry Pi 2 (Model B)

pi_2

The second generation of the Model B moves to the ARMv7 architecture, using a quad core, 900MHz Cortex-A7 CPU and the Broadcom BCM2836 SoC. The memory is increased to 1GB, but all other hardware remains the same as the Model B+.

 

 

 

Raspberry Pi Zero

pi_z

The Raspberry Pi Zero,  which has a smaller footprint and less connectivity, is based on ARMv6 architecture for the original Model A and Model B, using 1GHz single core ARM11 device and the original Broadcom 2835 SoC. It had only 1 micro USB port (OTG mode) and a mini HDMI connector for video and audio. Additional (composite) video and audio are available via GPIO pins. A micro SD card slot is available for storage and by default the GPIO 40 pin connector is unpopulated.

 

 

 

Raspberry Pi 3 (Model B)

pi_2

The third generation of the Model B sees a move to the ARMv8 architecture, using a quad core, 1.2GHz 64 bit Cortex-A53 CPU and the Broadcom BCM2837 SoC. The memory stays at 1GB, and all other connectors and ports remains the same as the Pi 2 and Model B+. In addition, wireless networking (802.11n) and Bluetooth (4.1, BLE) are added.

Raspberry Pi P6 Reset Hack

I’ve been trying to get some code running on my Pi 2. The code has been ‘problematic’ to get running, and I’m running into frequent hangs on the Pi where I cannot initiate a new SSH or console session. It’s also complicated because the Pi is outside in the garage (I have a GPS hooked up so it needs some visibility of sky). That means that every time it hangs I have to head out to the garage, pull the micro USB cable, reinsert it and then start the whole ‘Edit, Compile, Run, Head out to the garage to Reset’ cycle again.

Anyway, in an effort to simplify things I was looking around for a way of remotely resetting the Pi without having a connection to it. I found a ton of sites talking about the P6/RUN header on the newer boards, but this was mostly just about adding pins to short out with a jumper or adding a momentary switch to do the same. What I wanted was something more like connecting an Arduino pin, or a pin from another Pi to the P6/RUN on the target Pi and forcing a reset that way. What I wanted was a “Raspberry Pi P6 Reset Hack” – unfortunately AdaFruit don’t sell a kit for that.PiP6PullUpResistor_thumb

I was initially concerned about the current that the watchdog Pi would have to sink on the GPIO0 pin, but looking at schematics it seems the RUN pin is pulled up to 3.3V by a 10K resistor – a little bit of Ohms law says this will mean 3.3v/10K = 0.33mA will flow, well within the recommended limits of the GPIO pins 2mA to 16mA

I have an ESP8266-12 laying around just waiting for this kind of thing, but for the sake of speed I opted for another Pi I had (already hooked up, working and configured). So this essentially came down to :

  • Solder header pins on the target Pi (the one to be reset)
  • Connect the grounds of the target and ‘watchdog’ Pis together
  • Connect a GPIO pin from the ‘watchdog’ Pi (GPIO0) to the RUN pin on the target Pi
  • Putting together a small app to force the GPIO0 pin low for a few milliseconds and then high again.

PiP6WithHeaderPins_thumb Pi2P6WithGndAndGpioConnected_thumb

For the app to be run on the ‘watchdog’ Pi, I’m making use of the excellent wiringPi library. Instructions for downloading and building it can be found at http://wiringpi.com/
The code for ‘reset-app’ is simply (nano reset-app.c):

 

#define <wiringPi.h> 
int main (void) 
{
      wiringPiSetup();
      pinMode(0, OUTPUT);
      digitalWrite(0, HIGH);
      delay(500);
      digitalWrite(0, LOW);
      delay(500);
      digitalWrite(0, HIGH);
      return 0; 
}

… then to build it just execute :

sudo gcc –Wall –o reset-app reset-app.c –lwiringPi

Now when my target Pi hangs I can just ssh into the watchdog Pi, and run sudo  ./reset-app  and the target Pi reboots.
Also, when I’m done with this testing/hanging stuff I may simply connect a switch to the header for ‘’future ‘just-in-case’ things…

DISCLAIMERS

This is a QuickAndNasty™ solution. I am not responsible for any damage to your Pi, your electrics, your health or anything else – anything you do as a result of reading this is at your own risk.
Using this to reset you Pi can result in SDcard corruption !!   All calculations are off the top of my head, and could be wrong.

There are a ton of things to improve it also:

  • It relies on the GPIO pin on the watchdog ‘floating high’ while it is an input – it really should be set as an output (HIGH) at start-up.
  • I’ve not tested what happens when the watchdog Pi reboots – there’s a chance (likelihood?) that it will reboot the target Pi.
  • The ‘reset-app’ can be improved (drastically!!)

EDIT: I have tested what happens when the watchdog Pi reboots and, for me, it does not reboot the target Pi – however there is a chance (likelihood ?) that it will reboot the target Pi.
Anyway – enjoy, and let me know if you found it useful….