#include "mbed.h"
#include "ESP8266Interface.h"
#include "TCPSocketConnection.h"
#include "ifttt.h"
//added from ESP8266_HTTP_HelloWorld
#include "HTTPClient.h"
#include "Websocket.h"
//added dnsresolve to try andd resolve url
//#include "dnsresolve.h"
//Setup for water sensor
AnalogIn ain(A0); //Readd water sensor
DigitalOut dout(LED1); //Set LED to track sensor
int flagVar = 0; //varible to track on off sensor flag
int varOne = 0; // flag to track information sent so far.
ESP8266Interface wifi(D1,D0,D2,"your SSID","your password",115200); // TX,RX,Reset,SSID,Password,Baud
RawSerial pc(USBTX, USBRX); // tx, rx
//***********************************8 added from HTTP program (2 variables below)
HTTPClient http;
char str[512];
Servo myservo(local p15);
int main()
{
pc.baud(9600);
wifi.init(); //Reset
wifi.connect(); //Use DHCP
printf("IP Address is %s \n\r", wifi.getIPAddress());
TCPSocketConnection socket;
//p3BOd9RqoIvPxpKWx7uyD68x8suCOP_s3pPzF5icyki
// Initialize ifttt object, add up to 3 optional values, trigger event.
/* char theUrl = DNSResolver("http://.thingspeak.com");
pc.printf("URL is = c%
HTTP return code %d = data from function ", theUrl,DNSResolver());
*/
//GET Read to see if request was made.
pc.printf("\n Reading feild 1 Thingspeak...\n\r");
int fieldOne = http.get("http://"your thing speak"/fields/2/last?key=your key", str, 512);//IP address is httpbin.org/get
int loopBreak = atoi (str);
pc.printf("Field Speak READ: %s\n\r", str);
for(float p=0; p<1.0; p += 0.1) {
myservo = p;
wait(0.8);
}
Comments