Very Confused with how to connect Parallax 3-pin LCD output to Blynk LCD widget

I have a Parallax 2 x 16 Serial LCD with Piezo Speaker, it has three pins: GND, RX & 5V.

LCD to Arduino:
RX – Pin 6
GND - GND
5V – 5V

I’m really unsure of how to connect my LCD output to show on the Blynk LCD widget. I’ve read a lot of the documentation, but given my LCD I don’t understand where to place and edit the variables (lcd.print(), lcd.clear()) to get the LCD to connect to the Blynk app.

:confused:

This sketch is from the manufacturer with an added IR sensor…


#include <SoftwareSerial.h>

const int TxPin = 6;
int irPin = 2;
int count = 0;
boolean state = true;
SoftwareSerial mySerial = SoftwareSerial(255, TxPin); //This code was provided by the manufacturer, Parallax, without it I cannot run my LCD display properly.


void setup() {
  
  pinMode(TxPin, OUTPUT);
  pinMode(irPin,INPUT);       //IR Sensor 
  digitalWrite(TxPin, HIGH);
  
  mySerial.begin(9600);
  //delay(100);
  mySerial.write(12);                 // Clear             
  mySerial.write(17);                 // Turn backlight on
  //delay(5);                           // Required delay            
  mySerial.println("Bottle Count'r:");  // First line
  mySerial.write(13);                 // Form feed
  mySerial.println(count);            // Second line
  //delay(3000);                        // Wait 3 seconds
}

void loop() {
  
  if (!digitalRead(irPin) && state){  
    count++;  
    state = false;  
    mySerial.write(179);
    mySerial.println(count);  
  
  }  
  if (digitalRead(irPin))  
  {  
    state = true;  
    delay(100);  
  } 
  
}

Okay, let’s start with you sharing information about the type of board you’re using, your connection type, the version of Blynk and the version of the Blynk library that you are using, plus your sketch that currently sends data to an LCD widget in the Blynk app.
Information about which pin(s) that LCD widget is attached to, and whether it is in Simple or Advanced mode, plus whatever other widgets you have used in Blynk and what they are used for would be very useful.

Pete.

I’m so sorry! I’ve been working on this project for two weeks and I just realized that I’m overthinking this when I really need to just take my IR sensor data and have it display via Blynk app with a value display widget :woman_facepalming: :woman_facepalming: :woman_facepalming:

I placed what I think is the code that will work with my IR Sensor and commented it out in caps lock to stand out.

Is that correct way of doing it?

