Overview

This particular enchanted object is right out of the storybooks. Deep in the forest is a small cottage owned by a timeless couple, Hans and Matilda who are doomed never to meet. When it is wet he goes outside but when it is dry she must leave the house.

 

The idea was to take an old fashioned "cat gut" based weather house and use the electronic components to bring it up to date. The key features would be servo driven mechanics, LED showing the temperature and the Arduino Yun for getting the weather from the internet.

 

BeforeAfter
WeatherHouse.jpgFinished House~2[1].jpg

 

The project has stayed fairly true to it's original idea, the LED bar graph for the temperature has been swapped with the coloured LED and the need to have a button to check the temperature has been eliminated. The mechanics have been 3D printed and fitted together with magnets under the cottage so that the figures move straight in and out of the house with no obvious form of propulsion.

 

Infomatic.png

 

About me

Before the project I knew a bit about Arduino, nothing of the Linino portion of the Yún and had not touched Linux for years. I also had not coded in Python before or used RGB LEDS and piezo sensors. I'd only just started with 3D printed back in January. I do have some electronics background having done GCSE and AS-Level electronics and then a degree at Imperial college back in early 1990s. I've been in software ever since and just returned to electronics as a hobby in the last couple of years.

 

Thanks

Hans and Matilda are just fictional characters so in reality all the work on this project was done by myself.

IMAG1535[1].jpg

However, I can't take all the credit.

 

Thanks to Atmel, Element14 and Infineon for providing the kit for the project.

A special thanks to Christian DeFeo and team for setting up the challenge.

 

Thanks to everyone who's provided help and support along the way

My wife Rebecca for acting as a sounding board and putting up with the late nights coding and noisy printer in the kitchen.

Alan Barnet for support and ideas

Support and advice from the Element14 community Jan Cumps, Clem Martins, Frederick Vandenbosch, shabaz, Ambrogio Galbusera and Mark Beckett

Inderpreet Singh and peteroakes for their support and RGB lighting code

Charles Gantt for his enthusiastic reports

Eric Styles for advice on magnets

AdaFruit for their splendid Powerboost board and DHT22 library.

Michael Anthony Schwager for the Enable Interrupts Library

Michael Margolis,Philip van Allen and Korman for the variable speed Servo Library

jwaldha for the technique on how to turn off the Linino portion of the Arduino Yún

the members of the Arduino forum for their treasure trove of ideas and information

 

Posts

As well as the weekly "story" posts I added a few out of character ones for interest and to include extra technical details.

 

Enchanted Objects Design Challenge - Disaster strikes the Enchanted Cottage

A big thanks from Hans, Matilda and myself

Enchanted Objects Design Challenge - Remodelling the Enchanted Cottage

Enchanted Objects Design Challenge - Matilda is not happy

Enchanted Objects Design Challenge - The Woodcutter and the Blacksmith

Enchanted Cottage CAD models

Enchanted Objects Design Challenge - Back on the straight and narrow

Servo and mechanics in action

Enchanted Objects Design Challenge - Yum Yum Yun at the Enchanted Cottage

Enchanted Objects Design Challenge - Channels and a special delivery to the Enchanted Cottage

Enchanted Objects Design Challenge - The snake, the troll and the fighting dwarves

Setting up a Python Development Environment

Listening to weather on the radio

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

Enchanted Objects Design Challenge - The Blue Haired Woman and Off Grid Living

Enchanted Objects Design Challenge - Hans meets "Injector"

Enchanted Objects Design Challenge - Farmer Hogg and the Lockity Gowan

Enchanted Objects Design Challenge - Taming the Python

Enchanted Objects Design Challenge - The Glowing Golem and shiny battery box

Enchanted Objects Design Challenge - Sleeping Golem

Enchanted Objects Design Challenge - The townsfolk get Rickrolled

Enchanted Objects Design Challenge - This is not the WiFi you are looking for

Enchanted Objects Design Challenge - An unexpected visitor to the Enchanted Cottage

