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.
This commit is contained in:
Andre Neto
2026-10-08 14:03:53 +01:00
parent 1526dd5b8e
commit 8a27282d4a
4 changed files with 40 additions and 5 deletions
+7 -5
View File
@@ -2,11 +2,13 @@
#include <Wire.h> // This library is already built in to the Arduino IDE
#include <LiquidCrystal_I2C.h> //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" +
+11
View File
@@ -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";