Building a portable Raspberry Pi workstation from a foldable 4.3″ screen

For ages, I’ve been meaning to take one of these 4.3 inch TFT screens and embed a Raspberry Pi inside it. I realise, of course, that the resolution of the screen isn’t anything much (certainly not “high resolution” as it states on the description!) at 480px x 272px (ish) but it’s very cute the way it just “pops up” when you press the button and there seemed to be enough space in the bottom for a Pi. So, I went ahead and bought one. It arrived the next day and I went down to The Den (my shed) to take it apart. On opening my tool draw, I found a foldable 4.3″ screen… that’s right… I’d bought something I already owned… Never mind, eh!

The base

I took the bottom off it and took a look to see what the possibilities were. To my surprise, the screen driver board was tiny (more on that later) and there was plenty of room. Not for a full Pi 3, maybe, with it’s pre-soldered 40-pin header, but a Zero W would fit in very comfortably. I took a rotary tool to some of the base plate supports (but not the screw ‘tubes’):

The driver board

The problem with these mini-screens is that they are primarily designed to be used as reversing-camera screens inside cars. That means that they are expecting a 12V power supply. They come with a cable that contains two composite inputs and a barrel jack for a 12V supply. This cable is pre-soldered onto the driver board. I knew, based on the work of other people (including SK Pang, way back when) that the screen is actually powered from 5V. So, the 12V supply must be converted into 5V by components on the controller board. Knowing that I’d need to solder onto the board, I un-stuck it from the base and inspected it.

Apart from inspecting it, I de-soldered the cable from the pads top-right and then re-soldered a ground wire and a wire to be used for composite video. I then realised that, when I’d turned the board over, I’d subconsciously noticed something. You see the solder holes bottom right? They were labelled SDA, SCL, VCC33 and GND on the underside. That means that somewhere on the board was something to do with I2C. I wondered if, perhaps, the screen was powered from 3V3, rather than 5V. I could have gone to the bother of powering it up with 12V and finding a 5V point, but I thought, what the heck, I might as well see what happened.

To start with, when powered with 3V3 at that solder point, nothing happened. In fact, nothing happened when I then powered the screen with 12V. Odd, I thought. I wondered whether it needed a composite video input signal to activate the screen. So, I needed to check how the Zero’s composite video was output. I found this guide on Adafruit which told me the answer.

Close-up of the Zero. Composite video marked. Note: the signal line is on the left, the right-hand hole is ground.

Sure enough, when I manually held the composite wire and ground to the Zero in the correct place and powered the 3V3 point, the screen flickered to life. So, now I knew what I needed to do. I needed to connect the composite and ground from the Zero to the composite and ground wire already soldered and power the screen on the 3V3 line.

Power & LED

So, I needed to power both the Pi and the screen. I took the 3V3 for the screen off the 3V3 rail of the Pi and then hacked into a USB cable I had lying around for the 5V power for the Pi which would then go to a USB battery pack.

Oh, I decided to add an LED, because blinkies! There was, bizarrely, a speaker hole in the case… but no speaker. So, I decided to drill it out and add an LED with inline resistor. I passed the wires through the hole and then soldered it to GPIO 21 and GND, conveniently located at the end of the GPIO rows.

Here’s what it looked like when I finished hot-gluing everything down and rotary-tooling some holes in the base for the two USB ports.

I grabbed a microUSB shim so that I could connect up a wireless mini keyboard to my mini workstation.

And, finally, here’s a video of the workstation in use. The keyboard is actually wireless, but I hadn’t charged it, hence the cable!

New cooking add-on for the Raspberry Pi: presenting the pi-topCOOKER

This was, obviously, an April Fools Day joke, courtesy of the good folks over at pi-top! Hope you enjoyed it as much as I did!

Pure genius from pi-top today. They have released a fantastic new add on for the Raspberry Pi. Called the pi-topCOOKER, it slides onto the rail of your pi-top and harnesses the power of the new cooling bridge. The heat generated is fed onto a conductive plate on top of the COOKER allowing you to cook food with your pi-top!

They’ve gone further and developed recipes and teaching resources that will teach you how to cook!

It’s simply amazing what they’ve achieved. Let the hyper-enthusiastic Cat Lamin tell you all about it in the video below. You can buy the board from all good stockists and, of course, from pi-top themselves 🙂

The MagPi issue 68 is out – explore the Raspberry Pi 3B+ and see a preview of Pi Wars 2018

