Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Monitoring Statistik Channel Youtube
- #include <ESP8266WiFi.h>
- #include <ESP8266HTTPClient.h>
- #include <ArduinoJson.h>
- #include <LiquidCrystal_I2C.h>
- //Sesuaikan dengan addres i2c dan ukuran LCD yg digunakan
- LiquidCrystal_I2C lcd(0x27, 20, 4);
- const char* ssid = "xxxxxxx"; //masukkan ssid anda
- const char* password = "xxxxxx"; //masukkan password anda
- void setup () {
- Serial.begin(115200);
- WiFi.begin(ssid, password);
- lcd.begin();
- lcd.backlight();
- while (WiFi.status() != WL_CONNECTED) {
- delay(1000);
- Serial.println("Connecting..");
- }
- if(WiFi.status() == WL_CONNECTED){
- Serial.println("Connected!!!");
- }
- else{
- Serial.println("Connected Failed!!!");
- }
- }
- void loop() {
- if (WiFi.status() == WL_CONNECTED) {
- HTTPClient http;
- http.begin("http://192.168.43.220/rizkyprojects/Web/parsing-youtube.php"); //Silakan ganti dengan ip address dan sesuaikan dengan direktori penyimpanan file php anda
- int httpCode = http.GET();
- if (httpCode > 0) {
- char json[500];
- String payload = http.getString();
- payload.toCharArray(json, 500);
- //StaticJsonDocument<200> doc;
- DynamicJsonDocument doc(JSON_OBJECT_SIZE(4));
- // Deserialize the JSON document
- deserializeJson(doc, json);
- const char* Channel = doc["Channel"];
- int Subscribers = doc["Subscribers"];
- int Videos = doc["Videos"];
- int Views = doc["Views"];
- Serial.print("Channel : ");
- Serial.println(Channel);
- Serial.print("Subscribers : ");
- Serial.println(Subscribers);
- Serial.print("Total Video : ");
- Serial.println(Videos);
- Serial.print("Total View : ");
- Serial.println(Views);
- Serial.println("");
- lcd.setCursor(0,0);
- lcd.print("Channel: ");
- lcd.print(Channel);
- lcd.print(" ");
- lcd.setCursor(0,1);
- lcd.print("Subscribers: ");
- lcd.print(Subscribers);
- lcd.print(" ");
- lcd.setCursor(0,2);
- lcd.print("Videos: ");
- lcd.print(Videos);
- lcd.print(" ");
- lcd.setCursor(0,3);
- lcd.print("Views: ");
- lcd.print(Views);
- lcd.print(" ");
- }
- http.end();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement