<?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 Juha Mustonen on Medium]]></title>
        <description><![CDATA[Stories by Juha Mustonen on Medium]]></description>
        <link>https://medium.com/@juha.p.mustonen?source=rss-91ea6aa7bbdc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zfys5WehvwXOG-dc.jpg</url>
            <title>Stories by Juha Mustonen on Medium</title>
            <link>https://medium.com/@juha.p.mustonen?source=rss-91ea6aa7bbdc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 19:58:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@juha.p.mustonen/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[Look ma, I created a home IoT setup with AWS, Raspberry Pi, Telegram and RuuviTags]]></title>
            <link>https://medium.com/nordcloud-engineering/look-ma-i-created-a-home-iot-setup-with-aws-raspberry-pi-telegram-and-ruuvitags-7e9a86d09e7b?source=rss-91ea6aa7bbdc------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e9a86d09e7b</guid>
            <category><![CDATA[ruuvitag]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Juha Mustonen]]></dc:creator>
            <pubDate>Wed, 07 Aug 2019 12:08:08 GMT</pubDate>
            <atom:updated>2019-08-07T12:08:08.370Z</atom:updated>
            <content:encoded><![CDATA[<p>Hobby projects are a fun way to try and learn new things. This time, I decided to build a simple IoT setup for home, to collect and visualise information like temperature, humidity and pressure. While learning by doing was definitely one of the reasons I decided to embark the project, I for example wanted to control the radiators located in the attic: Not necessarily by switching power on/off, but getting alarms if I’m heating it too much or little, so that I can tune the power manually. Saving some money, in practice. Also, it is nice the get reminders from humidor that the cigars are getting dried out 😉</p><p>I personally learned several things while working on it, and via this blog post, hopefully you can too!</p><h3>Overview</h3><p>Idea of the project is relatively simple: Place a few <a href="https://ruuvi.com/">RuuviTag -sensors</a> around the house, collect the data and push it into AWS cloud for permanent storage and additional processing. From there, several solutions can be built around the data, visualisation and alarms being being only few of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*KKPYAkpmm5TwwbUraXh5ow.png" /><figcaption>Overview of the setup</figcaption></figure><p>Solution is built using AWS serverless technologies that keeps the running expenses low while requiring almost non-existing maintenance. Following code samples are only snippets from the complete solution, but I’ve tried to collect the relevant parts.</p><h3>Collect data with RuuviTags and Raspberry Pi</h3><p>Tag sensors broadcasts their data (humidity, temperature, pressure etc.) via Bluetooth LE periodically. Because Ruuvi is an open source friendly product, <a href="https://lab.ruuvi.com/">there are already several ready-made solutions and libraries</a> to utilise. I went with <a href="https://github.com/Espesen/node-ruuvitag">node-ruuvitag</a>, which is a Node.js module (Note: I found that module works best with Linux and Node 8.x but you may be successful with other combinations, too).</p><p>Raspberry Pi runs a small Node.js application that both listens the incoming messages from RuuviTags and forwards them into AWS IoT service. App communicates with AWS cloud using thingShadow client, found in <a href="https://github.com/aws/aws-iot-device-sdk-js">AWS IoT Device SDK module</a>. Application authenticates using X.509 certificates generated by you or AWS IoT Core.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3ed960ec5e3c447a326332363fe289d/href">https://medium.com/media/e3ed960ec5e3c447a326332363fe289d/href</a></iframe><p>The scripts runs as a Linux service. While tags broadcast data every second or so, the app in Raspberry Pi forwards the data only once in 10 minutes for each tag, which is more than sufficient for the purpose. This is also an easy way to keep processing and storing costs very low in AWS.</p><blockquote>When building an IoT or big data solution, one may initially aim for near real-time data transfers and high data resolutions while the solution built on top of it may not really require it. Alternatively, consider sending data in batches once an hour and with 10 minute resolution may be sufficient and is also cheaper to execute.</blockquote><p>When running the broadcast listening script in Raspberry Pi, there are couple things to consider:</p><ul><li><strong>All the tags may not appear at first reading</strong>: (Re)run ruuvi.findTags() every 30mins or so, to ensure all the tags get collected</li><li><strong>Raspberry Pi can drop from WLAN</strong>: <a href="http://wpdemo.pihome.eu/2017/10/19/auto-reconnecting-wifi-on-raspberry/">Setup a script to automatically reconnect</a> in a case that happens</li></ul><p>With these in place, the setup have been working without issues, so far.</p><h3>Process data in AWS using IoT Core and friends</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*B1LBiq6g78L8QOb2ZuC2Iw.png" /><figcaption>AWS processing overview</figcaption></figure><p>Once the data hits the AWS IoT Core there can be several rules for handling the incoming data. In this case, I setup a lambda to be triggered for each message. AWS IoT provides also a way to do the DynamoDB inserts directly from the messages, but I found it more versatile and development friendly approach to use the lambda between, instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*NQ2QfyBQoEihLSOELUalCA.png" /><figcaption>AWS IoT Core act rule</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b6f2b0f38516d9444648f6f412a5684/href">https://medium.com/media/1b6f2b0f38516d9444648f6f412a5684/href</a></iframe><p>DynamoDB works well as permanent storage in this case: Data structure is simple and service provides on demand based scalability and billing. Just pay attention when designing the table structure and make sure it fits with you use cases as changes done afterwards may be laborious. For more information about the topic, I recommend you to <a href="https://www.youtube.com/watch?v=HaEPXoXVf2k">watch a talk about Advanced Design Patterns for DynamoDB</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ZwLbq7OtUOKU-KvRF3FIQ.png" /><figcaption>DynamoDB structure I end up using</figcaption></figure><h3>Visualise data with React and Highcharts</h3><p>Once we have the data stored in semi structured format in AWS cloud, it can be visualised or processed further. I set up a periodic lambda to retrieve the data from DynamoDB and generate CSV files into public S3 bucket, for React clients to pick up. CSV format was preferred over for example JSON to decrease the file size. At some point, I may also try out using the <a href="https://en.wikipedia.org/wiki/Apache_Parquet">Parquet -format</a> and see if it suits even better for the purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*0Sq490ImGbBcOu2J9pH4LQ.png" /><figcaption>Overview visualisations for each tag</figcaption></figure><p>The React application fetches the CSV file from S3 using custom hook and passes it to Highcharts -component.</p><blockquote>During my professional career, I’ve learnt the data visualisations are often causing various challenges due to limitations and/or bugs with the implementation. After using several chart components, I personally prefer using <a href="https://www.highcharts.com/">Highcharts</a> over other libraries, if possible.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63692c1bbc7233aaa33cf928d96648e8/href">https://medium.com/media/63692c1bbc7233aaa33cf928d96648e8/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*QH5zq-EgypOFxZVehjIrkw.png" /><figcaption>Snapshot from the tag placed outside</figcaption></figure><h3>Send notifications with Telegram bots</h3><p>Visualisations works well to see the status and how the values vary by the time. However, in case something drastic happens, like humidor humidity gets below preferred level, I’d like to get an immediate notification about it. This can be done for example using <a href="https://core.telegram.org/bots">Telegram bots</a>:</p><ol><li>Define the limits for each tag for example into DynamoDB table</li><li>Compare limits with actual measurement whenever data arrives in custom lambda</li><li>If value exceeds the limit, trigger SNS message (so that we can subscribe several actions to it)</li><li>Listen into SNS topic and send Telegram message to message group you’re participating in</li><li>Profit!</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xTSclwpAgRxd7jtYVRV0Wg.png" /><figcaption>Limits in DynamoDB</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa7f5c8256cc085ad520a90cc5f48848/href">https://medium.com/media/fa7f5c8256cc085ad520a90cc5f48848/href</a></iframe><h3>Summary</h3><p>By now, you should have some kind of understanding how one can combine IoT sensor, AWS services and outputs like web apps and Telegram nicely together using serverless technologies. If you’ve built something similar or taken very different approach, I’d be happy hear it!</p><p><strong>Price tag</strong></p><p>Building and running your own IoT solution using RuuviTags, Raspberry Pi and AWS Cloud does not require big investments. Here are some approximate expenses from the setup:</p><ul><li>3-pack of RuuviTags: 90e (ok, I wish these were a little bit cheaper so I’d buy these more since the product is nice)</li><li>Raspberry Pi with accessories: 50e</li><li>Energy used by RPi: <a href="http://www.pidramble.com/wiki/benchmarks/power-consumption">http://www.pidramble.com/wiki/benchmarks/power-consumption</a></li><li>Lambda executions: $0,3/month</li><li>SNS notifications: $0,01/month</li><li>S3 storage: $0,01/month</li><li>DynamoDB: $0,01/month</li></ul><p>And after looking into numbers, there are several places to optimise as well. For example, some lambdas are executed more often than really needed.</p><p><strong>Next steps</strong></p><p>I’m happy say this hobby project has achieved that certain level of readiness, where it is running smoothly days through <em>and</em> being valuable for me. As a next steps, I’m planning to add some kind of time range selection. As the amount of data is increasing, it will be interesting to see how values vary in long term. Also, it would be a good exercise to integrate some additional AWS services, detect drastic changes or communication failures between device and cloud when they happen. This or that, at least now I have a good base for continue from here or build something totally different next time 🙂</p><h3>References, credits and derivative work</h3><p>This project is no by means a snowflake and has been inspired by existing projects and work:</p><ul><li>Node.js module receiving RuuviTag messages: <a href="https://www.npmjs.com/package/node-ruuvitag">https://www.npmjs.com/package/node-ruuvitag</a></li><li>Blog post: A Telegram Bot to retrieve data from RuuviTag <a href="https://medium.com/@france193/ruuvitag-telegram-bot-48bd03a61f3c">https://medium.com/@france193/ruuvitag-telegram-bot-48bd03a61f3c</a></li><li>Illustrations are adapted from icons sets created by <a href="https://www.flaticon.com/authors/freepik">https://www.flaticon.com/authors/freepik</a></li></ul><p>At Nordcloud we are always looking for talented people. If you enjoy reading this post and would like to work with public cloud projects on a daily basis — check out our open positions <a href="https://nordcloud.com/careers/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e9a86d09e7b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nordcloud-engineering/look-ma-i-created-a-home-iot-setup-with-aws-raspberry-pi-telegram-and-ruuvitags-7e9a86d09e7b">Look ma, I created a home IoT setup with AWS, Raspberry Pi, Telegram and RuuviTags</a> was originally published in <a href="https://medium.com/nordcloud-engineering">Nordcloud Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>