<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Riccardo Ferrazzo on Medium]]></title>
        <description><![CDATA[Stories by Riccardo Ferrazzo on Medium]]></description>
        <link>https://medium.com/@rferrazz?source=rss-48b30fe9d7cd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5M6Zb9aiKUXYTB-g</url>
            <title>Stories by Riccardo Ferrazzo on Medium</title>
            <link>https://medium.com/@rferrazz?source=rss-48b30fe9d7cd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:11:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rferrazz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hacking my house]]></title>
            <link>https://rferrazz.medium.com/hacking-my-house-86fb5d9d54b3?source=rss-48b30fe9d7cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/86fb5d9d54b3</guid>
            <category><![CDATA[home]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[home-automation]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Riccardo Ferrazzo]]></dc:creator>
            <pubDate>Sat, 02 Jan 2021 15:05:56 GMT</pubDate>
            <atom:updated>2021-01-02T21:51:00.366Z</atom:updated>
            <content:encoded><![CDATA[<h4>The first of a series of articles about my DIY smart home. I am going to give an overview of why i did it, what it does and design decisions of the system.</h4><p>I always thought that my home would have been smart and I always had the dream to build it kinda like Jarvis in the Iron man movie. Don’t want the fake smart world we are submerged with. I’m not a fan of how big internet companies shaped our houses full of wifi enabled devices that do not talk eachoter and are considered smart because you have to swear at them. I want something hidden, integrated, that makes me feel that I live in a smart home just because I don’t have to do a thing to make the magic happen.</p><p>There are some ready made solutions but being a programmer I wanted to do something on my own.</p><h3>Components</h3><p>I started searching something easy to program and that was fitting my needs and I found a a PLC like controller powered by the Raspberry Pi 3 created by Unipi Technology. The product is called UniPi Neuron: <a href="https://www.unipi.technology/products/unipi-neuron-3">https://www.unipi.technology/products/unipi-neuron-3</a></p><p>The device runs a customized linux distribution Based on Raspbian. My criminal mind went through the idea of using just the hardware they provide plus their open source kernel modules and to make a custom linux distribution based on yocto that powers my own IOT system.</p><p>The constraint I put to the system are the following:</p><ul><li>Local first because remote connection might not be there</li><li>Easy to deploy on embedded devices: this means using Go as the language (because it is reasonably fast, safer than C++ and it comes with a next level toolchain), having a single executable to deploy and a single configuration file</li><li>Hidden. Tech is not shown. The house is pretty standard at a first glance</li><li>Use existing household stuff and wired components as much as I can (standard thermal valves, standard light switches, plugs, etc…)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AlaOJ1r6Sl4gWifenP3wTg.jpeg" /><figcaption>My kitchen</figcaption></figure><p>Today I live in my new house. The system I made is still not 100% complete but it is stable and it currently controls:</p><ul><li>An heating system with 7 zones. One for each room. The system turns on or off the floor heating based on some rules about the temperature and the hot water flow of each room (small rooms made the boiler to start and stop often because the quantity of water to heat up is not enough to make it run for a while. So the rule is to group together rooms that are close to the starting temperature if they are small)</li><li>Control something like 40 digital devices like lights plugs, the doorbell and others. Either from wall switches or via an event based automation system</li><li>Control 4 leds stripes via PWM outputs</li><li>Execute an action after a given period of time (useful to turn off bathroom heating or lights that might be left on by mistake)</li><li>Execute actions at a given time (minute precision)</li><li>Execute something at sunrise/sunset (useful for garden lights)</li><li>Execute something in reaction to any kind of other event</li><li>Send notifications via telegram in reaction to an event</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8NVTX9Qi2lYzYp1ipYCRjA.png" /></figure><p>And of course it comes with a not yet finished Android app</p><p>In the next article i want to talk about the Go application that runs everything and how it works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86fb5d9d54b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless e-commerce: lessons learned]]></title>
            <link>https://rferrazz.medium.com/serverless-e-commerce-lessons-learned-608b90cbdc39?source=rss-48b30fe9d7cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/608b90cbdc39</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[hugo]]></category>
            <category><![CDATA[stripe]]></category>
            <category><![CDATA[static-site]]></category>
            <dc:creator><![CDATA[Riccardo Ferrazzo]]></dc:creator>
            <pubDate>Fri, 29 Mar 2019 07:31:01 GMT</pubDate>
            <atom:updated>2019-03-29T13:06:43.385Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJ46qvZ6k-_T0kOEHAcB0Q.png" /></figure><p>This winter I decided to give my mother an unusual Christmas gift. She owns a beachwear shop in a nearby seaside city and she is always looking for ways to increase her incomes and to promote her shop. So I decided to make her an e-commerce website. Being not a web developer this resulted in the occasion to learn something new.</p><p>I had a big constraint: the cost of running the website should have been the lower possible. Optimistically it should not have had fixed fees.</p><p>I started searching for the best solutions and quickly realized that static websites are gaining a lot of traction these days and that hosting a static website has lower costs then his dynamic counterpart. Then I found <a href="https://www.netlify.com/">Netlify</a> and I fell in love with the level of automation it offers. Just push to a repo and it takes care of the deployment 😍 All of a sudden the embedded world seems so old fashioned.</p><p>I choose <a href="https://gohugo.io/"><strong>Hugo</strong></a><strong> as the static website framework</strong> because it is fast, easy to grasp and written in Go which is a great language. I was not able to find good free e-commerce themes for Hugo so I created my own theme based on a free html template found online. That gave me the ability to customize the website without constraints and to learn Hugo a little more.</p><p>Kept the website structure as simple as possible since the website is selling just bikinis and so far we have less than 50 products. It has just a landing page, a products page that lists all the items for sale and a page that shows a detailed view of each product and correlated products (thanks to the .Site.RegularPages.Related variable on Hugo). Filtering is done dynamically via javascript on the listing page.</p><p>Once the showroom was in place I had to add the shopping cart and the payment gateway. I already did a research on the subject and the obvious solution was to use <a href="https://snipcart.com/"><strong>Snipcart</strong></a> for a serverless e-commerce website. Adding that to my website was a breeze. It offers a dynamic cart, a checkout form and a secure payment gateway (for more on this subject visit this blog post: <a href="https://snipcart.com/blog/hugo-tutorial-static-site-ecommerce">https://snipcart.com/blog/hugo-tutorial-static-site-ecommerce</a>).</p><p>Unfortunately after the website was almost ready I found a big drawback in using Snipcart: the price. Snipcart has a monthly fee of 9€ if your store makes less than 442€ in revenue in the same period of time. Not a big bother for someone who is sure to meet the target but for a newly born website this could be too much. This was hitting hard against the constraint I had and I finally decided to ditch Snipcart and to find a cheaper alternative.</p><p>The solution i came up with was to use <strong>Stripe as a payment backend</strong>. Stripe does charge a fixed amount per payment no matter of the volume of your monthly transactions. Stripe is not targeted to static websites. It is rather a collection of tools that can be adapted to a wide range of uses with some glue code. Going this way required an additional effort to prepare a cart that works across my website pages and a checkout page to collect shipping informations as well as payment details.</p><p>Implemented a basic Javascript cart that is using localstorage to store chosen products and details about them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*aWLjN2WMNmWoeiI_rw-tYw.png" /><figcaption>JS cart in all of his glory</figcaption></figure><p>The checkout page uses <strong>Stripe JS</strong> and <strong>Stripe elements</strong> to fetch the payment details and then it triggers the payment backend via a POST request to a lambda function stored on AWS. The lambda function uses informations passed via the post request to validate the products and make the payment through <strong>Stripe Order</strong> APIs. The function then returns a series of data on wether or not the payment was successful and — in case of an error — what the issue was about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*ItruSjPor_rUXqYI-64ypQ.png" /></figure><p><strong>Stripe Orders</strong> is providing the stock inventory database for my website. Investigated also the possibility to generate the product list on the website dynamically by fetching data from the stripe inventory. This would have allowed to display only available products giving a more valuable information to the customer, but I choose to not use it and generate all of the items as static pages from Hugo because that allowed Hugo to generate the sitemap, to have a better search engine indexing and to categorize products based on taxonomy terms. The latter allowed to show links to related products on the bottom of the product page and to allow the navigation by category. Currently stock inspection is done only while issuing the payment. When the store will gain more traction I am going to use Stripe Order APIs to show stock availability inside the product page with a POST request to another Lambda function.</p><h3>TL;DR</h3><ul><li>Static website generators are a valid alternative to dynamic websites especially if you are not aiming to have tons of products. It keeps the whole thing easy to manage and cheap</li><li>If you don’t have budget issues and you are not aiming for a super custom design Snipcart is the solution for a serverless e-commerce</li><li>Stripe is an extremely flexible alternative and it does not charge you if you don’t make any money. But it requires more work to be adapted to a static website</li><li>AWS API Gateway and AWS Lambda are the glue that allow a static website to become a serverless website. There alternatives (less tricky to use) but AWS is cheap and complete</li><li>A good design choice is to use static product pages and stuff them with a backend request to display stock availability of each product</li></ul><p>Ah BTW this is the final result: <a href="https://meraviliao.com/">https://meraviliao.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=608b90cbdc39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IOT embedded framework in GO]]></title>
            <link>https://rferrazz.medium.com/iot-embedded-framework-in-go-2b5a0adcee27?source=rss-48b30fe9d7cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b5a0adcee27</guid>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Riccardo Ferrazzo]]></dc:creator>
            <pubDate>Mon, 11 Feb 2019 17:31:01 GMT</pubDate>
            <atom:updated>2019-02-11T22:35:15.355Z</atom:updated>
            <content:encoded><![CDATA[<p>During my daylight job I am used to write a lot of complex C++ code that is going to empower high end embedded devices applications. Sometimes i had to work on some of those so called <strong>c</strong>o<strong>nnected devices</strong>. A category of devices that everyone is trying to push into the market no matter if it is really useful or not.</p><p>Every embedded connected project is facing big technical challenges that developers are struggling to solve: software updates, security, reliability and ease of use. So in my free time I started my own IOT project to see if given no constraints I was able to find some elegant technical solutions to overcome those issues. Here’s what i came up with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nQpWykOxvjjr_AgbEwdksg.png" /></figure><p><a href="https://github.com/GoChik"><strong>Chik</strong></a><strong> </strong>A framework made in GO that allows you to create IOT monolithic applications just by assembling or creating components called Handlers. The framework provides a pub sub based in process communication framework as well as a request reply like framework to communicate with another device over the network and an interface to store/retrieve data. The framework uses Json as the format for messages and stored data.</p><h3><strong>Why GO?</strong></h3><p>GO is not so popular on embedded devices. The vast majority of embedded projects i worked for during my daylight job were using C++ but GO has several advantages that are making the whole thing a lot easier:</p><ul><li>It is reasonably fast: It is not as fast as C++ but most of the times it is fast enough.</li><li>It is <strong>easier</strong> and <strong>faster</strong> to write complex applications in GO rather <strong>than C++</strong> because go does have a garbage collector and memory management is “assisted” I know these days C++ has improved a lot but it is not meant to be an easy language like GO.</li><li>It is statically linked: every library is bundled within the executable and that simply throws out of the windows all the frustrations an embedded C++ developer is facing everyday: lack of standard toolchains, dynamic linking nightmares and - when developing for embedded devices - even a worse situation.</li><li><strong>It does not require an embedded SDK</strong>: GO compiler can cross compile for a wide range of architechtures. Let’s suppose you want to cross-compile for your raspberrypy: just issue the following command: GOOS=linux GOARCH=arm GOARM=6 go build and you’re done how easy is that instead of having to spend hours in front of the PC that’s just compiling the yocto embedded SDK hoping this is the last time you are running bitbake</li></ul><h3>Architecture</h3><p>The framework allows allows to create monolithic applications by creating an instance of the Controller element. It acts as the bus for messages and the orchestrator for the various building blocks called Handlers. The controller manages the lifetime of handlers, gives them the channel to communicate one each other and allows to send messages to the outer world via a Remote.</p><p>Handler is an interface that contains a single function: Run. It gets executed in a goroutine and can communicate and receive messages through the Controller API. Having multiple goroutines helps the application to scale well on different hardwares even being a monolithic one. Here’s an example of an handler</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31df894a667b2d06a07c73aa1712318f/href">https://medium.com/media/31df894a667b2d06a07c73aa1712318f/href</a></iframe><p>The remote communicates with the outer world and the mobile app (yes there’s one) with a stream of data sent through a persistent TLS connection. the server runs the same software as the client but with different handlers. Currently it is provided only of a routing handler that allows to forward messages to the destination client based on the uuid of the recipient of the message. I choose to run a persistent TCP stream instead of a more common http REST API because I really enjoy having lights to respond immediately to commands I am issuing them from the mobile application.</p><p>In addition to the binary for the software a Json configuration file must be provided. If it is not there the application will create a reference one when started. The file contains configuration data for each handler as well as a storage section for the storage of runtime data such as timers. This allows to ease the backup or a migration to another hardware because only a single file needs to be copied.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b921cc875073cbfc88fe8a4490aebeaf/href">https://medium.com/media/b921cc875073cbfc88fe8a4490aebeaf/href</a></iframe><p>Using Only Json as the stored data format and message payload data format helped a lot because it is a human readable format and there’s no need to write adapter classes to convert data. As a plus GO has great <a href="https://golang.org/pkg/encoding/json/">builtin json APIs</a>.</p><h3><strong>Project status and roadmap</strong></h3><p>I am currently using a client written with the framework on an old <a href="https://www.8devices.com/products/carambola">MIPSel</a> device that controls my garden lights. I put it also on a RaspberryPi zero to switch my parents garden lights and irrigation system. Then I have a cheap VPS that runs a server application for every device and does message forwarding. To control the whole system i made an incomplete Qt/QML app for Android that does the basic stuff such as setup timers, turn on/off something and update the remote device when a new version comes out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZHESNgEv8QcJto_1rp_5LA.jpeg" /><figcaption>Mobile application</figcaption></figure><p>The most important thing i want to add in the near future is mutual authentication. Currently clients are checking the validity of the server certificate because that was easy with LetsEncrypt. Client side authentication requires a lot more effort to manage certificates from the various devices so it has to be done with care.</p><p>Other than that I want to add more handlers for things like new protocols, and third party access like Google home and Apple HomeKit and give some love to the mobile application but since it is mostly a spare time project I will do what’s more fun first and what I really need second.</p><p>As a final note i think GO can be a blast in the embedded world. And this framework is my proof of concept that it is doable. Hope to see some innovations in the embedded field in the years to come.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b5a0adcee27" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>