Enchanted Objects Design Challenge - Knock Knock

Enchanted Objects Design Challenge - The Crystal Cave

Enchanted Objects Design Challenge - Turn on and offable

Enchanted Objects Design Challenge - Windows 10

Enchanted Objects Design Challenge - The Lode Stone

Enchanted Objects Design Challenge - A tale of two bridges

Yet another way of blinking an LED on the Arduino

Swapping out the bridge

A bit of 3D Printing

Enchanted Objects Design Challenge - Locking the doors

Enchanted Objects Design Challenge - Tools

Enchanted Objects Design Challenge - Painting, top panel and new magnet carriers

Enchanted Objects Design Challenge - System Overview

Enchanted Objects Design Challenge - Python Start, Python Stop

Enchanted Objects Design Challenge - Planning and Building

Enchanted Objects Design Challenge - Testing

Enchanted Objects Design Challenge - And they all lived happily ever after

 

General Interest

These posts were created for general interest and reference but were not specifically to do with the project.

Superclock

Useful videos and references

Securing IOT devices

Other enchanted objects

More enchanted objects

Extreme Enchanting

 

Technical issues and challenges

The build for the Enchanted Cottage was not all smooth progress. There were a selection of technical challenges and mistakes along the way.

 

The servo provided was a continuous rotation servo, to use that would have made the project particularly challenging. The tinkerkit servo was also a bit large for my house so I purchased a smaller positional servo.

The Arduino Yún provided it's own set of challenges. Firstly was making it connect to the Web API using a HTTPS connection, this required installing the certificates and jumping through some hoops to get the python components needed. Luckily there was more than one Python library to use so I managed to find one that worked and validated the certificates.

The mechanics to make the figure move took a few attempts, firstly to get the correct motion then to get something that could be reliably 3D printed.

The wiring took a couple of goes to get right, I had initially put the cables too far into the sockets leaving no room for the pins. I also used solid core for these wires which is all I really had spare. This mean that the wiring loom was quite stiff and difficult to manoeuvre, swapping this with flexible cable would make sense.

There were some physical issues too, the short cable on the LiPo battery is definitely one to watch for. Generally finding enough space for all of the components so that they did not clash and issues like the height of the components on the Yún and different holes in the proto board meant for a few on the fly changes being needed to the structure. The woodwork would be built differently knowing what I know now. The proto board inevitably ended up a little messy as the layout was revised a few times. Again there was difficulty finding space for the connectors so that they did not clash with the board and mounting struts.

Managing power became one of the key topics as I wanted to run the house on batteries, I found what I needed online for that and my experiments produced good results.

The Infineon RGB shield was easy to use and the previous challengers had generated some good documentation and code libraries. I knew I'd be right on the lower current limits of the board but with the right settings and timings the current was set correctly.

The knock knock circuit was heavily researched before incorporating into the project. The circuit was straight forward to understand and build with just the lack of a pull up resistor on the comparator output causing any delay.

 

I've learnt a few bits of electronics along the way such as driving MOSFETS and handling the signal from the Piezo transducer and I've learnt lots about the Arduino Yún.

 

Circuit Diagrams, 3D Models and Code

 

All of the files for the project can be found on GitHub which I've been using all through the project to manage the project and share files between computers.

 

https://github.com/Workshopshed/EnchantedObjects

GitHub.png

 

Code: https://github.com/Workshopshed/EnchantedObjects/tree/master/Code

 

The code is a combination of C++ on the Arduino side and Python on the Linino side, there are also some shell scripts to help setting up the system. The decision to use C++ classes to segregate the functionality was not done to create re-usable libraries for others but to make the code clear to read and maintain. The decision to use Python was based on that it was an easy language for beginners and that it was already installed on the Yún.

 

As mentioned above there are several libraries incorporated into the code

 

AdaFruit - DHT22 library - https://github.com/adafruit/DHT-sensor-library

