← Back to list

Project LOKi — Part 3: The Sync

The ESP32 was officially aliveWe finally got our hands dirty — literally and figuratively. After weeks of planning and parts arriving, the…

Michael de Guzman · 2025-06-09 20:45 · 6 claps · 4.4 min read
#iot #raspberry-pi #esp32 #smart-garden #supabase
Open on Medium ↗
Wiki topics: 📟 · Gadgets & IoT

Project LOKi — Part 3: The Sync

The moisture is strong with this one.

The moisture is strong with this one.

We finally got our hands dirty — literally and figuratively. After weeks of planning and parts arriving, the wiring began. Not everything went smoothly (spoiler: power issues), but LOKi is now doing actual work. It’s reading sensors, storing data, and syncing with the cloud.

Not quite a win yet — but definitely a satisfying achievement.

Missed the earlier parts? 🌱 Part 1: The Plan — where the vision for LOKi was born. 🔌 Part 2: The Setup — where the parts arrived, the backend got started, and realised how many cables one plant can need.

Powering the ESP32 (a tiny detour)

Before anything else, I had to get the ESP32-WROOM-S3 running. I plugged it into my Mac using a USB-C cable — it lit up, so I assumed it was good to go. But something was off. It wasn’t behaving right.

That’s when I remembered something Ivan told me when he first introduced me to ESP32: “It’s usually more stable with a USB-A connection.” That stuck with me. I didn’t have a USB-A port on my Mac, but luckily, my wife had a USB-C to USB-A adapter. I hooked it up using a USB-A to USB-C cable — and boom, everything worked properly.

Turns out USB-A was the secret. Thanks, Ivan. Thanks, wife. Thanks, random drawer.

Turns out USB-A was the secret. Thanks, Ivan. Thanks, wife. Thanks, random drawer.

The ESP32 was officially alive.

Wiring with a breadboard for the first time

I watched a couple of quick YouTube videos to get my head around how to use the breadboard with the ESP32. Once I had the basics, I went ahead and wired the moisture sensor. No issues. Then the DHT22 for temperature and humidity — again, no major hiccups.

It was my first time wiring something like this, and I half expected a headache. But it came together surprisingly smoothly.

Relay hiccup (a familiar pain)

When we tried wiring the relay, we expected it to click when moisture dropped below a certain level. But… silence.

So I bypassed the sensor logic and tried triggering the relay directly by sending a signal from the ESP32. Still no click.

That’s when it hit me — the ESP32’s 5V pin doesn’t provide enough current to drive the relay module. Logic was sound. Wiring was fine. It just wasn’t getting the juice it needed.

We’ve paused that part for now while waiting for an external 5V power supply and proper wiring connectors to arrive.

So close. But the relay stayed silent. Turns out enthusiasm isn’t the same as amperage.

So close. But the relay stayed silent. Turns out enthusiasm isn’t the same as amperage.

Making the data flow — from plant to cloud

With the relay on hold, we pivoted. We wanted to make sure sensor data could get from the plant to the Pi to Supabase. And that part is now solid.

  • I set up the Raspberry Pi, installed Python, Flask, and SQLite.
  • Created a simple REST API to accept POST requests from the ESP32.
  • Moisture, temperature, and humidity readings are now being sent and stored locally on the Pi.

To make this more robust, the Pi also runs a scheduled job every hour to sync unsynced records to Supabase. That way, even if the internet drops or Supabase has a blip, nothing gets lost.

This is what relief looks like when you’ve been staring at wires all day.

This is what relief looks like when you’ve been staring at wires all day.

Remote Configuration: Talking to LOKi without opening the gates

This was important.

I wanted a way to remotely update how LOKi behaves — how often it reads sensors, how often it syncs, and eventually even commands like “water the plant now.”

But I had two constraints:

  1. I didn’t want to expose the Pi to the internet (no port forwarding, no open endpoints).
  2. ESP32 doesn’t have the horsepower or flexibility to host an endpoint securely.

So here’s the solution we landed on:

  • All config values (like reading intervals) live in Supabase.
  • The Pi polls Supabase on a timer — say every 15 minutes — to check for changes. If any values (like how often it should send data) have changed, it updates its local store.
  • The ESP32, on the other hand, only reads config once — during bootup — by calling a local endpoint on the Pi. That tells it how often it should read moisture, temperature, and humidity values.

This approach keeps the ESP32 lean — no unnecessary polling, preserving power. And it allows us to change behavior dynamically without opening our home network to the world.

Eventually, this same flow could let us send “on-demand” commands from a mobile app — like forcing a watering cycle or requesting a health check.

Meet the LOKi brain. Thanks, Jonathan.

Meet the LOKi brain. Thanks, Jonathan.

What happened to the ODC Back-End?

Before we started the wiring last Saturday, I checked my OutSystems Developer Cloud (ODC) Personal Environment — and it had already expired. No backups. My bad.

OutSystems does send expiry notices, but I ignored them thinking I’d get to it “later.” There’s no auto-backup for personal environments, and when it’s gone, it’s gone.

Thankfully, all our Supabase schema was safe, so I just continued development from there. I’ll rebuild the ODC app later.

Long weekends are for LOKi

Thanks to the long weekend in Melbourne, I had more time than usual to work on the project — and honestly, it made me genuinely happy.

There’s a quiet kind of joy when something finally works — not a milestone, just that subtle “oh nice, that actually did it” moment. The kind where you make it work with whatever parts you had, no fuss, just figuring it out.

Basil’s wired. LOKi’s listening. Ignore the garbage bags — the plant is the real star here.

Basil’s wired. LOKi’s listening. Ignore the garbage bags — the plant is the real star here.

LOKi is far from done. But it’s alive. And that’s more than enough motivation to keep building.

Catch you later, Jedi Gardeners 🌿💻🍅


메타데이터
post_id
024d5ae910db
slug
project-loki-part-3-the-signal-024d5ae910db
url
https://medium.com/@michael.de.guzman/project-loki-part-3-the-signal-024d5ae910db
canonical_url
https://medium.com/@michael.de.guzman/project-loki-part-3-the-signal-024d5ae910db
author_url
https://medium.com/@michael.de.guzman
status
ok
fetched_at
2026-06-09 15:37:30