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 IFTTT mbed
Fork of SimpleIoTBoard_sample by
main.cpp
00001 #include "mbed.h" 00002 #include "ESP8266Interface.h" 00003 #include "TCPSocketConnection.h" 00004 #include "ifttt.h" 00005 #include "SoftSerialSendOnry.h" 00006 00007 AnalogIn thermistor(dp13); /* Temperature sensor connected to Analog Grove connector */ 00008 00009 ESP8266Interface wifi(dp16,dp15,dp4,"SSID","Password",115200); // TX,RX,Reset,SSID,Password,Baud 00010 00011 SoftSerialSendOnry pc(dp10); // tx 00012 00013 float getTemperature() 00014 { 00015 unsigned int a, beta = 3975; 00016 float temperature, resistance; 00017 00018 a = thermistor.read_u16(); /* Read analog value */ 00019 00020 /* Calculate the resistance of the thermistor from analog votage read. */ 00021 resistance= (float) 10000.0 * ((65536.0 / a) - 1.0); 00022 00023 /* Convert the resistance to temperature using Steinhart's Hart equation */ 00024 temperature=(1/((log(resistance/10000.0)/beta) + (1.0/298.15)))-273.15; 00025 00026 return(temperature); 00027 } 00028 00029 int main() 00030 { 00031 pc.baud(9600); 00032 wifi.init(); //Reset 00033 wifi.connect(); //Use DHCP 00034 pc.printf("IP Address is %s \n\r", wifi.getIPAddress()); 00035 TCPSocketConnection socket; 00036 00037 // Initialize ifttt object, add up to 3 optional values, trigger event. 00038 IFTTT ifttt("EventName","Secret Key", &socket); // EventName, Secret Key, socket to use 00039 00040 char tmp[64]; 00041 00042 sprintf(tmp,"%f",getTemperature()); 00043 00044 ifttt.addIngredients(tmp,"value2","value3"); 00045 ifttt.trigger(IFTTT_POST); 00046 }
Generated on Fri Jul 15 2022 01:56:56 by
1.7.2
