After their successes with the mechanics and Arduino Yun, Hans and Matilda decided to celebrate with a trip to the local inn, the "Adam and Eve". They walked up to the bar and was greeted by the bartender. Whilst they were being served they noticed a large snake behind the bar.


Photos thanks to Will Russell

Suddenly the door burst open and a large troll charged in and marched up to the bar. He started shouting in a language which Hans and Matilda did not recognise. The snake lifted it's head and proceeded to slide along the back of the bar until it reached a dusty looking bottle. The snake flicked its tongue. The bartender picked up the bottle and poured a generous measure into a glass and passed it to the troll. The troll slapped some gold coins on the bar and marched over to a full table of people who quickly vacated to give the troll a seat.


From over the other side of the bar Hans and Matilda heard some raised voices. A group of dwarves were having some drinks with a tall dark haired lady. A dwarf with glasses seemed to be angry with one of the others who he claimed was not doing his fair share of the mining. The argument quickly deteriorated into a fight and the accused dwarf picked up a bottle and raised it above his head. Before he could bring down his arm it was wrapped in the coils of the snake. Hans and Matilda watched in amazement as the two fighting dwarves disappeared into endless coils of snake. It was at this point they realised exactly how big the snake was. The snake and dwarf coils headed outside, shortly after only the snake returned.


After finishing their drinks, Hans and Matilda thanked the bartender and asked about the snake. He told them he had bought it from a Burmese traveller when it was only a foot long. He had initially fed it on rats caught in the cellar, now he just leaves it to roam the forest at night. Hans and Matilda walked home much more quickly than usual that evening.


The next morning Hans was working on the Arduino Yun, he realised that both the parsing of the weather data and also security checks could be handled in Python on the OpenWRT side of the Yun.


Hans thought that the Python script could return a simple string representing the weather, either success or an error with precipitation and temperature as additional parameters.


Message formats:


He also confirmed that python already installed on the Yun.


Hans looked at the different options for reading an API and the requests library looks to be a good solution. It was straight forward to install this on the development machine.


pip install requests


To install it onto the Yun required a little more effort as PIP is not installed.


opkg update
opkg install distribute
opkg install python-openssl
easy_install pip

When Hans tried to install this, the Yun ran out of space. "No space left on device". So he followed the instructions for mounting the file system onto an SD card. After making space for the tools used to expand the disks he succeeded expanding the disks and returned to installing pip.


To prove his concept would work he created a simple demo.

import requests, json
print 'Getting Weather'
weather_url = ""
r = requests.get(weather_url)
print r.status_code
j = json.loads(r.content)
print j['query']['results']['channel']['item']['condition']['text']


Not a perfect result but definitely a few steps in the right direction.

root@EnchantedCottage:/mnt/sda1/Python# python
Getting Weather
/usr/lib/python2.7/site-packages/requests/packages/urllib3/util/ InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see


Now it was just a case of dealing with the InsecurePlatformWarning, handling timeouts and network errors, parsing the JSON and passing in the correct location code.


Python Reference

Exception handling

Make call using requests.get


Also timeouts etc here


Next: Enchanted Objects Design Challenge - The flaming postman, the blind man and a trip to the market