I use Arduino UNO and ESP8266-01 in my project. I’ve been observing the system for about three days. The problems I encounter are;
1- Wifi module is experiencing disconnections.
2- Data transfer between BLYNK and arduino is very slow. I can’t follow the graphical snapshots.
3- The data read by Arduino Nun is updated too late in the application
I’m adding the code below and a few screenshots so you can have ideas.
I would appreciate it if you would share your expensive experience and opinions with me. Thank you to all concerned
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include "Adafruit_CCS811.h"
#include <DHT.h>
char auth[] = "3ebxxxxxcae41xxxxxx6";
char ssid[] = "xxx";
char pass[] = "xxxx";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
#define DHTPIN 4
#define DHTTYPE DHT22
Adafruit_CCS811 ccs;
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
int c = ccs.geteCO2();
float n = dht.readHumidity();
float s = dht.readTemperature();
int sicaklikset;
int nemset;
int co2set;
BLYNK_CONNECTED() {
// Request Blynk server to re-send latest values for all pins
Blynk.syncAll();
// You can also update individual virtual pins like this:
//Blynk.syncVirtual(V0, V2);
// Let's write your hardware uptime to Virtual Pin 6
int value = millis() / 1000;
Blynk.virtualWrite(V6, value);
}
BLYNK_WRITE(V3)
{
// You'll get uptime value here as result of syncAll()
int sicaklikset = param.asInt();
}
BLYNK_WRITE(V4)
{
// You'll get uptime value here as result of syncAll()
int nemset = param.asInt();
}
BLYNK_WRITE(V5)
{
// You'll get uptime value here as result of syncAll()
int co2set = param.asInt();
}
void sendSensor()
{
ccs.readData();
int c = ccs.geteCO2();
float n = dht.readHumidity();
float s = dht.readTemperature();
Blynk.virtualWrite(V0, s);
Blynk.virtualWrite(V1, n);
Blynk.virtualWrite(V2, c);
}
void setup() {
Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
ccs.begin();
dht.begin();
timer.setInterval(1000L, sendSensor);
}
void loop() {
Blynk.run();
timer.run();
}
Even with what looks like a fairly good ping, I suspect it all comes down to your network… The WiFi, Router, Internet… perhaps even your phone??
I am running multiple Arduino/ESP-01 combos in a very congested WiFi area (including on my own network) and getting very good responses even from heavy or fast responding tasks. However I am also using a Local Server, so that helps.
BTW, how are you determining this “slow” speed anyhow?? You are reading sensors once per second… so, it is like taking many seconds, minutes, hours, days… to show on your App??
It’s also worth noting that with Superchart, the minimum granularity is 1 minute, so the readings taken every 5 seconds will be averaged out and allocated to the record for that minute.
The connection to local server is very similar to connecting to cloud server - just specifying the IP address and port of the local server instead of blynk-cloud.com in your blynk.begin command.
You’ve shared a screenshot of one of your gauges, but this doesn’t answer the question that @Gunner asked - what makes you think that the updates to the gauges in the app are slow?
I’d suggest that you add some Serial.print commands into your sendSensor function to print the values to your serial monitor and see what the delay is between the values appearing there and in the app.
You should be setting the refresh interval to PUSH when using virtual pins.
The only difference would be in the Blynk.begin() command… so not much to show that will do you any good… besides it is all in the documentation and the examples…
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(xxx,xxx,xxx,xxx), 8080);