Posting Status ke Facebook Page Dengan NodeMCU

Posting Status ke Facebook Page Dengan NodeMCU
930 x 180 AD PLACEMENT

Halo teman – teman semua pada tutorial kali ini DT Production akan memberikan tutorial cara memposting status ke halaman facebook dengan menggunakan Nodemcu.

Teman – teman dapat mengembangkan example atau tutorial ini misalnya di tambahkan sensor PIR atau proyek monitoring temperatur dll. Disini kita akan menggunakan WiFi kontroler yaitu Nodemcu dan Base board dari Nodemcu sendiri. jika teman – teman belum mempunyai keduanya, teman – teman bisa membeli di toko DT Production. Silahkan klik link berikut untuk pembelian via Tokopedia.

930 x 180 AD PLACEMENT

LAMPIRAN

/*
 * sketch from https://dt-production.com
 * Online store : https://www.tokopedia.com/dtproduction
 * 
 * Terimakasih telah mengunjungi atau menonton video di channel DT Production
 * semoga bisa bermanfaat untuk teman - teman semuanya.
 * 
*/
#include 

String MakerIFTTT_Key ;
; String MakerIFTTT_Event;
char *append_str(char *here, String s) {
  int i = 0;
  while (*here++ = s[i]) {
    i++;
  };
  return here - 1;
}
char *append_ul(char *here, unsigned long u) {
  char buf[20];
  return append_str(here, ultoa(u, buf, 10));
}
char post_rqst[256]; char *p; char *content_length_here; char *json_start; int compi;
const char* ssid = "XXXXXXXXXXXX";
const char* password = "XXXXXXXXXXXX";
const char* host = "maker.ifttt.com";
boolean kirim = true;
int index_status = 1;
WiFiClient client;

void setup()
{
  Serial.begin(115200);
  delay(100);
  Serial.println("DT Production");
  Serial.println("Start Koneksi");
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}


void loop()
{
  
  connecting();

  if (kirim) {
    Serial.println("Kirim Status..");
    MakerIFTTT_Key = "XXXXXXXX";
    MakerIFTTT_Event = "XXXXXXX";
    p = post_rqst;
    p = append_str(p, "POST /trigger/");
    p = append_str(p, MakerIFTTT_Event);
    p = append_str(p, "/with/key/");
    p = append_str(p, MakerIFTTT_Key);
    p = append_str(p, " HTTP/1.1\r\n");
    p = append_str(p, "Host: maker.ifttt.com\r\n");
    p = append_str(p, "Content-Type: application/json\r\n");
    p = append_str(p, "Content-Length: ");
    content_length_here = p;
    p = append_str(p, "NN\r\n");
    p = append_str(p, "\r\n");
    json_start = p;
    p = append_str(p, "{\"value1\":\"");
    p = append_str(p, "Hello");
    p = append_str(p, "\",\"value2\":\"");
    p = append_str(p, "DT Production");
    p = append_str(p, "\",\"value3\":\"");
    p = append_str(p, "Ini status ke "+String(index_status));
    p = append_str(p, "\"}");

    compi = strlen(json_start);
    content_length_here[0] = '0' + (compi / 10);
    content_length_here[1] = '0' + (compi % 10);
    client.print(post_rqst);
    Serial.println("Terkirim ke IFTTT");
    index_status+=1;
    delay(10000);
  }else{
    Serial.println("Koneksi putus dengan IFTT !");
  }
}

void connecting(){
  const int httpPort = 80;
  if (!client.connect(host, httpPort))
  {
    Serial.println("Gagal koneksi ke IFTTT");
    kirim=false;
    return;
  }
  kirim = true;
}

930 x 180 AD PLACEMENT

930 x 180 AD PLACEMENT

Programmer & Videographer.

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

You might also like
930 x 180 AD PLACEMENT