Hello, my hardware took too long to connect to blynk server.
im using two VL53L0X sensor and one lcd i2c using esp32S2
when i connect three of them all together, the blynk took too long to connect sometimes forever.
however, when i connect just the sensors (no LCD), the blynk connected, took around 1-2s to connect.
same goes to when i just connect the lcd I2C (no sensors), the blynk took only 1-2s to connect.
Im wondering wheres the problem
LCD and sensors using the same SDA, SDL, GND and VCC pins. is this the reason why?
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "*************"
#define BLYNK_DEVICE_NAME "ESP32 Fertilizer Mixer"
#define BLYNK_AUTH_TOKEN "*******************"
#define M1A 5
#define M2A 6
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "Adafruit_VL53L0X.h"
// address we will assign if dual sensor is present
#define LOX1_ADDRESS 0x30
#define LOX2_ADDRESS 0x31
// set the pins to shutdown
#define SHT_LOX1 7
#define SHT_LOX2 6
char auth[] = "jcwJkQMGZ3A181****************";
char ssid[] = "N**************";
char pass[] = "n**********";
Adafruit_VL53L0X lox1 = Adafruit_VL53L0X();
Adafruit_VL53L0X lox2 = Adafruit_VL53L0X();
LiquidCrystal_I2C lcd(0x27,16,2);
BlynkTimer timer;
VL53L0X_RangingMeasurementData_t measure1;
VL53L0X_RangingMeasurementData_t measure2;
void setID() {
// all reset
digitalWrite(SHT_LOX1, LOW);
digitalWrite(SHT_LOX2, LOW);
delay(10);
// all unreset
digitalWrite(SHT_LOX1, HIGH);
digitalWrite(SHT_LOX2, HIGH);
delay(10);
// activating LOX1 and resetting LOX2
digitalWrite(SHT_LOX1, HIGH);
digitalWrite(SHT_LOX2, LOW);
// initing LOX1
if(!lox1.begin(LOX1_ADDRESS)) {
Serial.println(F("Failed to boot first VL53L0X"));
while(1);
}
delay(10);
// activating LOX2
digitalWrite(SHT_LOX2, HIGH);
delay(10);
//initing LOX2
if(!lox2.begin(LOX2_ADDRESS)) {
Serial.println(F("Failed to boot second VL53L0X"));
while(1);
}
}
void read_dual_sensors()
{
lox1.rangingTest(&measure1, false); // pass in 'true' to get debug data printout!
lox2.rangingTest(&measure2, false); // pass in 'true' to get debug data printout!
// print sensor one reading
Serial.print(F("pump A: "));
if(measure1.RangeStatus != 4) { // if not out of range
Serial.print(measure1.RangeMilliMeter);
} else {
Serial.print(F("Out of range"));
}
Serial.print(F(" "));
// print sensor two reading
Serial.print(F("Pump B: "));
if(measure2.RangeStatus != 4) {
Serial.print(measure2.RangeMilliMeter);
} else {
Serial.print(F("Out of range"));
}
Serial.println();
}
void sensorpinsetup()
{
digitalWrite(SHT_LOX1, LOW);
digitalWrite(SHT_LOX2, LOW);
Serial.println(F("Both in reset mode...(pins are low)"));
Serial.println(F("Starting..."));
}
void lcddisplay()
{
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello, fikhriyah!");
lcd.setCursor(1,1);
lcd.print("Hello, Fathul!");
delay(2000);
lcd.clear();
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// wait until serial port opens for native USB devices
pinMode(M1A, OUTPUT);
pinMode(M2A, OUTPUT);
while (! Serial) { delay(1); }
pinMode(SHT_LOX1, OUTPUT);
pinMode(SHT_LOX2, OUTPUT);
//offpumpA(); //default state
//offpumpB();
lcddisplay();
sensorpinsetup();
setID();
timer.setInterval(1000L, read_dual_sensors);
}
void loop()
{
Blynk.run();
timer.run();
}