UPDATE March 2021: Bill Siever’s Make Code extension has been updated to support both V1 and V2 of the micro:bit and is now an approved extension. Just search for ‘dstemp’ in the extension search (or use the new URL: https://github.com/bsiever/microbit-dstemp).
I had a DS18B20 1-wire Temperature Sensor that came with the excellent Sensors CamJam EduKit for Raspberry Pi – I wondered if you could use this with micro:bit to get more accurate external temperature readings. It turns out, thanks to my amazing colleagues Mark and Carlos, that you can!
The version of the DS18B20 Temperature Sensor I have is waterproof, so this means I can make an alarm to tell me when my coffee is getting cold (although I’d probably need to use pin 1 or pin 2 for the sensor instead of pin 0).
Here’s what you need:
micro:bit
DS18B20 temperature sensor
some way of connecting it, e.g. breadboard, jumper wires and crocodile clip leads
You do this by clicking on the cog wheel, going to extensions, and paste https://github.com/DFRobot/pxt-ds18b20 in the ‘Search or enter project URL’ box.
You should see you have some new blocks you can use, one to show the temperature as a number, another as a string:
This project will show a bar graph of the temperature, but if your micro:bit firmware is up-to-date and you’re using a recent version of Chrome, you can also use webUSB to log temperature data on a connected computer, plot it in real time on a graph and save for later analysis in a spreadsheet or other program.
Here are a couple of simpler projects, one that just shows the temperature as a rounded integer when you press button A:
And another that uses a truncated string to show the temperature to 1 decimal place:
or: what to do when your son tells you 10 minutes before he needs to go to school that the old family iMac is broken and he can’t get his work off that needs handing in like right now.
Symptom: old Mac running MacOS Snow Leopard 10.6.8 will get to login screen, but when you log in you get a blank desktop, no icons, no menu, just a mouse pointer.
Cause: the startup disk is utterly full despite like nobody downloading anything on it like, ever, oh my god.
Solution: using target disk mode wasn’t an option as we didn’t have the right adaptors or leads – the idea is you boot it up in a special way (hold down letter T on keyboard as it boots) so it becomes a Firewire or Thunderbolt disk, you mount it on another Mac, delete some files, disconnect, reboot. So that left me with the command line Single User Mode.
Here’s what I did. Rebooted the Mac holding down cmd S. This takes you to a command line where – if you are very careful and know what you’re doing – you can manually delete some files or folders to free up some space. What the first two guides I found didn’t tell me, however, is that this mounts the disk as read only, so you need to type sudo /sbin/mount -uw / to mount the drive in a way that allows you to delete files.
You can see how much space is free using df -h
Remove files using the rm command – I’m not going to explain how to remove folders because it’s risky – have a look online, and be careful!
Proceed with extreme caution. Luckily, I knew there was an old Dropbox folder, not updated in years, on my login so I was able to delete one folder and free up 2GB of space, enough to restart the Mac (type reboot).
Note that Single User Mode only works on old Macs – MacOS High Sierra 10.13 or earlier – presumably because this is a massive security hole allowing anyone to read your files.
Back in 2016, I made KettleRun, a micro:bit game where you had to navigate your space ship through a canyon in order to be rewarded with a nice, hot cup of tea.
Now I’ve made a version for the Pimoroni scroll:bit – this is a bright 17×7 pixel (odd dimensions, right?) external LED display that you can program from MakeCode by adding the scroll:bit extension.
My new version of the game is a bit different – you navigate your ship (a bright dot on the left of the screen) through the canyon by tilting the micro:bit down and up. It has no levels, but the game gets faster as you go. You get more points the longer you survive, losing one of your 9 lives if you bash into rocks. Your lives are shown with a bar-graph on the micro:bit’s own 5×5 red LED display.
This is a slight twist on my original Little Box of Poems I originally made back in 2012. It mashes that up with Papert-inspired random poetry to create surreal haiku-like poems or story starters.
This project uses a BBC micro:bit and a serial thermal printer. Wiring it up is very simple: connect the black data wire on the printer to GND on the micro:bit, and the printer’s yellow data RX wire to pin 8 on the micro:bit (you could use another pin, I just happened to use pin 8). The printer needs 5 volts to power it, so it needs a separate power supply. Luckily USB sockets give 5v, and thanks to this tutorial from the awesome Tanya Fish I chopped up an old unwanted USB lead to make my own source of printer power.
Parts list:
micro:bit with power source, battery or USB.
Some way of connecting pins – edge connector and jumper wires or crocodile clip leads.
A serial thermal till-roll printer like this one and some thermal paper.
A 5v power source for the printer – an old USB lead chopped up and a USB power source will do nicely.
The Python program is in two parts – the first part is all the functions to send control codes for different styles of printing – most of these aren’t used in this project but you might have fun playing with them – you can also print different kinds of barcode if you look here.
The second part creates lists of different kinds of words: animal / people nouns, verbs, adverbs, prepositions, adjectives and place nouns. Each time you press button A, it picks a random word from each category and prints them out. You could use this as a story starter, use it as a passphrase or just enjoy the surreal haiku-like poems. Add your own words. How long a story can you get a machine to write? Let me know what you do with this idea, using a printer, 2-line LCD or just the built-in LED display.
I had one of these cheap 16 x 2 LCD display modules hanging around that I bought to go with some Arduino or Raspberry Pi project that I never finished – in fact I couldn’t get the thing to work at all.
So I’m delighted to have got it working with a micro:bit! Here’s what I used:
16 x 2 LCD module
medium-large breadboard
a whole heap of jumper wires, some male-male, some male-female
a BBC micro:bit
a Kitronik micro:bit breakout board
a 5V power supply
a 1KΩ resistor
I used this project as the basis, which includes a Python program to drive the display (registration required). You don’t need to download MicroPython to program a micro:bit, you can use the online editor – the beta Python editor will even allow you to flash programs straight to your micro:bit over webUSB if you’re using Chrome.
The wiring diagram isn’t very clear on that website, so here’s a list of all the pins on the LCD display and what you need to connect them to:
LCD pin
LCD function
connect to
1
GND – 0v
GND on micro:bit & -ve 5v
2
5v in
+ve 5v
3
Contrast
GND via a resistor
4
Register select
micro:bit pin 0
5
Read/write
GND
6
Enable
micro:bit pin 1
7
Data DB0
not connected
8
Data DB1
not connected
9
Data DB2
not connected
10
Data DB3
not connected
11
Data DB4
micro:bit pin 8
12
Data DB5
micro:bit pin 12
13
Data DB6
micro:bit pin 2
14
Data DB7
micro:bit pin 13
15
Backlight +ve
+ve 5v
16
Backlight GND
-ve 5v
I tried driving the whole thing off the 3v supply on the micro:bit, but it didn’t work – I think you really do need an external 5v power supply as there has to be a bigger difference in voltage between the power in and the contrast pin (although perhaps someone can do something clever with this information?) I didn’t have one to hand, so I chopped an old USB lead in half, and stripped the wires back to get 5v off the red (positive) and black (negative) wires, which I connected to the +ve and -ve (GND) rails on my breadboard.
Normally you’d use a potentiometer to adjust the contrast, but I just used a 1KΩ resistor instead.
You’ll see in the video that I added a little switch as well to turn the backlight on and off and you’ll see below I found an old volume control or something which I’ve pressed into service as a contrast knob on my maximum / minimum temperature display:
Here’s the Python program that does the temperature display (not including the LCD driver code):
It would be nice if someone made an adaptor to allow you to plug one of these common LCD modules straight into a micro:bit, with a USB input for 5v display power, maybe back-powering the micro:bit with 3v?
Now what else shall I do with it? Show received radio messages from other micro:bits, make another Little Box of Poems or other random fact dispenser?