The connecting display on the I2C bus to Arduino (A4, A5), while nothing appears on the display. Sketch I add, also by an experimental way it was found out that without the command “Blynk.begin (auth)” the data on the display are displayed. I would be grateful if someone tells me what I’m doing wrong))).
#include <Adafruit_Sensor.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
char auth[] = "ca59e6a7a9e64dd8900c27f038289174";
#define DHTPIN 2
LiquidCrystal_I2C lcd(0x27,20,4);
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
if (isnan(h)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Blynk.virtualWrite(V5, h);
}
void setup()
{
lcd.init();
lcd.backlight();
dht.begin();
Serial.begin(9600);
Blynk.begin(auth); // If this command comment, then the data on the display are displayed
timer.setInterval(1000L, sendSensor);
}
void loop() {
delay(500);
float h = dht.readHumidity();
lcd.setCursor(5,1);
lcd.print(h);
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}
}
Hi, I’m just not a very smart student. I would like to ask for help if you are not hard, can I write a sketch because I’m still a beginner in this topic?
This isn’t the place to come if you want someone to write your code for you. We’ll be happy to provide feedback and point you in the right direction, if you make the effort to understand the code that you’ve picked-up off of the internet.
In your particular case, I’d imagine that the problem Is to do with this:
Pin A4 on the Arduino is used to select the SD card on the combined Ethernet/SD card shield. The SD card and the Ethernet interface can’t be active at the same time.
I’d guess that when the Ethernet card is active (which it needs to be ALL of the time with a standard Blynk sketch) the LCD can’t be used.
A bit of internet research may reveal a solution, provided it doesn’t involve temporarily disabling the Ethernet shield via GPIO pin 10 while you write data to the LCD, as this will cause Blynk to disconnect.
Maybe there are libraries that allow different GPIO pins to be used for I2C.