DigiStump DigiSpark Arduino and Debian 8 64bit

UPDATE 2016-02-02: There is an updated version of the script below which also works with the DigiSpark Pro. See below.

In the space recently we’ve been playing with the super low cost Digistump Digispark 16.5MHz boards and the Arduino 1.6.5 environment.

Unfortunately there are some issues with these working out of the box with 64-bit versions of Linux (we use Debian 8 64-bit) as one of the attached binaries is compiled for 32bit only. However, after some major head scratching, I have managed to get them to work reliably.

To get them to work. You need to install the Digispark hardware library as normal and then follow the steps below.

Installing the DigiSpark library

Add the following line to the Additional Boards Manager URLs in File –> Preferences. If you have previously added boards to this list, you will have to separate them with a ; or use the button to edit it in list form. If you need an in-depth guide, there’s one in the links at the bottom from everyone’s favourite Adafruit.
http://digistump.com/package_digistump_index.json

Fixing the missing bits

Once you’ve done that, you will need to download the following script (I’d of included it as a downloadable file, but someone disabled it on our server)…

#!/bin/bash

# Adds necessary libraries and UDEV rule for using the Digistump DigiSpark boards in Arduino 1.6.5 on Debian 8 64-bit
# Written by James Muirhead. 2015-10-12

# This works on the 16.5MHz original Digispark. Has not been tested on other varients.

# Checks if you are root, as this is required.
if [ $(whoami) == “root” ]
then
# Updates apt then installs 2 necessary libraries and their dependencies
apt-get update
apt-get -y install libusb-dev lib32stdc++6

# Adds UDEV rule which adds the DigiSpark device to the dialout group, same as required by Arduino IDE.
echo ‘SUBSYSTEM==”usb”, ATTR{idVendor}==”16d0″, ATTR{idProduct}==”0753″, MODE=”0660″, GROUP=”dialout”‘ > /etc/udev/rules.d/99digispark.rules

# Restarts UDEV to enable the above.
service udev restart


echo "DONE!!!"31
else
echo "You need to be root to run this script, use su / root to try again."
fi

Right, once you’ve got the above copied into a file called e.g. digispark.sh you will need to make it executable. To do this, you will need to log in as root (type su at the command line and type your root password). Then type the following to make the file executable.

chmod a+x digispark.sh

Ok, once the file is executable, stay root and run the following…
./digispark.sh
This may (or more likely will) take some time, so leave it till it’s done what needs to be done.

Once finished, close and re-open the Arduino IDE.

DONE!!!

Once this is all done, you should be able to upload a sketch to your DigiSpark without problems.

Links

Update 2016-02-02

I’ve written a new version of the script above which also works for the Digispark Pro. Follow the same instructions as above, but use the script below instead. It is longer, but does a few more things.

And, just because I’m feeling nice, I’ve put it on GitHub to make life easier.
DOWNLOAD NOW

#!/bin/bash

# Digispark installer.
# Written by James Muirhead.
# 2015-10-12
# https://www.sheffieldhackspace.org.uk

# CHANGE LOG
# 2015-10-16 – Only installs 32-bit extensions if 64 bit OS detected.
# 2015-11-04 – Now creates UDEV rule for DigiSpark & DgiSpark Pro.

if [ $(whoami) == “root” ]
then
apt-get update

# Installs required library.
apt-get -y install libusb-dev

# Checks for 64-bit environment and installs required 64-bit extensions.
uname -a | grep x86_64
if [ $? == 0 ]
then
apt-get -y install lib32stdc++6
fi

# Creates UDEV rule for DigiSpark
echo “# Rule to allow use of the basic DigiSpark (ATtiny85) board in the Arduino IDE 1.6.3+” > /etc/udev/rules.d/99digispark.rules
echo “# Written by James Muirhead (@PhantomFreak), 2015-10-12.” >> /etc/udev/rules.d/99digispark.rules
echo “# https://www.sheffieldhackspace.org.uk” >> /etc/udev/rules.d/99digispark.rules
echo “” >> /etc/udev/rules.d/99digispark.rules
echo ‘SUBSYSTEM==”usb”, ATTR{idVendor}==”16d0″, ATTR{idProduct}==”0753″, MODE=”0660″, GROUP=”dialout”‘ >> /etc/udev/rules.d/99digispark.rules
# Creates UDEV rule for DigiSpark Pro.
echo “# Rule to allow the use of DigiSpark Pro (ATtiny167) board in the Arduino IDE 1.6.3+” > /etc/udev/rules.d/99digispark-pro.rules
echo “# Written by James Muirhead (@PhantomFreak), 2015-11-04.” >> /etc/udev/rules.d/99digispark-pro.rules
echo “# https://www.sheffieldhackspace.org.uk” >> /etc/udev/rules.d/99digispark-pro.rules
echo “” >> /etc/udev/rules.d/99digispark.rules
echo ‘SUBSYSTEM==”usb”, ATTR{idVendor}==”16d0″, ATTR{idProduct}==”0753″, MODE=”16d0″, GROUP=”dialout”‘ >> /etc/udev/rules.d/99digispark-pro.rules

