<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet type="text/xsl" href="/localcopy.xslt"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Home on rohanrd.xyz</title>
    <link>https://rohanrd.in/</link>
    <description>Recent content in Home on rohanrd.xyz</description>
    <generator>Hugo</generator>
    <language>en-US</language>
    <lastBuildDate>Sun, 01 Feb 2026 12:32:14 +0530</lastBuildDate>
    <atom:link href="https://rohanrd.in/index.xml" rel="self" type="application/rss+xml" />
            <item>
            <title>Secure Your Browsing With DoH/DoT</title>
            <link>https://rohanrd.in/posts/doh-and-dot/</link>
            <pubDate>Sun, 01 Feb 2026 12:32:14 +0530</pubDate>
            <guid>https://rohanrd.in/posts/doh-and-dot/</guid>
                        <description> &lt;p&gt;Domain Name System or DNS is one of the core building blocks of Internet. We use it everyday unknowingly. It&amp;rsquo;s one of those things where you don&amp;rsquo;t have to know about it to use it just like internal combustion engine (ICE) of a car. We drive the car but we don&amp;rsquo;t have to be experts in how ICE works. Of course, knowing a few bits about ICE like it&amp;rsquo;s power, when to change it&amp;rsquo;s oil is good for you. Similarly knowing a few bits about DNS can drastically improve your Internet experience.&lt;/p&gt; </description>
            <content:encoded>&lt;p&gt;Domain Name System or DNS is one of the core building blocks of Internet. We use it everyday unknowingly. It&amp;rsquo;s one of those things where you don&amp;rsquo;t have to know about it to use it just like internal combustion engine (ICE) of a car. We drive the car but we don&amp;rsquo;t have to be experts in how ICE works. Of course, knowing a few bits about ICE like it&amp;rsquo;s power, when to change it&amp;rsquo;s oil is good for you. Similarly knowing a few bits about DNS can drastically improve your Internet experience.&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-is-dns&#34;&gt;&#xA;  What is DNS?&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;When you open a website in your browser one of the first things that happens is your browser tries to find the IP address of the remote server on which the website is hosted&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;. For this purpose, it issues a DNS query to DNS server. The DNS server is different from the website server. The job of the DNS server is to maintain dictionary of IP address of different websites and respond to DNS queries started by client browsers&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;. Once the DNS server responds to browser query, the browser can use the IP address in response of the DNS query to connect to remote server and render the website for you.&lt;/p&gt;&#xA;&lt;h2 id=&#34;dns-queries-are-not-encrypted&#34;&gt;&#xA;  DNS Queries Are Not Encrypted&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Unlike popular belief using Incognito mode or using HTTPS is not enough to preserve your privacy on the Internet. In most cases, the DNS queries are not encrypted meaning the communication that initially happens between your browser and DNS server is readable by anyone snooping on your traffic. This type of attack is known as man in the middle attack. Unfortunately a large number of Internet users are just unaware that this allows snooping entity to know what websites you are visiting.&lt;/p&gt;&#xA;&lt;h2 id=&#34;use-dohdot&#34;&gt;&#xA;  Use DoH/DoT&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;DNS over HTTPS (DoH) or DNS over TLS (DoT) are two standards that secure you against the man in the middle attack. Most modern browsers support DoH nowadays. You can also enable DoH/DoT at operating system level so that even the apps other than browsers use encrypted DNS. There are many DoH/DoT providers like Google, Cloudflare which offer the encrypted DNS service for free.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer: I am creator of WebShield&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://webshield.in&#34;&gt;webshield.in&lt;/a&gt;&lt;!-- raw HTML omitted --&gt; also implements both DoH and DoT standard and protects you against MITM attack. On top of encrypted DNS WebShield also provides you with ability to&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Block certain categories of websites like malware, phishing, adult content, etc,. across your devices.&lt;/li&gt;&#xA;&lt;li&gt;Setup access schedules on different categories of websites.&lt;/li&gt;&#xA;&lt;li&gt;Configure different profiles for different members in the family.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Check it out and let me know if you have any queries or suggestions.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;IP addresses are unique addresses by which computers are identified on the Internet. The two computers must know each others IP address before they can connect.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;This raises a question how does browser knows about the IP address of DNS server. This is configured as a part of network configuration. Whey you connect to WiFi, the router let&amp;rsquo;s your computer know about DNS servers that your computer can use.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</content:encoded>
            </item>
            <item>
            <title>Distractions</title>
            <link>https://rohanrd.in/posts/distractions/</link>
            <pubDate>Mon, 18 Aug 2025 21:37:05 +0530</pubDate>
            <guid>https://rohanrd.in/posts/distractions/</guid>
                        <description> &lt;p&gt;Our age is age of distractions. Instant messages, notifications, breaking news, endless stories, cute pet videos, random comments on social media are all distractions of one form or other. These distractions are dividing our attention which is already in short supply. Due to this, anything real like relationships, our own problems and issues, our thoughts and ideas forever remain on back burner. We don&amp;rsquo;t have time to sit with our own thoughts and ideas. How can we be healthy if we remain disconnected from ourselves?&lt;/p&gt; </description>
            <content:encoded>&lt;p&gt;Our age is age of distractions. Instant messages, notifications, breaking news, endless stories, cute pet videos, random comments on social media are all distractions of one form or other. These distractions are dividing our attention which is already in short supply. Due to this, anything real like relationships, our own problems and issues, our thoughts and ideas forever remain on back burner. We don&amp;rsquo;t have time to sit with our own thoughts and ideas. How can we be healthy if we remain disconnected from ourselves?&lt;/p&gt;&#xA;&lt;p&gt;We distract ourselves with shorts, reels or some random series on a streaming platform. We desperately want connection with real people but settle for fictional characters. Binge watching helps subsume the pain of truth. Truth that we should be working on our own problems, developing new skills, building strong relationships with real people. Somewhere in the back of our minds we all are well aware of this. We know all these distractions are sucking happiness out of our lives. But instant gratification wins over real hard work. &amp;ldquo;What are you talking about, Rohan? I can easily stave off distractions&amp;rdquo;. Maybe you can but I have found it incredibly hard thing to do. Maybe that&amp;rsquo;s just me but something tells me I&amp;rsquo;m not alone.&lt;/p&gt;&#xA;&lt;p&gt;Large corporations have poured billions to ensure as many eyeballs as possible remain active on their platforms. Why is notification on every social media plotform, red? Because we humans associate red with danger, something that needs our attention. That is why traffic light for stop is red. These large corporations have discovered numerous such hacks and they employ it without any regard for users well being. For them our attention is worth billions. The real question is how much our own attention is worth to us? What would we achieve if we could direct all our energy into our own well being?&lt;/p&gt;&#xA;&lt;p&gt;So how do we focus on ourselves? Well the first thing is to identify these distractions. It may be the most crucial step. Once we identify distractions it becomes easier to block them. The blocking process can involve using browser extensions or apps that block access to certain websites with fixed time slots. No solution is full proof. You will go back and forth between blocking and unblocking. What is important is you enable blocking every time you unblock. Think of it like this: blocking distractions is like building a muscle in your brain. The more you practice the stronger it becomes. Doom scrolling is what they gave us and took control of our time. Blocking is our way of fighting back and taking back that control.&lt;/p&gt;&#xA;</content:encoded>
            </item>
            <item>
            <title>Hosting Website on Phone</title>
            <link>https://rohanrd.in/posts/hosting-website-on-phone/</link>
            <pubDate>Sun, 08 Jun 2025 00:36:12 +0530</pubDate>
            <guid>https://rohanrd.in/posts/hosting-website-on-phone/</guid>
                        <description> &lt;p&gt;If you follow this blog, you must have come across my previous post that talked about how &lt;a href=&#34;https://rohanrd.xyz/posts/every-phone-should-be-able-to-run-personal-website/&#34;&gt;every phone should be able to host personal website&lt;/a&gt;. Well in this post I&amp;rsquo;m doing exactly that. If you haven&amp;rsquo;t read that post, please do.&lt;/p&gt;&#xA;&lt;p&gt;Hosting a website is not that hard. Anyone with Linux server could do it in few key strokes but it&amp;rsquo;s not that easy on phone. Modern phone operating systems have locked down the phones to a point that anything like hosting website feels like a wild idea.&lt;/p&gt; </description>
            <content:encoded>&lt;p&gt;If you follow this blog, you must have come across my previous post that talked about how &lt;a href=&#34;https://rohanrd.xyz/posts/every-phone-should-be-able-to-run-personal-website/&#34;&gt;every phone should be able to host personal website&lt;/a&gt;. Well in this post I&amp;rsquo;m doing exactly that. If you haven&amp;rsquo;t read that post, please do.&lt;/p&gt;&#xA;&lt;p&gt;Hosting a website is not that hard. Anyone with Linux server could do it in few key strokes but it&amp;rsquo;s not that easy on phone. Modern phone operating systems have locked down the phones to a point that anything like hosting website feels like a wild idea.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-problem&#34;&gt;&#xA;  The Problem&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;On Android, no application can bind on port below 1024&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;. It basically means even if you start a webserver on your phone the remote browser will have to specify the port number of your server along with url of your server. It will work but I think you will agree that it does not have the same feel to it. The website should be accessible just by it&amp;rsquo;s domain name.&lt;/p&gt;&#xA;&lt;p&gt;You can solve the port issue by adding another device like Raspberry Pi in front of your phone which can act as reverse proxy but then why would you not host on the Pi itself. Also your web server would not be truly mobile in that case. Another approach would be to root your phone but again that is too much&#xA;of hassle for hosting a simple website.&lt;/p&gt;&#xA;&lt;p&gt;For a long time, there was no real solution to this problem. I even complained about the port binding issue to Android development team to no avail. But finally it&amp;rsquo;s possible. Enters DNS HTTPS records.&lt;/p&gt;&#xA;&lt;h2 id=&#34;dns-https-records&#34;&gt;&#xA;  DNS HTTPS Records&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;What are HTTPS Records?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;HTTPS-records allows browsers to efficiently obtain complete instructions for accessing a web-site for a domain name - including supported protocols (HTTP/1.1, 2, 3, etc.), ip address(es), port number, and public keys (all optional) - saving the browser from doing a number of DNS lookups and other protocol negotiation steps.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Theres lot you can do with HTTPS records but we are interested in its ability  to specify port number in the DNS record itself. The client browser will connect directly on that port. This basically allows us to run web server on any port above 1024 without having to worry about sharing the port information. Users will be able to access your phone site just by domain name! I have tested it with Cloudflare and it works like charm. Below screenshot shows how we can define the HTTPS records for a domain on Cloudflare.&lt;/p&gt;&#xA;&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/https-dns-record.png&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/https-dns-record.png&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;So there you have it. A way to run fully functional web server on a phone. What will you do with it?&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;I am not sure if iOS allows this on phone. Let me know if you have done something like this on iPhone.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</content:encoded>
            </item>
            <item>
            <title>Selfhosting With IPv6 and mTLS</title>
            <link>https://rohanrd.in/posts/selfhosting-with-ipv6-and-mtls/</link>
            <pubDate>Sun, 06 Oct 2024 21:14:27 +0530</pubDate>
            <guid>https://rohanrd.in/posts/selfhosting-with-ipv6-and-mtls/</guid>
                        <description> Uncomplicate self hosting with IPv6 and mTLS </description>
            <content:encoded>&lt;p&gt;People who frequent this blog know I love self hosting. I&amp;rsquo;m hosting like a dozen of services from home.&#xA;The pain is accessing these services on the go.&#xA;In India, CG-NAT is norm and getting a static IPv4 address is expensive.&#xA;So I&amp;rsquo;m left with few options to access these services like VPN, third party tunnels or use IPv6.&lt;/p&gt;&#xA;&lt;p&gt;Now I get why a lot of self hosters prefer VPNs but I think they are just too much work for home use.&#xA;Not to mention I would have to setup a private server to expose my home VPN network as I&amp;rsquo;m on CG-NAT &lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;.&#xA;I&amp;rsquo;m not a fan of third party tunnels either. So I&amp;rsquo;m left with plain IPv6 approach. Fortunately I get IPv6 at home and on mobile as well.&#xA;Technically I should be able to access the services at home without much hassle.&#xA;But then security wise I&amp;rsquo;m exposing my server to all sorts of bots and bad actors.&lt;/p&gt;&#xA;&lt;p&gt;Solution? Expose services on IPv6 with mTLS enabled reverse-proxy.&#xA;mTLS ensures that only authenticated clients can connect to my home server.&#xA;It achieves this by requesting client a pre-issued certificate. If the certificate is valid,&#xA;the reverse-proxy allows connection to the backend service.&#xA;Here&amp;rsquo;s a good &lt;a href=&#34;https://fardog.io/blog/2017/12/30/client-side-certificate-authentication-with-nginx/&#34;&gt;resource&lt;/a&gt;&#xA;that shows how to create your own CA and obtain the needed certs. The article is for nginx but I use caddy.&#xA;mTLS config for caddy is quite simple:&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;https://yourdomain.com {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;tls your@email.com{                  # allows SSL connection&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;&#x9;client_auth {                               # mTLS config block&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;&#x9;&#x9;mode require_and_verify&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;&#x9;&#x9;trusted_ca_cert_file /etc/caddy/certs/private-ca.crt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;&#x9;}&#x9;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;reverse_proxy :5006&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;Like with everything there are some disadvantages of this method.&#xA;The major one is you have to access most of your services via browser only because lot of mobile apps do not support mTLS auth.&#xA;Another one is you can&amp;rsquo;t access your services from network that does not support IPv6. The 2nd one is non-issue for me.&#xA;I am mitigating the first one by using apps that do support mTLS or I use the web version only.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;I tried setting up IPv6 only VPN but again it was complicating things.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</content:encoded>
                <category>self hosting</category>
            </item>
            <item>
            <title>Why RSS</title>
            <link>https://rohanrd.in/posts/why-rss/</link>
            <pubDate>Thu, 15 Aug 2024 02:49:22 +0530</pubDate>
            <guid>https://rohanrd.in/posts/why-rss/</guid>
                        <description> Ditch the feed. RSS is all you need </description>
            <content:encoded>&lt;p&gt;Gone are the days when you could just find a random blog on Internet where someone wrote about tinkering with their home lab or someone shared about the obscure art they know. Today&amp;rsquo;s web is highly curated and everything is filtered out to show you the content that would generate most revenue. Search engines are filled with optimized results that can easily be categorized as spam. And social media is filled with highly polished, attractive content that may not add any value at all to an individuals life.&lt;/p&gt;&#xA;&lt;p&gt;I blame Ads. The web has become increasingly hostile place because of ads. Huge corporations are pouring billions to grab eyeballs on the web. The ads are becoming intrusive and there are third party trackers everywhere. Trackers that track your interests and show you ads depending on that.  Using web without an adblocker is a nightmare. Now it&amp;rsquo;s getting difficult to block ads as well &lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;. Then there&amp;rsquo;s case of AI generated content which is only going to increase and it will become increasingly difficult to discern from real content.&lt;/p&gt;&#xA;&lt;h2 id=&#34;ditch-the-feed&#34;&gt;&#xA;  Ditch The Feed&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;I mostly hang out on Hacker News and Reddit. I don&amp;rsquo;t have any other social media and I have found myself worrying about global politics, climate change, microplastics and whole lot of other things. Things that I have no control over. Don&amp;rsquo;t get me wrong it&amp;rsquo;s good to be informed about these things but constant influx of such information is not helping anyone. It&amp;rsquo;s critical to regulate what we consume on web because our brains have a tendency to think about what we consume. Our very thoughts could be the result of what information we are consuming. Seriously ditch the feed that someone else is curating for you! &lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;curate-your-own&#34;&gt;&#xA;  Curate Your Own&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;After all issues above one might want to ditch all the social media and web along with it but we all know that&amp;rsquo;s not possible. The best we can do is limit the influx of information and curate it such that it&amp;rsquo;s good for our well being. Find people and organizations you can trust. There are bloggers and content creators who know their craft and audience. These are the once who prefer authenticity over anything else. You will never see AI generated content from these &lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;. You can also trust their content. Subscribe to such people and organizations. Add them to your feed or remove them if they aren&amp;rsquo;t adding any value to your life. Curate your own feed religiously.&lt;/p&gt;&#xA;&lt;p&gt;But how?  Enters RSS.&lt;/p&gt;&#xA;&lt;h2 id=&#34;introdution-to-rss&#34;&gt;&#xA;  Introdution to RSS&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;It&amp;rsquo;s like a social media feed but you are the curator. You choose sources that will appear in your feed and not some algorithm which is prioritizing revenue of some corporation over your interests. There are no trackers or intrusive ads in RSS. You can configure how frequently you want to refresh the feed. You choose the application to browse the feed. Unlike web where you only have Chrome or Firefox for browsing, RSS feeds can be read on any of 1000s of clients available. Choose one that suits you I will recommend &lt;a href=&#34;https://github.com/prof18/feed-flow&#34;&gt;Feed flow&lt;/a&gt;. You can even use browser to read your feed. I am using miniflux and this is how my feed looks like:&lt;/p&gt;&#xA;&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/miniflux.png&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/miniflux.png&#34; alt=&#34;RSS feed curated with miniflux&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;A Word of Advice: limit the number of sources and frequency of refresh. That way you will have the best possible experience browsing the web. Once you become accustomed to RSS you can configure it to consume everything from blogs to YouTube videos and even podcasts. Your RSS feed should be a place where you can find information that you are interested in. Unlike social media, RSS feed will get boring fast and hence non addictive. You will spend less time on web and more time with yourself.&lt;/p&gt;&#xA;&lt;p&gt;One more thing, sometimes websites do not provide RSS feed and in that case there&amp;rsquo;s nothing we can do except request them to provide one. But such sites are limited and most websites will provide RSS feed. For example, you can subscribe to this blog by clicking on RSS icon below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://rohanrd.xyz/index.xml&#34;&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/rss.svg&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/rss.svg&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next time you want to subscribe to anyone just look for above icon. Happy curating!&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://www.androidpolice.com/google-chrome-manifest-v2-extensions-warning/&#34;&gt;Google Chrome has started warning users that their ad blockers may soon be disabled&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;As much as I had like to avoid entire social media it still has some value so I have limited Reddit and Hacker news to once a week. It&amp;rsquo;s still new so I will see how it goes.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:3&#34;&gt;&#xA;&lt;p&gt;I am not against using AI generated content. It has it&amp;rsquo;s place but it should be clearly marked as such.&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</content:encoded>
                <category>self hosting</category>
            </item>
            <item>
            <title>Goodbye Google. Hello Ecosia!</title>
            <link>https://rohanrd.in/posts/ecosia/</link>
            <pubDate>Sun, 16 Jun 2024 01:57:39 +0530</pubDate>
            <guid>https://rohanrd.in/posts/ecosia/</guid>
                        <description> Why I switched from Google to Ecosia </description>
            <content:encoded>&lt;p&gt;There was a time I thought I would never switch away from Google. But times change, things fall apart. An incredible search engine starts giving you answers for the questions you never asked. A search engines job is to find best results for given keywords and then allow the user to navigate away from them. With Google, they are choosing the result for me. They are showing way too much information that I&amp;rsquo;m not really looking for. Try searching for a city and you will know what I&amp;rsquo;m talking about.&lt;/p&gt;&#xA;&lt;p&gt;They are tuning search such that it becomes more accessible to people who like asking questions and getting answers. There&amp;rsquo;s nothing wrong with this. The sweet analytics that they collect must have been telling them that large number of people like to ask questions and are expecting answers. So that&amp;rsquo;s the direction they have chosen for search. This is normal progression of any Software when they choose to follow analytics. Of course with their popularity they could have chosen to ignore analytics and make search better. Everyone would eventually learn the art of searching but that&amp;rsquo;s just my idealism.&lt;/p&gt;&#xA;&lt;p&gt;I prefer good old searching with keywords instead of asking questions. When I&amp;rsquo;m typing those keywords I want the search engine to find all the pages across the web that might have those keywords. Google still does that but there focus has shifted from returning best results to keeping users engaged on the search page. AI generated answers are now front and center. Then there&amp;rsquo;s that annoying questions panel that keeps expanding with more questions if you click one of the answers. Search results are below all these panels. This shows their priorities. Instead of all this AI fluff they could have chosen to solve the SEO spam issue but no.&lt;/p&gt;&#xA;&lt;p&gt;Anyways, my search experience has siginificantly deviated from what it was few years ago. I don&amp;rsquo;t think they can ever go back on this. New and existing users now expect everything that they have been doing on search page. People like me who prefer the good old search will just have to find new search engine.&lt;/p&gt;&#xA;&lt;h2 id=&#34;hello-ecosia&#34;&gt;&#xA;  Hello Ecosia&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;I found out about Ecosia from a comment on Hacker News. It stated that the search engine plants trees when you search. My first thought was that must be some poor search engine which plants trees just to create headlines. But I was wrong. Few days later, I was annoyed with Google and decided to try Ecosia. It&amp;rsquo;s been a long time that I used a search engine other than Google and I was not disappointed with the results. The best way to try out a search engine is to change your deafult search in your browser and use it for few days. I have been using Ecosia for a month now and I&amp;rsquo;m happy to say that I love it. I don&amp;rsquo;t see myself switching back to Google.&lt;/p&gt;&#xA;&lt;p&gt;The search engine is clean. It does not have any dynamic panels that expand at will. Search results are front and center and AI is hidden away in separate tab. They do show occasional information panels like currency converter or the dictionary panel but these panels are limited and are useful when shown. Searching on Ecosia reminds you of old days of Google. You can&amp;rsquo;t sign in to Ecosia. They don&amp;rsquo;t store any history and is good from user privacy perspective. You can disable the cookies you don&amp;rsquo;t need from their settings page.&lt;/p&gt;&#xA;&lt;p&gt;With Ecosia it&amp;rsquo;s not just better search experience, 100% of their profits go to climate action. They really do plant trees when we are searching! All the information regarding their financials is easily accessible from homepage and they are very transparent about their spending. I actually disabled my adblocker for Ecosia. These ads help them make profits which finally go to climate action. It&amp;rsquo;s refreshing to see a company using their profits for better tomorrow.&lt;/p&gt;&#xA;&lt;p&gt;If you are excited to try it out, here you go: &lt;a href=&#34;https://www.ecosia.org&#34;&gt;https://www.ecosia.org&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Subscribe to RSS feed for future updates!&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;P.S.&#xA;If you are someone who prefers Google but don&amp;rsquo;t like the new changes that are happening on results page then you can still get old results only page by using the &amp;ldquo;Web&amp;rdquo; filter from &amp;ldquo;More&amp;rdquo; dropdown. With this filter, Google will not show any AI answers or suggest any questions. I tried this for few days but the way this feature is hidden away shows Google&amp;rsquo;s priorities.&lt;/p&gt;&#xA;</content:encoded>
                <category>sustainability</category>
            </item>
            <item>
            <title>Every Phone Should Be Able to Run Personal Website</title>
            <link>https://rohanrd.in/posts/every-phone-should-have-web-server/</link>
            <pubDate>Sat, 05 Aug 2023 19:51:52 +0530</pubDate>
            <guid>https://rohanrd.in/posts/every-phone-should-have-web-server/</guid>
                        <description> Old Nokia phones could run personal websites, why can&amp;rsquo;t today&amp;rsquo;s phones? </description>
            <content:encoded>&lt;p&gt;Back in 2009, anynone with a Nokia could have a personal website running on their own phone. You could host your own blog or share photos directly from your camera roll. People could message you or even send you sms over HTTP. There was other functionality but you get the gist. Sadly this amazing piece of tech was never widely adopted. Today&amp;rsquo;s phones are far more powerful than those Nokias both in performance and battery backup and still we don&amp;rsquo;t see anyone running a server on their phone. Why?&lt;/p&gt;&#xA;&lt;p&gt;I think this is because doing something like this that would make web more open was never a priority for large corporations. Think about it there&amp;rsquo;s no incentive for them to work on something like this. In fact, it might be something they want to actively avoid in order for their walled gardens to flourish. Then there are some tech aspects too that need to be worked on. A large number of population is behind CG-NAT and hence can&amp;rsquo;t use mobile server like this. Although this is changing with IPv6. Then there&amp;rsquo;s Android&amp;rsquo;s case of not allowing any application to bind below 1000 port. This prevents running web server on traditional 80 or 443 port.&lt;/p&gt;&#xA;&lt;p&gt;Today&amp;rsquo;s phone can definitely handle a small personal static website that has similar functionality like that of original Nokia web server. The reason I think this is needed is because a large percent of Internet users cannot afford hosting personal websites or have no idea how to. If we made setting up a website as easy as few clicks a lot of people would want to create their own websites.&lt;/p&gt;&#xA;&lt;p&gt;Early Internet users had the privilege of self hosting from home, at that time there was no CG-NAT. Today&amp;rsquo;s users never got to experience that possibility. Most of current population joined Internet when their devices were already behind CG-NAT. Maybe the next billion websites can come from average phone users but someone has to provide the software to do it easily. All we need is to package a server like caddy for Android/iOS and provide IPv6 connectivity.&lt;/p&gt;&#xA;</content:encoded>
            </item>
            <item>
            <title>First Steps After Installing Raspbian</title>
            <link>https://rohanrd.in/posts/getting-started-with-selfhosting-part-2/</link>
            <pubDate>Sun, 19 Mar 2023 17:07:37 +0530</pubDate>
            <guid>https://rohanrd.in/posts/getting-started-with-selfhosting-part-2/</guid>
                        <description> &lt;p&gt;We discussed regarding the hardware that I use for self hosting &lt;a href=&#34;https://rohanrd.xyz/posts/getting-started-with-self-hosting/&#34;&gt;here&lt;/a&gt;. Let&amp;rsquo;s prepare our Pi for selfhosting&lt;/p&gt;&#xA;&lt;h2 id=&#34;install-raspbian&#34;&gt;&#xA;  Install Raspbian&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Downloads&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.raspberrypi.com/software/&#34;&gt;Raspberry Pi Imager&lt;/a&gt; is the quick and easy way to install Raspberry Pi OS and other operating systems to a microSD card, ready to use with your Raspberry Pi&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.raspberrypi.com/software/operating-systems/&#34;&gt;Download Raspbian Lite.&lt;/a&gt; Choose 64 bit version&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Once you have downloaded these, start imager tool. Now choose &amp;ldquo;Use custom&amp;rdquo; option and specify the OS image location. Next you have to choose the storage option which will list the memory card that you will be inserting in Raspberry Pi. Once you have set these, select the gear icon to specify initial preferences for the OS. specify below options and check the set hostname box. You can also set the locale. I am assuming you will be using Ethernet connection. But if you want to use WiFi you should set those preferences as well.&lt;/p&gt; </description>
            <content:encoded>&lt;p&gt;We discussed regarding the hardware that I use for self hosting &lt;a href=&#34;https://rohanrd.xyz/posts/getting-started-with-self-hosting/&#34;&gt;here&lt;/a&gt;. Let&amp;rsquo;s prepare our Pi for selfhosting&lt;/p&gt;&#xA;&lt;h2 id=&#34;install-raspbian&#34;&gt;&#xA;  Install Raspbian&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Downloads&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.raspberrypi.com/software/&#34;&gt;Raspberry Pi Imager&lt;/a&gt; is the quick and easy way to install Raspberry Pi OS and other operating systems to a microSD card, ready to use with your Raspberry Pi&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.raspberrypi.com/software/operating-systems/&#34;&gt;Download Raspbian Lite.&lt;/a&gt; Choose 64 bit version&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Once you have downloaded these, start imager tool. Now choose &amp;ldquo;Use custom&amp;rdquo; option and specify the OS image location. Next you have to choose the storage option which will list the memory card that you will be inserting in Raspberry Pi. Once you have set these, select the gear icon to specify initial preferences for the OS. specify below options and check the set hostname box. You can also set the locale. I am assuming you will be using Ethernet connection. But if you want to use WiFi you should set those preferences as well.&lt;/p&gt;&#xA;&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/os-preferences.png&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/os-preferences.png&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;Write the image, it will take some time and will give a message when you can eject the memory card. You can now insert it in the memory card slot on your Pi. At this point you are ready to power on your Pi. Once it&amp;rsquo;s powered on, use app like Wifiman on your phone to determine IP address of your Pi. You can log into the shell of your Pi using ssh&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ssh pi@192.168.1.12&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;It will prompt you for the password that we set earlier. Your Pi is ready to self host but let&amp;rsquo;s do some housekeeping before we install any applications.&lt;/p&gt;&#xA;&lt;h2 id=&#34;install-log2ram&#34;&gt;&#xA;  Install Log2ram&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Log2ram is required because we don&amp;rsquo;t want to write logs generated by our applications to the memory card. Instead we store those logs in RAM. This is mostly useful for preventing wear and tear of our SD card. Run below commands to install &lt;code&gt;log2ram&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ bookworm main&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; sudo tee /etc/apt/sources.list.d/azlux.list&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo wget -O /usr/share/keyrings/azlux-archive-keyring.gpg  https://azlux.fr/repo.gpg&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo apt update&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo apt install log2ram&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;After installation you need to reboot. You can check if it&amp;rsquo;s working by checking log2ram service status or by running below command&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo df -h &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; grep log2ram&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;More details on installation and troubleshooting &lt;a href=&#34;https://github.com/azlux/log2ram&#34;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;install-podman&#34;&gt;&#xA;  Install Podman&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Podman is a tool for managing OCI containers and pods. Don&amp;rsquo;t worry about what it is and what it does. You will have your answers as soon as you start using it. You can use below command to install podman&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;sudo apt install podman&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now run &lt;code&gt;podman ps&lt;/code&gt; it&amp;rsquo;s output should be clean one liner. If you see error relate to &lt;code&gt;cgroup&lt;/code&gt; do the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create directory &lt;code&gt;mkdir -p ~/.config/containers&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Add a file &lt;code&gt;containers.conf&lt;/code&gt; in the directory created above using below command&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cat &amp;gt; ~/.config/containers/containers.conf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;engine&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nv&#34;&gt;events_logger&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;file&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nv&#34;&gt;cgroup_manager&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;cgroupfs&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;ol start=&#34;3&#34;&gt;&#xA;&lt;li&gt;Run the &lt;code&gt;podman ps&lt;/code&gt; command again and the error related to cgroup should be gone.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2 id=&#34;mount-external-drives&#34;&gt;&#xA;  Mount External Drives&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Our apps and data will stay on external drives since we want to prevent wear and tear of memory card. Follow these steps to mount external drive:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your external drive should be visible in output of command &lt;code&gt;sudo blkid&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Note the UUID corresponding to your drive from above command&lt;/li&gt;&#xA;&lt;li&gt;Create a folder like &lt;code&gt;/mnt/avalon&lt;/code&gt; where we will mount our external drive. Change permissions or ownership of this directory as required.&lt;/li&gt;&#xA;&lt;li&gt;Make backup of file &lt;code&gt;/etc/fstab&lt;/code&gt; and add below line at the end of file. Update your UUID and mount location and keeping everything else same.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;UUID=f8cd0001-1328-4f6a-80fa-8c7b7dea09a4 /mnt/avalon ext4 defaults,auto,users,rw,nofail,exec 0 0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;mount -av&lt;/code&gt; to reload changes made to &lt;code&gt;/etc/fstab&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;You Raspberry Pi is now ready for installing self hosted applications.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;I am assuming you have ext4 drive. If your drive is formatted as some different filesystem you will have to update fstab accordingly. Here&amp;rsquo;s a good &lt;a href=&#34;https://pimylifeup.com/raspberry-pi-mount-usb-drive/&#34;&gt;reference&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</content:encoded>
                <category>self hosting</category>
            </item>
            <item>
            <title>Toxic Positivity</title>
            <link>https://rohanrd.in/posts/toxic-positivity/</link>
            <pubDate>Sun, 12 Mar 2023 17:22:47 +0530</pubDate>
            <guid>https://rohanrd.in/posts/toxic-positivity/</guid>
                        <description> Seek truth, not positivity </description>
            <content:encoded>&lt;p&gt;Imagine our ancestors, who were primarily hunter-gatherers, when faced with predator like a Lion thought &amp;ldquo;This lion will not eat me&amp;rdquo;.&#xA;Or consider example of the 2008 financial crisis, people thought &amp;ldquo;mortgage backed securities will never go down&amp;rdquo;. Then every now and then&#xA;throughout the world their are banks that collapsed and eventually had to be bailed out by government. In each of these examples, people&#xA;failed to consider a perspective. These people were not dumb but they were blinded by what I call toxic positivity.&#xA;I see so many instances where the situation was dire and people were being positive about it. All it does is exacerbates the problem.&lt;/p&gt;&#xA;&lt;p&gt;Now consider the flip side, which I think was how our hunter-gatherer ancestors would have solved the problem.&#xA;Instead of relying on Lion not eating them. They controlled what they could, expecting the worst. They started living and&#xA;hunting in groups which gave them obvious advantage. They did this until man became the apex predator in the food chain. If they had not&#xA;done that we would not be here seeing this day.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; Same goes for the financial crisis, if more people had considered&#xA;a negative perspective&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; that financial crisis could have been avoided. This negative perspective is what I call thoughtful&#xA;negativity.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Thoughtful negativity is better than toxic positivity&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In conclusion what I want to say is negative perspective is not bad. Perception of reality is always subjective. If we consider the negative&#xA;perspective along with positive, I think, we get a more clearer picture of reality.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;Reminds me of a scene from The Leftovers season 2. It&amp;rsquo;s opening scene and is very beautiful depiction of how our human race has evolved. I will not spoil that scene for you. Go watch it, it&amp;rsquo;s worth watching.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;Few people did considered the negative perspective and earned quite some money. You can watch the movie Big Short or related documentaries if you haven&amp;rsquo;t already&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</content:encoded>
                <category>ramblings</category>
            </item>
            <item>
            <title>Getting Started With Self Hosting</title>
            <link>https://rohanrd.in/posts/low_cost_server/</link>
            <pubDate>Sat, 09 Apr 2022 07:59:26 +0530</pubDate>
            <guid>https://rohanrd.in/posts/low_cost_server/</guid>
                        <description> Get started with your self hosting journey </description>
            <content:encoded>&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/pi_server.jpg&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/pi_server.jpg&#34; alt=&#34;Raspberry PI server with external hard drive&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;People in tech circles are increasingly moving towards self hosting and I believe this trend is going to catch on with general population as both hardware and Software continues to evolve. This evolution has already reached to a point where a layman with few hours to spare can self host alernative to most of popular cloud based applications. In this blog post I am going to show you the hardware that I have used for low cost server setup at my home.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-server&#34;&gt;&#xA;  The Server&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;You can use old PC/laptop as server for your home in which case you don&amp;rsquo;t even have to buy anything but I would recommend that you use a Raspberry Pi instead. There are quite a few advantages if you go this route.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;They are fast and low on power consumption. You can stream 4K content with Raspberry Pi 4.&lt;/li&gt;&#xA;&lt;li&gt;They are cheap. 4GB version will cost you around 5000 INR without accessories.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;We want our server to run 24x7&lt;!-- raw HTML omitted --&gt;1&lt;!-- raw HTML omitted --&gt; and the power consumption adds up over time so it is an important factor while choosing the hardware for our server. A Raspberry Pi will cost you once in beginning but its going to save you lot of money in the long run. Here&amp;rsquo;s a &lt;a href=&#34;https://tinyurl.com/nwu6sn4s&#34;&gt;calculator&lt;/a&gt; to calculate power consumption of any appliance. 10W is average power consumption of Pi. Try putting 65W on that calculator and see how numbers change.&lt;/p&gt;&#xA;&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/power_calc.png&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/power_calc.png&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;h2 id=&#34;storage&#34;&gt;&#xA;  Storage&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;If you are just beginning your self hosting journey I would advise you to start with a Pen drive. This way you can experiment while keeping costs down. If you are determined to have long term self hosting solution then read on.&lt;/p&gt;&#xA;&lt;p&gt;The storage you choose depends on what you want to use your server for. For me, I want to host a Jellyfin media server that can playback 4K content. This requires that I have at least a Tera byte of storage. Note that Raspberry Pi runs of a memory card and you don&amp;rsquo;t need anything else but I would suggest to use that only for booting the Pi. Any data that you want to store for long term should never end up on that memory card. Always use external storage like a pen drive or HDD with Pi. suitable for its booting but not for any long term storage.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Few considerations while choosing storage hardware&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pi should be able to serve 4K content. This requires that the HDD be connected over USB3.0.&lt;/li&gt;&#xA;&lt;li&gt;The drive should go to sleep when not in use. This reduces power consumption as well as wear and tear of the drive thus increasing the life span.&lt;/li&gt;&#xA;&lt;li&gt;Our storage solution should have proper heat dissipation.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;You can connect an external HDD to your Pi and be done with it but there are 2 disavantages to this approach. First, xxternal HDDs have poor heat dissipation which is okay considering they are built for one off usage and not running a mediacenter of them. They are certainly not designed to run 24x7. Second, external HDDs usually have 2.5inch form factor which limits their speed to 5400RPM. These are basically same hard disks as laptops which are slow as compared to internal hard disks used in desktops&lt;/p&gt;&#xA;&lt;p&gt;After careful consideration of many HDD connectivity solutions I came to conclusion that PiBox dock is best hardware for our low cost server. It can suspend the drive when not in use. It supports both 3.5/2.5 inch HDD and has USB3.0 interface. I have chosen Seagate Barracuda 3.5 inch HDD for my requirement. Another advantage of going with internal HDD is that they are cheaper as compared to their external counterpart. Regarding heat dissipation, since our drive is internal and docked there is no need for additional heat dissipation. I have checked temperatures and they are well within operating range of HDD. Ideally we should be using an enclosure with fans but that goes way over the budget for the low cost server that we want to build.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bill of Materials&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.pibox.in/product/raspberry-pi-4b-4gb/&#34;&gt;Raspberry PI 4&lt;/a&gt; with case and fan - INR 5800&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.pibox.in/product/pibox-india-usb-3-0-hard-drive-docking-station-usb-to-sata-docking-station-with-10tb-drive-support-for-2-5-inch-3-5-inch-hdd-ssd-supports-sata-i-ii-iii-and-uasp-asm1153e-top-loading-desi/&#34;&gt;PiBox HDD Dock&lt;/a&gt; - INR 1100&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.amazon.in/Seagate-BarraCuda-ST1000DM010-Desktop-Latest/dp/B01LNJBA2I/&#34;&gt;Seagate Barracuda HDD 1TB&lt;/a&gt; - INR 3000&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;It costs little below INR 10,000 but if you compared this to the NAS solutions that are available in market this is pretty low cost. Not to mention its robust as well. I have been streaming 4K content, hosting an alternative to Google Photos and also a document server capable of running OCR on incoming documents but Raspberry Pi hardly breaks a sweat&lt;!-- raw HTML omitted --&gt;2&lt;!-- raw HTML omitted --&gt;. It&amp;rsquo;s a tiny little beast. In my next post I will show you the kind of applications that I am self hosting at home. So stay tuned.&lt;/p&gt;&#xA;&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/pi.jpg&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/pi.jpg&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;We can turn off our server every night further improving cost savings but I will leave that as an exercise for the reader&lt;/li&gt;&#xA;&lt;li&gt;Your Pi will have hard time if you are expecting it to perform OCR while also transcoding media streams for multiple users. So yes your apps need to be configured properly to make the best out of this low cost setup.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;</content:encoded>
                <category>self hosting</category>
            </item>
            <item>
            <title>Why Start Self Hosting</title>
            <link>https://rohanrd.in/posts/why_self_host/</link>
            <pubDate>Wed, 23 Mar 2022 00:02:34 +0530</pubDate>
            <guid>https://rohanrd.in/posts/why_self_host/</guid>
                        <description> Take control back of your digital life </description>
            <content:encoded>&lt;p&gt;Remember Picasa? There is no native application even today that comes close to it&amp;rsquo;s feature parity. But sadly it was discontinued in favour of a cloud application: Google Photos. What happened with Picasa also happened to millions of other applications around the same time Picasa was discontinued. The applications we use to run on our PC have moved to cloud. It makes sense from corporations perspective because they get more control over updates, user data and licenses but users are at huge disadavantage as they no longer are in control of their own data. You might ask why that is such an issue? Let&amp;rsquo;s see:&lt;/p&gt;&#xA;&lt;p&gt;Consider this, you carefully curate your playlists on Spotify but every now and then you see a certain song missing from your playlist. Same goes for videos saved in your YouTube playlists or other music/video streaming services. Then there is also the case of OTT streaming platforms where the show you were going to watch over weekend has now disappeared. If this was not bad imagine what happens when you need document from your email but the provider has suspended your account because of something you did (which was not even violation of terms of service) on other service of that email provider. &lt;a href=&#34;https://hn.algolia.com/?q=account&amp;#43;suspended&#34;&gt;Hacker News is littered with such stories&lt;/a&gt;. There are some stories where the user never figured out what they had done wrong to deserve suspension of account.&lt;/p&gt;&#xA;&lt;p&gt;Then there is this whole different problem of corporations tracking you and your data. Whenever I bring this up people are like &amp;ldquo;I don&amp;rsquo;t care, I have nothing to hide&amp;rdquo;. But this is exactly similiar to saying &amp;ldquo;I don&amp;rsquo;t care about free speech because I have nothing to say&amp;rdquo;. Would you give up your right to free speech because you have nothing to say? No. The same goes about right to privacy. The data you share is used to cater you personalized ads. That same data is also used to ensure that you spend maximum time with the particular service. There are millions of engineers across the world who are getting paid hefty sum to keep as many eyeballs as possible glued to service offered by their employers. This engineering talent is supposed to be solving world&amp;rsquo;s problems but instead they are ensuring how everyone wastes their time. That&amp;rsquo;s a whole different topic for another blog post.&lt;/p&gt;&#xA;&lt;p&gt;What self hosting does is it protects you against all these issues and more. It gives you the peace of mind by keeping you in control of your data. You can choose if you never want your data to leave your premises or home. You can also choose to make your data available to you whenever or wherever you want it securely. In upcoming posts, we will explore self hosted applications and how they protect you and your data. But if you cannot wait, head over to &lt;a href=&#34;https://www.reddit.com/r/selfhosted&#34;&gt;r/selfhosted&lt;/a&gt; or check out this &lt;a href=&#34;https://github.com/awesome-selfhosted/awesome-selfhosted/blob/master/README.md&#34;&gt;awesome self hosted list&lt;/a&gt; to get started with your self hosting journey.&lt;/p&gt;&#xA;&lt;p&gt;Subscribe to RSS feed to stay updated.&lt;/p&gt;&#xA;</content:encoded>
                <category>self hosting</category>
            </item>
            <item>
            <title>Monitoring Solar Power Over WiFi</title>
            <link>https://rohanrd.in/posts/monitoring_solar_panel_output_over_wifi/</link>
            <pubDate>Wed, 20 Jan 2021 00:00:00 +0000</pubDate>
            <guid>https://rohanrd.in/posts/monitoring_solar_panel_output_over_wifi/</guid>
                        <description> Measuring solar panel output with Arduino and ESP8266 and viewing it on Grafana dashboard with InfluxDB hosted on Raspberry PI </description>
            <content:encoded>&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/solar_panel.jpg&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/solar_panel.jpg&#34; alt=&#34;solar panel&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;India is rapidly switching to renewable energy sources. It&amp;rsquo;s not just the government that&amp;rsquo;s making the switch but people as well have been switching to solar roof tops for their power requirements. In our society, 30-40% houses have set up solar panels on their roofs. Most of these houses do not pay at all to the MSEB but on the other hand contribute surplus to the grid.&lt;/p&gt;&#xA;&lt;p&gt;The one that is setup at my home - shown in picture above - has 2.27 kWh capacity. Over the past 3-4 months I have been monitoring the output of these panels and they have been on average producing 220-270 kW per month. There is around 70-100 units of surplus which is fed into the grid every month. I have seen output of about maximum 11.6 kWh in a single day. Rest of days it fluctuates in 6-8 kWh range. There are many parameters affecting output like weather, panel temperature, dust on the panels. I do not have any control over the weather but rest two parameters can be kept in check to improve efficiency of these panels.&lt;/p&gt;&#xA;&lt;p&gt;Currently, only way to monitor output of these panels is by checking the inverter manually. This is not helpful at all. Moreover I would prefer to have this data recorded on per minute basis rather than looking at aggregates at the end of the day. I need a system that will continuously log the panel output to a central database. Logging to central database has its own advantages: I can not only do a thorough analysis but also get power stats over the Internet. Let&amp;rsquo;s build this 😃&lt;/p&gt;&#xA;&lt;h3 id=&#34;components&#34;&gt;&#xA;  Components&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/sct_resize.jpg&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/sct_resize.jpg&#34; alt=&#34;floatright&#34; title=&#34;The sensor must be clipped on phase&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;figcaption&gt;The sensor must be clipped on phase&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;SCT-013-030: A non-invasive current sensor with a clip-on. I did not wanted to meddle with 230V mains supply, hence this sensor. You can clip it on any wire and it will generate output voltage corresponding to the current flowing from the wire.&lt;/li&gt;&#xA;&lt;li&gt;Arduino Uno: I had this sitting in my closet. It has an ADC onboard which can be used to measure output of the current sensor.&lt;/li&gt;&#xA;&lt;li&gt;ESP01 WiFi module: This module can directly transmit data over WiFi network and it was the cheapest one that I found. Also, it seems it can be easily interfaced with Arduino.&lt;/li&gt;&#xA;&lt;li&gt;3.3V power supply: ESP01 needs a regulated 3.3v power supply&lt;/li&gt;&#xA;&lt;li&gt;A raspberry pi: This is used for capturing the data shared by ESP01 and as a data logger. Eventually this will also be used as a server to broadcast captured data over Internet.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3 id=&#34;a-note-on-esp01&#34;&gt;&#xA;  A Note on ESP01&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;I am using Micropython firmware for ESP01. Stock AT firmware should also work. I chose Micropython because I was facing issues communicating with Arduino over serial. Although I later found out that the issue was because of power supply. ESP01 strictly needs 3.3V[1]. The issue went away once it was powered by a dedicated 3.3V power supply instead of Arduino&amp;rsquo;s 3.3V supply. I spent lot of time resolving this issue. 😅&lt;/p&gt;&#xA;&lt;h3 id=&#34;interfacing-arduino-with-esp01&#34;&gt;&#xA;  Interfacing Arduino With ESP01&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;The interfacing here is for serial communication between Arduino and ESP01. If you want to flash or load programs on ESP01 using Arduino you will have to change wiring. Refer this &lt;a href=&#34;https://www.ankshilp.com/flashing_esp_with_arduino/&#34;&gt;note&lt;/a&gt; for wiring, flashing and loading programs on ESP01.&lt;/p&gt;&#xA;&lt;p&gt;Below is the wiring between UNO and ESP01 for serial communication. You can choose different pins for RX &amp;amp; TX in your code.&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;UNO — ESP8266&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    RX — 11 &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    TX — 10 &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    GND — GND &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    3.3V — VCC &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    3.3V — CH_PD&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;The configuration of Arduino environment is out of scope of this article. Arduino IDE makes it very easy to load programs on Arduino.&lt;/p&gt;&#xA;&lt;h3 id=&#34;serial-io-and-broadcast&#34;&gt;&#xA;  Serial I/O and Broadcast&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;Serial write with Arduino&lt;/strong&gt;&lt;br&gt;&#xA;Here&amp;rsquo;s listing of code that writes &lt;code&gt;Hello from Arduino&lt;/code&gt; to ESP01&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;SoftwareSerial.h&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define RX 10&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define TX 11&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;SoftwareSerial&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;esp8266&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;RX&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;TX&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;setup&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;esp8266&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;begin&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;115200&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;loop&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;esp8266&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Hello from Arduino&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;delay&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;3000&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;&lt;strong&gt;Serial read from ESP01&lt;/strong&gt;&lt;br&gt;&#xA;ESP SoC has 2 serial I/Os. UART 1 is write only and UART 0 can do perform both read and write. That is why we have to use UART0 for communication with Arduino. But there&amp;rsquo;s a catch with UART0, it is used by micropython REPL for loading programs. The only way to communicate with Arduino over serial is to detach UART0 from REPL. Doing this would disable the functionality to load or edit programs until it is re-attached[2].&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;uos&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;dupterm&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kc&#34;&gt;None&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;            &lt;span class=&#34;c1&#34;&gt;# detach UART from REPL. &lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;uart&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;UART&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;115200&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;          &lt;span class=&#34;c1&#34;&gt;# UART 0 is available for our program&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;uart&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;any&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;message&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;uart&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;readline&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;   &lt;span class=&#34;c1&#34;&gt;# read data from serial input&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;uos&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;dupterm&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;uart&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;            &lt;span class=&#34;c1&#34;&gt;# re-attach UART with REPL before end of program&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;&lt;strong&gt;Broadcast over WiFi&lt;/strong&gt;&lt;br&gt;&#xA;Now that the data is read from serial it&amp;rsquo;s time to broadcast it over WiFi using below function&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;broadcast&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;message&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;bytes&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;cs&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;socket&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;AF_INET&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;SOCK_DGRAM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;cs&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sendto&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;message&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;192.168.0.255&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;7007&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;The socket is a UDP socket as selected by &lt;code&gt;SOCK_DGRAM&lt;/code&gt; parameter. We are choosing to send the message over broadcast address &lt;code&gt;192.168.0.255&lt;/code&gt; so that we can receive it on any device on network. Listening to the message on a Linux system is as easy as running the command&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# listen continuosly for messages on udp socket port 7007&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;nc -kul &lt;span class=&#34;m&#34;&gt;7007&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;I would recommend that you run the serial read and broadcast operation on your ESP01 before you load the actual program to confirm everything is working properly.&lt;/p&gt;&#xA;&lt;h3 id=&#34;measuring-current&#34;&gt;&#xA;  Measuring Current&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;We can measure AC output voltage of CT sensor using ADC on Arduino. The signal first needs to be shifted above 0V in order to meet requirements of ADC. We use a voltage divider circuit as shown below to shift the analog signal by 2.5V so that its lower peak always stays above 0V. Note that our CT sensor has  output of 0-1V.&lt;/p&gt;&#xA;&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/circuit.png&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/circuit.png&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;We will be using &lt;a href=&#34;https://github.com/openenergymonitor/EmonLib&#34;&gt;EmonLib&lt;/a&gt; from &lt;a href=&#34;https://openenergymonitor.org/&#34;&gt;Open Energy Monitor&lt;/a&gt; to sample and measure the RMS current. Here&amp;rsquo;s a code listing to read current from A0 pin with EmonLib.&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;EnergyMonitor&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;emon1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;setup&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;n&#34;&gt;Serial&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;begin&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;9600&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;n&#34;&gt;emon1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;current&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;30&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;//specify pin and calibration&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;loop&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;I&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;emon1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;calcIrms&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1480&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt; &#x9;&#x9;&lt;span class=&#34;c1&#34;&gt;//number of samples to take &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;n&#34;&gt;Serial&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;println&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;cu value=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;I&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&#x9;&lt;span class=&#34;c1&#34;&gt;//write data to esp in a InfluxDB line format&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;n&#34;&gt;delay&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;3000&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;&lt;code&gt;emon1.current(1,30)&lt;/code&gt; is used to choose ADC pin and for calibration. For the sensor I am using, it is 30. You can find out more about calibration calculation &lt;a href=&#34;https://github.com/openenergymonitor/learn/blob/master/view/electricity-monitoring/ctac/emonlib-calibration-theory.md&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h3 id=&#34;data-logging-and-dashboarding&#34;&gt;&#xA;  Data Logging And Dashboarding&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;For logging we are going to use timeseries database InfluxDB. InfluxDB integrates well with Grafana which we will be using for dashboarding. Both InfluxDB and Grafana will be installed on Raspberry Pi. Installation of both application is pretty straightforward. You can refer the guides included in notes below[3].&lt;/p&gt;&#xA;&lt;h4 id=&#34;ingesting-data-with-influxdb-line-protocol&#34;&gt;&#xA;  Ingesting Data With InfluxDB Line Protocol&#xA;&lt;/h4&gt;&#xA;&lt;p&gt;The fastest way of inserting a record in InfluxDB is through it&amp;rsquo;s CLI. Here&amp;rsquo;s an example:&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ influxdb&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;gt; CREATE pmon&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;gt; USE pmon&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;gt; cu value=2.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;gt; cu value=2.5&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;First we create database pmon and then insert values 2.2 and 2.5 as current(cu) in it. You can see inserted records along with timestamps using &lt;code&gt;show measurements&lt;/code&gt; command. InfluxDB supports a lot of interfaces REST, UDP, etc,. Since we have already implemented the broadcast over UDP with ESP01 we will be using UDP interface of InfluxDB but first we need to enable UDP interface before we can start ingesting data over it. You can enable the interface in &lt;code&gt;influxdb.conf&lt;/code&gt;. This file on  exist at &lt;code&gt;/etc/influxdb/influxdb.conf&lt;/code&gt; on raspbian. In the udp section add&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;[[&lt;/span&gt;udp&lt;span class=&#34;o&#34;&gt;]]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nv&#34;&gt;enabled&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;true&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  bind-address &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;0.0.0.0:7007&amp;#34;&lt;/span&gt;&#x9;&#x9;&lt;span class=&#34;c1&#34;&gt;# port address to listen on&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nv&#34;&gt;database&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;pmon&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  retention-policy &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  batch-size &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; 2&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;span class=&#34;c1&#34;&gt;# write to database after collecting this many measurements&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;There are more options in the config file which you can explore as per your requirement.&lt;/p&gt;&#xA;&lt;h4 id=&#34;dashboard-with-grafana&#34;&gt;&#xA;  Dashboard with Grafana&#xA;&lt;/h4&gt;&#xA;&lt;p&gt;Integrating Grafana with InfluxDB is pretty easy. Grafana can be accessed from browser for its configuration. Just point your browser to your Pi IP with 3000 port and that should open Grafana. You will have to go through some basic configuration steps and then from the settings panel you can add InfluxDB as data source. That&amp;rsquo;s it. You can start creating panels for the data that has been recorded.&lt;/p&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s Grafana dashboard for my home setup&lt;/p&gt;&#xA;&lt;p&gt;&lt;figure&gt;&lt;a href=&#34;https://rohanrd.in/static/solar.png&#34; class=&#34;lightbox-image&#34;&gt;&#xA;  &lt;img src=&#34;https://rohanrd.in/static/solar.png&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&#xA;&lt;/a&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&#xA;&lt;/p&gt;&#xA;&lt;h4 id=&#34;creating-grafana-panels&#34;&gt;&#xA;  Creating Grafana Panels&#xA;&lt;/h4&gt;&#xA;&lt;p&gt;InfluxDB queries are fairly easy to understand so I will just put the queries behind each panel that I have used&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Current Panel&lt;br&gt;&#xA;&lt;code&gt;SELECT value FROM &amp;quot;cu&amp;quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Power Panel&lt;br&gt;&#xA;&lt;code&gt;SELECT value*252 FROM &amp;quot;cu&amp;quot;&lt;/code&gt;&lt;br&gt;&#xA;The voltage at my home averages around 252V. Since, P=VxI. Power generated = 252*value.&lt;/li&gt;&#xA;&lt;li&gt;Energy Generated Hourly in Wh panel&lt;br&gt;&#xA;&lt;code&gt;SELECT integral(&amp;quot;power&amp;quot;)/3600 FROM (SELECT value*252 AS power FROM &amp;quot;cu&amp;quot;) WHERE $timeFilter GROUP BY time(1h) fill(null)&lt;/code&gt;&lt;br&gt;&#xA;Energy generated is the area under the power curve. Hence, the integral. We are calculating energy generated on per hour basis.&lt;/li&gt;&#xA;&lt;li&gt;Today&amp;rsquo;s generation panel&lt;br&gt;&#xA;&lt;code&gt;SELECT integral(&amp;quot;value&amp;quot;)*252/3600000 FROM (SELECT value FROM &amp;quot;cu&amp;quot;)  where time &amp;gt; now()-12h&lt;/code&gt;&lt;br&gt;&#xA;Same as energy generated calculation but here we do for last 12 hours.&lt;/li&gt;&#xA;&lt;li&gt;Monthly energy generated panel&lt;br&gt;&#xA;Same as today&amp;rsquo;s generation panel but calculated over period of &lt;code&gt;30d&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Carbon panels&lt;br&gt;&#xA;Carbon generated per kWh is called as carbon factor for the grid. For India, it is 0.7 and thus &lt;code&gt;Energy(E)*0.7&lt;/code&gt; gives us the carbon removed from atmosphere.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3 id=&#34;final-words&#34;&gt;&#xA;  Final Words&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;I am very happy with this setup and it&amp;rsquo;s been very reliable so far even though I have done all of this on a bread board! The current readings are pretty accurate above 1A. There is deviation in power and energy measurements but this is because we are assuming constant voltage while in reality it fluctuates quite a bit. Maybe I will add voltage sensor to this!&lt;/p&gt;&#xA;&lt;h3 id=&#34;repository&#34;&gt;&#xA;  Repository&#xA;&lt;/h3&gt;&#xA;&lt;p&gt;Both micropython and arduino code is uploaded at &lt;a href=&#34;https://github.com/quaintdev/EnergyMonitor&#34;&gt;https://github.com/quaintdev/EnergyMonitor&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There are instances when people have ran ESP01 chip on 5V. This is most probably because of how different manufactures design their chips. The ESP8266 SoC on board ESP01 needs 3.3V.&lt;/li&gt;&#xA;&lt;li&gt;Our program is expected to communicate with Arduino continously and that is why we cannot re-attach the REPL. In the final code listing I have added delay of 10 seconds before detatching REPL. This gives us enough time to load new programs on ESP if required. If we do not do this then we loose the ability to load programs on ESP until we re-flash the firmware.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://grafana.com/tutorials/install-grafana-on-raspberry-pi/&#34;&gt;Install grafana on Raspberry PI&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&#34;https://gist.github.com/boseji/bb71910d43283a1b84ab200bcce43c26&#34;&gt;Install influxdb on Raspberry PI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://learn.openenergymonitor.org/electricity-monitoring/ct-sensors/interface-with-arduino&#34;&gt;CT sensor interfacing with Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;</content:encoded>
                <category>projects</category>
            </item>
            <item>
            <title>Inheritance with Golang</title>
            <link>https://rohanrd.in/posts/inheritance_with_golang/</link>
            <pubDate>Sun, 24 May 2020 12:49:08 +0000</pubDate>
            <guid>https://rohanrd.in/posts/inheritance_with_golang/</guid>
                        <description> Implementing inheritance pattern in Go without using Interfaces </description>
            <content:encoded>&lt;p&gt;After taking dozens of Golang interviews over past 6 months, I have realized lot of candidates have no idea when to use or not use Go interfaces. During interviews, I asked people simple problem: there are 3 entities Student, Teacher and Employee. All these 3 entities will have a name parameter. We need a method which will print name of that entity on console. There must be only one implementation of the method and we should be able to call the method as below&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;var s Student&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    s.PrintName()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    var t Teacher&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    t.PrintName()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;Sounds simple, right? Surprisingly, only 2-3 candidates gave the expected answer, others chose interfaces to solve this. They would define &lt;code&gt;printName()&lt;/code&gt; as interface method and then I would go on to ask them would it not require 3 methods each for one entity? That would confuse them and they would then come up with even bizzare solution to this problem using interfaces.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-solution&#34;&gt;&#xA;  The solution&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;This problem does not require interfaces at all. Consider below code&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;type People struct{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        Name struct&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    func (p *People) PrintName(){&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        fmt.Println(&amp;#34;Name:&amp;#34;, p.Name)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    type Student struct{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        People&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    type Teacher struct{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        People&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;Below code now works perfectly&lt;/p&gt;&#xA;&lt;div class=&#34;codeblock&#34;&gt;&#xA;  &lt;div class=&#34;codeblock-actions&#34;&gt;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--wrap&#34;&#xA;            data-wrap-toggle&#xA;            data-icon-button&#xA;            aria-pressed=&#34;false&#34;&#xA;            title=&#34;Enable soft wrap&#34;&#xA;            data-wrap-title=&#34;Enable soft wrap&#34;&#xA;            data-nowrap-title=&#34;Disable soft wrap&#34;&gt;&#xA;      &lt;svg viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M4 6h16M4 10h12a4 4 0 0 1 0 8h-2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;/&gt;&#xA;        &lt;path d=&#34;M14 18l-2-2m2 2l-2 2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;&#xA;    &lt;button type=&#34;button&#34;&#xA;            class=&#34;codeblock-action codeblock-action--copy&#34;&#xA;            data-copy-code&#xA;            data-icon-button&#xA;            title=&#34;Copy code&#34;&#xA;            data-copied-title=&#34;COPIED&#34;&gt;&#xA;      &lt;svg class=&#34;icon-copy&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;svg class=&#34;icon-check&#34; viewBox=&#34;0 0 24 24&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34;&gt;&#xA;        &lt;path d=&#34;M20 6L9 17l-5-5&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; fill=&#34;none&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;var s Student&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    s.PrintName()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    var t Teacher&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    t.PrintName()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;p&gt;The name parameter is common across all three entities so we define new entity called &lt;code&gt;Person&lt;/code&gt; and embed it inside all three entities. We implement a method call &lt;code&gt;PrintName()&lt;/code&gt; on &lt;code&gt;Person&lt;/code&gt; struct and that method becomes available for all three entities.&lt;/p&gt;&#xA;&lt;p&gt;As you can see, embedding is the fastest way to acheieve inheritance in Golang. That&amp;rsquo;s all for now people.&lt;/p&gt;&#xA;&lt;p&gt;Take care &amp;amp; have a great day!&lt;/p&gt;&#xA;</content:encoded>
                <category>golang</category>
            </item>
  </channel>
</rss>
