The BMP180 temperature/barometer sensor as a Unibus device on the PiDP-11


The first of (hopefully) many hardware hacks. This is mainly intended as a simple how-to for adding hardware stuff to the PiDP-11. Any i2c device (screens, sensors, whatnot) can be connected in a similarly easy fashion. And using a PiDP-11 instead of an Arduino has many, many compelling advantages:

  • 4 meg of RAM, infinite disk storage, proper languages, operating systems and assemblers, networking capability

  • Physically at least a factor 100 bigger in size than an Arduino. Size matters.

So, with the 'Why oh why' question out of the way, this is how to add an I2C peripheral to the PiDP-11 and get yourself a reason to do some PDP-11 programming afterwards! Please remember, when you see my code, this was intended to be the absolute minimum of simh programming - to show how minimal the effort is. It's a demonstration hack.



The BMP180 is a nifty little board. About 1*1cm, it fits everywhere and needs 4 wires to hook it up to the PiDP-11. Here (link) is its data sheet. On the PiDP-11, the required 3.3V, SDA and SCL lines can be found on the i2c connector footprint right above the GPIO connector.

Solder a 3 pin angled header on the i2c footprint as per the picture below.

The fourth required wire is GND, you can find a free GND pin on the serial console port for now.

Where to get them: Adafruit (link) but also on Aliexpress. This Aliexpress link will probably not last, but search for BMP180. They are around $0.90 including shipping... The board pictured has 5 pins as it offers on-board 5V-3.3V level conversion. You do not need that, the 4 pin boards are fine.

Software & explanation


The source files for the PiDP-11's simh emulator need a few modifications and additions.


First the practical steps: (they are detailed step-by-step in the downloadable pdp11_i2c.c)

  • Download the modified files here (link) and just copy them into the /opt/pidp11/src/02.3_simh/src/PDP11 directory, overwriting some old files. Note a few files will be added into a new i2c subdirectory.

  • Recompile the simh server.

    • For the 2019 software version: Here is an updated version of quickmake (link) you can copy into /opt/pidp11/src/02.3_simh/src. It will compile a version with the new wiringPi sources added.

    • (no longer relevant) For the 2018 'github' software version: Here is a convenient makefile (link) you can copy into /opt/pidp11/src/02.3_simh/src. It has the new wiringPi sources added, and the second time you run it, compiling simh will take only a few seconds as this makefile keeps unchanged .o files around. As opposed to the regular makefiles.


Before you do this, it makes sense to check the sensor really works, from the Pi rather than the PDP-11 environment. Adafruit has a good in-depth web page here,  but the steps are just (1) use raspi-config the check the i2c port is enabled; then do 'sudo apt-get install -y i2c-tools' and 'sudo i2cdetect -y 1'. All the other steps you read about were not needed in my case at least. If you see device 77 come up, all is good.

Using the BMP180 from the PDP-11:

You should write your own PDP-11 program, of course. But from the simh command line you can check the sensor output quickly. First, do 'help icr' to read about the new unibus device. Then, do 'att icr junk.txt' which will initialise the i2c driver. Yes, primitive. This is just a hack. The junk.txt file does nothing. Now, do 'ex 177716100' to see the temperature (times 10, in octal!) or 'ex 177716102' to read the air pressure (in octal, and in Pa. Divide by 10000 to get bar).

Explaining the code (so you can take i2c hacking further)

i2c devices on the Pi are best handled through Gordon Henderson's wiringPi (link). The files in the i2c subdirectory are from wiringPi, with only a few ugly modifications from me (apologies to Gordon). 

Within simh, only two steps are necessary:

  1. Make a new unibus device that the PDP-11 can read from/write to.

  2. Hook up that device to wiringPi's i2c functions. In this case, the BMP180 demo code in wiringPi.

1. Making a new unibus device:

The simh source code can be daunting. Luckily, you do not need to go into it much. Three steps are required to make a new device on the unibus that simh will use:

  • copy (for instance) the paper tape device (pdp11_pt.c) into a new file (pdp11_i2c.c) and modify it a bit to suit your needs. The bare minimum that is required can be seen in my pdp11_i2c.c; see the comments at the top of the file for details.

  • add your new device to the list of devices known to simh in pdp11_sys.c, just add an entry in "DEVICE *sim_devices[] = {", line 204.

  • add your device to the autoconfig device list in pdp11_io_lib.c, just before the last "NULL, -1 item", line 786. Just copy the PTP and PTR entries, and give them a new address to live on. 016100 is one you can use. The PDP-11 uses memory-mapped I/O, this is where the device will be mapped.

See - the simh source code may be tough to fathom sometimes, but flexible it is!

2. Hook it up to the wiringPi support code

I did this simply by inserting 'bmp180Setup (100);', the wiringPi i2c init call for the BMP180, into the attach function of the paper tape reader. And then, you can read the i2c device (logically, in the former paper tape's read function icr_rd) through a '*data = (int32) analogRead(100)' line.

Both of the above-mentioned functions come from wiringPi's example code for the BMP180. The 'analogRead' is a bit misleading, there is nothing analog about it, but you'll see Gordon's reason to do it like this if you read bmp180.c. The other thing is the (100) value in the function call. Just assume the register addresses of the BMP180 i2c device start at 100. So pin 100 = register 0 = temperature, pin 101 = register 1 = pressure.

To close:

If you start developing a similar project, first make a Raspberry Pi version to test it all out. Understanding wiringPi will make it very easy. Then, drop the init and io functions into a copied simh device. It is amazingly painless.

Follow-up: wrap the hardware in an RSX device driver

The above sets up the real (i2C) and virtual (PDP-11) hardware. Lee Gleason took it much further, explaining how to set up a device driver for the BMP180 in RSX and then even uses it in Basic or Fortran. See his rather interesting blog posts here:

RSX Device Driver

Use in assembly language under RSX

Use in Basic and Fortran

Excellent! Now this is a complete how-to on adding hardware to the PDP-11 and supporting it for use in a proper programming environment. 



Gigatron - the computer without a microprocessor!

This is a personal web site. Although a real effort was made to trace owners of all illustrations used on the site, please let me know through the Contacts page if you feel that any materials infringe on copyrights or Fair Use. I would like to thank and for the kind permission for the use of some of their pictures.

This site was designed with the
website builder. Create your website today.
Start Now