SD2IEC for Commodore 64

After winning a cheap bid on a Commodore 64 off eBay  the other day I’ve looked into  building a SD2IEC.

The SD2IEC is a storage device using an SD card and interfacing with the IEC bus using a ATMega644 microcontroller.

I used most of the information from 16 Bit Dust .  Looking at the schematic I already had most of components.

I already had a SD Card with a built in 3.3 voltage regulator so did’t need to add this into the build. Also used the ATMega1284



First step is to program the microcontroller with a bootloader.   Having already built a USB Tiny ISP it was a simple step to program it. Schematic for this I got from AdaFruit

Bootloader files are available from  

Download /bootloader/, extract the files and write

newboot-0.4.1-larsp-m644p.hex  to the microcontroller. I used avrdude:

avrdude -c usbtiny -p m1284 -e -V -U flash:w:newboot-0.4.1-larsp-m1284p.hex

avrdude -c usbtiny -p m1284 -U lfuse:w:0xd7:m -U hfuse:w:0xd2:m -U efuse:w:0xfc:m


Next comes building the circuit. I used a veroboard and there were not that many components to add.  Didn’t have to use R1-R6 as they were already on the SD Card.


Data cable pinouts

Power cable pinout

Not as pretty as the bought ones but it didn’t cost me anything to build and was a fun project.

After assembling copy the S2IEC firmware to the root of the SD Card. Power on and the red LED will flash for two seconds while it looks for a valid firmware. The green LED should then flash while it accesses the card. When it starts to flash the firmware the green LED will flash rapidly.

To test if the computer is successfully connecting to the SD2IEC device you can use the following simple program:

10 OPEN15,8,15:INPUT#15,A$,B$,C$,D$

20 CLOSE15

30 PRINT A$,B$,C$,D$


This will print the current SD2IEC firmware to the screen.

Building TZXDuino

To load programs on the AZ Spectrum you need a cassette player…or so I thought.


Came across TZXDuino which lets you play files from the SD card using an Arduino and a amplifier.


Rigged this up in a morning and it works beautifully. I updated the code to use a LCD 16×2 without I2C.

Its fairly easy to build and uses:

  • Arduino Mini Pro
  • SD Card
  • LCD 16×2
  • 5 x buttons
  • LM386 amplifier (Circuit from StackExchange)



Programming the 28C256

Not having a programmer for this chip I decided to  use my Arduino. After trying out various projects on the internet I eventually came across TommyPROM which uses 74LS164 serial to parallel shift registers. Wired up to my Arduino Uno, fired up TerraTerm  and uploaded the diagnostic ROM to the 28C256.

The 28C256 is a reflashable  EEPROM and almost the same pinouts as the 27C256 (OTP)

To replace the 27C256 with the 28C256 you need to go the following:

From StackExchange:

Comparing them side by side you can see the differences:

  • The ’27 has: a. pin #1, Vpp which in circuit is not used (either Gnd or Vcc) b. pin #27, A14 which is a driven address line.
  • The ’28 has: a. pin #1, A14 is a driven address line. b. pin #27, /WE Which must be tied high in circuit.


When you place the ’28 in circuit you must:

  • Lift pin #1 of the ’28 so it does not contact the Vpp pad
  • Lift Pin # 27 of the ’28 so that it does not contact the A14 Pad
  • solder or join or bridge the lifted pin 27 to Pin #28 of the ’28 (tying /WE high)
  • connect the PAD at Pin location #27 on the board with a blue wire to the lifted pin #1 of the ’28.


Spectrum RGB DIN to SCART Pinouts

After looking on the internet there seems to be a lot of confusing information on the pinouts for building a DIN to SCART cable. I’ve looked through the harlequin schematic and SCART pinouts and it should be as follows:

Spectrum Harlequin RGB DIN to SCART
DIN  ———–> SCART PIN – SCART Function
Pin 1 ———–> pin 5, 9, 13, 17 Ground
Pin 2 ———–> pin 8 — Switching (need +5V to +8V for on @ 16:9 or +9.5V to +12V for on @ 4:3)
Pin 3 ———–> pin 16 — Blanking (need +1V to +3V to select RGB mode)
Pin 4 ———–> pin 11 — Green video
Pin 5 ———–> pin 2 (Right), pin 6 (Left) audio
Pin 6 ———–> pin 15 — Red video
Pin 7 ———–> pin 7 — Blue video
Pin 8 ———–> pin 20 — Composite sync

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:

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

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: (ESP8266_Arduino_Uno_Hello_00.ino)

More to follow.