From dba151ed1547dd0a8a0137c1b55da91dd12b3eea Mon Sep 17 00:00:00 2001 From: SidharthBSunil <91207543+SidharthBSunil@users.noreply.github.com> Date: Sat, 1 Nov 2025 08:05:27 +0530 Subject: [PATCH] Add weather API integration with Meshtastic --- examples/weather_api_integration.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/weather_api_integration.py diff --git a/examples/weather_api_integration.py b/examples/weather_api_integration.py new file mode 100644 index 000000000..9bf490b24 --- /dev/null +++ b/examples/weather_api_integration.py @@ -0,0 +1,22 @@ +import requests +import meshtastic +import meshtastic.serial_interface + +# ---- Get weather data ---- +lat, lon = 9.9312, 76.2673 +url = f"https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}¤t_weather=true&hourly=relative_humidity_2m" + +response = requests.get(url) +data = response.json() + +temp = data["current_weather"]["temperature"] +humidity = data["hourly"]["relative_humidity_2m"][0] + +message = f" Weather: {temp}°C, {humidity}% humidity" + +# ---- Send over Meshtastic ---- +iface = meshtastic.serial_interface.SerialInterface() +iface.sendText(message) + +print("Sent:", message) +iface.close()