# Restarts UDEV
service udev restart


echo "All done, please close all open Arduino IDE windows & reopen before attemptting to upload code."
exit 0
else
echo "You are not root, please use sudo or su to continue."
exit 1
fi

Mam Tor Kite Aerial Photography

Several members of the group attended Geeks in the Peeks recently (4th-6th September 2015). As part of this on the Saturday, we decided to take my Kite Aerial Photography rig to the top of Mam Tor to see if we could take some photos. I brought along my Raspberry Pi based system (A model A with a camera module, air pressure sensor, USB wifi card (for the web UI preview and start/stop/shutdown buttons) and LiPo battery) which takes images every 7 seconds, on average while airborne.

The wind was nice and smooth and resulted in the Kite flying very stably. This helped produce some very clear and well focused images with little smearing effect (common in gustier winds). See below for some examples…

008

Image 8

022

Image 22

051

Image 51

066

Image 66

067

Image 67

Relative Altitude data for period of use.

Relative Altitude data for period of use.

NB: In the graph above, you can see that towards the end of the flight, the camera appears to be below the starting altitude. This is caused by the kite camera taking the initial reading on altitude (based on air pressure) while it is already some way up above it’s ground level starting point (it takes a little while for the Raspberry Pi to actually boot up to the point it can run the code to control the camera). However, as you can see the highest image was taken at 40m above the start altitude. From the spreadsheet the Pi makes, I can tell you it was image 29.

Image 29, highest in the series.

Image 29, highest in the series.

Kite and camera in flight above Mam Tor

Kite and camera in flight above Mam Tor

From the above you can see the Kite clearly in the sky as well as a brown spec hanging from it, this is the Raspberry Pi kite camera hanging from a Picavet device (this allows the camera platform to always be level while in flight suspended below the kite’s string).

Andy restraining AJ to prevent him being pulled away by kite.

Comedy moments… Andy restrains AJ to prevent him being pulled away by kite.

For more information of Kite Aerial Photography, start with Wikipedia and see how you get on. However, if you have any questions or a desire to see a full & in-depth article on KAP, please leave a message below and I’ll be sure to start work on it. There is also a great YouTube video from the folks at Make Magazine here, this was in fact the original inspiration for me to get into Kite Aerial Photography after I left University.

For more information on Geeks In The Peaks, please see their Twitter & attending.io pages.

Salvaging Lead Acid Batteries

Working on a previous project to make a prototype Pi UPS I pulled a number of salvaged lead acid batteries out of the scrap bin.

Battery Resuscitation through Desulfation

Battery Resuscitation through Desulfation

It quickly became apparent that the batteries were all flat and as each had a terminal voltage of around 0.5V they appeared to be beyond life ever again. Not surprising considering the number of years they had lived in the scrap bin without ever having a charge.

Initial attempts to put a charge into them and get them going again were without success. Even over voltage-ing them a little to get them started failed miserably. The best of them was taking around 10 micro amps. After leaving them on charge for 5 days or so the situation had not improved. So what were we looking at ? Maybe they had dried out, maybe the plates had fallen apart and were now mush or maybe being overly discharged the plates were caked irretrievably in insoluble hard lead sulphate crystals.

There are plenty of miracle cures for dead lead acid batteries and desulfation. Frankly I am rather sceptical of most of them. But for some reason I thought although slightly implausible desulfation was a fun hack to try. Chemical means to reverse the crystal build up were out as the batteries are sealed units. So it was time to rummage through the internet for ideas and then hit the scrap bins again for parts. The circuit I settled on is here Pulse Desulfator Doc. This formed the basis and the prototype as shown in the photo was a derivation of this.

Having nothing to loose other than a bit of time constructing and debugging it I set too to build it. The inductor was a hand wound approximation, the logic inverter shown in the schematic was replaced with a simple transistor based inverter using a 2N2222 NPN transistor and the mark space ratio of the 555 astabel circuit needed adjusting. Probably because the inductor value was a touch lower than it should have been. But in the end it appeared to be working.

