Pink Walls

The Sensor Who Cried Rain !

Let me tell you a story. A story of sensors, rain, and the long, bumpy road to getting a window to politely tell me: “Hey, close me. It’s about to pour.”

This was the idea: a weather-aware window sensor that could detect if a window was open, check if rain was incoming, and send an alert. It sounded cute and useful, and I thought, “How hard can it be?” (Spoiler Alert: REALLY HARD) Window Sensor Idea

Toolbox

What You Should Know Before We Start

Before diving in, here are a few terms that might sound scary but are actually pretty simple once you get the hang of them:

You don’t need to be an expert in any of these, I wasn’t either! You’ll get it along the way.

Step 1: Meeting The Things Stack

The Things Stack is like a matchmaking service for IoT devices. I made an account, selected the cluster (Germany/Europe), created an application, and registered the Dragino sensor.

The tricky part? The App Key. I clicked “generate” by accident, and it broke everything. The new key didn’t match the sensor’s info. Lesson learned: don’t touch things unless you mean it.

Once fixed, the sensor popped up in the Live Data tab. Magic!

Window Sensor Idea

Step 2: Prettying Things Up with Datacake

Datacake is a really clean interface to show live sensor data. A friend recommended it and I’m so glad they did.

I linked Datacake via a webhook from The Things Stack, popped in the DevEUI, and boom! Data started flowing. Seeing the “open” status appear for the first time? Unironically thrilling.

Window Sensor Idea

Step 3: Calling the Weather Gods (OpenWeather)

After signing up on OpenWeather and grabbing an API key, I set out to combine real-time weather data with my sensor info. Because just knowing the window is open? Not enough. I wanted to know if it was about to rain on my window’s parade (and my floor).

Step 4: Server Time! (aka. The Node.js Era)

I created a local Node.js server to handle POST requests from The Things Stack and fetch weather info from OpenWeather. No frameworks, just plain Node.js.

I used PowerShell to manually test the POST request and watched the data show up in the terminal. Very satisfying.

Step 5: Webhooks… and the Realisation That the Internet Doesn’t See Your Laptop

So here’s the twist: The Things Stack can’t see your localhost. To make your webhook actually work, it needs a public URL. Cue my adventures in online hosting:

What I Learned

Once It All Worked: The Output

When everything came together, this is the JSON output I got:

I double-checked it against the OpenWeather site ; it matched perfectly. Real-time weather + real-time window status = success!

Window Sensor Idea

What’s Next?

Thanks for reading!
See you next time,

-Carina