Whilst Matilda was planning and rebuilding Hans hit the books to study the new electronics they were going to add to their house. Hans was having trouble understanding the Yun parts, "why does it need two processors on one board?" he thought to himself.
Dinner at the Sprats'
Hans and Matilda were lucky to have kind neighbours and everyone has helped them out following the fire. One the night they visited their friends Mr and Mrs Sprat. When it came to dinner, Mr Sprat carved up a roast duck. Hans and Matilda were served the best slices of *** meat. On his wife's plate he placed a leg covered in a rich crispy skin. On his own plate were placed the dry pieces that had been a bit overcooked. At the end of the meal there was nothing left but bones. After dinner Mrs Sprat mentioned that she'd heard in the market place that the Wolf was planning to interfere with their weather reporting but was not sure how.
Fun with the Yun
The following day Hans was studying the Yun manual again and he thought of Jack Sprat and his wife. The Yun was made up of two parts, an Atmel ATMega microcontroller designed to interface to sensors and the real world and an Atheros processor running router software to connect to the WiFi and internet. Complementary functions fulfilled by each part.
Useful links
Linino wiki - upgradeimage
Arduino - YunUBootReflash
Checking the weather
The there was a curl example in the ArduinoYun Getting Started Guide that looked appropriate "It should be simple to modify this to connect to the weather service", he thought.
#include <Process.h> void setup() { // Initialize Bridge Bridge.begin(); // Initialize Serial Serial.begin(9600); // Wait until a Serial Monitor is connected. while (!Serial); // run various example processes runCurl(); } void loop() { // Do nothing here. } void runCurl() { // Launch "curl" command and get Arduino ascii art logo from the network // curl is command line program for transferring data using different internet protocols Process p; // Create a process and call it "p" p.begin("curl"); // Process that launch the "curl" command p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl" p.run(); // Run the process and wait for its termination // Print arduino logo over the Serial // A process output can be read with the stream methods while (p.available()>0) { char c = p.read(); Serial.print(c); } // Ensure the last bit of data is sent. Serial.flush(); }
swapping out the URL parameter with one for the for the weather in Chicago
http://query.yahooapis.com/v1/public/yql?q=select%20item.condition.text%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22Chicago%20IL%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
produced a JSON result with the weather conditions that would need to be parsed.
{"query": {"count":1,"created":"2015-04-10T10:24:59Z","lang":"en-GB","results": {"channel": {"item": {"condition": {"text":"Cloudy"} } } } } }
Based on his experiments Hans sketched up a class diagram for the software.
Thoughts of the Wolf
Hans smiled as the message appeared on his screen but his thoughts soon turned to the Wolf. How could he be sure that the server he was connecting to was the real server? How could he ensure his request had not been tampered with and how did he know that the response was legitimate?
Next: Enchanted Objects Design Challenge - Channels and a special delivery to the Enchanted Cottage