23 March 2020

Standard

Today has been a little rough – partly I think down to us having such a great and productive weekend, while today was back to the challenge of juggling our work with the kids needs.

I woke early – I’d meant to get up at 6am to do some work before the rest of the family woke, but woke at 5am instead with thoughts of Covid-19 running through my head and my muscles aching from my exertions in the garden over the weekend

The morning went well, with F following the Joe Wicks PE session on YouTube first thing, then getting herself showered, and B reading in bed, then eventually getting up (we’re being a bit forgiving as he is still coughing although improving everyday). B had no interest in getting up to do PE!

F Ready for PE
F Ready for PE

I was on calls for a large part of the day which probably contributed to it being more challenging. During the morning it seemed to me that things went well but I wasn’t really paying attention I have to admit. D got lunch ready and we all ate … but after lunch things didn’t go so smoothly.

The kids first online art class straight after lunch was very welcome but somewhat stressful because of the limited space & materials and not helped by F refusing to mix and use pink (which made the blossoming tree picture a challenge!)

B and F having a virtual art lesson
B and F having a virtual art lesson

Things went downhill after that with both D and I getting stressed by the competing demands of work and children, and F being unhappy – stress and upset all round.

However there were positives – B, F & I had a short band practice (band name: Fantasy Land – B on keyboard, F on drums, and me on lead vocals and violin). We’ve made good progress with Viva la Vida and I think might be able to record a performance off the first half to share soon.

As well as online art there was chance to get outside again (although much colder than the weekend) and then a virtual Kung Fu session for F – so plenty of exercise for her today.

I tried to join the first session of Gareth Malone’s Great British Home Chorus at 5:30, but work, children and dinner all conspired against me. But one thing I’m realising is that there is suddenly so much going on online I have to be careful I don’t try and do everything – my own choir is running virtual rehearsals and other sessions – and it would make more sense to focus on these things that I can do with my friends and local community, rather than join a huge project for the sake of it.

The announcement this evening of a lockdown in the UK with more strict enforcement was as depressing as it was expected (and probably overdue), and I find myself trying to catch up with work this evening (although actually writing this instead!), trying to catchup a bit.

But tomorrow is another day and one on which I only have one scheduled call – so I’m hoping it will be easier for me to give the kids the attention & support they need and deserve (and I’ve signed up for Disney+ so that should raise some smiles in the house – not least with D!)

Stay safe, stay strong.

Cooking with sound

Standard

This project was to enable us to play audio content (music/podcasts/radio) from our iPhones/iPad in the kitchen. It took me under an hour to complete…

Why?

We already use the Apple Airplay facility to play audio content in our living room using iOS devices + an AppleTV connected to a sound system. We wanted to get a similar setup in our kitchen at a low cost.

Time needed

The initial work took my under an hour, but then the subsequent troubleshooting (see Issues below) took another couple of hours at least.

Kit

  • Raspberry Pi Model B
  • Wifi Dongle
  • Logitech mm50 (or similar)

This set of kit was chosen for no better reason than I had it lying around not really doing anything (my son uses the Raspberry Pi sometimes but generally uses an old laptop rather than the Pi now).

