<?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 Sergio Casero on Medium]]></title>
        <description><![CDATA[Stories by Sergio Casero on Medium]]></description>
        <link>https://medium.com/@sergio.casero23?source=rss-7fb476b72930------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ZF0Q5fJ9iZ76kehl.</url>
            <title>Stories by Sergio Casero on Medium</title>
            <link>https://medium.com/@sergio.casero23?source=rss-7fb476b72930------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 03:19:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sergio.casero23/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[Developing Building Light Controller with Android Things]]></title>
            <link>https://medium.com/@sergio.casero23/developing-building-light-controller-with-android-things-661c9da00a72?source=rss-7fb476b72930------2</link>
            <guid isPermaLink="false">https://medium.com/p/661c9da00a72</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[android-things]]></category>
            <category><![CDATA[raspberry-pi-3]]></category>
            <category><![CDATA[led-lighting]]></category>
            <dc:creator><![CDATA[Sergio Casero]]></dc:creator>
            <pubDate>Wed, 01 Feb 2017 17:19:42 GMT</pubDate>
            <atom:updated>2017-02-06T07:53:53.834Z</atom:updated>
            <content:encoded><![CDATA[<p>First of all, this is my first Story in medium, so please give me feedback!</p><p>Parts:<br>1. Introduction <strong>(In this post)</strong></p><p>2. The first approach, Listing ports and connecting with Firebase <strong>(In this post)</strong></p><p>3. Create a client app for managing lights <strong>(In this post)</strong></p><p>4. Provide Authentication based on firebase auth (<strong>Writing post… :)</strong>)</p><p>5. Summary</p><h3><strong>Introduction</strong></h3><h3>The problem</h3><p>My father in law has a company about hostelry. The company works fine, and they have moved to another building. That building has two floors and lots of space, and obviously lots of lights. The problem is every day they must turn on/off all lights, but sometimes they forget to do it (because remember, it’s big, see the picture below). This issue increases the costs and, althought they have LED lights, decrease the lifetime of the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXxoOxopXum4eY0IRMlboA.png" /></figure><h3>The solution</h3><p>I thought to develop one system for providing them the light control with their smartphones, and Google released Android Things so… why not? ¯\_(ツ)_/¯</p><p>I developed a system with Android Things and a tradicional Android app for manage the lights! :)</p><h4>Goals</h4><ul><li>Remote control</li><li>Easy to use</li><li>Cheap (about 70–80€)</li></ul><h4>Hardware</h4><ul><li>Raspberry PI ( <a href="https://goo.gl/pdiVcp">https://goo.gl/pdiVcp</a>)</li><li>Relay boards (x2) ( <a href="https://goo.gl/1bRGLc">https://goo.gl/1bRGLc</a>)</li><li>Wires ( <a href="https://goo.gl/9I7VKJ">https://goo.gl/9I7VKJ</a>)</li><li>Power supply and case(<a href="https://goo.gl/MRR3Cq">https://goo.gl/MRR3Cq</a>)</li></ul><h4>Optional</h4><ul><li>Relay case (<a href="https://goo.gl/ps7OdV">https://goo.gl/ps7OdV</a>)</li></ul><p>So system price is 39€ + 2x13€ + 12€ = 77€, cool! :)</p><h4>Technologies</h4><ul><li>Android Things</li><li>Firebase Database &amp; auth</li><li>Android</li></ul><h3>2. The first approach, Listing ports and connecting with Firebase</h3><p>The first thing we need to do is searching for available ports, and show them into the UI. Why? Because Android Things is compatible with another boards, and I tried to develop the system for all of them.</p><p>As we only need to simulate switch, we should use the GPIO api. This is the TODO list:<br>1. Get GPIOs</p><p>2. Display GPIOs to the user for helping him with connections between relay board and Android things device</p><p>3. Create model into firebase</p><p>So… Let’s go!. Listing ports is really easy, see the comments in the code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f766eeda929d314accf54b735496e03f/href">https://medium.com/media/f766eeda929d314accf54b735496e03f/href</a></iframe><p>UI Details is on github repo (at the end os this post)</p><p>This is the result (Android Things doesn’t support screen capture right now, sorry):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m7CwvZaVD2saK-WLhL0vAg.jpeg" /></figure><h3>2. Connecting to firebase:</h3><p>That’s also simple, We only need to configure firebase into our project (with the plugin, for example)</p><p>I have created 2 models, one to identify the relay in firebase(RelayDto) and the other is for managing GPIO port. And that’s all, simple push RelayDto to firebase:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6e043b3dfbb331b5840f23c372759be/href">https://medium.com/media/d6e043b3dfbb331b5840f23c372759be/href</a></iframe><p>And should looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*HyLAbDy_DYWRzF3nm4yxpQ.png" /></figure><p>That’s all! Our Android things app is done! Right now we can listen to the changes with firebase listeners and switch the value of the port:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9ea8ec719f274bf442a278dc158f529/href">https://medium.com/media/a9ea8ec719f274bf442a278dc158f529/href</a></iframe><p>Android things app looks really nice! (or not, We will try to implement auth based on firebase ;) )</p><p>So…</p><p>3. Create a client app for managing the lights</p><p>We have to implement the client app, but… This is a common Android app with firebase. We only need to display a Recycler View (or something like that) and when user clicks on each light, switch the value and push it to firebase.</p><p>App looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zpHbcR80Odtnay1HvaQFbg.png" /></figure><p>And demo video:</p><h3>Sergio Casero on Twitter</h3><p>AndroidThings, @Firebase, @Raspberry_Pi and relay board (and @oneplus 3, for sure)... ¯\_(ツ)_/¯ https://t.co/VTJ8MYecyl</p><p>Thanks to <a href="https://medium.com/u/6f30f39b0588">Luis Ibáñez</a>, <a href="https://medium.com/u/67befe2e881b">Fernandroid</a>, @ernestoyaquello and @javiKx2 for helping me to write this story.</p><p>In the next post, we will see about how to provide “auth” based on Firebase :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=661c9da00a72" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>