Raspberry Pi: Headless Remote Desktop

So, I see the newest Raspbian comes preinstalled with RealVNC and in Headless mode, it doesnt bring up a desktop. Sigh, I got work to do, don’t have time to deal with forced-on-users commercial shit (Just a way to get you to buy RealVNC – F*ck you Eben)

So, lets get rid of it (:

First up, lets install TightVNC – XRDP doesn’t play nice if RealVNC is installed and has a dependency on TightVNC.  Installing it, removes RealVNC for you (:

sudo apt install -y tightvncserver

Next, lets install XRDP – just makes it easier to use RDP (built into all OS’s) without having to install a VNC viewer on PCs you want to use to connect to the headless pi

sudo apt install -y xrdp

That’s it actually!

Fire up a RDP Client (start, run, mstsc) and connect to the IP of your Pi!


Lipo Charge/Boost/Protect board in 18650 cell holder format


Disclaimer:  The circuit in use here came from GreatScott: YouTube video related to this project: https://www.youtube.com/watch?v=Fj0XuYiE7HU
Thanks for the circuit GreatScott, it really works well!  The awesome find of the lipo (LI-ion, sorry, Thanks to Jenny from Hackaday for pointing out the oversight in battery chemistry) protection chip with 2.9v cutoff – ruined way too many cells with the DW01’s 2.5v!

So, down to business:  We all know the frustration of trying to run portable electronics, whether handheld Pi’s or trying to use a cheap reverse-lcd as an extra cheap DSLR Monitor (My primary use case for making these – the one linked runs off 5v input too, perfect for Pi projects etc too) from Lithium cells:

  • You need to provide a charger circuit to safely charge using the correct CC/CV charge cycle
  • The cell needs to be protected against shorts, overcharge, overdischarge, etc
  • Boost the voltage to (usually) 5v – most widgets work with at least 5v or up.

In the past I used to use Protected Lithium Cells (Way more $$$ than salvaged or unprotected cells) and stick in both a MT3608 Boost Circuit and a TP4056 charger circuit.   Bulky, but it did the job (most of the time). Later on, China started adding protection circuits on the TP4056 boards. But the circuit was based around the DW01 protection IC which only cuts off the cell at 2.5v discharged level.   Not good for the life of your cells ):

So couple months ago, GreatScott made a video where he designed a circuit.  Nothing too innovative, just the same TP4056 charger the MT3608 Boost combined on one PCB.  He did add a Lipo  (Correction Li-ion) protection circuit though, initially using the same DW01.  But then, the Aha moment from this video, he found a footprint compatible IC the FS312F-G – which is set at 2.9v! Way healthier for your cell’s longevity!

First of all I had to redraw all his work in Eagle (As I wont be using a cloud based service like EasyEDA for obvious reasons) and then order the PCBs. I added two boost circuits since I had the board space, as I can imagine needing dual voltages at some point (for example if that reverse LCD needed 12v and the Pi needed 5v – i could run both off one board.

I decided to make the form factor fit onto these nice 18650 cell holders, as around here 18650s can be had for free from salvaged laptop batteries quite easily.

Here’s the Eagle files:  Feel free to go make your own!


If you don’t like Google Drive, here’s a Github repo too https://github.com/openbuilds-engineer/LIPOManager

Update: Sunday 27 May:  Featured on Hackaday: https://hackaday.com/2018/05/27/a-li-ion-booster-pack-done-right/ so lets add some more pictures taken since the original article:


Using it to power the reverse LCD mentioned above to run a RetroPie rig

And, I used it to power the super awesome $30 DSO150 Pocket Oscilloscope by just changing the resistors on the MT3608’s output, to set its output voltage to 9v


Using HY28B / Texy 2.8 TFT with Raspbian Jessie 2017-04-10

I have been lazy… I admit…I havent updated my Pis in over a year!

So, with great eager I started yesterday, by downloading the latest Rasbian 2017-04-10 image thinking, well, this will be quick (:
How wrong was I!  I only just finished up with the first one!


Why this long? Well, the underpants-devs (aka linux developers = pimply guys sitting in their underpants in their mom’s basement) again went and changed a tonne of stuff without updating the docs and tutorials we all rely on. Fuck you linux devs… fuck you


Anyway, figured I’ll document what worked for me – maybe it helps someone else with the HY28B, Texy 2.8, or other ILI9325 based TFTs


  1. Write a fresh SD with the latest Rasbian Jessie (This worked with 2017-04-10… if the underpants-devs have their way, please consider this already broken, again) (fuck you underpants-devs)
  2. Put a blank file called ‘ssh’ in the boot partition before you eject the SD.   Yip those underpants-kids figured they’ll vent some of their anger about all the teasing at school, on you, by disabling SSH until you do! Urrrg.  “security” “iot” fuck… Anyway, if Rasbian sees /boot/ssh it enables SSH…
  3. Once finally booted up, SSH into the Pi
  4.  sudo nano /boot/config.txt
  5. add a new overlay:
  6. Edit the kernel command line
    sudo nano /boot/cmdline.txt
  7. at the end of the line, add:
     fbcon=map:10 fbcon=font:VGA8X8
  8. Change the font:
    sudo dpkg-reconfigure console-setup
  9. Go through the following menu choices:
    Encoding to use on the console: <UTF-8>
    Character set to support: <Guess optimal character set>
    Font for the console: Terminus (default is VGA)
    Font size: 6×12 (framebuffer only)
  10. Install packages needed for touch
    sudo apt-get update
    sudo apt-get install libts-bin evtest xinput
  11. Install the ‘evdev’ touch drivers
     sudo apt-get install xserver-xorg-input-evdev
  12. To calibrate the touch panel for non-X based use
    sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_calibrate
  13. Edit
    sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf

    and change the line

    Option "fbdev" "/dev/fb0"


    Option "fbdev" "/dev/fb1"
  14. Enable X Windows
    sudo raspi-config
  15. Enable boot to GUI
  16. Reboot
  17. At this point the Desktop should launch in the TFT but touch calibration will be way messed up
  18. Install calibration tool:
    sudo apt-get install -y xinput-calibrator
  19. Change the input driver to evdev
    sudo nano /usr/share/X11/xorg.conf.d/40-libinput.conf
  20. At the bottom, look for the section dealing with “touchscreen” (ie ignore touchpad, pointer and keyboard)
  21. In the touchpad section, change the driver to evdev
  22. Section "InputClass"
     Identifier "libinput touchscreen catchall"
     MatchIsTouchscreen "on"
     MatchDevicePath "/dev/input/event*"
     #commented out# Driver "libinput"
     Driver "evdev"
  23. Reboot
  24. When the UI comes up, use a mouse to open a terminal and run
    'sudo xinput_calibrator'
  25. Copy the

    output from the terminal and paste in a new file:


    For Example:

    Section "InputClass"
      Identifier "calibration"
      MatchProduct "ADS7846 Touchscreen"
      Option "Calibration" "338 3879 198 3667"
      Option "SwapAxes" "1"
  26. Reboot one last time.
  27. When it comes up, touchscreen should at last be working!
  28. Install packages needed for Kiosk
     sudo apt-get install -y x11-xserver-utils unclutter
  29. Create/edit the file located here:
    nano /home/pi/.config/lxsession/LXDE-pi/autostart

    So that the file has this in it:

    @lxpanel --profile LXDE-pi
    @pcmanfm --desktop --profile LXDE-pi
    #@xscreensaver -no-splash
    @xset s off
    @xset -dpms
    @xset s noblank
    @sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/chromium/Default/Preferences
    @chromium-browser --incognito --noerrdialogs --kiosk bloggerbrothers.com
    @unclutter -idle 0.1 -root

Raspbian Jessie as OpenHAB + MQTT Server: Part 3: Add Websockets

Nowhere near completely usable, BUT, what IS working so far:

  • Websocket javascript with Paho library subscribes succesfully to the Websocket listener on Mosquitto
  • I can subscribe, and recieve all the published messages on the HAB
  • I am using the data received, to dynamically, and automatically, build up a device tree – it looks at the topic path (remember how a year a ago I wrote a post about why the topic name is important (; – here you see why – from the topic names i can deduce the entire hierarchy automatically)
  • Clicking any item in the tree brings ip a CONTROL interface – to be extended with sensorvalues, etc
  • The basic concept here is working great – by setting my devices to announce themselves, or response to a broadcast requesting them to announce themselves, I can cut a LOT of configuration out – theoretically I can have a new device connect to MQTT, send the page its name, location, connected devices, what those devices are (switch, dimmer, sensor, or actuator) and the javascript can automagically make a UI for it. This means you can mostly get away without a server, without a database.

Source being shared here: https://github.com/openhardwarecoza/ESP8266-Sketches/tree/master/htt-websocket-esp8266


Raspbian Jessie as OpenHAB + MQTT Server: Part 2: Add OpenHAB

I’ll be very brief on Part 2:  Since I already wrote extensively on the install and configuration:

sudo apt-get update
 sudo apt-get install oracle-java8-jdk
sudo update-java-alternatives -s jdk-8-oracle-arm-vfp-hflt
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add -
echo "deb http://dl.bintray.com/openhab/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/openhab.list
sudo apt-get update
sudo apt-get install openhab-runtime
sudo service openhab status
sudo service openhab start

See https://openhardwarecoza.wordpress.com/2015/03/29/openhab-mqtt-arduino-and-esp8266-part-1-setting-up-your-environment/ for more details on configuring OpenHAB


Raspbian Jessie as OpenHAB + MQTT Server: Part 1: Add Websockets!

My home automation system has been running stable for well over a year, but the versions of the software in use have started to show age.   For that matter, the hardware too.   I have been using an old Cubieboard A10 board to run OpenHAB +Mosquitto on, and lately, its been needing a reboot every now and then to keep on working

The friendly folks at FabCreator.com donated a new Raspberry Pi 3 to the LaserWeb project, so with that upgrade, I now have a spare Raspberry Pi B+ available (no longer in use for LaserWeb development) so I decided to repurpose this old B+ into a new OpenHAB+Mosquitto server.  Also, in the year or so since my last install, Mosquitto now comes with WebSocket support.  This is something I REALLY want to play with – would help a lot for adding quick dashboards onto the HAB (Not HAB – as in Home Automation Bus…  not OpenHAB – with WebSockets I can choose to listen in on the MQTT layer, and either just display updates, or also send MQTT messages to the broker, and in turn to the devices or the OpenHAB server. )

So, here we go:

1.  I downloaded Rasbian Jessie from Raspberrypi.org

2.  I burned it to an SD card with Win32DiskImager and booted up the Raspberry Pi B+

3.  Next, I configured a static IP, and did some standard setup (expand filesystem, allocate memory for headless use, overclock to medium, etc)

Install Mosquitto with WebSocket Support

The version of Mosquitto in the RPi repos doesnt support Websockets, so first we need to add a Repo from mosquitto.org, then install Mosquitto

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients

Note: At the time of writing this gave me  Mosquitto version 1.4.9 (build date Fri, 03 Jun 2016 09:02:12 +0100)

Enable Websocket Support

Open the Mosquitto config in your favourite editor

sudo nano /etc/mosquitto/mosquitto.conf

By default, mosquitto comes without any listeners.  We want to add two listeners:  one standard MQTT protocol listener on port 1883,    and a second listener on port 1884 (for the Websocket protocol)

Your config file should look something like this:  Once done, save and exit.














Restart mosquitto:

sudo service mosquitto restart

If you want to confirm that worked, run:

sudo netstat -nlp | grep mosquitto






As you can see in the screenshot above, both :1883 and :1884 are listening (:

Now, if you are anything like me, you’re probably anxious to test that newfound feature first right? Lets test that Websocket Connection!
But i’m also lazy, so lets test it without a single line of code (;

Head over to http://mitsuruog.github.io/what-mqtt/

Enter your local Websocket IP and connect. Subscribe and publish – see if it works (: – mine did! First try, this went easier than I expected



Check out my collection on Google Plus: https://plus.google.com/collection/ERlkgB for more details!


16 - 1 (1)