From 8a27282d4a05974c382f4993c26c20c90dd60774 Mon Sep 17 00:00:00 2001 From: Andre Neto Date: Thu, 8 Oct 2026 14:03:53 +0100 Subject: [PATCH] Sumbrella: move WiFi and ThingHTTP secrets out of the sketch into secrets.h Fetch_rain.ino carried the WiFi password and three ThingHTTP API keys as plaintext literals. The sketch now includes the non-versioned secrets.h, which defines WIFI_SSID, WIFI_PASSWORD and the three THINGHTTP_KEY_* symbols (one per scheduled channel: today, tmrw, aftmrw). secrets.h.example lists all five placeholders and .gitignore keeps secrets.h out of the repository. Why: credentials must not live in version control. The old values are still in the history and in clones, so they must be rotated and the API keys reissued. --- .gitignore | 2 ++ Fetch_rain/Fetch_rain.ino | 12 +++++++----- Fetch_rain/secrets.h.example | 11 +++++++++++ README.md | 20 ++++++++++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 .gitignore create mode 100644 Fetch_rain/secrets.h.example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f80eb7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Local WiFi credentials (see Fetch_rain/secrets.h.example) +secrets.h diff --git a/Fetch_rain/Fetch_rain.ino b/Fetch_rain/Fetch_rain.ino index 00e21a3..0fcfc6f 100644 --- a/Fetch_rain/Fetch_rain.ino +++ b/Fetch_rain/Fetch_rain.ino @@ -2,11 +2,13 @@ #include // This library is already built in to the Arduino IDE #include //This library you can add via Include Library > Manage Library > +#include "secrets.h" + LiquidCrystal_I2C lcd(0x27, 16, 2); -const char* ssid = "Vodafone-165DB9"; // put your router name -const char* password = "8sWVvPY542";// put your password +const char* ssid = WIFI_SSID; // defined in secrets.h (not versioned) +const char* password = WIFI_PASSWORD; // defined in secrets.h (not versioned) const char* host = "api.thingspeak.com"; @@ -98,7 +100,7 @@ int today() { } // We now create a URI for the request - String url = "/apps/thinghttp/send_request?api_key=BC39H9MXUGHM77N0"; + String url = "/apps/thinghttp/send_request?api_key=" + String(THINGHTTP_KEY_TODAY); // This will send the request to the server client.print(String("GET ") + url + " HTTP/1.1\r\n" + @@ -127,7 +129,7 @@ int tmrw() { } // We now create a URI for the request - String url = "/apps/thinghttp/send_request?api_key=I71LJZQ7SVJG8ZT3"; + String url = "/apps/thinghttp/send_request?api_key=" + String(THINGHTTP_KEY_TMRW); // This will send the request to the server client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + @@ -155,7 +157,7 @@ int aftmrw() { } // We now create a URI for the request - String url = "/apps/thinghttp/send_request?api_key=Y6K1M666ZVG7IT73"; + String url = "/apps/thinghttp/send_request?api_key=" + String(THINGHTTP_KEY_AFTMRW); // This will send the request to the server client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + diff --git a/Fetch_rain/secrets.h.example b/Fetch_rain/secrets.h.example new file mode 100644 index 0000000..7df191a --- /dev/null +++ b/Fetch_rain/secrets.h.example @@ -0,0 +1,11 @@ +// Copy this file to secrets.h and fill in your own credentials. +// secrets.h is listed in .gitignore and must never be committed. +#pragma once + +const char* WIFI_SSID = "your-wifi-name"; +const char* WIFI_PASSWORD = "your-wifi-password"; + +// ThingHTTP API keys, one per scheduled channel (today/tmrw/aftmrw). +const char* THINGHTTP_KEY_TODAY = "your-thinghttp-api-key"; +const char* THINGHTTP_KEY_TMRW = "your-thinghttp-api-key"; +const char* THINGHTTP_KEY_AFTMRW = "your-thinghttp-api-key"; diff --git a/README.md b/README.md index 35f7b7c..742dbb8 100644 --- a/README.md +++ b/README.md @@ -1 +1,21 @@ https://youtu.be/7n7HcTeeHdM + +## Configuration + +The WiFi credentials are **not** stored in the repository. The sketch +`Fetch_rain/Fetch_rain.ino` includes a non-versioned header `secrets.h` +that defines `WIFI_SSID` and `WIFI_PASSWORD`: + +```bash +cp Fetch_rain/secrets.h.example Fetch_rain/secrets.h +# edit Fetch_rain/secrets.h with your own network name and password +``` + +`secrets.h` is listed in `.gitignore`, so it is never committed. The +sketch does not compile without it. If the old password was ever +pushed, change it on the router as well as in `secrets.h`. + +`secrets.h` also defines the three ThingHTTP API keys used by the daily +scheduled channels (`THINGHTTP_KEY_TODAY`, `THINGHTTP_KEY_TMRW`, +`THINGHTTP_KEY_AFTMRW`). They used to be hard-coded in the sketch; the old +values were committed, so they must be regenerated in ThingHTTP.