<?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 Tal Klinger on Medium]]></title>
        <description><![CDATA[Stories by Tal Klinger on Medium]]></description>
        <link>https://medium.com/@talklinger?source=rss-c09637eccd14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KeoHBEu8RufgYQDJEOo04g.jpeg</url>
            <title>Stories by Tal Klinger on Medium</title>
            <link>https://medium.com/@talklinger?source=rss-c09637eccd14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:05:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@talklinger/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[IoT Security — Honeypot]]></title>
            <link>https://talklinger.medium.com/iot-security-honeypot-46ea73a44f95?source=rss-c09637eccd14------2</link>
            <guid isPermaLink="false">https://medium.com/p/46ea73a44f95</guid>
            <category><![CDATA[iot-security]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[embedded-security]]></category>
            <dc:creator><![CDATA[Tal Klinger]]></dc:creator>
            <pubDate>Thu, 07 Apr 2022 17:19:46 GMT</pubDate>
            <atom:updated>2022-04-07T17:19:46.138Z</atom:updated>
            <content:encoded><![CDATA[<h3>IoT Security — Honeypot</h3><p>I really like this sketch from The Office, it is not exactly a honeypot, but it includes some of the essence of a well designed <a href="https://en.wikipedia.org/wiki/Honeypot_(computing)">honeypot</a>,</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPjOHcPtAFdQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPjOHcPtAFdQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPjOHcPtAFdQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2fd10ef8e1bac9824d717eebf6897c4/href">https://medium.com/media/b2fd10ef8e1bac9824d717eebf6897c4/href</a></iframe><p>A honeypot is intended to distract, attract and identify attackers. Attackers in the IoT world could be anyone: your competition trying to replicate your success, clients trying to steal your secret sauce or just a random curious person that like to see the world burn.</p><p>So how does one create an IoT honeypot? The article will take you through the steps of making a simple honeypot.</p><h3>0x00 — Clean your code</h3><p>Whoopsy, plain text!</p><p>Yes, the first step is actually to <strong>clean your code from your sensitive information</strong>. You’d be amazed to see how many devices print sensitive data on their TX output…</p><p>Search for the following bad habits:</p><ul><li>print functions</li><li>logging functions that print to console as well</li></ul><p><strong>Bonus: </strong>Check out Phillippe Laulheret’s video on <a href="https://www.youtube.com/watch?v=HuCbr2588-w">how the most basic hacks are done</a></p><h3>0x01 — Create a distraction</h3><p>Oh, clumsy me!<strong> By now you should have applied step 0.</strong></p><p>As you already know attacker is looking for credentials in your plaintext prints , you can use this for your advantage.</p><p>Because your attacker is expecting something on the UART output, you can actually print over UART fake output that would be used in your controlled environment to lure and identify the attacker</p><p>The following code snippet includes simple examples for the ESP IDF, with fake outputs that would lead into the honeypot. Feel free to take these ideas and modify them to according to your heart’s desire.</p><pre><strong>static</strong> <strong>const</strong> char* TAG = &quot;MySecertModule&quot;;</pre><pre>//Example 1<br>ESP_LOGI(TAG, &quot;Connecting to my_secret_ssid using the password my_secret_passowrd&quot;);</pre><pre>//Example 2<br>ESP_LOGI(TAG, &quot;sending data to my_secret_https_endpoint&quot;);</pre><pre>//Example 3<br>ESP_LOGI(TAG, &quot;Connecting to my_secret_service at my_secret_address_and_port using the username my_user and password my_secret_passowrd&quot;);</pre><h3>0x02 — Luring the attacker</h3><p>Let&#39;s take example number 3 — secret service, with secret username and password, this is a very bad practice in general, as one should use a signed certificate unique for each device, not a username and a password.</p><p>This address and credentials will lead the attacker directly into a trap. There are many ways to implement such solution, if you are using AWS, there is a good example <a href="https://github.com/awslabs/aws-waf-security-automations">here</a> (bad bot honeypot) — it also covers steps 0x04 and 0x05.</p><h3>0x03 — Into the rabbit hole</h3><p>If you’d like to get more information about your attacker, you’d have to create some content that would keep your attackers attracted. Try adding content to enrich your user’s experience and in the meantime collect more information. <a href="https://github.com/paralax/awesome-honeypots">Here you can find a list of good ideas</a> or inspiration.</p><h3>0x04— Identify the attacker</h3><p>It is time to analyze the data from your honeypot, by now, you should have a list of IPs that point to your attacker or the vectors your attacker attacks from.</p><h3>0x05— Block your attacker</h3><p>Add the IPs to your blacklists and/or WAF, whether it&#39;s on your edge site or the cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*2k_yRRBfYpFVXt9v.jpg" /><figcaption>Venus flytrap, <a href="https://pixabay.com/service/license/">pixabay license</a></figcaption></figure><h3>0xFF — Summary</h3><p>In this post, I presented the basics on how to deceive attacker into a trap, how to identify them and how to make sure you block your attackers from your resources.</p><h3>TL;DR</h3><ul><li>Keep your code clean from any sensitive information — use secure elements to hide your secrets.</li><li>Create a distraction in plain sight</li><li>Lure your attackers to places you can track them</li><li>Try to buy as much time holding the attackers until you identify them</li><li>Block you attackers</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46ea73a44f95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating through the turbulent water of the chip shortage]]></title>
            <link>https://talklinger.medium.com/navigating-through-the-turbulent-water-of-the-chip-shortage-4af0c63a6aca?source=rss-c09637eccd14------2</link>
            <guid isPermaLink="false">https://medium.com/p/4af0c63a6aca</guid>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[challenge]]></category>
            <category><![CDATA[chip-shortage]]></category>
            <category><![CDATA[team-collaboration]]></category>
            <category><![CDATA[leadership]]></category>
            <dc:creator><![CDATA[Tal Klinger]]></dc:creator>
            <pubDate>Wed, 30 Mar 2022 23:03:00 GMT</pubDate>
            <atom:updated>2022-03-30T23:03:00.822Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*sgdsnF6Y1kL7pFal.jpg" /><figcaption>Galleon Sea Storm, <a href="https://pixabay.com/service/license/">pixabay license</a></figcaption></figure><p>Hardware is hard. The last two years for any hardware company was crazy: cars, gaming consoles, smartphones , graphic cards — everyone had to adapt to a new reality. Adapting products, delaying progress and market growth, delaying deliveries, these are mild effects of the chip shortage, some companies and product had hard time to endure this and even had to discontinue their product or sell or even close their business.</p><h3>Hard choices that need to be taken</h3><p>When these hard challenges appear, it is necessary to take hard choices, these choices need to be thought out and calculated. Compromises will be taken, not due to changes in philosophy or belief in key values, but in reaction to the the harsh reality that we are facing, otherwise, product time to market, overall budget and even the future of a solution is at major risk.</p><p>So what do we do when this happens? Do we <a href="https://www.reuters.com/business/autos-transportation/vws-seat-extend-assembly-curbs-spain-into-2022-chip-shortage-2021-09-16/">delay</a> manufacturing? Do we <a href="https://www.reddit.com/r/TeslaModelY/comments/qryiy6/missing_usb_ports/">depopulate</a> parts from our design just to release a product on time? Do we communicate this to <a href="https://www.theapplepost.com/2021/10/28/chip-shortages-and-manufacturing-disruptions-cost-apple-6-billion-during-q4-2021/">the media or investors</a>?</p><p>There is no magic formula to solve this, and mostly, it is more of an understanding how do we as a team, get out of this turbulent waters and endure hard times.</p><h3>Sharing with the team</h3><p>This is the first, hardest and most important thing to do: <strong>share the information with your team</strong>. This requires reserves of trust, stepping up to a challenge requires commitment to solve it and if you cannot trust your team on knowing what challenge the company faces, they will not be able to commit to the goal.</p><p>When you share the situation, <strong>do it clearly; </strong>Don’t be vague, don’t try to hide or silver line the problem. Your explanation doesn’t have to be in-depth when you share it, but it has to clear enough for each and every team member what challenges we are facing.</p><p>A good example could be:</p><p>“We are facing a major challenge sourcing parts for our systems, our plan to scale-up this year is at risk of one-year delay. This means a delay in revenue growth and other plans we have ahead based on this income and growth. We are considering multiple approaches to solve this problem, and this requires us to adapt as a team to the new circumstances. I trust each and every one of you, to understand, we are not delaying our growth and roadmap due to compromise on values, rather, we are using these values to solved situations that many other companies face right now. I know each and every one of you is capable of going through this hard time and can work out new approaches to improve ourselves and minimize our delay of growth. These improvements will improve our product’s endurance when the situation ends.”</p><p>Let&#39;s break the message down to its elements, to understand how we motivate people to solve this problem as a team:</p><blockquote><em>We are facing a major challenge sourcing parts for our systems</em></blockquote><p>This is a clear sentence, that explains <strong>very clearly</strong> what is the <strong><em>problem</em></strong>. It <strong>doesn’t go in-depth</strong> to which components, but every team member can understand what is the root cause.</p><blockquote>our plan to scale-up this year is at risk of one-year delay. This means a delay in revenue growth and other plans we have ahead based on this income and growth.</blockquote><p>This is the <strong><em>risk. </em></strong>What will happen if we don’t do any change.</p><blockquote>We are considering multiple approaches to solve this problem, and this requires us to adapt as a team to the new circumstances. I trust each and every one of you, to understand, we are not delaying our growth and roadmap due to compromise on values, rather, we are using these values to solved situations that many other companies face right now.</blockquote><p>The understanding that an <strong>alignment</strong> is required</p><blockquote>I know each and every one of you is capable of going through this hard time and can work out new approaches to improve ourselves and minimize our delay of growth.</blockquote><p>This is the <strong>call for action, </strong>instructing each and every team member that their action can contribute and get the team out of this hard situation.</p><blockquote>These improvements will improve our product’s endurance when the situation ends.</blockquote><p>This is the outlook for the future, how do we move <strong>onward</strong> and what do we gain from working it out?</p><p>People come stronger after facing challenges. This does not mean that we should make the same mistakes again or face the same challenge later on; As we continue on the journey, we should use these lessons.</p><h3>TL;DR</h3><ul><li>Share the challenges with your team, briefly but clearly</li><li>Frame the root causes</li><li>Ensure the team understands the risks and implications of failure to make a change</li><li>Communicate the (temporary) alignment in tactics and/or strategy</li><li>Make sure team members understand their contribution in the alignment</li><li>Motivate team members to bring their A-game to succeed in this change</li></ul><blockquote>Rough seas make stronger sailors. Tough times build greater people.</blockquote><p>— Robin Sharma</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4af0c63a6aca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to program boards with pyOCD]]></title>
            <link>https://talklinger.medium.com/how-to-program-boards-with-pyocd-7f92c888c765?source=rss-c09637eccd14------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f92c888c765</guid>
            <category><![CDATA[openocd]]></category>
            <category><![CDATA[pyocd]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <category><![CDATA[stm32]]></category>
            <dc:creator><![CDATA[Tal Klinger]]></dc:creator>
            <pubDate>Sun, 26 Sep 2021 16:43:16 GMT</pubDate>
            <atom:updated>2021-09-26T16:43:16.941Z</atom:updated>
            <content:encoded><![CDATA[<p>So you’ve got hundreds of boards waiting to be programmed and you want to delegate the task to others? You’re in the right place, this guide will walk you through on how use pyOCD, earse, flash and reset device. Once you’ll control the basics, you’d be able to automate the task and let others join your workforce to swiftly get these boards flashed and tested.</p><p>In this post, I will be using pyOCD (python bindings for OpenOCD) to program an STM based uController, if you are using a different uController, try to adjust the code to your MCU of choice.</p><h3>0x00 — prerequisites</h3><ul><li>In-circuit programmer (IE: SEGGER, ST-Link V2, etc’)</li><li>A dev board, evaluation board or any board you can connect your programmer to</li><li>A computer that can run openOCD and connect to the in-circuit programmer</li></ul><p>install openocd using your package manager, on Ubuntu run the following in the<strong> command line</strong>:</p><pre>sudo apt-get install openocd</pre><p>install pyocd package using pip:</p><pre>pip install pyocd</pre><p>To find the appropriate pack for your board, just run:</p><pre>pyocd pack -f &lt;boardname&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*cpV4ZPGWS_e-_pbXQk0POg.png" /></figure><p>Install the desired pack</p><pre>pyocd pack -- install stm32l01</pre><p>To show installed packages:</p><pre>pyocd pack -s</pre><p>You can also update existing packs by running:</p><pre>pyocd pack -u</pre><h3>0x01 — Erase, flash, reset</h3><p>I will be working with stm32l010f4pX, make sure to change the board name in the commands to your specific board.</p><p>Lets try to erase the flash prior to writing anything:</p><pre>pyocd erase -t stm32l010f4px --mass</pre><p>To flash the board with your app, just run the following:</p><pre>pyocd flash -t stm32l010f4px --base-address 0x8000000 app.bin</pre><p>Make sure that --base-address is aligned with your boards based offset.</p><p>From time to time, we’d need to force a reset to our device, to test different use cases, this command is very handy:</p><pre>pyocd reset -t stm32l010f4px -m sw</pre><p>You can also add -v at the end of the line to get more logging out each command</p><p><em>Note: In this following section, I ran the commands without any special options, you can review advanced options for each command by adding -h after the command. For example:</em></p><pre>pyocd erase -h</pre><h3>0x02 — Automate</h3><p>Now that we’ve mastered the basics, lets wrap the commands in a simple python script. This is nothing fancy nor follows the “best practices” of code development, but it gets the job done.</p><pre>import subprocess<br>import pyocd<br><br>class BoardLink():<br><br>    def __init__(self):<br>        self.family = &quot;stm32l01&quot;<br>        self.pack = &quot;STM32L0xx_DFP&quot;<br>        self.part_number = &quot;stm32l010f4px&quot;<br>        self.base_address = &quot;0x8000000&quot;<br><br>    def flash_binary(self):<br>        command = &quot; pyocd flash -e auto -t &quot; + str(self.part_number) + &quot; --base-address &quot; + str(self.base_address) + &quot; binaries/app.bin -v&quot;<br><br>    def erase_flash(self):<br>        commnad = &quot;pyocd erase -t &quot; + str(self.part_number) + &quot; --mass&quot;<br>        success_criteria = &quot;&quot;<br>        fail_criteria = &quot;&quot;<br>        return run_command(command, success_criteria, fail_criteria)<br><br>    def soft_reset(self):<br>        command = &quot;pyocd reset -t &quot; + str(self.part_number) + &quot; -m sw -v&quot;<br>        success_criteria = &quot;&quot;<br>        fail_criteria = &quot;&quot;<br>        return run_command(command, success_criteria, fail_criteria)<br><br>    def install_dependencies(self):<br>        command = &quot;pyocd pack --install &quot; + str(self.family)<br>        success_criteria = &quot;Downloading descriptors (001/001)&quot;<br>        fail_criteria = &quot;&quot;<br>        return run_command(command, success_criteria, fail_criteria)<br><br>    def show_dependencies(self):<br>        command = &quot;pyocd pack --show&quot;<br>        success_criteria = self.pack<br>        fail_criteria = &quot;&quot;<br>        return run_command(command, success_criteria, fail_criteria)<br><br>class Device():<br>    def __init__(self):<br>        self.serial_number = 0<br>        self.mac_address = &quot;&quot;<br>        self.factory_stage = &quot;init&quot;<br>        self.retries = 0<br><br>    def scan_device(self):<br>        #todo add you own way to scan the device&#39;s serial number<br>        #don&#39;t forget to add validation<br>        self.serial_number = input(&quot;Please enter the serial number and press Enter\n&quot;)<br>        return True<br><br>    def register_device(self):<br>        #todo add your own way of registration<br>        #don&#39;t forget to handle failures, updates to registered devices, etc&#39;<br>        return True<br><br>    def functional_testing(self):<br>        #todo add your tests to verify the defice<br>        #don&#39;t forget to handle failures, you can add as many tests and stages as you&#39;d ike<br>        return True<br><br>def run_command(command, success_criteria, fail_criteria):<br>    debug_console_output = subprocess.run(str(command),<br>        shell = True,<br>        capture_output = True,<br>        check = False)<br>    #todo handle issues using success_criteria and fail_criteria<br>    if success_criteria in debug_console_output.stdout.decode(&quot;utf-8&quot;):<br>        return True<br>    else:<br>        return False<br><br>if __name__ == &quot;__main__&quot;:<br>    pyocd_link = BoardLink()<br>    if pyocd_link.show_dependencies():<br>        pass<br>    else:<br>        pyocd_link.install_dependencies()<br>    while(True):<br>        device_under_test = Device()<br>        #device_under_test.retries = 0<br>        while(device_under_test.factory_stage != &quot;registered&quot; and device_under_test.factory_stage != &quot;failed&quot;):<br>            #todo add your own timers for each stage, maximum amout of retries and so on, the loop is here for these retries.<br>            if device_under_test.factory_stage == &quot;init&quot;:<br>                device_under_test.scan_device()<br>                device_under_test.factory_stage = &quot;scanned&quot;<br>            if device_under_test.factory_stage == &quot;scanned&quot;:<br>                if pyocd_link.flash_binary():<br>                    device_under_test.factory_stage = &quot;flashed&quot;<br>                else:<br>                    device_under_test.factory_stage = &quot;failed&quot;<br>            if device_under_test.factory_stage == &quot;flashed&quot;:<br>                if device_under_test.functional_testing():<br>                    device_under_test.factory_stage = &quot;tested&quot;<br>                else:<br>                    device_under_test.factory_stage = &quot;failed&quot;<br>            if device_under_test.factory_stage == &quot;tested&quot;:<br>                if device_under_test.register_device():<br>                    device_under_test.factory_stage = &quot;registered&quot;<br>                    print(&quot;Device &quot; + str(device_under_test.serial_number) + &quot; successfully registered&quot;)<br>                else:<br>                    device_under_test.factory_stage = &quot;failed&quot;<br>            if device_under_test.factory_stage == &quot;failed&quot;:<br>                print(&quot;Device &quot; + str(device_under_test.serial_number) + &quot; failed the test&quot;)<br>            #device_under_test.retries = device_under_test.retries + 1</pre><p><strong>Pro tip:</strong> Add some kind of a registration, either to a local DB or a cloud platform to ensure your don’t lose crucial data during production, such as S/N to MAC/IMEI coupling or even inventory management.</p><h3>0xFF — summary</h3><p>Hopefully, you made it through this guide and you were able to install openOCD and program your device manually, try going the extra mile and automating with your own script and jig to make things faster</p><h3>TL;DR</h3><ul><li>Install openOCD</li><li>Install pyocd</li><li>Install pyocd pack for your uController</li><li>Flash your binary to your board</li><li>Pack the commands in a nice script to save time on your production line</li><li>Use a jig to make things simpler for your staff</li><li>Use -v when using pyocd if you need more verobisty</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f92c888c765" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Your IoT Device Energy Consumption]]></title>
            <link>https://medium.com/tech-at-trax/optimizing-your-iot-device-energy-consumption-3e8e90d4a02d?source=rss-c09637eccd14------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e8e90d4a02d</guid>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[energy-efficiency]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[battery]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <dc:creator><![CDATA[Tal Klinger]]></dc:creator>
            <pubDate>Mon, 08 Feb 2021 12:14:09 GMT</pubDate>
            <atom:updated>2021-02-08T12:14:09.991Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a word, and many engineers are not going to like this word: <strong>Batteries.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*6Al93O_VxMzFyo1k.jpg" /><figcaption><a href="https://www.flickr.com/photos/30713600@N00/6997580445">“low battery”</a> by <a href="https://www.flickr.com/photos/30713600@N00">twicepix</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/2.0/?ref=ccsearch&amp;atype=rich">CC BY-SA 2.0</a></figcaption></figure><p>Yes, these things that make our lives so simple by not connecting every device to a wall outlet as consumers makes our lives hard as engineers.</p><p>Imagine how the world would look if we had to plug pacemakers into an outlet. Contrarily, how would it feel if we had to change batteries every week?</p><p>This is where trade-off engineering turns into an art — how do we design a device that consumes less energy without compromising on functionality.</p><p>The pacemaker example is an extreme yet clear representation of this trade-off — this device that must operate without any quality compromises over a period of 5–10 years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/0*pRqmU62kdKo73haF.png" /><figcaption>Creative Commons <a href="https://xkcd.com/license.html">XKCD</a></figcaption></figure><p>So how is it related to our work? Well, IoT devices are all around us— monitoring your beer freshness, counting people within a store or even helping your local grocery store never run out of milk — all of this magic, on batteries.</p><p>So how can one reduce a device’s battery consumption? In the following article, we’ll review several techniques to reduce battery consumption in “on” states — all of this was done with the <a href="https://www.qoitech.com/">Otii Arc</a> — an engineer’s multitool that serves as a power supply and analyzer.</p><h3>Frequency Matters</h3><p>CPU/MCU tend to consume more energy when they run at higher frequencies, but higher frequencies do not guarantee better or faster operation for your IoT device.</p><p>Lets take a concrete example: here is my base profile and the improved one with a lower frequency:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZqzbYg2RVwjkGcSNAafBg.png" /><figcaption>160Mhz compared to 80 Mhz</figcaption></figure><p>And if we dive deeper, we can see that the average current in similar tasks is 4~7mA lower while maintaining the original operation time, meaning, no additional compute was needed to conduct the operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JzNsJVc-zyQ8DeHkokCNKw.png" /><figcaption>Same region is highlighted and compared on the upper right part</figcaption></figure><p>Just a side note — in my specific example, the application does not conduct heavy compute, so there is no effect on timing at all when frequency is raised or reduced — I would recommend to test both options (raising and lowering) just to see what parts of your states machine benefit from this change.</p><h3>Cut Connections</h3><p>Or at least reduce your packet transmission. If you have a WiFi enabled device and you need to keep a socket open, try to reduce the keep alive packet transmission to minimum.</p><p>For BLE — depending on your chosen topology, you can strategize how you send your data in bigger intervals and still maintain full functionality.</p><p>And the key takeout — if you don’t need to keep a connection open or send data — <strong>turn of your emitter immediately or put it to standby</strong> if you’re going to retransmit within a period of time shorter than your cold start.</p><h3>Turn Things Off — Immediately</h3><p>This may be very obvious, but turn off your peripherals as soon as you don’t need them anymore, don’t wait the extra milliseconds. Sometimes we forget to turn off things as soon as possible (boiler, oven, AC) just because we turn them on a few moments later, but due to the fact that we need to save each and every joul, it matters.</p><h3>Idle - The Silent Killer</h3><p>Let&#39;s say you have an I2C operation, and you’re sleeping 10ms in between operations, even though I2C operations should take <a href="https://en.wikipedia.org/wiki/I%C2%B2C#Design">micro-seconds</a> . You are adding up (10-x)*NumberOfOperations ms to your idleness, this could sum up to quite a lot of energy in case your base profile is quite high.</p><p>Another common mistake that is related to idleness is using pre-defined waits for operations that send a notification when they are done. By waiting extra time for the confirmation, we waste extra Joules on nothing. This can be improved by using interrupts instead of polling for signal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYg4j0ysCfxyQrzH60Gm9w.png" /><figcaption>Original VS optimized</figcaption></figure><h3>Your Engineers’ Artifacts</h3><p>So your engineers made it and released this amazing product, but they didn’t clean up their debugging components, such as blinking LEDs, printing messages, enabling debug tools (UART) — these all sum up to quite a lot of energy.</p><p>Assuming you are using a LED at full brightness, it could <a href="https://learn.adafruit.com/battery-power-for-led-pixels-and-strips/estimating-running-time">potentially</a> drain to 10–20mA per LED.</p><p>You’d be amazed how much you can save just by cleaning before deploying to production.</p><h3>Restructuring The State Machine</h3><p>A similar example planning a multi-stop commute plan — you can organize your trip by multiple methods:</p><ul><li>Priority -opening/closing time for destinations, I must arrive when something is still open.</li><li>Distance between points —<a href="https://en.wikipedia.org/wiki/Travelling_salesman_problem">the travelling salesperson problem.</a></li><li>Logical order — I can drop off the pizza only after I pick it up from the restaurant.</li></ul><p>The same thing applies to your device — if we are focused on <strong>functionality</strong> and <strong>energy efficiency</strong>, we can do some non-trivial ordering to reduce cold start penalties.</p><h3><strong>Summary</strong></h3><p>By following these simple guideline, I was able to reduce the overall energy consumption in <strong>on</strong> state by 66% (7.5mWh to 2.5mWh per iteration), which is the major part of the energy consumption throughout the day.</p><p>To conclude, these guidelines could significantly help you reduce your overall energy consumption when developing a battery based IoT product.</p><p>Of course we can explore the <strong>deep-sleep</strong> realm, but this is something that would be more board specific or related more to the selected architecture.</p><p>If you are interested in deep sleep techniques, I highly recommend that you check out <a href="https://www.kevindarrah.com/">Kevin Darrah</a> and his <a href="https://www.youtube.com/channel/UC42d7zFnWU0dYVk_M0JED6w">Youtube channel</a>.</p><h3>TL;DR</h3><ul><li>Reduce your MCU/CPU <strong>core frequency to minimum</strong>.</li><li><strong>Reduce the WiFi/BLE transmit interval</strong> for socket keepalive.</li><li>Turn off any unused peripherals<strong> as soon as possible</strong>.</li><li><strong>Avoid predefined idle time frames</strong>, use interrupts instead.</li><li><strong>Remove</strong> <strong>any</strong> “debug in release” code — <strong>debug LEDs, prints, UART access.</strong></li><li><strong>Reconsider your state machine design</strong>, sometimes you’d be surprised how much you can save with a different sequence — cold start vs warm standby.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e8e90d4a02d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tech-at-trax/optimizing-your-iot-device-energy-consumption-3e8e90d4a02d">Optimizing Your IoT Device Energy Consumption</a> was originally published in <a href="https://medium.com/tech-at-trax">Tech at Trax</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>