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


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.


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!


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!


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).


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)


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.


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!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.