// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TMPLVsoL2Ltg"
#define BLYNK_DEVICE_NAME "MONITORING BATERAI"
#define BLYNK_AUTH_TOKEN "IZ58pgLk2sleQDkOoEKymi0z8gvFpUui"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Ssj";
char pass[] = "siskahjo";
BlynkTimer timer;
bool process = false;
String buff = "";
float _data[3];
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
Blynk.virtualWrite(V0, _data[0]);
Blynk.virtualWrite(V1, _data[1]);
Blynk.virtualWrite(V2, _data[2]);
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
if (Serial.available()) {
char in = Serial.read();
if (in != '\n') {
buff += in;
} else {
process = true;
}
}
if (process) {
process = false;
buff += ",";
for (uint8_t i = 0; i < 4; i++) {
_data[i] = (buff.substring(0, buff.indexOf(','))).toFloat();
buff = buff.substring(buff.indexOf(',') + 1);
Serial.println(_data[i]);
}
Serial.println(buff);
buff = "";
}
Blynk.run();
timer.run();
}