230Vac Fluorescent battery-backed lantern |
It would be nice to have a bit of extra light sometimes during normal conditions, so why not mount it on the ESP8266 IoT Extension? And it would even be nicer if I could control it by voice command.
I do not have Google Home or Amazon Echo yet, but my Android smartphone does have Google Assistant which will capture my voice commands. I just need to forward the command words to the ESP8266 IoT device.
Robosapien has a great writeup on using the ESP8266 with Google Assistant, IFTTT and Adafruit IO. I really wish I could improve on it, but I believe Robosapien has had the last word on the subject. I simply followed all the steps and replaced his hardware with my ESP8266 IoT AC Mains Power Extension.
The process just took half a day, and I now have a voice controlled 20-year old lantern!
Update (2018-11-27): after running the IoT lantern a few days, I noticed a new WiFi access point with an extremely strong signal:
iwlist wlan0 scan
Cell 04 - Address: xx:xx:xx:xx:xx:xx
Channel:10
Frequency:2.457 GHz (Channel 10)
Quality=70/70 Signal level=-34 dBm
Encryption key:off
ESSID:"ESP_1CC60D"
Bit Rates:5.5 Mb/s; 11 Mb/s; 1 Mb/s; 2 Mb/s; 6 Mb/s
12 Mb/s; 24 Mb/s; 48 Mb/s
Bit Rates:54 Mb/s; 9 Mb/s; 18 Mb/s; 36 Mb/s
Mode:Master
Extra:tsf=0000000008b54204
Extra: Last beacon: 4442ms ago
IE: Unknown: 000A4553505F314343363044
IE: Unknown: 01088B9682840C183060
IE: Unknown: 03010A
IE: Unknown: 0706534720010D14
IE: Unknown: 32046C122448
IE: Unknown: DD0918FE34030100000000
It turned out to come from the lantern code, and while it does not interfere with its operation, it is also a security risk as it is an open Access Point. As usual the Internet provided an answer; there is a bug in the ESP8266 Arduino library. There is a workaround: you just need to insert
WiFi.mode(WIFI_STA)
after calling WiFi.begin().
My setup code now looks like:
void setup() {
Serial.begin(115200);
pinMode(0, OUTPUT); // 2018-10-26 set gpio to o/p
// Connect to WiFi access point.
Serial.println(); Serial.println();
Serial.print("Connecting to ");
Serial.println(WLAN_SSID);
WiFi.begin(WLAN_SSID, WLAN_PASS);
WiFi.mode(WIFI_STA); // 2018-11-27 remove rogue AP
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Setup MQTT subscription for onoff feed.
mqtt.subscribe(&lantern);
}
Lantern with IoT Power Extension |
Note reversed (data zero) logic |
Youtube video |