ZX Spectrum Harlequin

After spending a good few hours reading up on retro computers and wanting to relive my childhood I’ve decided to give the ZX Spectrum Harlequin a go.

Yes, I know its probably cheaper to buy a complete assembled board or even a ZX Spectrum from eBay, but where is the fun in that!

There are many blogs and sites out there with a wealth on info so this should be a fun journey.

From ByteDelight:

A couple of years ago, Chris Smith reverse engineered the ZX Spectrum ULA (you can obtain the ZX Spectrum ULA Book to read about that).
Chris also developed the Harlequin: a ZX Spectrum 48K clone based on parts that replace the ULA, so no ULA is needed.
ZX Spectrum fans continued on this development which resulted in the design that is now known as the ‘Harlequin Superfo’. The current rev G is the most stable one.
You can now assemble a complete and 100% compatible ZX Spectrum 48K clone yourself!


I’ve decided to try and do this as cheaply as possibly and source the components from various locations.

First order of business. Order stuff!

  • Ordered Harlequin PCB from eBay for £15

  • Ordered ZX Spectrum case and keyboard from eBay for £10
  • For the parts list I started of with a bill of materials that Sergey Kiselev posted on his blog.

I already had some of these components  so managed to trim the list down. The remainder of the items I ordered from Mouser and eBay.  (Components mostly from China shipping time will be long but prepared to wait)

Link to my  Spectrum Harlequin BOM with prices.

I’ve also ordered a AT28C256 instead of the EPROM as this lets you reprogram the chip. The AT27C256 is a OTP.

Next, while I wait for parts I need to look it an Arduino based EEPROM programmer. Simple EEPROM Programmer from this site looks interesting.



3.5″ TFT Touchscreen for Raspberry Pi

I recently purchased one of these cheap 3.5″ TFT displays for the Raspberry Pi from eBay for £10 and spent many hours trawling the web trying to get it working.




This is a summary of all the steps I needed to follow from various sources.

Running the latest Debian Stretch Lite

First step is to install the Waveshare drivers:

wget http://www.waveshare.com/w/upload/9/9d/LCD-show-151020.tar.gz
tar xzvf LCD-show-151020.tar.gz
cd LCD-show
sudo ./LCD35-show

Raspberry Pi will then reboot.

Create udev rules:
sudo nano /etc/udev/rules.d/95-ads7846.rules


SUBSYSTEM==”input”, KERNEL==”event[0-9]*”, ATTRS{name}==”ADS7846*”, SYMLINK+=”input/touchscreen”

Reboot the Pi again.

Install dependencies for pygame

sudo apt-get install python-pip git libsdl-dev libsdl-image1.2-dev \
libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libportmidi-dev \
libavformat-dev libswscale-dev libjpeg-dev libfreetype6-dev \
evtest tslib libts-bin

The latest sdl libraries caused all sorts of issues with the touchscreen on Debian jessie/stretch. It works but the x/y values from the touchscreen were very intermittent.

Downgrading to sdl 1.2.15-5 fixed the issue. (More info here)

#enable wheezy package sources
echo "deb http://archive.raspbian.org/raspbian wheezy main
" > /etc/apt/sources.list.d/wheezy.list
#set stable as default package source (currently jessie)
echo "APT::Default-release \"stable\";
" > /etc/apt/apt.conf.d/10defaultRelease
#set the priority for libsdl from wheezy higher then the jessie package
echo "Package: libsdl1.2debian
Pin: release n=jessie
Pin-Priority: -10
Package: libsdl1.2debian
Pin: release n=wheezy
Pin-Priority: 900
" > /etc/apt/preferences.d/libsdl
apt-get update
apt-get -y --force-yes install libsdl1.2debian/wheezy

Once the library has been downgraded then it’s time to calibrate the touchscreen:
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 TSLIB_CALIBFILE=/etc/pointercal ts_calibrate

Follow the onscreen instructions to calibrate the TFT Screen.

Install pygame library required for python:
sudo pip install pygame

I then used the following code as an example to build a python driven menu for the Pi:

Temperature sensors using WeMos

After trying for a few months to get mysensors working on a Arduino mini pro with a NRF24L01+ I eventually gave up as the radio was too unstable. Works fine one day and next it loses communication. I tried all the tips and tricks to get these devices stable but had no luck. I now have a drawer full of them gathering dust.

There are loads of posts on various forums with various issues on the NRF24L01+

Next I tried a WeMOS D1 Mini Pro  which has a built in ESP8266 wifi module. This works great. I’ve now got 6 temperature sensors running and have they have been stable for 2 months so far.


The WeMOS is dirty cheap. You can find them all over eBay for $3-$4 with free shipping. They are stable, coding on them is really easy and there are plenty of examples of code on GitHub.

Description: The D1 mini is a mini wifi board based on ESP-8266EX.


  • 11 digital input/output pins, all pins have interrupt/pwm/I2C/one-wire supported(except D0)
  • 1 analog input(3.2V max input)
  • a Micro USB connection

