I've always been a big fan of small portable computers/gadgets with proper hardware keyboards. So at some point I decided it would be fun to make something like that. My main use case for a device like this is flashing and debugging some embedded device in the field without the need to bring my laptop.
Note: this article will go through the build process and some interesting details. For those who aren't interested in details, the summary of used components and the code/3D models are at the end of the article.
Note: I did a talk about this at DORS/CLUC 2019 conference. Slides are available at https://bit.ly/hgtermslides and video will be available in a week or so.
EDIT 2019-05-08: here's the talk from the DORS/CLUC2019 conference: https://www.youtube-nocookie.com/watch?v=_vco84tjuYo
2019-05-14: this page got featured on Hackaday.com: https://hackaday.com/2019/05/14/this-is-the-raspberry-pi-mini-laptop-that-we-want 2019-05-16: got featured on Liliputing: https://liliputing.com/2019/05/hgterm-converts-a-raspberry-pi-into-a-versatile-handheld-computer.html 2019-05-16: got featured on ZDNet: https://www.zdnet.com/article/using-raspberry-pi-and-a-3d-printed-case-this-guys-made-a-slick-mini-laptop/
Table of Contents
Hardware
Since this should be a device for field use I had some requirements:
- long battery life (at least 5-6 hours)
- reasonable performance
- power management (shutdown, battery charging, battery monitoring)
- high resolution touch screen
- hardware keyboard
- GPIOs, analog inputs, serial port
- "stand mode" where display can be opened up to 270°
- SD card reader (TODO)
- proper sound (TODO)
There are many similar projects to this one (most notably NODE terminal and NanoPi2 UMPC) but they don't really fit the requirements listed above (mainly due to the small battery and lack of I/O).
For the display I chose Pimoroni's Hyperpixel4, 4" display with capacitive touch and 800x480 resolution. The screen looks beautiful but it takes pretty much all of the Raspberry's GPIO pins. The good thing is that it exposes one I2C bus which can then be used for GPIOs. The first idea was to add an I2C port expander and ADC but I realized that a better option would be to add an Arduino board inside which would handle power management, GPIOs and analog inputs as an I2C slave device which I can query from Pi. That, together with USB-serial converter, would cover the I/O needs. Display connects to Pi's GPIO port directly which means that Pi will go to the device's "lid" and bottom part will contain battery and keyboard.
For keyboard I went with small Rii bluetooth keyboard I found on Aliexpress as it has all the standard keys (Ctrl, Alt, Meta, function keys, ...) and backlight. The good thing (which is also a bad thing) is that since it is wireless it only requires power to work. But it will often go into the power saving mode and takes few seconds to wake up. I had an idea to attach a microcontroller directly to keyboard matrix but that would be a whole project by itself. Also, there is an unpopulated pin header on the keyboard PCB which might be used to re-flash the onboard controller – I should investigate it at some point.
Here we can see the display, Raspberry Pi, keyboard (with battery underneath it), an RTC circuit (Adafruit PiRTC), Arduino Pro Mini and power management board.
I decided to go with Raspberry Pi 3 board. Using Raspberry Pi Zero would save a lot of space but the performance would be awful. Going with 3B+ would increase performance a bit but at the expense of higher power usage.
To make everything as small and as tightly packed as possible, the Pi had to be "prepared". This means everything that takes up space (and isn't needed) goes away: USB ports (we'll have only one), ethernet port (WiFi is enough and USB-ethernet can be plugged if needed), HDMI (only one display can be active at a time), camera and display connector (don't need them) and audio connector (onboard sound is terrible, TODO: add USB sound card). I even cut the GPIO pins to some 60% and removed the plastic which holds header pins.
All of that was done to make the display fit as close as possible to the Pi and the final result was some 5mm of space between the two (ignoring the height of components). And this is the space where everything else should fit.
Power
The power supply was an interesting story. At first I planned to use a powerbank – I had a Canyon 4000mAh powerbank which had a four LED status indicator and a power key for which I figured out how it could be triggered from the Arduino board (for cutting off the power). It also had some unneeded features like fast charging. So, to get everything as small as possible I started cutting away the "unneeded parts". In the picture below everything was still working and I should've stopped at that point. But I haven't.
Next try was with Xiaomi 5000mAh powerbank which had the same looking features (LED indicators and a power button) but it turned out the button isn't useful for cutting the power as it powered on again as soon as it detected there is even slight power draw. But the battery from this powerbank was really nice (5000mAh and just a little bit smaller than the keyboard) so I decided to use it in the build. For the power management board in the end I went with Adafruit's Powerboost 1000C (which I should've done immediately).
Using Kicad I made a schematic of the connections inside. Power management part was inspired by lipopi project but with a few differences. When the power button is pressed it connects Powerboost's enable input to the battery which enables the Powerboost board. EN pin is pulled high to arduino board's power supply but the pin 8 can be used to pull it low and turn it off. Pin 9 is used to detect the state of the power button so that the shutdown procedure can be triggered when the key is pressed but also the "hard poweroff" (in case Pi isn't responding) can be done by holding the power button for a few seconds.
Fitting everything
When trying to fit a bunch of small boards (Powerboost, RTC, arduino, USB-Serial) in the space between Pi and display, one quickly realizes it's actually not that easy – small boards need to be carefully placed at the right positions so they don't collide with components on the Pi board. This required a lot of the display dettach-attach cycles and resulted in damaged screen (I think I damaged the flat cables at one point). On the other side, now that the screen was broken I could test everything in a more relaxed manner and, when everything works, just put in a working screen (easier said than done :)).
Thermal
One important thing to consider is the thermal management. When loaded, Pi tends to heat up quite well and that heat somehow needs to be removed from it. In a local electronic store called Chipoteka I found small copper heatsinks with adhesive on one side and mounted two of them onto the main CPU. But, since there will be no air flow inside the enclosure this only increased the thermal capacity but didn't handle the cooling. So I decided to add an alluminum plate on the other side of the Pi and thermally "connect" it to the Pi using thermally conductive pad (ARCTIC thermal pad). The image below shows temperature rise across six minute when all four cores are fully loaded (while the enclosure is closed). We see that it gets to about 73°C and stays there which isn't perfect but it's good enough.
Testing
Next step was to put in the new display and finish up all the connections. This included adding the power management resistors and battery voltage measurement resistors (soldered them directly to the boards).
Enclosure
I built the 3D model of enclosure in FreeCad and 3D printed it on Anycubic i3 mega 3D printer. "Double" hinges allow the screen to fully open to "stand mode". FreeCad model and printable files are available in the git repository.
Final assembly
Final step was to assemble everything.
Software
There are few required software components:
- GUI
- RTC
- Arduino code (power management and GPIOs)
- display brightness
- battery status panel widget
- system service for handling power button
- other software
For the GUI I went with standard Raspbian distribution and replaced Openbox
windows manager with i3 as tiling WM better fits the
small screen. Here is a guide
on how to replace the window manager. However, one step is missing – at the
begining one needs to copy the /etc/xdg/lxsession
to ~/.config/
to get
the default configuration.
Hyperpixel screen and RTC are installed by using the scripts linked on the
product pages. One thing to note: since the Hyperpixel display creates new I2C
bus (/dev/i2c-3
) the PiRTC will not work by default but loading and enabling
the module in /etc/rc.local
fixes this.
Hyperpixel's backlight brightness can be adjusted using PWM on pin 19. I added
tools/brightness.py
script which handles this and I'm triggering it from
keyboard using Win++
and Win+-
key combinations.
I also assigned xdotool click 3
command to Win+,
key combination which
enables me to use right click when needed (touch the screen to position the
cursor and hit the key combo to simulate right click).
In Arduino, available GPIOs are exposed as I2C registers. Check the
tools/arduino
sketch in the repository for the details.
There is an LX panel widget in tools/lxpanel-battery
. Currently
it only displays the battery voltage. At some point I'll have to record the
voltage during the discharge and convert it to percentage.
Besides that, I've installed standard Arduino GUI, platform IO and the open source FPGA toolchain. And of course, the Retropie.
Videos
Following YouTube videos show the process of Arduino programming (using platformIO), ULX3S FPGA board flashing and playing a game in emulator.
Summary
I'm very happy with the results. The device is quite thick and heavy (mostly due to the huge battery) but fits nicely in the hand. And the keyboard is much more usable than standard smartphone on-screen keyboard.
Used components:
- Raspberry Pi 3B
- Hyperpixel4
- PiRTC
- PowerBoost 1000C
- USB-serial
- Arduino Pro Mini
- Rii i5BT(518) Mini Bluetooth Wireless Keyboard
Repository with code and 3D models: https://bitbucket.org/igor_b/hgterm/
Comments
52 Comments
This is beautiful. Could you offer some guidance on performing that surgery on the Pi? I have destroyed a couple of them trying to do the same thing. I couldn't suck enough solder away to loosen those components! Very high melting point.
It was quite tricky to remove all and I did break some of the pads. The trick is to "flood" it with new solder, instead of sucking it out, so you have a big melted blob of it and then it's easier to remove the components. I used 80W soldering iron set to some 380°C. Also, cut as much of the metal parts as you can with cutting pliers prior to removing the components.
Firstly Well Done Igor !! this creation looks like a SOLID piece of technology that appears to have been store bought - thats how good it looks !!!!
Absolutely Beautiful and well done with the case 3D Printed Designs and also keeping this open-source for anyone wishing to re-create it, totally blown-away man !!!
I also have a Tip for easier de-soldering of parts. There is this stuff you can buy, called Chip-Quik, its a solder-based metal that STAYS molten for a good few seconds when youve taken the heat of the soldering tip off of the pad your heating up, like 10-12 seconds BUT ===---->> this stuff is EXPENSIVE..
The solution, is to buy BISMUTH metal samples from ebay, and then melt some of this onto your soldering iron tip then apply it to whatever you are desoldering and now you have all the power of Chip-Quik WITHOUT the ABSURDLY HIGH PRICE TAG !!!!
Bismuth is relatively cheap compared to the official Chip-Quik AND by weight you get a LOT more Bismuth if bought like this, Bismuth is the metal that stays liquid long after the soldering tip is removed from the component/PCB, i bought 100 grams of Bismuth YEARS ago and still have half left lol
So it lasts you ages too without hurting the wallet lol
Anyhoo, once again thanks for sharing your awesome design, its just gorgeous !!!
forgot to give a linked example, DO NOT BUY The CRYSTALS, make sure its the actual metal Bismuth, like this listing on ebay:
wow, that's a really great tip! thanks! I'll definitely try it out.
Sorry, but no. It takes too much effort and I've already built it so I have no desire to do it again :)
hvala! :) inače, nađe nas se iz hrv tu i tamo. npr, trenutno 2. i 5. mjesto hackadayevog natječaja su hrvatski projekti: https://prize.supplyframe.com/
je je, Radiona ti je zakon (ja sam jedan od prvih članova :)). baš mi je drago da si bio na izložbi. ne sjećam se što je tamo bilo, ali vrlo vjerojatno je i neki moj rad bio izložen.
there's a list of used components under Summary section so you can purchase them anywhere (I got most of them on Mouser and AliExpress)
i am working on the same project and i am at a standstill with the display and enclosure. For the display I purchased an hdmi display bc i heard the pi display port was mainly for proprietary displays. The issue i have with that the u shape hdmi adapter increases the height of the display. I am considering a alternatives and the only viable option I can come up with is to remove the hdmi port and solder the connections directly, which isnt easy IMO bc the pin pads are tiny. The enclosure is another issue i have. I had intended on making it by hand using acrylic, since i have no experience with 3D printing or CAD building. Also, I am having second thoughts about quality. Ideally i would like something more refined so i don't have to build another one again. I took a look at your CAD file and i had hope to adapt it the dimensions of my project, but I am lost. A side note, have you considered using a digitized keyboard? I incorporated it into my project because i thought it would cut down on space and thought it would look great flushed with the enclosure.
cool! after i built this i found this project https://www.thingiverse.com/thing:2430252 which uses HDMI display but replaced the HDMI connector with flat cable (similar to your idea). regarding my 3D modelling skills I'm not very good in FreeCAD so I haven't done it the best/smartest way which makes it harder to change and adapt to something else (I also had troubles when I had to change something deep down in object hierarchy). for keyboard, this was the best one I found (actually, finding this keyboard started it all). I would really like if it was normal wired keyboard as this bluetooth one has a lot of downsides (biggest one being entering power save mode after few seconds of inactivity so it needs some time to wake up) but I couldn't find any. which one are you using?
yup that is what i thought as well, so i got wireless keyboard with a dongle. https://www.amazon.com/dp/B0776T8QDC/ref=cm_sw_r_em_apa_i_qYF3CbEGGHT7M
I tore it apart and reduced it to two boards. the digitized keyboard and controller. I accidentally ripped off the an pin pad while trying to salavge some switches. Somehow I randomly found a way place to bypass it and saved it. when i tested against a bluetooth keyboard i got annoyed that its sleep function was too frequent and to reconnect would be a constant annoyance. So instead, i am dedicating a usb port to house the dongle and hide it within the enclosure and expose the remaining 3.
i don't really like that one as there's tactile feedback so it's like typing on touch screen which I really don't like :). it would be great to find this keyboard I used but just the key matrix without the bluetooth part although the chance for that is really low.
Thank you for taking your time and sharing about your project with us. It will be a big help for a lot of young programmers like us.
my pleasure :)
Amazing!! You are a genius. I wish i could have half the good ideas you have and be able to accomplish them. By the way, is it possible to use the phone screen as the screen for this invention? Regards!
thanks! unfortunately phone screen can't be used.
If you feel hard to remove connectors from Raspberry Pi by soldering work, you can purchase a customized Raspberry Pi without any connectors on it. Check here: https://www.physical-computing.jp/product/1268
wow, that's really cool! I didn't know about that. thanks for sharing!
i already had some of the used stuff, but it should be something like $150 plus raspberry, shipping, 3d printing (plus cost of the stuff you break during the build phase :))
Well done, been holding out on attempting this but with the release of the RPI4 I've been looking at it again. Do you think you'll update/make a new version with an RPI4?
thanks! i don't think i'll do it with pi4 (even though it's a great upgrade) for the same reason i avoided 3b+ - it has a higher current draw and heats up more which doesn't go well with battery power and tight enclosure. but i started working on a big improvement so maybe i'll have something much better in the upcoming months.
When I use the same keyboard with a HyperPixel 4.0 screen the keyboard mapping is wrong. For instance, I press the shifted 2 and get a double quote (") instead of At Sign (@). How did you fix this?
You need to change the keyboard layout. I actually like " as shift+2 as it is croatian layout and I set it like that. To change the layout to USuse "setxkbmap us" command (or set it using raspi-config in localization options)
haven't tried it but probably not without modifying the case
Was the internal battery removed from the bank and then wired to the adafruit? Or was the whole battery housing and the board inside used?
yes, the battery was taken from the powerbank and wired to powerboost pcb