Issue 68 of the Raspberry Pi magazine The MagPi is out. Inside is a feature on the new Raspberry Pi 3B+ and a massive 8-page spread on Pi Wars, the Raspberry Pi-powered robotics competition that myself and Tim Richardson run which is coming up on 21st & 22nd April. (Get tickets to watch here!) Plenty of other features, projects, news and reviews are in there too! Download a copy here or buy it from newsagents or online.

Heart-rate monitor uses a Wemos, a small OLED display and MicroPython

This is one of my rare not-strictly-Raspberry-Pi blog posts. Although using a Wemos, because the programming is in Micro Python, it wouldn’t be difficult to convert to using, say, an MCP3008 chip to read the analog values and then GPIO Zero to access the converted digital reading.

Martin Fitzpatrick has taken a Wemos D1 Mini and flashed Micro Python to it (you can find out how to do that from a Raspberry Pi or other Linux machine here). He’s then taken a Pulsesensor analog heart rate sensor and wired it up to the Wemos’ power pins and analog input. A bit of maths later and he has the heart rate detected and flashing the Wemos’ built-in LED. He’s then taken a small OLED display, displayed the pulse as a graph and worked out the average beats per minute. The cute little heart in the corner is a nice touch. You can find out how to do it yourself over on his blog.

Norwich Raspberry Jam (Thorpe) – Saturday, 5th May

Jools Bamford has started up a new Raspberry Jam in Thorpe, Norwich. The event, which is happening on Saturday, 5th May from 10am-1pm, takes place at Thorpe St Andrew High School and Sixth Form. Thorpe is located in East Norwich, just off the ring road. They’re hoping to run workshops and drop-in sessions and have a show and tell area. The event is completely free, but you will need a ticket – you can get them from Eventbrite. For those of you on Twitter, you can reach Jools on @ThorpeRaspberry.

palmPi – (yet another) handheld Raspberry Pi device

I recently posted a tutorial on using an HD44780 LCD (with I2C backpack) with the Raspberry Pi. I mentioned at the time that I had also been looking at small enclosures for the Pi in the hope of making something. Well, in a few hours of spare time I had in between bouts of Pi Wars admin, I dug out my soldering iron, rotary tool and various other oddments and made something I’m calling palmPi.

Bill of materials

Tools used

Construction – Hardware

Preparation

First of all, I soldered a 40-pin male header onto the Raspberry Pi Zero W and a female header onto the perma proto board. This means I could connect the proto board to the Pi Zero. I could have soldered everything together permanently first of all, but I wanted to use a Raspberry Pi 3 to do the installs and programming on to start with as it’s a lot quicker than the Pi Zero. I also (very loosely) placed all the components inside the case to make sure they’d fit in the space.

LCD

The first thing I did was to make sure that I could get some output on the screen. I used my own tutorial for the HD44780 and wired up jumper cables to the pins, bending them down slightly to get the right angle.

I managed to lose the little jumper that enabled the LCD back light (doh!) so I just plugged an extra F-F jumper cable in to connect the two pins. I cut the ends off and stripped the four main jumper wires and then tinned the stranded ends to make them easier to work with. This requires a fair amount of skill because you don’t want to make them too thick otherwise they won’t go through the proto board. Having established (by plugging directly into the Pi) that the screen worked, I soldered the LCD wires to the proto board so that it was more permanent. I hot-glued the screen into the pre-cut hole in the enclosure. It’s not perfect, but it will do for me. The alternative was to get Tim to laser-cut me something that would fit snuggly but what with Pi Wars, I didn’t want to add to his workload!

Button

I knew that, at the very least, I wanted a button to shutdown the Pi safely. I looked through my (large) collection of buttons and decided to use an illuminated button (obviously because I wanted the extra soldering practice..!)

I soldered four wires to the bottom of the button and then heat-shrinked the terminals. I then soldered the wires onto the perma proto board – I used two GPIO pins, one for the LED so I could blink it and one to read the actual button press. Don’t do what I did and forget to put the washer back on beforehand otherwise you’ll have to do what I did and hot-glue the button in place!) At this point, I realised I should have soldered an inline resistor for the LED, but knew from past experience that it wasn’t the end of the world (he says, hoping that’s true). If you’re doing this yourself, use 220 ohms, or similar, on the ground lead.

On/off switch

The whole project is run off a LiPo battery connected via a PowerBoost 1000C which is able to supply 5V at 1A, just enough for a Pi Zero W. One of the nice things about the 1000C is that it has pins that disconnect the battery entirely from your Pi and other hardware. You can read about all those pins over on the Adafruit site. So, I soldered wires to the switch, heat-shrinked them and then soldered the other ends to the PowerBoost. The other nice thing is that the board has an LED status indicator that lights up if the output power is switched on. So, I was able to test out the switch independently of booting up the Pi. I then got the rotary tool out and drilled holes for the button and the switch. I’ve decided my rotary tool skills need… improving… There’s a bit of air around the illuminated button. Oops!

