Letizia and I have been in New Zealand for almost a month, and we love it.
We hike and swim almost daily and we rest a lot. We hired a campervan, and we move often, exploring mountain trails, and beautiful beaches.
I haven’t checked Instagram, Twitter, or emails since we arrived here and I don’t feel any pressure in doing so. However, we have data SIMs in our phones so sometimes I find myself entrenched a little too much into reading news here and there, mostly on Reddit and Facebook.
I’m not a fan of new year’s resolutions but I took some time to reflect on the year that had just passed.
Three things I did well in 2018
I got married
In September Letizia and I got married. It was the very best day of my life and I had the chance to experience something unique. For the first time ever, all of my friends and family gathered under the same roof to enjoy a day together.
The preparation for the wedding kept us busy for the previous 7 months, but it was totally worth it. We’ll always cherish this memory together.
I got a coach
In august I started a professional development path with a coach, and it was really great. I realised how important it find someone who can help move up to the next level. The same way it happens in sports, a coach is not going to do the work for you, and it’s not giving you a magic potion. A coach helps finding new directions, opportunities, and answers, simply asking questions, exploring arguments, and focusing the conversation on what matters. A good coach does not leave any stone unturned and forces you face fundamental questions about yourselves. It was empowering and somehow liberating.
I picked up free-diving
In March I signed up for a free-diving course that ended in June. It was an amazing experience that opened up a new world of opportunities. I am fascinated by my aspects of this discipline and I definitely got hooked to it. I’m just at the very beginning of this adventure, and I can’t wait to developing it further.
Two things I did not well in 2018
I gained weight
I’ve struggled with my weight since I can remember. I’ve had these 10kg of extra weight on me for my entire adult life, but now getting closer to my 40s things won’t get any easier in trying to get rid of them. This year, on the contrary, I gained a few kilos more, and it’s not good.
I neglected photography
This year I did not take as many pictures as I wanted, and definitely not as good ones as I wished. For many months my camera collected dust on a shelf, while I was busy at something else. Photography has given me great opportunities in life, and amazing joy in the past. This year was definitely bad, on that aspect.
One thing I’ll focus in the next three months
In just 9 days I’ll take a sabbatical leave from work. Letizia and I will leave for three months, exploring New Zealand and the pacific islands. The plan is the hike and dive for the entire time, not bothering with anything else. I already deleted Instagram, Twitter, and Facebook from my phone. I’ll delete more apps as soon as the sabbatical kicks in.
I won’t post regular updates of the sabbatical, and until mid April 2019, this blog will fly in autopilot, with a few scheduled posts. I will probably read email once a week or so, or even less frequently.
I’ll have my camera with me, but I’ll select and publish photos only at the end of the trip.
The less complicated part of the whole project is the one that brings the WOW factor!
We are all so used to the wonders of the Internet, interconnected devices, screens, and even voice-activated assistants like Alexa that as soon as things move, we all stare in awe.
To achieve such an effect, with the box that self-opens and closes, only three pieces of hardware are strictly required: a microcontroller, and two servos.
Hardware List
Arduino MKR1000.
2# Servo.
Wires.
Breadboard.
Micro-USB Cable.
I went for an MKR1000 because it has integrated WiFi capabilities, and it was sitting in a drawer in my studio. Any WiFi-powered Arduino would actually do the job.
The servos are super basic too. I used two SG90 I had spare, but anything similar would do.
Wires and breadboard made the circuit easy to build and easy to tear down without any soldering or permanent connection.
The whole circuit is powered via a Micro-USB cable connected to a phone charger. This gives a handy 5V power supply for the servos without a dedicated power circuit.
The code initializes the Wi-Fi connection and subscribes a topic on the MQTT Broker. It then moves the servos according to the message it receives.
Important to notice, in the code, how the two servos are mounted facing each other, so they move in opposite angles. Not a big deal, but it might look cryptic in the code.
In the next posts, I’ll show how the cardboard box is built and how to make the Alexa interface to sound nice when it receives the command. Stay tuned!
As mentioned previously, the central part of the project is represented by the Infrastructure and Logic, both performed on a Raspberry Pi 3, powered by Raspbian.
The two pieces of software that I’m using are Node-RED for the automation and Mosquitto for the signaling.
Let’s see them in details:
Node-RED
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
It allows representing every piece of your automation system with a node, configuring its behavior, and connecting it with all the other elements of your system. It also allows to program functions, manipulate the messages, set delays, and so on.
There are a ton of libraries to operate with many different devices and services. For this project I used just a handful of them:
Let’s see how they are interconnected and configured:
Alexa-local node
The configuration of this block is trivial. It’s just enough to give a name to the node, and it will be the name that Alexa will list in the discovered devices. After this node is deployed it’s necessary to give an “Alexa, discover devices” command to make it appear in the smart home section of your Alexa as a new device. You can find the Alexa-local node on GitHub or in the install palette on Node-RED.
Function “Open” node
This function takes the message coming from Alexa and manipulates the payload to control the opening of the box.
The function is extremely simple:
Delay node and Close Template node
The first node introduces a 20-second delay before triggering the close template.
The close template is defined as follows:
Once again, this is nothing fancy.
MQTT-out node
As you might have understood, the only two messages that this node receives are true, when it’s time to open the box, and false, 20 seconds later, when it’s time to close it.
These messages are sent to an MQTT broker with the topic box_open as follows:
And that’s all it’s needed on Node-RED to make it work. Let’s now see how to tell the Arduino board to open and close the box.
Mosquitto
To interface Arduino to Node-RED I went for the most appropriate protocol: MQTT. This protocol requires a broker, a piece of software that receives signals from the many different agents, and dispatches them to the appropriate recepients.
And this is all you need to know to make it work on our Raspberry Pi. You simply install Mosquitto and make sure it’s configured as your MQTT broker on Node-RED and on the Arduino sketch. Voila!
Downloads and resources
You can find the Node-Red Flow, and all the rest of the resources on this GitHub repository.
It’s all released under GPL!
That’s all for today, in the next posts I’ll show you how to configure Alexa, how to build the box, the circuit board, and configure Arduino.