Cheap wireless/battery LED indicator

Hey I’m hoping to work around the bad plumbing in my house, where if someone’s in the shower and someone else uses the kitchen sink bad times are had. I have a xiaomi gateway with a spare motion sensor, so was thinking that could be aimed in the shower to detect occupancy (may have to explain to guests that it is a sensor not a camera haha), maybe even work from humidity sensor.

The problem is how to indicate this occupancy in the kitchen. I thought of getting the kitchen chromecast to repeatedly warn not to turn the kitchen tap on, but aside from being amusing once and relying on the kitchen amp being on and correct input set, would be quite obnoxious.

What would be ideal would be a xiaomi gateway led indicator light or something (which I think doesn’t exist), using a full mains powered LED lightbulb or strip seems like overkill (one could argue the concept of this ‘solution’ is). Is there such a device?

I’m running on a Pi3 with zwave, wifi, xiaomi hub and bluetooth, as potential triggers. Would probably like to avoid some DIY esp8266 project which I’d never get around to…

1 Like

Your best option for battery power would probably be zwave. but that’ll probably take more time than you want to spend. I know you said you wanted to ovoid esp8266 but Its probably your cheapest option. because its wifi it wont last long on battery so it would have to b plugged in. But you said you didnt want esp8266 because you would probably never get around to it. The following sketch is built for cloudMQTT and turns pin D1 on a nodemcu board on and off, but could easily modified for a normal esp8266 board.

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char* ssid = “YOUR SSID”;
const char* password = “YOUR PASSWORD”;
const char* mqttServer = “YOUR MQTT ADDRESS”;
const int mqttPort = 18339;
const char* mqttUser = “esp8266”;
const char* mqttPassword = “esp8266”;

WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
pinMode(D1, OUTPUT); // Initialize the BUILTIN_LED pin as an output
pinMode(BUILTIN_LED, OUTPUT);

Serial.begin(115200);

digitalWrite(BUILTIN_LED, LOW); // Turn the LED on (Note that LOW is the voltage level

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println(“Connecting to WiFi…”);
}
Serial.println(“Connected to the WiFi network”);

client.setServer(mqttServer, mqttPort);
client.setCallback(callback);

while (!client.connected()) {
Serial.println(“Connecting to MQTT…”);

if (client.connect("ESP8266Client", mqttUser, mqttPassword )) {

  Serial.println("connected");  

} else {

  Serial.print("failed with state ");
  Serial.print(client.state());
  delay(2000);

}

}

client.publish(“esp/desklight”, “Desklight is Online”);
client.subscribe(“esp/desklight”);

}

void callback(char* topic, byte* payload, unsigned int length) {

Serial.print("Message arrived in topic: ");
Serial.println(topic);

Serial.print(“Message:”);
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}

Serial.println();
Serial.println("-----------------------");

if ((char)payload[0] == ‘1’) {
digitalWrite(D1, LOW); // Turn the LED off (Note that LOW is the voltage level
} else if ((char)payload[0] == ‘2’) {
digitalWrite(D1, HIGH); // Turn the LED on by making the voltage HIGH
}
}

void reconnect() {
// Loop until we’re reconnected
while (!client.connected()) {
Serial.print(“Attempting MQTT connection…”);
// Attempt to connect
if (client.connect(“ESP8266Client”, mqttUser, mqttPassword )) {
Serial.println(“connected”);
// Once connected, publish an announcement…
client.publish(“esp/desklight”, “Connected”);
// … and resubscribe
client.subscribe(“esp/desklight”);
} else {
Serial.print(“failed, rc=”);
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}

void loop() {

if (!client.connected()) {
reconnect();

}
client.loop();
}

I hope this helps, I use it for diy relay control but just attaching a LED to it should work just fine. Its probably the easiest and fastest way to do this

Thanks very much for the reply.

I suppose I’ve gone this far in my home automation game that I should probably dabble in esp8266/more electrical hardware stuff. And thanks for the code example!

I’ve ordered a wifi led rgb strip… I figure for 20 quid it’ll do the job and provide some much needed ambient lighting when it’s not solving the problem directly, I do feel like I should get a bit more hacky though.

Yea, If you have any issues with the code let me know

This is my EXACT use case! I found this thread by Googling for “battery powered MQTT led” or some such…but the use case of shower occupancy and poor plumbing is EXACTLY what I’m trying to alert “sink users” to! How funny. What did you end up doing?