New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Lakshmi Iyer

iyerdev

@iyer-l · Joined September 2026

Newcomer

Backend developer · logistics · 21 years in the field

Topics
1
Replies
6
Points
0
Newcomer10 points to Member

Forum Replies Created

Viewing 6 posts – 1 through 6 (of 6 total)

Both at once is fine. The Uno has a comparator that switches the 5 V rail to the regulator when VIN is above roughly 6.6 V, and USB data keeps working because the serial lines don’t care where power comes from. Your laptop is not at risk from that.

The trouble is the solenoid. A solenoid coil with no flyback diode throws a big voltage spike every time the relay opens, and that spike goes through your shared breadboard ground. That’s the jump in the analog reading and very likely the USB dropping out. What I’d change:

  • A 1N4007 across the solenoid, cathode to +12 V.
  • Take the relay coil power from the 12 V side or a separate 5 V supply, not the Uno’s 5V pin. The onboard regulator gets hot feeding a relay off 12 V in.
  • Run the valve’s ground back to the adapter, and join it to the Uno ground at one point only, not through the breadboard rails the sensor uses.
  • 100 nF plus 10 µF across the sensor supply, close to the sensor.
  • In the sketch, don’t sample for a second after switching the valve, and average 8 readings.

On the laptop side, send only clean readings and let Hermetry stamp the time unless your laptop clock is synced:

import serial, requests
s = serial.Serial("/dev/ttyACM0", 9600, timeout=5)
URL = "https://<your-host>/api/v1/telemetry"
HDR = {"Authorization": "Bearer <device token>", "Content-Type": "application/json"}
while True:
line = s.readline().decode(errors="ignore").strip()
if line.isdigit():
requests.post(URL, json={"soil_moisture": int(line)}, headers=HDR, timeout=10)

Payload rules are on Device HTTP API.

Accepted solution♥ 6
Viewing 6 posts – 1 through 6 (of 6 total)