Now the acid test (see what I did there….). From the picture you can just see the ammeter on the bench PSU showing the battery taking a charge of 200 milli amps. So success. It took 2 days of float charge plus the desulfator pulsing away to get this recovery. Over this period the input current could be seen steadily increasing, whereas before with a stable DC supply it had just sat there and done nothing. The open circuit voltage of the battery at the time of writing now shows 4.5 volts so there is a way to go yet. It could be a couple of weeks or so before the battery is as recovered as it ever will be. In reality I can’t see them ever being “as new” however a trick worth knowing about and trying when salvaging neglected lead acid batteries.

Not to self if trying this with an old car battery check the electrolyte levels first and be prepared to except that the plates could just be mush and the battery beyond recovery.

Prototype Pi UPS

After advocating for a while that it is worth running up services on Pi Servers one at a time as needed. It occurred to me that we have no UPS to keep them going when the mains electricity drops out. We also have no way to prompt services to shut down in an orderly manor under the same circumstances. This gets to be more critical when we are running infrastructure services like RfID door access and a space automation MQTT broker.

An uninterruptible power supply for the Raspberry Pi

An uninterruptible power supply for the Raspberry Pi

Being as I am also running similar services at home I needed a similar solution for home. Sounds like a call to hack then, first stop was the junk and scrap bins, then a quick rummage through the spare bits left over from Chinese AliExpress shopping trips.

I found an ex UPS maintenance free lead acid battery that had sat in the scrap bin for too many years and a couple of these tiny 3A SMPSU DC-DC switcher modules that are incredibly cheap. The SMPSU modules can cope with up to 28V input and the output voltage is set by a small potentiometer. I also found a scrap laptop PSU that had a decent current delivery at under 24V. All in all the most expensive bits were the screw terminals that you can see from the picture I used to make conections to the board.

Lead Acid batteries have the useful property of being low maintenance and they will take a float charge providing you supply them with a constant voltage at the maunfacturers reccomended value. They will sit there on this float charge for as long as the battery will live. So after a quick rummage on the internet the first switch module was adjusted to provide a constant voltage at the manufacturers reccomended float value of 6.85V for the battery shown. The battery and input to the second switch module were conencted in parralel across the output of the first switcher. The ouput votlage of the second switcher was set to the 5.1V that is best to feed Pi’s with.

That then was the prototype UPS finished. When the supply to the UPS fails the battery takes over and supplys the Pi. When the mains supply comes back on the battery goes straight onto float charge and the Pi is running from the mains. Providing that the battery float voltage is less than the supply voltage and the Pi voltage is less than the battery voltage it all works. At 6V these thresholds are all a little close together and the UPS could do with a 12V battery and then adjusting to charge at that voltage instead. But this does work and the concept is proved.

The next task is to scale this up to run a whole shelf of Pi’s, with a mains high current SMPSU to drive the float voltage and supply the Pi’s, a salvaged car battery for the uninteruptible bit and one of these cheap tiny DC-DC SMPSU’s per Pi. But that is another article for another day.

Indoor environment sensor with ESP8266

Burnell Bot Breadboard

As part of our hacking the space project, we’re building a network of sensors and effectors in our space. Communicating over WiFi using the MQTT protocol, the idea is to make lots of data about the hackspace easily available for members to use in their projects, and to make it easy for members to add their own data streams to the space’s network of things.

One of these is the Burnell Bot, responsible for monitoring motion and light intensity, plus temperature and humidity. These data will end up being used to automate the hackspace’s lights and heating, as well as forming part of our security system. In the meantime, they’re flying over the WiFi in our hackspace ready for members to monitor and use however they want.

At its heart is an ESP8266-12E, sitting on a handy breakout board; you can see its silver enclosure covering most of the board, plus the etched WiFi antenna. This takes input from a BH1750 light sensor over I2C, a passive infra-red motion sensor that sends a digital HIGH signal in response to movement, and the DHT22 temperature and humidity sensor. Thanks to the support for ESP8266 in the latest Arduino IDE, the BH1750 and DHT22 are used via their existing Arduino libraries. A couple of warning messages pop up when compiling, but the code runs without issue. The motion sensor, of course, is monitored by simply checking the status of a GPIO pin set to input. Data from each sensor are transmitted over MQTT in their appropriate topics, subject to dampening (e.g. change in light level must exceed a certain threshold before being reported) and throttling of message rates.

