<?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 Luca Gessi on Medium]]></title>
        <description><![CDATA[Stories by Luca Gessi on Medium]]></description>
        <link>https://medium.com/@lucagessi?source=rss-8c7cb0bae284------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FyzrSH5Qao2bdNtsKBO2Sg.png</url>
            <title>Stories by Luca Gessi on Medium</title>
            <link>https://medium.com/@lucagessi?source=rss-8c7cb0bae284------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:22:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lucagessi/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[RP2040 Smart Busy Board for toddlers]]></title>
            <link>https://lucagessi.medium.com/rp2040-smart-busy-board-for-toddlers-36c56d0be300?source=rss-8c7cb0bae284------2</link>
            <guid isPermaLink="false">https://medium.com/p/36c56d0be300</guid>
            <category><![CDATA[laser-cutting]]></category>
            <category><![CDATA[rp2040]]></category>
            <category><![CDATA[busy-board]]></category>
            <category><![CDATA[laser]]></category>
            <category><![CDATA[product-design]]></category>
            <dc:creator><![CDATA[Luca Gessi]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 10:09:04 GMT</pubDate>
            <atom:updated>2024-08-27T10:09:04.709Z</atom:updated>
            <content:encoded><![CDATA[<p>I am a Dad from 2 years now and I have always loved technology.</p><p>From this perspective I found a particular type of product named as Busy Board which let the child experment with hand manipulations, and find linkings with visual signals (leds). I bought a product from Amazon which is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/0*emiI-dKLq0CZIhpY.jpg" /><figcaption>Commercial typical wood made busy board</figcaption></figure><p>This product is phisically wired, every switch to its specific LED.</p><p>So I thought: what if I put a programmable microcontroller inside so that the led activity can be various and add other features, such as microphone and speaker?</p><p>From this very basic and crazy, for the time (and money) that I spent on design, I developed a Smart Busy Board with RP2040 microcontroller, audio output and microphone input. This can be the starting point for several application: child voice recognition, leds color control by voice and other.</p><p>The most difficult part was the production of wood container. I bought a milling machine (around 200€) and made some templeates for making holes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*BnajTPHhoISCRfXiaylfpA.png" /><figcaption>My first wood container vs commercial one</figcaption></figure><p>While thinking about making the container, I looked for a way to play sound with rp2040. This microcontroller is f*****ing awesome. It has some internal state machines PIO, which can be programmed to compute simple task in very deterministic timing. I used a PIO and DMA transfer for reading audio samples WAVE from FLASH (16 Kbit/s, 1 channel, 8 bit per sample) and send to PWM peripheral. After a minimal RC filter the audio signal is amplified using pam8302 (3W amplifier 2 channels).</p><p><a href="https://www.youtube.com/watch?v=tYW0N-ZTSBk">In this link a video of priliminary tests with RP2040 minimal board.</a></p><p>Then, I design the electronics using Kicad and made JLCPCB produce 10 protypes which assembly. I bought switches, 10mm leds and speaker mainly from aliexpress and alibaba.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*bgtJ2iEl8c1Z6HOhtYcb8w.png" /><figcaption>A sample image of the PCB</figcaption></figure><p>The board is powered from 2 AAA battery. I found that alkaline batteries has high internal resistance so I used Nimh rechargable batteries, 3 are better than 2 because the boost converter in the power stage has to step up from 3 to 5v instead of around 2 to 5 v (less current drain -&gt; less voltage drop -&gt; more battery life).</p><p>Another aspect to think about was how to make the holes in the wood container for leds and switches. It would be impossible to make them using drilling tool and by hand, so I spent other money and I bought a laser cutter, 5W.</p><p>I made all the shapes to cut using Inkscape and cut the front panel with 5w laser (around 8 repetition at 70% power). The wood is raw fir wood 5mm thick in the area of cutting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fuAddi8e2i87pk0G5VBuvw.png" /><figcaption>Laser cutting while doing (wrong) task</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*rolIHXbN9jg0R6bB3IKBAA.png" /><figcaption>First attempt…failed :D</figcaption></figure><p><a href="https://www.youtube.com/watch?v=DJzxB7Etznk">Here there is a video when the laser is working</a>.</p><p>Also other supporting wood materials, for battery screws, speaker, microphones and backcover, were made using laser cutting and glued in the main structure. I found it very funny to use and can be used to make very interesting things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*i3Qk9etWAdlz1ZGoswJKgg.png" /><figcaption>My son having fun with it</figcaption></figure><p><a href="https://youtu.be/5kGy6uCntX4">Here an example of more complex applications.</a> Audio is converted and loaded using uf2 format and python code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*fECOOGAl-N2fHg7HLGiK7g.png" /><figcaption>An image of internal components of Busy Board</figcaption></figure><p>Finally I glued all together and started to have fun!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iL6J4mPrSUHiz0aq1iRPhA.png" /><figcaption>Smart Busy Board programmed using USB C cable (and serial communication)</figcaption></figure><p><a href="https://www.youtube.com/watch?v=oEXn0e5uGsA&amp;list=PLOAKXwxFSrfZZQxw9ZxOF2chEkFq_zhzE">Here a video of a sample application loaded.</a></p><p><a href="https://www.facebook.com/profile.php?id=61564496033441">Here facebook page</a> (mainly in italian language for now)</p><p><a href="https://bitlab.store/">Here website</a></p><p><a href="https://www.youtube.com/@BitlabCreations">Here youtube channel</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36c56d0be300" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automatic garage door hack and hass integration]]></title>
            <link>https://lucagessi.medium.com/automatic-garage-door-hack-and-hass-integration-61fd8193e54a?source=rss-8c7cb0bae284------2</link>
            <guid isPermaLink="false">https://medium.com/p/61fd8193e54a</guid>
            <category><![CDATA[tasmota]]></category>
            <category><![CDATA[domotica]]></category>
            <category><![CDATA[home-assistant]]></category>
            <dc:creator><![CDATA[Luca Gessi]]></dc:creator>
            <pubDate>Mon, 11 Sep 2023 08:55:18 GMT</pubDate>
            <atom:updated>2023-09-11T08:55:18.554Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kKJJBTqWWV9yGzhc" /><figcaption>Garage board hacked with sonoff mini</figcaption></figure><p>I have an automatic door in garage which is controlloed by a 433Mhz remote controller. I wanted to integrate the command in home assistant so it would be possible to open the door using smartphone.</p><p>The first step was to open the plastic case and find the “controller”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tQylOTmcdtp67T4y" /></figure><p>The photo above shows the board. The buttons on the upper right when clicked works as the remote controller button, opens and closed the door. DONE. <br>I just solder two wires in parallel with the switch as in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jK9sqQTKc3qxoLdw" /></figure><p>The next step consisted in finding a way to close those button remotely. Fortunatly I found home a Sonoff mini with Tasmota firmware uploaded. Tasmosta let you customize the Sonoff, it exposes API Rest, MQTT and it is highly configurable.</p><p>The problem with Sonoff mini is that it has not a clear relay output but when it closes its output it just closes main power to its output. The solution of this was HACKING also this! Infact following this <a href="https://www.youtube.com/watch?v=3MPNsLCJ41c">tutorial on youtube</a> (it is in italian language but you can watch the video and follow images) the hacked board will have clean contact. I used a Dremel for cutting 2 pcb traces and it just worked fine!</p><p>After this, I upload Tasmota firmware to Sonoff mini. <br>Sonoff have by default a toggle function linked with the switch.</p><p>I configured Tasmota for generate a pulse of around 300ms. <a href="https://tasmota.github.io/docs/Commands/#control">See Tasmota commands for more information</a>.</p><p>In particular I set pulse duration using PulseTime&lt;x&gt; &lt;value&gt; so using REST API I can generate pulse using Power command.</p><p>After this I edit configuration.yaml of HASS. In particular I added a <a href="https://www.home-assistant.io/integrations/shell_command/">shell_command </a>which send a curl post request to the Tasmota device asking for powering the switch.</p><p>Now the device is working, the last thing to do is create a custom button.</p><p>Go to Settings, Devices &amp; Services, Helpers and click CREATE HELPER.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDcuxYVvxwrAH-MBVzmCWA.png" /></figure><p>Then create a Button with the name you want, <a href="https://www.home-assistant.io/integrations/input_button/">here the tutotial</a>.</p><p>Finally create the automation. Go in Settings, Automations &amp; Services and click create automation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tuh9mVqG97pw84ayP1sQ6g.png" /></figure><p>Configure the automation so that when the button you create is clicked it execute the shell command you defined above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9VgCe1OhTTdGMJSbBZl7Q.png" /></figure><p>Finally add your button in the dashboard you want and woila!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRt8iW3AOV6i7_7bJK0jMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*TYPZMCI7KoM2jqiUw8sy3Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61fd8193e54a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Consciousness is a chair]]></title>
            <link>https://lucagessi.medium.com/consciousness-is-a-chair-666ff84db8c6?source=rss-8c7cb0bae284------2</link>
            <guid isPermaLink="false">https://medium.com/p/666ff84db8c6</guid>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[chairs]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[awareness]]></category>
            <category><![CDATA[consciousness]]></category>
            <dc:creator><![CDATA[Luca Gessi]]></dc:creator>
            <pubDate>Thu, 07 Oct 2021 21:03:09 GMT</pubDate>
            <atom:updated>2021-10-07T21:06:51.856Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fdk2Ahk16L7LXEf00v7zhw.jpeg" /></figure><p>Chair: a place where a person sit down. It could be made by wood, steel or be simply a rock.</p><p>Chair is not an object. It is a concept. It deals with a person and its state of not being standing up.</p><h3>Unsupervised mind</h3><p>Do you think that mind works similar to a supervised algorithm?</p><p>What about knowing that an animal with 4 legs, a tail, which hates mouses and dogs is called a cat. Did you already know that animal? Or maybe at that specific moment when someone told you its name you recognise it? Do you need thousands of photos of cats for recognise it? No!</p><p>You already know it. You just didn’t know its name!</p><p>The mind is simply extremely curious. It finds out new concepts, ideas and can spontaneously classify objects. Labels are just a way to name them.</p><h3>Anonymous CNN classification</h3><p>Think about a CNN trained for classification. Suppose it can perfectly classify N objects. First layers extracts the main features and the last layers combine the learnt features in order to classify the objects.</p><p>The network uses N different combination of the learnt ones. But how many possible combination exists?</p><p>If we simply take a random combination of features does the output classifier make sense? What does it classify? Maybe it is a kind of creativity!</p><p>But it is just a supervised network so it just learn what you force it to learn.</p><h3>Unsupervised feature combination</h3><p>Now suppose we have an algorithm which can extract many features from images. This features are combined and ensembled then original concepts, creations born.</p><p>This method classify without the necessity of thousands of labeled samples.</p><p>The example is limited to image processing. Let’s try to imagine a system where sounds, vision, tactile sensors but also actuators like muscles, tongue are input and output.</p><p>During life experiences the brain understand that there is a correlation between, for example, a particular motion of tongue and the sound heard.</p><p>The correlation exists between the eyes motions and the image view.</p><p>The realization that exist these correlations between actions and sensors is the consciousness.</p><p>It is like a classification algorithm but it is a spontaneous realization (similar to an unsupervised method) that I can interact in some particolar manner with the experienced world.</p><p>So consciousness is like a chair, it is a concept, an abstraction wired in human mind, but the first one deals with the awareness of being able to interact with the world!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=666ff84db8c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Face recognition with PyTorch]]></title>
            <link>https://lucagessi.medium.com/face-recognition-with-pytorch-a771f52d7e28?source=rss-8c7cb0bae284------2</link>
            <guid isPermaLink="false">https://medium.com/p/a771f52d7e28</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[face-recognition]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <dc:creator><![CDATA[Luca Gessi]]></dc:creator>
            <pubDate>Sun, 11 Jul 2021 12:00:47 GMT</pubDate>
            <atom:updated>2021-07-11T12:25:55.184Z</atom:updated>
            <content:encoded><![CDATA[<p>Pretrained InceptionResnetV1 for Face Recognition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t4FnyjIbKSGKk9H8ae0wEA.png" /></figure><p>This story reflects my attempt to learn the basics of deep learning. Studing CNN, deep learning, PyTorch, I felt the necessity of implementing something real.</p><p>Face recognition is a technology capable of recognising face in digital images. My aim is to recognise my face in sample photos.</p><p>This article talks about:</p><ul><li>Generate my face samples using embedded notebook cam</li><li>Choose a faces dataset for training the model</li><li>Generate a dataset from the given images</li><li>Choose a pretrained model, load the model and train the last linear layer</li><li>See results</li></ul><h3>Getting face samples</h3><p>In order to generate my face samples I used opencv for access the embedded camera and saving images on disk.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37a1a201eb2898f06ac79a8f1f085697/href">https://medium.com/media/37a1a201eb2898f06ac79a8f1f085697/href</a></iframe><ul><li><em>VideoCapture</em> is a feature of opencv which let you use the embedded cam for recording and getting frames</li><li><em>folder</em> variable is the path where the images will be saved</li><li><em>video_capture.read </em>returns the actual frame</li><li><em>cv2.imwrite</em> write <em>frame</em> image into <em>filename</em> (with path) file</li></ul><p>Based on what key is pressed, the script:</p><ul><li>q: exits script</li><li>s or enter key: saves current video frame with current date name and jpeg extension</li></ul><p>I took around 180 photos of myself. The pictures are made with different facial expressions and using some kind of hats and accessories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ApZitOqB6LZmSUTrR0yQw.png" /><figcaption>Dataset samples</figcaption></figure><p>I took the images for noluca class from an open source face dataset. You can <a href="https://www.google.com/search?q=open+source+face+dataset">google</a> and find several of them.</p><p>Finally, I organised the images like in the image below. This allows pytorch dataloder to automatically create dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/104/1*PCq0GZWwjJIszWtlMH-DGQ.png" /><figcaption>Dataset folder structure</figcaption></figure><p><em>dataset/train/ </em>folder contains photos of my face (luca folder) and other person faces (noluca folder).</p><p>train images are 280 = 139 luca + 141 noluca</p><p>test images are 84 = 40 luca + 44 noluca</p><h3>Transfer Learning</h3><p>Transfer learning means using a pretrained neural network, usually by huge dataset, and reuse the layers before the last one in order to speed up the training process.</p><p>The pretrained CNN network can extract the main features of the image and use it for classification.</p><p>In order to reuse the network, you only have to train the last linear layer which use all the features as input and outputs the predicted classes.</p><h3><strong>Pre trained model: InceptionResnetV1</strong></h3><p>In onder to achieve high accuracy with low size dataset, I chose to apply transfer learning from a pretrained network.</p><p>There are several CNN network available. I chose InceptionResnetV1, trained with VGGFace2 dataset. <br><a href="https://github.com/timesler/facenet-pytorch">Here</a> you can find the repo of the PyTorch model I used.</p><p>The class already has the capability of train only the last linear layer. In order to do that, the model has to be created with variables <em>classify=True</em> and <em>num_classes=1 </em>.</p><p>I chose 1 class because I have implemented a binary classifier.</p><p>Printing the last linear layer from python console it returns: <em>Linear(in_features=512, out_features=1, bias=True)<br></em>the network extracts 512 features from the image and use it for classify me or not me.</p><p>In order to train and test the model using PyTorch, I followed the <a href="https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html">tutorial on the main site</a>.</p><p>The script loads my dataset using <em>datasets.ImageFolder .</em></p><p>Then I changed the criterion for training from <em>CrossEntropyLoss </em>to <em>BCEWithLogitsLoss</em> which is for binary classification.</p><p>During the training step, I used <em>preds = sigmoid_fun(outputs[:,0]) &gt; 0.5 </em>for generating predictions instead of <em>nn.max (</em>from the tutorial). <em>sigmoid_fun </em>is a <em>torch.nn.Sigmoid </em>utility for computing the Sigmoid function<em>.</em></p><p>After training the network for 25 epochs, it shows a best accuracy of 97%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*JTvqbOjfzfSjvhisTppF8A.png" /><figcaption>Accuracy</figcaption></figure><p>After the training, I saved the model using t<em>orch.save(model_ft.state_dict(), model_path).</em></p><p>With an other script, I load the trained model and show 6 random image from validation set.</p><p>The image below shows the predicted classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*wUSfBE87hHnVJkCESxiWaw.png" /><figcaption>6 predected classes from validation set</figcaption></figure><p>Next step will be to estimate the speed of the model and eventually speed it up.</p><p>Here you can find the code on my <a href="https://github.com/lucagessi/facerecognition/">github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a771f52d7e28" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>