/*************************************************************

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLDATy0OBQ"
#define BLYNK_DEVICE_NAME           "Latest Bottle Counter 0411"
#define BLYNK_AUTH_TOKEN            "x"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;


// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "BELL248";
char pass[] = x";


const int TxPin = 6;
int irPin = 2;
int count = 0;
boolean state = true;
SoftwareSerial mySerial = SoftwareSerial(255, TxPin); //This code was provided by the manufacturer, Parallax, without it I cannot run my LCD display properly.

BlynkTimer timer;


// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V1, count);
}


// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V1, millis() / 1000);
}

void setup()
{

  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);

  pinMode(TxPin, OUTPUT);
  pinMode(irPin, INPUT);      //IR Sensor
  digitalWrite(TxPin, HIGH);

  mySerial.begin(9600);
  //delay(100);
  mySerial.write(12);                 // Clear
  mySerial.write(17);                 // Turn backlight on
  //delay(5);                           // Required delay
  mySerial.println("Bottle Counter:");  // First line
  mySerial.write(13);                 // Form feed
  mySerial.println(count);            // Second line
  //delay(3000);                        // Wait 3 seconds
}

void loop()
{
  if (!digitalRead(irPin) && state) {
    count++;
    state = false;
    mySerial.write(179);
    mySerial.println(count);  //
    Blynk.virtualWrite(V5, count); //sensor data to blynk. WOULD THIS BE THE CORRECT WAY TO DO IT?
  }
  if (digitalRead(irPin))
  {
    state = true;
    delay(100);
  }

  Blynk.run();
  timer.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

You don’t like sharing info when requested do you?

You’ve mentioned an IR sensor, but provided no information about this sensor, and what it’s role is in this project.
And despite saying that your project just needs to be the IR sensor and a display widget, your sketch still appears to be cluttered with code for the physical LCD.

I’ve explained to you in a different topic that you can’t clutter-up your void loop like this, but because of your reluctance to stay focussed and provide straight answers to simple questions, it’s difficult to guide you to a better approach.

So, go back to basics, provide all of the information that has been requested, along with details of all of the hardware you are using and the overall aim for your project.

Pete.

The project I’m making is a IoT bottle counter it will sit on a rim of a bin; it uses a IR sensor to detect and count objects that pass in front of the IR sensor then the output is shown on an LCD so the user can see how many cans/bottles have been counted, and it has a internet element that will send an SMS text of the amount counted.

I can’t change the code for the LCD display, it is what it is and it works after hours of fiddling. Not important though, I need to focus on the getting the IR sensor data to show on a Value Display in the Blynk App.

The IR sensor has been placed within an IF statement. I’ve moved it up into the Void Setup() section to clean up the Void Loop().

The IR Sensor is set to Pin 2, in the code under int irPin = 2;

I do have a datastream set up for the IR Sensor, it has pin V5 set (not sure if I even need to have a datastream for the IR Sensor)

My instructor said to change the value for Blynk.virutalWrite(v5, val) too Blynk.virtualWrite(v5, count) since the IR Sensor output parameter is ‘count’ . But he does not have much experience with Arduino, so this is why things are jumbled.

Here is my latest code:

  
  #define BLYNK_TEMPLATE_ID           "TMPLDATy0OBQ"
  #define BLYNK_DEVICE_NAME           "Latest Bottle Counter 0411"
  #define BLYNK_AUTH_TOKEN            "9h2o9OqoT1ZnjDttqyKO3at20nJNfsUj"
  #define BLYNK_PRINT Serial
  
  #include <SoftwareSerial.h>
  #include <ESP8266WiFi.h>
  #include <BlynkSimpleEsp8266.h>
  
  char auth[] = BLYNK_AUTH_TOKEN;
  char ssid[] = "BELL248";
  char pass[] = "x";
  
  const int TxPin = 6;
  int irPin = 2;
  int count = 0;
  boolean state = true;
  
  SoftwareSerial mySerial = SoftwareSerial(255, TxPin); 
  
  BlynkTimer timer;


// This function is called every time the Virtual Pin 0 state changes
  BLYNK_WRITE(V0)
{
 // Set incoming value from pin V0 to a variable
  int value = param.asInt();

// Update state
  Blynk.virtualWrite(V5, count);
}
// This function sends Arduino's uptime every second to Virtual Pin 2.
  void myTimerEvent()
{
  Blynk.virtualWrite(V5, millis() / 1000);
}

void setup()
{

  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, myTimerEvent);

  pinMode(TxPin, OUTPUT);
  pinMode(irPin, INPUT);      
  digitalWrite(TxPin, HIGH);

  mySerial.begin(9600);                             
  mySerial.println("Bottle Counter:");  
  mySerial.write(13);                 
  mySerial.println(count);            

  if (!digitalRead(irPin) && state) {
    count++;
    state = false;
    mySerial.write(179);
    mySerial.println(count);  //
    
  }
  if (digitalRead(irPin))
  {
    state = true;
    delay(100);
  }
  Blynk.virtualWrite(V5, count); //sensor data to blynk                   
}

void loop()
{
  
  Blynk.run();
  timer.run();
 
}

Okay, I’ve asked enough times for info about your board type, sensor type, Blynk library version, widget setup etc and I can only assume that this information is top secret and that I don’t have sufficient security clearance for you to share that information with me.

I’ll focus my time spent on the forum on helping people who are prepared to give straight answers to clear questions.

Good luck with your project!

Pete.

2 Likes

Go ahead a close this thread, I figured it out.