Please help.
How ton run program without wifi, use blynk only to monitor when it required.
I have searches the same topic but they use different library or device so it’s not work in my project.
They use ESP8266Wifi.h and etherned. I use esp8266_lib.h as the library.
I use arduino mega and esp8266 as a shield.
I want to run my program without it connected to wifi, but I want the device send data to blynk when it required and anytime I want. It temporary data not a historycal data so it doesn’t need to save data to blynk cloud server.
Here is my code
#define A 22
#define B 23
#define C 24
#define D 25
int counter = 0;
int diam;
int akhir;
float volt;
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "54737a98fcd843968facd53968b53691";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "jonihermawanto";
char pass[] = "123456789";
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
BlynkTimer timer;
void saya(){
int sensorValue = analogRead(A14);
float volt = sensorValue*(5.00/1023.00);
Serial.print("voltase : ");
Serial.println (volt);
Blynk.virtualWrite(V4, volt);
}
void lampu(){
int sensorValue = analogRead(A14);
float volt = sensorValue*(5.00/1023.00);
if (volt>=4.01){
digitalWrite(C, HIGH);}
else if (volt <=3.82){
digitalWrite(D,HIGH);}
else {digitalWrite(C,LOW); digitalWrite(D,LOW);}}
void sensor(){
diam=digitalRead(A);
if (diam!=akhir){
if(digitalRead(B)!=diam){
counter ++;
}else{
counter --;}
Serial.print("Posisi : ");
Serial.println(counter);
Blynk.virtualWrite(V5, counter);}
akhir=diam;}
void setup (){
pinMode(A, INPUT);
pinMode(B, INPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
Serial.begin (9600);
akhir=digitalRead(A);
timer.setInterval(1000, saya);
timer.setInterval(100 , sensor);
timer.setInterval(10, lampu);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop (){
if (Blynk.connected()){
Blynk.run();}
timer.run();
}