Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ESP8266Interface mbed
Fork of ESP8266_Test by
Revision 12:33e4fa29ade9, committed 2015-07-24
- Comitter:
- ytsuboi
- Date:
- Fri Jul 24 04:05:52 2015 +0000
- Parent:
- 11:8acce2b8af6e
- Commit message:
- initial commit for publish
Changed in this revision
--- a/ESP8266Interface.lib Fri May 01 18:29:45 2015 +0000 +++ b/ESP8266Interface.lib Fri Jul 24 04:05:52 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ESP8266/code/ESP8266Interface/#22d30e936e4c +http://developer.mbed.org/teams/ESP8266/code/ESP8266Interface/#03fd9333670d
--- a/main.cpp Fri May 01 18:29:45 2015 +0000
+++ b/main.cpp Fri Jul 24 04:05:52 2015 +0000
@@ -1,14 +1,28 @@
#include "mbed.h"
#include "ESP8266Interface.h"
#include "TCPSocketConnection.h"
-
-const char* ECHO_SERVER_ADDRESS = "192.168.2.4";
-const int ECHO_SERVER_PORT = 8080;
-ESP8266Interface wifi(D1,D0,D10,"demossid","password",115200); // TX,RX,Reset,SSID,Password
+
+// You need to change these 4 lines.
+#define SSID "YOUR SSID"
+#define WIFIKEY "YOUR WIFI KEY"
+const char EVENT[] = "YOUR IFTTT EVENT NAME";
+const char KEY[] = "PUT YOUT IFTTT SECRET KEY HERE";
+//
+
+const char* ECHO_SERVER_ADDRESS = "54.243.120.63"; // maker.ifttt.com
+const int ECHO_SERVER_PORT = 80;
+
+ESP8266Interface wifi(p28,p27,p29,SSID,WIFIKEY,115200); // TX,RX,Reset,SSID,Password
RawSerial pc(USBTX, USBRX); // tx, rx
+AnalogIn pot1 (p19);
+AnalogIn pot2 (p20);
int main() {
pc.baud(115200);
+
+ int http_cmd_sz=800;
+ char http_cmd[http_cmd_sz];
+
wifi.init(); //Use DHCP
wifi.connect();
pc.printf("IP Address is %s\n", wifi.getIPAddress());
@@ -19,13 +33,20 @@
wait(1);
}
- char hello[] = "Hello World\n";
- socket.send_all(hello, sizeof(hello) - 1);
+ char Val1[6];
+ char Val2[6];
+ char Val3[6];
+ snprintf(Val1,5,"%.2f", (float)pot1);
+ snprintf(Val2,5,"%.2f", (float)pot2);
- char buf[256];
- int n = socket.receive(buf, 256);
+ snprintf(http_cmd, http_cmd_sz, "GET /trigger/%s/with/key/%s/?value1=%s&value2=%s&value3=%s HTTP/1.1\r\nHost: maker.ifttt.com\r\nConnection: close\r\n\r\n", EVENT, KEY, Val1, Val2, Val3);
+ pc.printf(http_cmd);
+ socket.send_all(http_cmd, sizeof(http_cmd) - 1);
+
+ char buf[512];
+ int n = socket.receive(buf, 512);
buf[n] = '\0';
- pc.printf("%s", buf);
+ pc.printf("%s\r\n", buf);
socket.close();
wifi.disconnect();
--- a/mbed.bld Fri May 01 18:29:45 2015 +0000 +++ b/mbed.bld Fri Jul 24 04:05:52 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/da0ca467f8b5 \ No newline at end of file
