Issues with LCD Widget

Hi everyone, I am using an Arduino Uno and connected via USB. The issue is the Arduino is not sending any data over to the LCD Widget on my Blynk I followed a bunch of an examples with no luck. Can anyone spot anything wrong?

#define BLYNK_PRINT SwSerial


#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX

#include <BlynkSimpleStream.h>

#include "VernierLib.h" //include Vernier functions in this sketch
VernierLib Vernier; //create an instance of the VernierLib library

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "HzyWnef-S9N-WqIe9BuFNORKxayZ7BSX";

WidgetLCD lcd(V3);

void setup()
{
  // Debug console
  SwSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  Vernier.autoID(); //identify the sensor being used
  
  while (Blynk.connect() == false) {
    // Wait until connected
  }


}




void sendsensor(){
  float sensorReading; //create global variable to store sensor reading
  sensorReading = Vernier.readSensor(); //read one data value
  delay(500); //wait half second

  if (sensorReading >=10) {
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    Serial.write(0);  
    lcd.clear(); //Use it to clear the LCD Widget
    lcd.print(4, 0, "Salt is low"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
    lcd.print(4, 1, sensorReading);
  } 

  if (sensorReading <5) {
    digitalWrite(10, HIGH); 
    digitalWrite(11, LOW);  
    Serial.write(1);
    lcd.clear(); //Use it to clear the LCD Widget
    lcd.print(4, 0, "Salt is high"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
    lcd.print(4, 1, sensorReading);
  } 
  
} 




void loop()
{
    Blynk.run();
    sendsensor();

}

You should start by reading this:

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/keep-your-void-loop-clean

Then stop calling your sendsensor() from the void loop and use a timer instead, and remove this:

You should also stop doing this:

and this:

The serial port is being used exclusively for communication with Blynk, you can’t send unexpected character to it and expect it to work.

Is your device showing as online in the app?

What Blynk library version are you using?

Do you have an FTDI adapter attached to pins 10 & 11? If so, what does it show in your SwSerial monitor?

Pete.

I got it working, it was because of the writing to the Serial. I also cleaned up my voidLoop like you suggested.

Question though. Is there a way that I can still write to the Serial without messing up Blynk, the program talks to the app Processing to then start audio using that serial message.

You need an additional piece of hardware, an FTDI (TTL to USB) adapter connected to your software serial pins.

But, the serial streaming connection method that you’re using at the moment isn’t a sustainable long term solution, so better to buy a NodeMCU or similar and connect via WiFi. If you do that then you can use your serial port for debugging.

Pete.

Awesome thanks so much!