티스토리 뷰

SWDesk/Firmware

IFTTT with Arduino

bizmaker 2020. 5. 10. 19:06

Sample Source Code

 

void b_Send2IFTTT(String EventValue){

  Serial.print("Connecting to ");
  Serial.println(IFTTTAddress);
  
  WiFiClient client;
  const int httpPort = 80;
  if(!client.connect(IFTTTAddress, httpPort)){
    Serial.println("Connection to IFTTT Failed");
    return;
  }

  //String urlString = String(IFTTTAddress) + "/trigger/";
  String urlString = "/trigger/";
  urlString += EventValue;
  urlString += "/with/key/";
  urlString += IFTTTKey;
  String mJson = String("{\"value1\":\"") + "Bilient\"}";

  Serial.print("[URL]");
  Serial.println(urlString);

  client.println(String("POST ") + urlString + " HTTP/1.1");
  client.println(String("Host: ") + String(IFTTTAddress));
  client.println("Content-Type: application/json");
  client.print("Content-Length: ");
  client.println(mJson.length());
  client.println();
  client.println(mJson);
  while(client.connected()){
    if(client.available()){
      String line = client.readStringUntil('\r');
      Serial.print(line);
    }else{
      delay(50);
    }
  }

  Serial.println();
  Serial.println("cloing connection");
  client.stop();
}

 

Reference : https://maker.ifttt.com 

 

IFTTT

Connect your Webhooks to woopla phone calls, Garadget and more. Integrate other services on IFTTT with your DIY projects. You can create Applets that work with any device or app that can make or receive a web request. If you'd like to build your own servic

ifttt.com

 

반응형

'SWDesk > Firmware' 카테고리의 다른 글

[BMS] Command Process for Master  (0) 2020.07.19
[BPM] Firmware Source for Master  (0) 2020.06.15
[BMS] Firmware for Measurement Device  (0) 2020.04.29
[BMS] Firmware for WiFi Device  (0) 2020.04.28
[BMS] Firmware for Wireless Device  (0) 2020.04.27