The great thing is you can use the ArduinoIDE to program the WeMOS which makes it really simple.

I had a DS18B20 temperature sensor connected and up and running in no time.

To log the data I’ve setup Domotitz on a spare Raspberry Pi and the WeMOS sens the temperate to Domoticz via HTTP calls.


See my code on Github for my water sensor which words on the same principle as the temperature sensors.


ESP8266 + DS18B20 LUA code completed

This LUA code on the ESP works like a bomb – really simple and really stable.

The temperature sensors are connected directly to the ESP’s GPIO0 pin. This eliminates the need for an Arduino as all the work is done by the ESP.




After having struggled for many days with the instability of the ESP (I almost got some code going which read the DS18B20 sensors and upload the reads via the wifi, but the ESP kept resetting or returning unpredictable results) I did some more reading up and found these clever guys are now using the microcontroller on the ESP to do lots more things.


With NodeMcu firmware you can connect the DS18B20 sensors directly to the ESP and run LUA code. No more need for the Arduino and no more AT commands!!!

Check out this guys blog for how to flash the firmware.

You can also download this great GUI (ESPlorer) for sending LUA code to the ESP


A day later, no arduino, and I seem to have stable code uploading the results.

This is great! Time to order a few more of these modules!

ESP8266 Wifi Module

Came across this module while looking at how to connect the Arduino to the net. There are the quick and easy and expensive ways to do it, and then there is a ESP8266.

WiFi Serial Transceiver Module

This goes for around £3 on eBay so thought I’d get some of these and see if I can get it working with the Arduino.

There is a wealth of info on the net on these chips as it seems everyone is starting to use them now.

Thought I’d document my progress, hopefully it helps someone else out.

I have been messing around for a few days now and almost have something working. Its taken a while as there were quite a few issues. This module is still in the early days of development and there are a number of bugs with a few developers bringing out there own firmware.

Here is a list of useful sites I’ve been using:

First the module is powered by 3.3V. I connected it up to a USB to TTL cable and it kepts rebooting. After hours of trying to figure out the issue I found a web page in German which someone suggested setting the voltage to 3.4V. That worked perfectly – reboot loop fixed.

Commands working via the serial cable and module seems pretty stable.

Next problem I had was the the module comes with older firmware on where the baud rate is fixed at 115200. When using this with the Arduino Uno it seems to create problems as its too fast for the Software Serial.

First step – head over to electrodragon and grab v0.9.2.2 firmware and the flasher application. This was fairly straightforward. Flashed to newer firmware and set baud rate to 9600.

Now to get the Arduino to talk to the module – this is where the fun comes in. There are countless pieces of code out there and I think I”ve tried most of them without much success. A lot of programs just send the AT commands to the module without checking the response. I would like to read the repsonses and make the running of the code bullet proof.

The code here seems to almost do the trick. I can send commands to the module but most of the time I don’t get a proper reponse back (OK)

After some more reading and trying to figure out why things don’t work…..enter the level shifter.

Summed up very nicely here

Next I decided to build a quick level shifter using these diagrams

The 5V to 3.3V shifter worked great, but for some reason the 3.3V to 5V wasn’t working. Double, tripple checked everything – no go! 🙁

Eventually I tried the 3.3V to 5V from http://iot-playground.com/2-uncategorised/17-esp8266-wifi-module-and-5v-arduino-connection


The labels are incorrect here – it should be ESP_TX, ARDUINO_RX

This worked perfectly – I can now send a command to the module and read the response back via the software serial. (Though code from the next still does not seem to work)

Next step is to either write the code from the ground up, or try and work out why other peoples code doesn’t work.

Going to be going this code:
https://gist.github.com/roboticboyer/ (ESP8266_Arduino_Uno_Hello_00.ino)

More to follow.

Raspberry Pi script to get cpu/memory/uptime/memory

From a few goole sources I put this script together to grab the cpu temperature, utilization, free memory and uptime from my raspberry pi weather station and write the results to my MySQL database.

I will use this data at some stage in my Weather Station project.

# Script to get Raspberry Pi temperate, cpu, memory, uptime and save data
# to mysql on suse.home. This will be used my the weather station web site system infomation

# Get temperature
temp=`/opt/vc/bin/vcgencmd measure_temp | cut -c 6-9`

# Get Uptime and convert to day h m s

To use the mysql client on the Pi you will need to first install it with:
sudo apt-get install mysql-client

Raspberry Pi weather station

A few months ago I started putting together a R-Pi weather station using:

After a corrupted Pi SD Card and loosing the backups I’ve decided to restart this and will document everything this time. Its taken about half a day to just work out what libraries I was using. 🙁

Luckily I stored my code in Github

To start off download the latest version of Wheezy.

Update to the latest version.
apt-get update
apt-get upgrade

I came across this site to remove all the extra packages you dont need on the Pi (If you are not running GUI)

First setup the wireless dongle. I used a cheap RT5370 dongle from eBay which works great.