The Logitech mm50 (http://www.macworld.com/article/1046722/logitechmm50.html) is an old iPod doc with an audio line in for a 3.5mm audio jack. As far as I can see the Logitech Pure-Fi Anywhere 2 is the same basic product (http://support.logitech.com/en_us/product/pure-fi-anywhere2). You can pick either of these models up second hand on eBay for under £30 (quite possibly much less).

Software

  • Raspbian Wheezy
  • Shairport-sync (https://github.com/mikebrady/shairport-sync)

This is open source software which enables streaming of audio (not video) content using Apple’s airplay protocol. It is a fork of the original Shairport software (which is no longer in development) but has added extra functions and seems to be under active development.

The Build

(ok, calling this a ‘build’ is over selling it a bit …)

All the software side of this project was based on the instructions at http://www.redsilico.com/multiroom-audio-raspberry-pi. For my purposes I didn’t need a DAAP/iTunes server because we only wanted to play audio directly from our iOS devices, which all support AirPlay already. I also already had the Raspberry Pi setup with the Wifi dongle so I basically started from the section headed “Install AirPlay software” using the instructions for shairport-sync.

I also checked and read through the instructions for shairport-sync on the shairport-sync github page to make sure I wasn’t missing anything.

Having installed the software and got it running, I attached the Logitech speakers to the Pi and successfully played music from my phone to the Pi – the tech part was done.

The Logitech mm50 (and the Logitech Pure-Fi Anywhere series) have two little metal feet that swing out at the back to stand up the speakers. I drilled a couple of small holes in each of these, then using these holes screwed the device upside down to the underside of a kitchen cabinet (and near a power socket but away from anything that might cause problems like steam from the kettle).

Then I used a large drill bit to drill a large enough hole to fit through the wires/connectors (the power cable for the Pi and the audio cable to join the Pi to the mm50). Finally, I put the Pi in the cupboard, pushe through the power and audio connectors, plugged everything in, and that was it – all done!

 

IMG_3184

Issues

I immediately tested the setup and it worked perfectly – I was able to stream music, BBC radio iPlayer content, Podcast content from my phone to the Pi.

However when I came back the next day and tried to use it again, my phone didn’t display the Pi as an Airplay option. I found that various things seemed to make the Pi display as an Airplay option again, but it always went away when it wasn’t in use and I had to somehow ‘trigger’ it again (one odd thing was that the Pi continued to display as an Airplay source in iTunes on my Mac, even when it didn’t appear on my phone). I reported this as an issue on the shairport-sync Github site and the developer (Mike Brady – who is very responsive and helpful) responded with some hints. After doing quite a bit of Googling, digging into how so called ‘zero-conf’ works, and looking at documentation around Airplay, I finally found the issue was not with shairport-sync or any of these things, but actually the Wifi dongle I was using going into some low power mode which meant it needed a prompt to ‘wake up’ and work.

I found this issue documented with a solution at https://www.raspberrypi.org/forums/viewtopic.php?t=61665).

In brief, the solution is:

In the directory /etc/modprobe.d/ make a file called 8192cu.conf
Add the following lines to the file and save it:

# Disable power management
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0

Once I’d done this a rebooted, the system worked without a problem.

IMG_3187

Snow in April

Standard

It came out of a dirty grey sky,

But was a surprise nonetheless.

I walked with my coat unbuttoned,

And let flakes fall on my jumper

Revelling in the feeling of the unexpected.

Fragments caught in my hair and melted,

Leaving icy tracks across my cheeks.

I looked up and caught a glimpse of infinity,

Before I was blinded by the falling flakes.

It didn’t last long,

It was snow in April

Sound the Octo-alert!

Standard

Both our children are currently big Octonauts fans – if you haven’t come across the Octonauts, they are a team of underwater explorers who featured in a series of books by a Canadian duo jointly known as Meomi. The books have been made into an incredibly popular TV cartoon shown in the UK on the CBeebies channel (the BBC channel aimed at younger children).

 Octoalert illustration

Whenever there is an emergency, Captain Barnacle will order “Sound the Octo-alert!” – the big button with the distinctive Octopus logo will be pressed, and alarms sounds, and the Octonauts report for duty. As I said, both our children are big fans, and Freya does a mean Octo-alert imitation, so when I was looking for a new Arduino project to do with Bryn, I thought building a working Octo-alert would be great fun.

While you can get an extension (called a shield) for an Arduino to record and play sound (e.g. http://www.ladyada.net/make/waveshield/) I hadn’t got one of these, and I thought a simpler (and in some ways more satisfying) approach would be to have the Arduino joined up to the computer and have a button on the Arduino trigger a sound/video file on the computer. A quick search found the Octoalert website – with a clickable Octo-alert image which then plays an mp3 of the Octo-alert sound. Given this was already there and worked, my idea morphed into triggering the alert from this website by simulating a ‘click’ on the image.

However, before we got to this point we needed to build an appropriate Arduino circuit and craft a button and console. The Arduino circuit is a very simple one – just a single button wired up to an LED and of course a pin on the Arduino. Once I’d put the circuit diagram on, Bryn was able to get going on the wiring. Some of the components are still a bit fiddly for Bryn to put into the breadboard by himself, but for the wires he can follow the diagram and put the wires in himself. I helped with the bits he couldn’t manage, and generally supervised him – but he could do a lot of this himself.

To create the button we cut in half a small plastic ball, Damyanti drew the logo, and Bryn set to work glueing on orange tissue paper

octoalert1

 

A simple ‘button press’ program for the Arduino is available from http://www.oomlout.com/oom.php/products/ardx/circ-07 and I adapted this slightly so that the LED flashed several times on a single button press, and so the button also controlled the output to the serial port – which allows the Arduino to send data back to the computer it is joined to. The Arduino code looked like this:

// set pin numbers:
const int buttonPin = 3;     // the number of the pushbutton pin
const int ledPin =  9;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  // initialize serial port
  Serial.begin(9600);  
}

int interval_time = 500;

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // LED off:    
    digitalWrite(ledPin, LOW);
    Serial.println("0");
    delay(interval_time);
  } else {
    // turn LED on:
    Serial.println("1");
    for (int i=0;i < 10;i++) { 
      digitalWrite(ledPin, HIGH); 
      delay(500);
      digitalWrite(ledPin, LOW);
      delay(500);
    }
    delay(interval_time);
  }
}

