Modified WiOn:
I decided to open it up to see what is inside. I noticed that it uses the same module as the Adafruit Industries HUZZAH ESP8266 breakout board, that I happened to have bought last year.
I had to add the wiring, and push button, that would allow me to reprogram this device via USB. I specifically utilized the Arduino IDE.
Pinout:
Now this little plug can be programmed to turn things on and off from computer programs, web pages, you name it. It can also even serve as a really tiny web server.
Here is a little "Hello World" Program to test WiFi, Relay (120v), and LEDs.
Hello World:
It's set up as a captive portal. I also energize the 120v outlet (Idiot Light) whenever someone tries to connect.
Here is some great documentation on programming the ESP8266:
https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-arduino-ide
Hello World Code Sample:
#include <ESP8266WiFi.h> #include <DNSServer.h>
#include <ESP8266WebServer.h>
const byte DNS_PORT = 53;
IPAddress apIP(192, 168, 1, 1);
DNSServer dnsServer;
ESP8266WebServer webServer(80);
String responseHTML = ""
"<!DOCTYPE html><html><head><title>Fool!!</title></head>"
"<body>"
" <h1>Fool!!!!!!!</h1>"
" <p>There is no free WiFi, you fool!!Hahahahaha</p>"
" <p>You did manage to activate the idiot light!</p>"
"</body></html>";
void setup()
{
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("Free iPhone WiFi");
//Make GPIO15 Output (Relay on this GPIO)
pinMode(15, OUTPUT);
dnsServer.start(DNS_PORT, "*", apIP);
// Replay to all requests with same HTML
webServer.onNotFound([]()
{
// Blink GPIO15 (Relay)
digitalWrite(15, HIGH);
delay(500);
digitalWrite(15, LOW);
delay(50);
digitalWrite(15, HIGH);
delay(50);
digitalWrite(15, LOW);
delay(50);
digitalWrite(15, HIGH);
delay(50);
//Send Response to Device.
webServer.send(200, "text/html", responseHTML);
});
webServer.begin();
}
//Wait for requests
void loop()
{
dnsServer.processNextRequest();
webServer.handleClient();
}
|
Amazon Echo!
Another person out on the inter-tubes wrote an Arduino sketch that will make an ESP8266 emulate a WeMo, when Amazon's Echo discovers devices on the network.
https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/
If you take this sketch and change the following line, it will work with a WiOn.
From.: const int relayPin = D1;
To...: const int relayPin = 15;
July 26, 2017 Update:
This device appears to have native support of the Amazon Echo. https://www.amazon.com/dp/B0722YY4GX
No comments:
Post a Comment