Michael Anthony Schwager - Enable Interrupts Library - https://github.com/GreyGnome/EnableInterrupt

Michael Margolis,Philip van Allen and Korman - Variable speed Servo Library - https://github.com/netlabtoolkit/VarSpeedServo

Inderpreet Singh and peteroakes - Infineon RGB lighting Library - https://github.com/inderpreet/infineonrgb_shield

Eberhard Fahle - configuring the handshaking line for the Arduino Yún

 

Electronics: https://github.com/Workshopshed/EnchantedObjects/tree/master/Electronics

 

The original plan was to use Fritizing to document a lot of the circuits. Fritzing provided it's own challenges so a mini tutorial was written on what was learnt. As the project progressed many of the schematics were simply done using Visio as all that was needed was the high level blocks and wires. For the full schematic Eagle was used as it's libraries were more extensive so fewer components needed to be designed.

Many data sheets and websites were referenced and are too plentiful to mention here but they are mentioned on the specific posts that utilised them as a reference section.

 

{gallery:width=500,height=500} Circuit Diagrams

Power Switch

Power Switch: Switches on an off the peripherals

Knock Knock

Knock Knock: Sensor circuit

DHT22

DHT22: Temperature and Humidity Sensor

RGB

RGB: Infineon RGB Shield and LED

Full Schematic

Schematic: Full schematic

 

Mechanics: https://github.com/Workshopshed/EnchantedObjects/tree/master/Mechanics

 

The 3D printed parts were all modelled in OpenSCAD so they have a source code as well as the STL files that were generated for printing.

 

{gallery:width=500,height=500} Printed Parts

Mechanism

Mechanism: Parts for the Watts Linkage

MagnetHousing.png

Magnet Housing: Holder for the magnets

FibreHousing.png

Fibre Housing: Attach fibre optics to the Arduino Yún

WindowFrame.png

Window: Replacement window

Top Panel

Top Panel: Show fibre status and buttons

WifiAndPowerButtons.png

Buttons: A couple of buttons to control the setup

Spacers

Spacers: Different heights of spacers for the boards

Security

Security has always been in the back of my mind whilst working on this project, the wolf is never far from the door.

Wolf.png

The thing that amazed me the most was that there were practically no end to end examples where people had created a secure connection to a HTTPS server. The ones I found had a one liner that mentioned installing certificates but no detail. I suspect this is because the Arduino Yún is targeted and used by hobbyists.

 

Secure communication could be done using a VPN but as the destination is not under our control, that's not possible, so an alternative way to secure the communication was used.

Enchanted Objects Design Challenge - Channels and a special delivery to the Enchanted Cottage

 

The key features of the communication are:

  • Certificates installed from a trusted source
  • Certificate provided by weather server validated to ensure identity of that server
  • Communication from weather server encrypted using TLS as provided by HTTPS end point

Enchanted Objects Design Challenge - Taming the Python

 

The cottage has been made to continue working in the case of a network failure of DOS attack

Enchanted Objects Design Challenge - The townsfolk get Rickrolled

 

The cottage has been made to continue working in the case of a power failure

Enchanted Objects Design Challenge - The Blue Haired Woman and Off Grid Living

 

To lock down the Yún the following principles were applied

  • Users and passwords
  • Handle brute force attacks
  • Remove unused functions
  • Apply principle of least privilege (limited implementation)

Enchanted Objects Design Challenge - Locking the doors

 

Instructions for use

Initial set up

  • The one time set up of the system is the out of the box experience provided by Arduino, you have to configure the WiFi to point to your local network.
  • Unless you live in Chicago,IL you'd also need to set your location in the configuration file.

User Operation

  • Then all the user has to do to get the weather is wait, the figures will automatically adjust their positions and the light changes colour as new data become available.
  • For impatient users they can simply knock on to roof to trigger a system wakeup and check for weather.
  • Rather than needing to read small digits the user can quickly tell the temperature from the LED colour.

 

