Multithreading on a $5 Chip: How Edge Devices Connect to the Cloud

Saurab Thakur Saurab Thakur
5 min read

Having a glowing, lightning-fast dashboard on your local network is incredibly satisfying. When you are sitting at your desk, you are the master of your homelab.

But what happens when you are miles away at the office, the sky turns black, and a massive thunderstorm rolls in? You pull out your phone, but you are not on your home Wi-Fi anymore. You can’t reach your local dashboard. You are completely blind to what is happening to your expensive server rack.

To solve this, the UPS Supervisor V2.0 doesn’t just stay local. It reaches out into the cloud, synchronizing its heartbeat globally so you can monitor your power from a coffee shop halfway around the world.

Here is how a tiny $5 microchip manages to juggle local power routing while securely chatting with the biggest cloud providers on earth.


The Danger of Opening Your Network

The easiest (and worst) way to access your home servers remotely is a technique called “Port Forwarding.” You punch a hole in your router’s firewall so that anyone on the internet can try to connect to your UPS.

Please, never do this. It is the digital equivalent of leaving your front door wide open and putting a neon sign outside. Hackers constantly scan the internet for open ports, and they will find your dashboard within hours.

Instead, the UPS Supervisor uses a highly secure intermediary broker: Google Firebase.

The microchip never accepts incoming connections from the open internet. Instead, it securely reaches out to Google’s servers. Every five seconds, the UPS packages up its current status—the battery voltage, the grid status, the temperature—and securely hands it to Firebase.

You can then open a custom Android App on your phone. Your phone talks to Google, and Google hands you the data. Your home network remains perfectly sealed, completely invisible to attackers, yet you get real-time telemetry on your screen.


The Multitasking Miracle

Talking to Google’s secure servers is hard work. When you type https://google.com into your computer, your powerful CPU effortlessly crunches the heavy cryptographic math required to establish a secure SSL/TLS connection.

When a tiny microchip tries to do this, it is like asking a toddler to lift a boulder. It takes the chip a few seconds of intense concentration to establish the secure connection.

If the microchip stops to concentrate on Google, it ignores everything else. If you try to click a button on your local dashboard at that exact moment, the chip ignores you. If a power outage happens, the chip might miss it.

To solve this, the UPS Supervisor uses an incredible piece of software engineering called FreeRTOS (Real-Time Operating System) to enable true multitasking.

The main “Brain” chip actually has two separate physical cores. We use FreeRTOS to assign the heavy, distracting cloud tasks entirely to a background thread. This thread handles the messy math of connecting to Firebase and pushing the data up to the cloud. Meanwhile, the main thread stays laser-focused on the local web dashboard and the physical power relays.

By keeping these tasks strictly separated, the local dashboard remains lightning-fast, the power routing remains perfectly reliable, and your phone gets its global updates without anyone stepping on each other’s toes.


Bridging Smart Plugs with Sinric Pro

What if you want to control your UPS using your voice? Or what if you have a third-party smart plug (like a Tapo P110) plugged into the wall, and you want the UPS to be able to turn it on or off automatically?

Reverse-engineering the proprietary code of every brand of smart plug is a nightmare. Instead, the UPS Supervisor uses a service called Sinric Pro.

Sinric Pro acts as a universal translator for smart home devices. The UPS Supervisor connects to Sinric Pro using another one of those secure, background multitasking threads. When the UPS decides it needs to cut power to the wall plug to recalibrate the battery, it simply asks Sinric Pro to do it. Sinric Pro talks to the smart plug’s cloud, which then commands the physical plug in your wall.

Suddenly, your custom DIY battery backup is fully integrated into the global smart home ecosystem. You can tell Alexa to “Turn on the server rack,” and the message flows from Amazon, through Sinric, directly into your microchip, and finally down to the physical relays.


Conclusion

By carefully leveraging the power of multitasking operating systems on cheap microchips, we can securely link physical hardware to massive cloud databases. You get the peace of mind of a tightly sealed local network, combined with the power of global, real-time remote control.


Next Steps: Monitoring your hardware is cool, but what if you are asleep? Up next, discover how the UPS Supervisor actively “thinks” and performs automated safety routines when disaster strikes in the middle of the night.


From this Series

More from the Blog

Share this article

You might also like

Table of contents