On the computer side I needed a mechanism to read the output on the serial port – I found a hint on how to do this here http://playground.arduino.cc/Interfacing/Ruby. I also needed a way of accessing the Octoalert website – I knew there was a Ruby Gem to control a browser called Watir, so I got this installed, and after a few false starts (the task was complicated by the fact that clicking the button on the website actually runs some javascript) I got some code working that could read the input from the Arduino and trigger the necessary javascript on the website:

#!/usr/bin/ruby
require 'rubygems'	
require 'watir-webdriver'
require 'serialport'

#params for serial port  
 port_str = "/dev/tty.usbmodem1411"
 baud_rate = 9600  
 data_bits = 8  
 stop_bits = 1  
 parity = SerialPort::NONE  

 sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity) 
 browser = Watir::Browser.new

 #just read forever  
 while true do
   while (i = sp.gets) do
   	puts i
    if i.to_i > 0
    	browser.goto "http://octoalert.com"
		browser.link(:id,"playLink").fire_event "onclick"
		sleep(7)
		browser.goto "http://brynpatelstephens.com"
   	else
		puts "No Octoalert"
	end
   end 
 end

With this code running on the computer, and the Arduino program loaded to the board we had a working button – we now needed to put the whole thing together.

A bit of improvisation with some cardboard and we mounted the Octo-alert button in such a way it could sit over the Arduino and pushing down on it pushed the actual button on the Arduino. I cut a hole in a cardboard box for the button to be mounted in, and Bryn decorated it in the style of the Octonauts instrument panel.

octoalert2

This was a nice project, in that it mixed some nice crafting (glueing the tissue paper, making the control panel) with a very simple circuit – all of which Bryn could either do by himself, or with a small amount of help. The programming was slightly more tricky, and I just got on this with while Bryn did other stuff – but I explained a bit about how the Arduino was able to ‘talk’ to the computer which I think he got. He also was quite concerned that by using the sound/graphic from the website that we were ‘stealing’ another’s work – which meant an opportunity to talk about the web and how it worked – although I’m not entirely sure he understood my explanation of using the website versus copying the files – and to be honest I’m not sure I quite understand it either – after all in both cases you end up with a copy of the file on your computer!