Story

The story aspect was written each week on the morning commute based on the planned work to be done. As the week progressed this occasionally resorted in a re-writing of the story so that the tale correctly reflected what was actually done, some of the topics were moved to later weeks as needed. Writing in the third person narrative was at times challenging and I decided fairly early on that it would be easier if Matilda did the mechanical aspects and Hans did the coding and electronics. However I did have to re-allocate some tasks between my alter-egos so that it was more evenly shared.

 

Costs and Cost Saving ideas

As mentioned in Enchanted Objects Design Challenge - How much!? there are many opportunities to reduce code on this project.

 

The key points are:

  • Build a single board based on a 3.3v supply, that would reduce a lot of the complexity such as connectors, physical support for the board, power regulators, level shifters etc.
  • Build the house from pre-printed panels that could be laser cut and simply assembled.
  • Simply assembly steps by eliminating some of the screws from the mechanism.

Working project demo

A quick demo of the house in action. The demo mostly shows the long boot time of the Linino portion of the Arduino Yún. It typically takes around 60s to boot and depending on the disk state it could take longer. I did some research into how this time can be reduced but did not have chance to implement anything.

On power up the figures move so that Matilda is just inside and Hans just outside. This would indicate a slight chance of rain.

The flashing light at the start of the process shows the system waiting for the boot. Once it's booted the light changes to indicate that it's processing the weather and then changes again to a the solid light with a  slight movement of the people to the middle position to show that it's going to be a "changeable day in Chicago" which is where I've configured the system to check for weather.

 

 

Improvements?

 

A few enhanced features have been suggested by various engineers, including Christmas lights and posting the status to the internet. Solar panels on the roof were also suggested, some calculations would be needed to determine if that would make a significant difference given the small roof size.

 

For me the biggest thing that could be improved would be reducing the size of the electronics and hence the size of the back if the cottage. With a custom board or simply smaller modules it should be possible to bring that width down to just a little more than the thickness of the servo.

 

It would also be good to have the weather information displayed on some kind of screen, I did look into 8x8 LED matrixes but those would consume a lot of power. The obvious low power option would be a electronic paper display as that only uses power when it updates. The Arduino could stream images from the Linino's storage onto the display to show for example a picture of a cloud when it's cloudy.

 

The software for the system focuses on the functional aspects, moving the servo, getting the weather etc. There is lots that could be done on the user interface such as providing an easy way to set the location and simplifying the UI provided by Arduino.

 

A couple of things planned for the project were dropped along the way. One idea was to use capacitive switches for the controls, however this was dropped in favour of the knock knock switch and simple top panel buttons. A clear plastic housing for the back of the cottage was planned but got cut at the end due to time constraints. A rather crazy idea of using a model railway smoke generator to provide a smoking chimney (on cold days) was also abandoned.

 

The Low Battery signal from the charging board is wired to the protoshield but nothing is done with it. That could be wired to one of the inputs and read in the code.

 

As mentioned above improving the boot speed would be a significant improvement to the system.

 

The Infineon shield was investigated to see if the Flashing and colour cycling functions could be offloaded to it's MCU. This required a special cable and software so was not attempted.

 

Conclusions

 

The design challenge has definitely lived up to it's name, it was very challenging. I've learnt a lot about embedded systems during this project, from interrupts and low power options on the Atmel microcontroller to MOSFETs and power control thanks to Infineon. I've also learnt a lot about 3D printing and designing models to make them print reliably. One of my key lesson's learnt is keeping an eye on the physical space required for connectors so that they don't clash with other components.

 

I'm happy will the end result and enjoyed making the Enchanted Cottage, and I'd like to thank Element14 for giving me the opportunity to participate.

 

Finale

And so our enchanting tale comes to its end. If you go down to the forest, there in a little clearing you will find an Enchanted Cottage. If you knock on the door then a delightful couple will pop out to tell you the weather. But be careful not to stay too long as you might bump into the wolf.