fork(2) download
  1. #include "EmonLib.h"
  2. EnergyMonitor emon1;
  3.  
  4. char ssid[] = "ISI DENGAN SSID WIFI";
  5. char pass[] = "ISI PASSWORD WIFI";
  6. int status = WL_IDLE_STATUS;
  7.  
  8. WiFiClient client;
  9. char server[] = "agnosthings.com";
  10.  
  11. void setup()
  12. {
  13. Serial.begin(9600);
  14.  
  15. emon1.current(5, 60); // Current: input pin, calibration.
  16. emon1.voltage(2, 234.26, 1.7); // Voltage: input pin, calibration, phase_shift
  17.  
  18. while ( status != WL_CONNECTED) {
  19. Serial.print("Attempting to connect to WPA SSID: ");
  20. Serial.println(ssid);
  21. // Connect to WPA/WPA2 network:
  22. status = WiFi.begin(ssid, pass);
  23. }
  24. delay(5000);
  25. }
  26.  
  27. void loop()
  28. {
  29.  
  30. emon1.calcVI(20,2000);
  31.  
  32. unsigned int long timemillis=millis(); //keeping the track of the time since the device is switched ON
  33. unsigned int long time=timemillis/1000;
  34.  
  35. float realPower = emon1.realPower;
  36. float apparentPower= emon1.apparentPower;
  37. float powerFactor= emon1.powerFactor;
  38. float supplyVoltag = emon1.Vrms;
  39. float Irms = emon1.Irms;
  40.  
  41.  
  42.  
  43. //displaying the values
  44. Serial.println("Watt : ");
  45. Serial.println(realPower);
  46.  
  47. String kwh = "";
  48. kwh+=String(int(realPower))+ "."+String(getDecimal(realPower));
  49.  
  50. String url_api = "ganti dengan url api dari agnosthings.com ?push=kwh={tmpval}";
  51. url_api.replace("{tmpval}", kwh);
  52.  
  53. boolean requestStatus = httpRequest(url_api);
  54. if(requestStatus == true)
  55. Serial.println("Sending data success! Suhu " +stringVal +" Pakan " + pakan);
  56. else
  57. Serial.println("Sending data failed!");
  58. Serial.println();
  59. client.stop();
  60. delay(1000);
  61. }
  62.  
  63. boolean httpRequest(String link) {
  64. // if you get a connection, report back via serial:
  65. Serial.println("Push data to server");
  66. if (client.connect(server, 80)) {
  67. // Make a HTTP request:
  68. client.println("GET " + link + " HTTP/1.0");
  69. client.println("Host: agnosthings.com");
  70. client.println();
  71. return true;
  72. } else {
  73. // You couldn't make the connection
  74. Serial.println("Connection Failed");
  75. client.stop();
  76. return false;
  77. }
  78. }
  79.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:21: fatal error: EmonLib.h: No such file or directory
compilation terminated.
stdout
Standard output is empty