And it wasn’t just fun for me and Bryn – Freya got to join in too as you can see in this video – yes, it’s time to sound the Octo-alert 🙂

Arduino powered dinosaur

Standard

Bryn’s recent 5th birthday brought with it an extremely cool Dinosaur toy (available from Maplins in the UK). It consisted of a set of cleverly engineered cardboard cutouts which you fold and join to make a T-Rex, coupled with a motor, cogs, wires, battery box, switch and plastic stick, which all join together to make the cardboard T-Rex move and gnash it’s teeth when you’ve put it all together.

Bryn and I built it (although to be honest the cardboard folding/joining was pretty fiddly, and while he pushed the motor, battery box etc. in the base confidently, I had to do most of the construction of the cardboard model. The result was much much better than I really expected. The dinosaur moved (on the spot) and it’s teeth gnashed pretty effectively – enough for Bryn to play a game of putting his finger near it’s mouth and getting ‘bitten’.

The next day, I had an idea that if the dinosaur’s motor could be driven off our arduino, we could wire the dinosaur up. I asked Bryn, if he’d like to do this as a project and he was keen, so the next day we sat down to do this.

The most recent project we’d done with the arduino had been using a light sensitive resistor to detect light levels and switch an LED on/off, so making the dinosaur light activated seemed an obvious way to go. I got the basic motor circuit design out (details at http://www.oomlout.com/oom.php/products/ardx/circ-03) and started to try to work out how wire the photo-resistor.

While I was doing this, I was pretty impressed that Bryn just got on and wired up the motor circuit from the diagram pinned to the breadboard. While I had to put the more fiddly components in, all the wires Bryn did without prompting or help.

I was able to wire up the photo-resistor separately on the same breadboard (using http://www.oomlout.com/oom.php/products/ardx/circ-09) – including (at Bryn’s request) an LED also to be controlled by light levels. I have to admit it took me a little while to work out the wiring, and this led me to just write the code to run the circuit without really getting Bryn to help – which I was sorry about afterwards.

I’d got some concerns about whether the arduino board would drive the motor OK, as I hadn’t been able to establish what voltage/current was required for the motor. The circuit above uses a transistor to enable the arduino to drive a small toy motor, but I wasn’t sure if it would be enough for the dinosaurs motor (which usually runs off two AA batteries).

We covered the photo-resistor – and success. The dinosaur leapt (if slightly lethargically as the motor clearly not quite getting the power it really needed) to life. A dinosaur that comes to life when you switch the lights off!

I guess the next step would be to get some LEDs on wires to push through the cardboard as eyes, and some sound effects …

More Arduino projects

Standard

“Dad, can we play Arduino this morning?” asked 4 year old Bryn at the weekend – music to the ears of a geek parent 🙂 We had such a pleasant hour building and using a temperature sensor I thought I ought to blog it, and also another project we did quite a while back getting the Arduino to play sounds. (see also my previous post on the first two projects we did)

Music Maker

This was a project we did a while ago. Again we were playing with the Arduino at Bryn’s request, and he asked if we could make some sounds. I knew there was a piezo speaker in the starter kit we had, so I looked up the example circuit that used it, and found it played “Twinkle, Twinkle Little Star” (or Twinkle Twinkle Traffic Light for those of you with similarly aged children).

We worked together to wire up the circuit, and then I downloaded the program (http://www.arduino.cc/en/Tutorial/Melody) and we loaded it onto the Arduino. Uploading the program to the board is one of the easiest things for Bryn to do on the computer side – just clicking an icon to compile and upload the program. The nice thing about this is that it emphasises the connection between the program on the computer and the behaviour of the circuit.

This worked fine, but wasn’t quite what Bryn wanted – he said he wanted to push a button to make music. Since this required me to get my head round wiring up and programming a button – which I’d not done before – I went for the simplest thing I could think of, and set up a button so it would play a random note from a C major scale (within an octave range). I was pretty happy to get this working.

But Bryn was still not happy – he wanted several buttons, each one to play a different note – essentially he wanted to build an electronic piano 🙂 After some more work we got there – 3 push buttons, each playing a different note (I only had 3 buttons in the kit, so we couldn’t do anymore). Bryn was very happy with this.

We had a lot of fun, but it was harder to get Bryn engaged on the programming side with this one. The transformation of frequencies into specific notes clearly makes it difficult to relate the program to simple notes, and ‘melody’ code isn’t the most elegant in the world. But it was nice that Bryn had a clear idea in his head of what he wanted it to do, and we worked towards getting it working together.

Temperature sensor

 

This was the most recent project, following Bryn’s request at the weekend. Unlike with the music project, Bryn didn’t have any particular idea this time round, but I was inspired both by the fact it was shaping up to be a warm day, and the fact the Arduino starter kit has a temperature sensor in it. Even before started the build, this gave us a chance to talk about temperature and thermometers – of course thermometers are pretty familiar ground to a young child, and since our daughter had been ill recently Bryn had seen the thermometer in action quite a few times.

We built the basic circuit – actually one of the simplest so far and Bryn was able to put wires in at my direction, only needing my help with the temperature sensor itself, and with a few wires on the occasions when they didn’t slip into the breadboard without a bit of a push.

Once we had it wired up, I showed Bryn the output on the computer screen – this was the temperature in celsius being taken at frequent intervals. Bryn was able to read the numbers on screen. We measured the temperature in our dining area, where we did the build, and then moved into the conservatory. We could see the numbers go up which gave a chance to talk about “higher” and “lower” and how the numbers were higher because it was (noticeably) warmer.

Then we went on a measuring spree – outside (cooler); fridge (cooler but not by much); Freezer (took a while but went below zero). With the freezer we had to wait quite a while watching the numbers go down and down before it got below zero – but Bryn seemed to enjoy every minute of it. While we waited we talked about the ‘scale’ and I explained how 100 was for boiling water and 0 was for freezing.

Then more measuring upstairs, finding the warmest bedroom (ours!).

Although there wasn’t much to change in the program, I showed Bryn how there was a number in the program that told the Arduino which analogue pin the sensor was connected to. We then moved the wire to another pin, he could read the number from the board (with a bit of help) and type the new number into the program, and upload it to the Arduino so the new configuration worked.

It was a great project, and lots of good stuff to share and learn. In an ideal world I would have liked to design a better way of displaying the temperature on the computer in advance – something colour coded, with large digits reflecting an average reading. However, Bryn seemed relatively comfortable just reading the number from the serial port monitor!

Arduino Thermometer

We covered a large number of things:

  • What is temperature
  • Reading numbers on the celsius scale
  • Boiling and Freezing points
  • Updating a program when you update a circuit
  • The link between the circuit and the program

Pretty amazing for a Saturday morning

Arduino and son

Standard

Not quite sure where to blog this, so it’s going here on our rather unloved personal/food blog (for a better loved blog you might want to have a look at the stuff Damyanti has been doing over on Overdue Books)

For a while now I’ve been wondering how I might introduce Bryn (now 4) to the concepts of computer programming. I’d looked at all the usual ‘programming for kids’ stuff, and had a look at Scratch, Hackety Hack and other languages aimed at children learning to programme, but felt this would all be difficult for a 3-4 year old to get to grips with – especially as he isn’t yet reading and has only recently started writing – although he can recognise letters and numbers.

I did find a couple of approaches that were fun for both of us which were the Lightbot game and a Constructa-Bot (a programmable ‘robot’ aimed at the primary school market) – both of which require you to plan a series of moves, and programming them into a robot (one virtual and one physical). Lightbot was fun, but got too hard too quickly. The Constructa-Bot works well, and I think will get more use in the future – partly this is about thinking up ‘games’ to play with the bot.

At the same time I’ve had it in mind for a while to get myself an Arduino kit to play with. Arduino is an “open-source electronics prototyping platform” – essentially allowing you to build electronics circuits – and write software to run on it. A really simple example of what you can do is wire up a circuit with an LED and make it blink on and off as detailed at http://arduino.cc/en/Tutorial/Blink. To encourage me, Damyanti got me a book on programming Arduino for Christmas and so I ordered an introductory kit from oomlout.

While the Arduino was for me, and I hadn’t even thought of doing it with Bryn – I guess I assumed it would be fiddly and a bit difficult – it has already proved a great way of engaging Bryn with basic concepts of electronics, programming and just the basic idea that these are tools that can be used to create.

So far we’ve done two little ‘projects’:

Colour wheels

This was the first one we did together. Damyanti drew some circles on a piece of card, and Bryn decorated them with lines, squiggles, spots, spirals and stars. They did this while I worked out how to wire up a motor, and got a programme (or ‘sketch’ as they are called for arduinos – no idea why) written that would just spin the motor for a number of seconds.

Having got this working we attached the ‘wheels’ to the motors spindle and watched what happened to the colours and patterns as it span around. Bryn was immediately interested in the circuit and how the motor was controlled – and once I’d got the cursor in the right place in the programme he could type in numbers to set the length of time the motor would spin for each time, and then press the button to upload the sketch to the Arduino board.

Traffic Lights

After the colour wheel project both Bryn and I wanted to do something else. I asked for suggestions on Twitter and I think it was @bencc who suggested traffic lights – which immediately seemed like an ideal project. I had red and green LEDs, and Bryn has plenty of toy cars, and I knew that even my basic Arduino knowledge could manage a simple circuit and programme which would change the lights at set intervals.

This time Bryn was keen to help with the whole circuit – so we did this together, and this worked better than I thought. Although wiring stuff up (using a ‘breadboard’ to plug the components into) proved a bit fiddly, and some of the components I had to do, Bryn was able to plug the connecting wires in with only a very little help.

I’d got the (very simple) programme ready, and we uploaded it, and played around with the time between the lights changing – doing some very very short times to get a flickering affect, and longer times that might be more suitable for traffic lights.

The next stage of the project was to make a box for the Arduino to slot into to make the ‘traffic lights’ – Damyanti found a suitable box, cut some holes in the right places and got it ready for Bryn to decorate – we got out a road that Bryn and Damyanti had made a while ago and some toy cars – and you can see the results in the picture above.

Next…?

The challenge is to think of projects that are fun, engaging, and within my ability to carry out (as well as Bryn’s!) – any suggestions welcome :). I love the way the two projects above combine fun, creativity and technical concepts.

Long time, no posts

Standard

Haven’t posted for ages, so thought I should. I’ve also updated our current reading – we don’t really read that slowly!

I wasn’t very well today – first time I’ve been off work for ages. I slept until 1 o’clock – but I’m still feeling a bit tired now.

We spent last weekend in Bristol. We had a really nice time – we went to see The Incredibles on Saturday – which I’d really recommend – and then ended up in a pub called The Old Duke, which has live jazz every night. We saw a singer called Beth Rowley and her band. The keyboard player was really good, as was the singer. Some really good stuff, including a jazz interpretation George Formby’s "I’m leaning on a lampost" – which sounds strange, but was really good.

On Sunday, we saw the ‘Earth From the Air‘ exhibition, and also went up to the Clifton Suspension Bridge, before meeting some friends for a drink, then heading home.

Unfortunately we forgot our camera, so no pictures of our weekend.

This week we’ve had a couple of pictures framed – one that Damyanti took, and one of an Indian print on fabric. This second one is quite large – don’t know where we are going to put that – perhaps somewhere in the corridor.

We’ve hopefully got a quiet weekend coming up. We’ve got some Christmas shopping to do. We did buy one Christmas present last weekend – which is probably the earliest I’ve ever bought a Christmas present – but still quite a few to go, and less than a month before we go to India!

We are also meeting some friends tomorrow in Richmond, so hopefully we should have a nice afternoon.