You will also need to install some libraries – took me ages to get it working at first. After this was installed it worked first time.
sudo apt-get install firmware-ralink

To get the BMP085 working via i2c, there are some setup steps that need to be performed.
I2C Installation for Raspberry Pi – Step by Step Guide

Also to read the MCP3008 chip there are some additional steps that need to be done. A script needs to run at startup.

The R-Pi collects all the data from the sensors and writes it to a MySQL database running on a internal server. I’m busy working on the php code for the weather front end so its a work in progress.

Netware 3.12 on the Raspberry Pi

After successfully booting Windws 1.01 – 95 on the Pi, for the next feat I decided to try and get Netware 3.12 booting.

This proved a challenge and took quite a few hours to get working. Initially I used the same method I did for the booting of Windows but when trying to get Netware running there were loads of abend issues when mounting the SYS volume.

The install was successful on Virtualbox but I ran into problems with the ATA driver – when using this and mounting the SYS volume there were disk errors would I tried to repair with vrepair but they just kept returning.

After reading through How To: install Novell Netware 3.x on VMware I decided to try loading the latest patches.

Update Netware 3.12

A good few hours later with the system patched I then used the IDEATA driver instead of the ATA driver and now the SYS volume was successfully mounted in VirtualBox!!!

I then copied over the vdi file to the Pi and ran under qemu.

Abends when the SYS volume was mounted! Agghh!!!

After retrying with the latest qemu (1.1.2) which still gave issues I then decided to give bochs a bash
Bochs is another open source emulator which luckily is already package so no need to compile. The latest version I used was 2.4.6-5

apt-get install bochs

A few more hours later after figuring out how bochs works – you need a .bochsrc file.

This site was helpful for the config of bochs.

Here’s what mine looks like:

romimage: file=/usr/share/bochs/BIOS-bochs-latest
display_library: sdl
log: bochsout.txt
ata0-master: type=disk, path=”netware.vdi”, mode=flat, cylinders=243, heads=16, spt=63
ata0-slave: type=cdrom, path=”Installation.img”, status=inserted
floppya: 1_44=”Disk1.img”, status=inserted
boot: disk

I then tried to run the vdi file with bochs….only to find out bochs doesn’t support vdi files. Luckily there is a VirtualBox tool that lets you convert the file to .img

vboxmanage clonehd source.vdi destination.img --format RAW

Changed the .bochrs file to
ata0-master: type=disk, path="netware.img", mode=flat, cylinders=243, heads=16, spt=63

Started bochs and waited a few mins….and what do you know. SYS vol mounted and Netware 3.12 booting!!!

Bochs seems a lot slower than qemu but as least its working (Takes about 8 mins to startup Netware)

I did some editing on the video and speeded some parts up.

Jump forward to see the Netware snake – should bring back some good memories for some.

Windows emulation on the Pi

After reading a few posts on the RaspBerry Pi forums from users who have gotten Win95 working on the R-Pi I decided to give it go and see if I could run Windows from v1.0 to 95.

Windows runs on the R-Pi via qemu but its really slow. This is really just to show that it can be done – its hardly usable though, especially Windows 95.

There are lots of helpful threads on getting this to work. I started off reading this one:

Win95 on the Pi

I also wanted to remote to my R-Pi via Xming which is really easy to do:
Xming to the Pi

My first attempt to get Win95 booting proved tricky but I eventually got it working with Qemu and a older version of Wheezy. For some reason Win95 kept crashing with the latest version of Wheezy

Here are the steps I used to get Windows 95 booting:

Downloaded 2013-09-10-wheezy-raspbian.zip

Expands FS

Do a apt-get update and apt-get upgrade

Windows 95 only successfully boots with Qemu 0.15.50. To install this you need to download from source and compile

Download older version of Qemuwget http://thoronir.net/raspi-dev/qemu-git.tar.bz2

Install libsdl sudo apt-get install libsdl1.2-dev

tar -xvf qemu-git.tar.bz2

cd qemu

./configure --target-list=i386-softmmu --enable-sdl --extra-cflags="-O3 -mfloat-abi=hard -mfpu=vfp -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -march=armv6zk"


After a few mins you will some errors – you will need to edit 2 files to get rid of these errors:

Edit qemu/tcg/arm/tcg-target.c and qemu\tcg\i386\tcg-target.c

Search for: static void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)

And replace with:

static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)

Run make and make installl which should now complete. It took around 15 mins to compile on my Pi.

Now that you qemu built, copy the Windows 95 img file to the Pi and run qemu win95.img -m 64

After successfully running Windows 95 I decided to try out Windows 1.01, 2.1, 2.11, Windows for Workgroups 3.1

All successfully booted and running on the Pi

I found the best way to create the images is to install VirtualBox and then setup Windows. Once you have it working copy over the vdi file to the R-Pi which you can then run with qemu.

Windows 1.01

Windows 2.1

Windows 2.11

Windows for Workgroups 3.1

Windows 95