BMP280

The BMP280 is a nice little breakout board which lets you have the sensor output over I2C. Again, I soldered wires to the breakout board, drilled a hole with the rotary tool, passed them through and soldered them onto the perma proto. Taking the do-a-little, test-a-little approach, I made sure that the sensor was being picked up:

i2cdetect -y 1

…and that sensor readings were coming through to the Pi using code (of which more later).

Analog

To read from the TMP36 sensor, I needed to add an analog-to-digital converter. I had some ADS1115/1015 boards left over from another project and these give you four analog channels. I soldered the ADS directly onto the perma proto board using pass-through headers to save on vertical space inside the case.

I then took the TMP36 sensor, looked up the pin-outs again (sigh) and soldered it to channel A0 on the perma proto board, 3v3 and GND.

Once again, I checked to make sure I could read the output and then realised that I needed to work out the conversion from the ADS reading to the actual temperature. (Eurgh! Maths!) That nifty bit of manipulation was contained in a function:

adc = Adafruit_ADS1x15.ADS1015()

def read_internal_temperature():
  ADC_GAIN = 2
  adc_reading = adc.read_adc(0, gain=ADC_GAIN)
  adc_mv = ((adc_reading * 2.048)/2048) * 1000

  temp_c = (adc_mv - 500) / 10
  temp_f = (temp_c * 1.8) + 32

  return "{:+.2f}".format(temp_c), "{:+.2f}".format(temp_f)

Power

As well as the on/off switch enable pins, I also soldered the 5V and GND pins from the PowerBoost to the 5V and GND rails on the perma proto, thus powering the Pi from the battery. Up until then, I had powered the Pi (and everything else) from a normal PSU. The nice thing about the on/off switch at this point is that you can hook the battery up, but leave it toggled off using the on/off switch and still power the Pi and sensors etc from the mains. Always consider whether running off the battery is a good idea at any point – you don’t want the battery to run down and for the Pi to crash in the middle of editing your code! If you’re running a Pi 3 off one of these batteries, you will not only get under-power warnings but the battery won’t last for very long.

I’ve just realised I forgot to wire up the low-battery-warning pin to a GPIO – I’ll take it apart later and do that!

After getting everything soldered up and finished, I then rotary cut another hole in the case for a power cable and then hot-glued the PowerBoost to the case. I was quite chuffed – everything is attached to the top half of the case, meaning that I can take the bottom on and off without pulling any wires out! Here’s a picture of the PowerBoost (it’s that shadowed blue bit in the centre, at the bottom) in it’s final place beneath the main perma proto and the Pi Zero W.

And here is a final picture of the innards. The LCD is on the left and you can see the on/off toggle switch at the bottom, the illuminated button at the top and then the perma proto (with hidden Pi Zero underneath) on the right. The bit of electrical tape on the proto is where I’ve temporarily attached the battery to the proto board for storage.

Software

The main structure of the program is similar to that which I wrote for the Picorder but it’s a lot simpler because I’m using fewer sensors. It sets everything up then loops through, getting readings from the sensors and outputting them to the LCD.

To read the BMP280, I pulled in some code from Matt Hawkins (Raspberry Pi Spy). It’s a great mini-library which reads all the sensor outputs and returns them from a function. You can find out how it works over on Matt’s blog. I carried out a little bit of updating to get it to Python 3-standards.

To read the ADS1115 analog values, I installed and used an Adafruit library which is handily documented over on their learning platform.

I decided at this point that I wanted to log the sensor readings to an online platform. I chose Initial State. I’ve been following them for a couple of years and it’s a very mature platform. It’s also free to use up to a point and would suit my purposes. My code sets up a new ‘thread’ (a separate process, sort of) to take and log the readings to Initial State. This is a very simple implementation and doesn’t do much more than log the readings and then wait for 15 minutes before logging again. You can see one of the graphs it produces below:

And you can see the configurable dashboard with all the readings on below:

All of my code is available here on GitHub.

Yes, I have left my Initial State bucket credentials in there! I’m not paying for my plan and you can’t see the output anyway. Normally, you wouldn’t do this, you’d put them in a config file and set-up a .gitignore file to not commit those.

Update: I’ve now added code that tweets the startup, sensor readings and shutdown. For this, I followed the instructions on this page for the Twython library.

See it in action

I’m sure by now you’d like to actually see the palmPi in all its glory! Or maybe not, but anyway, here goes!