Now that our planning permission has gone through (the downside of being hosted in such a great, historic building is dealing with its listed status) and we’ve refurbished our ceilings ready for the wiring grids to be installed, expect to see a few of these appearing in the space and start thinking of things to do with the data!

Personally, I want to add sensors for carbon dioxide, carbon monoxide, nitrous oxide and particulates, to keep an eye on our air quality and to try to get a sense of whether the reported effects of high CO2 / low O2 in classrooms (impaired concentration, amongst other things) affects our hacking. If you want to get involved in this or other projects, get in touch or just look at our calendar and turn up to a session!

Sous Vide cooking with ESP8266

sousvide controller breadboard

We have a couple of members interested in the geeky side of cookery, and our experimental foods day a little while ago was a great success.

Along these lines, I wanted to try sous vide cooking, a style of cooking in which foods are held at an accurately regulated temperature in order to favour some cooking reactions over others. It’s most commonly used when cooking meats, resulting in amazingly tender, juicy meat even from the toughest cuts. People with an interest in food chemistry — as a biologist by training, I’m definitely one of them — can also have a fascinating time experimenting with the cooking of, for example, the humble egg.

This project was to turn my slow cooker into a sous vide water bath. Along with several other SHH&M members, I’ve been playing with the ESP8266 microcontroller: a great little chip with easy WiFi connectivity, a decent number of GPIO pins and, fairly recently, support in the Arduino IDE, making it very easily accessible to anyone with some passing familiarity with using Arduino. As part of our hackspace renovation project we’re setting up a system of sensors and effectors that communicate using the excellent MQTT messaging protocol; there’s a great Arduino libraries for MQTT, so getting my sous vide controller to report its heating activity and my food’s temperature over WiFi was simple.

On the breadboard, you can see a ESP8266-12E with a silvery enclosure and the etched WiFi antenna. It takes input from a waterproof DS18B20 temperature probe using the standard Arduino library, which works perfectly with the ESP despite some warnings thrown up by the compiler. The ESP gets its power from a switch-mode (“bucky”) voltage regulator set to 3.3v; a second voltage regulator next to it provides 5v to the 240v AC relay. Both are fed from a 12v, 1A wall wart, not shown here. The relay, isolated from touch and moisture in its lunchbox housing, controls the power running through a short extension lead and happily accepts the 3.3v control signal from one of the ESP’s GPIO pins. The cluster of unused wires in the top right of the breadboard are in place to connect with my USB->serial board, in case I need to reflash firmware or debug over serial.

In use, the slow cooker is turned to “high” and plugged into the modified extension lead. The ESP8266 monitors the temperature in the slow cooker via the waterproof temperature probe and, by switching the relay, controls the heating. The logic is managed by a popular Arduino PID library, based heavily on their example code for relay-controlled systems.

Temperature data from about 20 hours of sous vide cooking

Temperature data from about 20 hours of sous vide cooking

PID algorithm output -- in each 10 second chunk of time, for how many seconds the heating element was receiving power, over about 20 hours of sous vide cooking

PID algorithm output — in each 10 second chunk of time, for how many seconds the heating element was receiving power, over about 20 hours of sous vide cooking

Data from the sous vide controller is reported over WiFi via MQTT, meaning that I could keep an eye on the two critical parameters (current temperature and how hard it was working to increase the temperature) using my laptop, phone, or, in principle, other ESP or Arduino devices connected to my flat’s WiFi. The excellent MQTT Spy even generates handy graphs from your incoming data in real time, bringing the food geekery to new heights. In future, also sending the data to something like data.sparkfun, to easily monitor and graph data when I’m out of the flat, should be straightforward.

The most important part of the post: The resulting food is amazing! So far I’ve only used it for meat, although there are plenty of interesting things like eggs and custards that I’m keen to try. Traditionally tough cuts of meat — shoulder of lamb, beef brisket — come out rare, tender, and juicy, with their distinctive flavours intact. More tender cuts, like sirloin steak, are done to perfection every time and, really, have to be tried to be believed. This was a quick and hacky project, but the results are fantastic. Definitely a success, and well worth making yourself.

The PID algorithm needs tweaking to improve temperature regulation to within a degree or two (easy but time consuming, and in the current warm weather I’m trying to avoid having a bath of hot water sitting in my well-insulated flat for hours on end), it needs to go in a case, and it needs a better control mechanism than re-flashing the firmware to change the target temperature. Getting the ESP to host a simple web page displaying controls — or even to just accept commands over MQTT — should be simple enough.

