Integrating Blynk with Arduino Uno, ESP8266, and i2c Lcd (Cont'd)

Continuing the discussion from Integrating Blynk with Arduino Uno, ESP8266, and i2c Lcd:

Continuing from my first post (above)… I edited the code to try and at least get it working before adding the rest of the functionality shown in the initial post. I added a timer and got everything out of the void loop. I also changed the baud rate of the ESP8266 to 9600 using AT commands in case it was incompatible with Arduino Uno. I still can’t get the i2c lcd or Blynk to connect. Any additional advice in how to fix the code would be greatly appreciated.


#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <Wire.h> //includes outside library allowing communication over i2c devices
#include <LiquidCrystal_I2C.h> //includes outside library allowing interfacing with LCD screens

char auth[] = "Tcivy65XclOzyqZB9rdv1BeGgO58A-JW";
char ssid[] = "Agnes24";
char pass[] = "dresserrand";
#include <SoftwareSerial.h>

SoftwareSerial EspSerial(2, 3); // RX, TX

#define Esp8266_baudRate 9600
ESP8266 wifi(&EspSerial);

//pressure measurement variables
float       pressureInput = A1; //select the proper analog input pin for the 3-wire pressure transducer
const float pressureZero = 99.5; //analog reading of pressure transducer at 0 psi
const float pressureMax = 929.775; //analog reading of pressure transducer at 150 psi
const int   pressureTransducerMaxPSI = 150; //maximum pressure rating of transducer being used.
float       pressureValue = 0; //variable to store the pressure value calculated from analog value 

//display variables
const int   baudRate = 9600; //constant to set the baud rate for the serial monitor
const int   sensorReadDelay = 1000; //constant integer to set the sensor read delay in milliseconds
const int   pressDisplayDelay = 500; //constant integer to set the pressure status message read delay in milliseconds

LiquidCrystal_I2C lcd(0x27, 20, 4); //sets the LCD I2C communication address: format(address, columns, rows)

BlynkTimer timer;

void myTimerEvent()
 pressureValue = analogRead(pressureInput); //reads value from the input pin and assigns a variable
 pressureValue = ((pressureValue - pressureZero) * pressureTransducerMaxPSI) / (pressureMax - pressureZero); // conversion equation to convert analog reading to psi

Serial.print(pressureValue, 1); //prints value from previous line to serial
 lcd.setCursor(0,2); //sets cursor to column 0, row 2
 lcd.print("Press.: "); //prints label
 lcd.print(pressureValue, 1); //prints pressure value to LCD screen, 1 digit on float
 lcd.print(" psig"); //prints label after value
 lcd.print("   "); //to clear the display after large values or negatives
 delay(sensorReadDelay); //delay in milliseconds between read values

  Blynk.virtualWrite(V5, pressureValue);

void setup()
Serial.begin(baudRate); //initializes serial communication at selected baud rate bits per second


lcd.init(); //initializes the LCD screen
lcd.backlight(); //initializes the LCD backlight

Blynk.begin(auth, wifi, ssid, pass);

timer.setInterval(1000L, myTimerEvent);

void loop()
{;; //initiates BlynkTimer

A post was merged into an existing topic: Integrating Blynk with Arduino Uno, ESP8266, and i2c Lcd