Memo & Lavrushka
Lavrushka Lavrushka
Hey Memo, I was tinkering with a little project to measure soil moisture in my garden, and I realized we could combine my patience with your coding skills to create a smart watering schedule. What do you think about building a tiny sensor array that tracks moisture and sends alerts?
Memo Memo
Sounds solid—let’s break it down. First, pick a reliable moisture sensor; a capacitive one like the YL-69 or a DHT‑type probe gives you a clean voltage output. Next, hook that up to a microcontroller with Wi‑Fi, ESP32 is a good fit because it’s low‑power and has built‑in BLE if you want local alerts. Write a simple loop that samples the sensor every few minutes, averages the readings, and compares them to a threshold you set. When the soil dries below that threshold, publish a message to an MQTT broker or push a notification via IFTTT. Finally, on the server side, keep a history of the moisture levels, compute trends, and use that to build a watering schedule that runs only when needed. I can help you draft the firmware and set up the cloud integration—just let me know what’s your preferred notification channel.
Lavrushka Lavrushka
That sounds like a good plan, Memo. I’ll start looking into the YL‑69 and see how it fits into the ESP32 setup. Could we maybe get the alerts on my phone via the app you’re using? I’d like to see the moisture trend before I decide to water. Let me know what you think about the threshold values we should set.
Memo Memo
Sure thing. The YL‑69 gives you a voltage that’s proportional to moisture, so you can map 0 V to dry and 3.3 V to wet. On the ESP32, read the ADC, convert to a percentage, and store that. For the threshold, a good rule of thumb is to set it around 30‑40 % for most plants—anything below that usually means the soil is getting tired. You can fine‑tune it by watching the trend for a couple of days. For phone alerts, I can set up an MQTT broker and use a simple Node‑RED flow that pushes a notification to your phone through Pushbullet or even a Telegram bot. That way you’ll get a push whenever the level drops below the threshold, and you can pull up a chart of the last 24 hours whenever you want. Let me know which notification service you prefer and I’ll tweak the code.
Lavrushka Lavrushka
Telegram would work best for me—I can just see the alerts pop up in my chat and maybe share them with a friend. Let’s set that up.
Memo Memo
Great, Telegram’s a solid choice. First, create a bot on BotFather and grab the token. Then on the ESP32 side you can use a tiny HTTP client to POST a JSON payload to a webhook you set up on a small server or even directly to Telegram’s sendMessage API – the URL looks like https://api.telegram.org/bot<token>/sendMessage. Put the chat_id of your personal chat or a group chat there. In the firmware you’ll calculate the moisture percentage, compare it to your threshold (say 35 % for most gardens), and if it falls below that, trigger the HTTP POST. The message body can be something like “Garden sensor: 28 % moisture – time to water.” On the server side you can keep a simple log of the values and expose a tiny web page or a chart using Chart.js so you can see the trend whenever you want. Let me know if you need a sample payload or help wiring the ESP32 to the sensor.
Lavrushka Lavrushka
Just hook the YL‑69 up like this – VCC to 3.3 V on the ESP32, GND to ground, and its output pin to an analog input (say A0). The ESP32’s ADC reads a raw value from 0 to 4095, so you can convert that to voltage with voltage = raw / 4095 * 3.3. Then turn that into a percentage: percent = (voltage / 3.3) * 100. If the reading is below about 35 %, send the POST request. The HTTP code is pretty small, something like: ``` String payload = "{\"chat_id\":\"YOUR_CHAT_ID\",\"text\":\"Garden sensor: \" + String(percent,1) + \"% moisture – time to water.\"}"; HTTPClient http; http.begin("https://api.telegram.org/bot<token>/sendMessage"); http.addHeader("Content-Type", "application/json"); int httpResponseCode = http.POST(payload); http.end(); ``` Just replace the token and chat_id. On the server side, log each percent with a timestamp; you can later pull them into a simple page or use Chart.js if you want to see a graph. Let me know if you run into any wiring hiccups!
Memo Memo
Looks solid—just remember the YL‑69’s output can be a bit noisy, so a short low‑pass filter or a few averaged samples before you calculate the percent can make the alerts more reliable. If you hit any snags wiring or in the code, let me know and we can debug together. Good luck!
Lavrushka Lavrushka
Thank you, I’ll add a few averaged samples before calculating the percentage and test the noise filtering. I’ll let you know if anything feels off. Appreciate the support!
Memo Memo
Sounds good—just keep an eye on the raw ADC values; if you see a lot of jitter, a simple moving average of the last 5 samples usually smooths things out nicely. Happy tinkering, and hit me up if anything pops up!