If you’re interested in learning to make this sort of project — or already know how, and want to meet up or work with others who do — come along to SHH&M! Get in touch with us here, or look at our calendar and just turn up to one of our scheduled meetings and introduce yourself.

A quick snapshot

Busy times here at SHH&M! A few snapshots of things our members have been working on recently in the hackspace:

Project Snapshots

 

 

Some of the stuff we’ve been up to lately includes:

  • Upgrading one of our 3D printers
  • Building comfy deckchairs for slow afternoons in the coutyard
  • Ultra-lightweight aircraft for indoor flying
  • Building and upgrading our network and servers
  • Running workshops, including amazing ice-cream!
  • Arduino and ESP8266 programming
  • Prototyping a pocket-sized (taking-to-the-pub-sized!) boardgame
  • Learning woodworking and joinery
  • …plus our high altitude balloon project, catching up with friends and being inspired by cool projects at the Halifax Mini Maker Faire, further work on our RFID entry system, and a hundred other things that I don’t have photos of.

 
It’s been another good month, and it’s only going to get better! If you’re interested in joining in, at any skill level (NB: “any” definitely includes “complete beginner”), get in touch or look at our calendar and just turn up to a session!

Experimental Foods Day

IMG_20150509_171559

This Saturday we made dry ice icecreams and sorbets, had a chocolate truffle making masterclass, and experimented with molecular gastronomy to make burst-in-the-mouth fruit puree spheres. Plus a BBQ and our normal hacking session alongside. An exhausting, brilliant day!

For the dry ice icecream, we made a couple of batches of simple custard, cooled to around room temperature using a dry ice bath (because why not?):
P1000982

…then everyone started adding their own mix of flavours, before quickly beating in dry ice converted to a powder in a finely calibrated process of Janine frenetically bashing it with a hammer.

P1000998

Verdict: Amazing icecream! My personal favourite was the Glenlivet whisky icecream, but they were all (vanilla, cherry and chocolate, chocolate mint, Rum, Kahlúa) fantastic.

Andy’s Kiwi, Apple and Lime sorbet was similarly great. The fizzy taste from the dry ice gave it a really delicious edge.

Sarah ran our truffle making masterclass — deliciously messy, with fantastic results! Another great mix of flavours tried out — my personal favourite was chocolate and Henderson’s Relish. Because I’m pretty sure it’s illegal to cook anything in this city without at least a splash of Hendo’s.
P1010009
P1010014

Finally, a bit of molecular gastronomy. We got hold of some calcium lactate gluconate and sodium alginate to try out “reverse spherification”. A simple berry puree was mixed with the calcium salt, and dropped into a bath of sodium algniate, for about 2 minutes. This grows a thin layer of flavourless gel around the droplet of fruit, making a burst-in-the-mouth fruit sphere! Well, sort of sphere:
P1010008

Never mind that they look like monkey kidneys, they were delicious, a really fun texture, and surprisingly simple and enjoyable to make. Lots of finesse needed for perfect spheres, but definitely worth trying yourself!

Finally, our incipient tradition of a BBQ and a few beers in the sunny courtyard before cleaning up and heading home to our respective food comas.

Thanks to everyone for helping out! If you missed it (maybe you haven’t come along to a meet yet?), you should’ve been there!

PS: There may have been some further gratuitous playing careful and sensible use of the dry ice:

IMG_20150509_142922

…but our lips are sealed.

Marvellous Marble Machines

marblemachine1c
[This post by SHHM member Janine]

One of the items that caught the imagination of several visitors to the Portland Works Open Day, was the “Marble Machine 1” (see photos). The machine is designed by Martin Raysford and is one of several versions that are available directly from his website (MSRaynsord.co.uk), or at many of the Maker Faires across the UK.
marblemachine1b

The kit comes as several flat pieces of wood, with the pieces laser cut out, bar small holding pieces that need to be cut with a scalpel. These are great fun to make, instructions are clear, with only wood glue required from the builder to make the item.

The spiral section of the machine is pulled out and extended from a flat piece of wood and is kept in place under grooves in the mounting stand.

The machine is either operated by the handle or a battery operated motor can be added.

Marble machine 4 is also available (see below).
marblemachine4
marblemachine4b

This machine uses pillars rising and falling to move the marbles up to the top of the track. Again, this can be battery operated.

I’m currently building the Marble Machine 2 – will take some in progress photos for the next blog!

Numerous other laser cut ply toys are also available…

Janine