Unable to connect device, I have edited the blynk-ser bat file and tried multiple options. No luck

I am trying to connect my Arduino Uno to the Blynk-cloud for the past two days, and have tried many suggestions throughout the forums. So far, I have…

  • Followed the QuickStart Guide at the initial sign up page. I have never any output in Serial Monitor.
  • Edited the blynk-ser.bat file to reflect the COM: I am using with my Arduino (COM6). Closed the CMD.
  • Uploaded my sketch first, then I have ran the bat file. No connection. Nothing in Serial Monitor.
  • Tried various other sketches under the Examples > Blynk. They too don’t work.

Nothing connects my Arduino to Blynk. I also tried a Ethernet Shield with RJ-45 connecting the shield to the internet connection.

Hardware: Arduino Uno w/ USB
OS: Windows 10
Server: Blynk Cloud
Library Blynk Version: 1.0.1
Connection: USB


#define BLYNK_TEMPLATE_ID "TMPL_Y8-0079"
#define BLYNK_DEVICE_NAME "Bottle Counter"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxx" (I use the actual token in my sketch**)

const int TxPin = 6;
int irPin = 2;
int count = 0;
boolean state = true;
#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);

void setup() {
    
  pinMode(TxPin, OUTPUT);
  pinMode(irPin,INPUT);
  digitalWrite(TxPin, HIGH);
  
  mySerial.begin(9600);
  delay(100);
  mySerial.write(12);                   
  mySerial.write(17);               
  delay(5);                           
  mySerial.print("Bottle Counter:"); 
  mySerial.write(13);                 
  mySerial.println(count);   
                 
}

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

I would be beyond grateful for help at this point :pray:

Can you explain what are you trying to achieve here ?
Why are you using a variable Tx pin ?
Why Rx pin is 255 ?

your should add

Blynk.begin(Serial, auth);

to Your void setup.

and

Blynk.run();

to your void loop.

and you should always keep your void loop as clean as possible, check this out

You also need to change the server to blynk.cloud if you are using Blynk IoT.

The command window needs to be open at all times.

Pete.

Hi there,

Thank you for getting back to me. Finally the code running without errors, but still no connection to the Blynk IoT. :sob:

For the: SoftwareSerial mySerial = SoftwareSerial(255, TxPin);

That line of code was provided by the manufacturer of the LCD I’m using, without it my lcd will not work (Parallax Serial LCD 27797).

I’m going to have to drop Blynk, it’s just not working out and I’m beyond frustrated at this point. Thank you though :slight_smile:

No, this command needs to be your void setup

That error message is because you don’t have the necessary Blynk libraries included in your sketch.

I’d suggest that you try one of the Sketch Builder examples, such as this:

Once you have it working correctly then you can add your own code in to it.

There’s a big difference between a piece of demo code from an LCD manufacturer, and the code that you would actually use in a working project.
I’m not familiar with this particular LCD display, but normal practice is to send data to the LCD once, when the information to be displayed changes, rather than constantly repeating the process of writing the same data to the display hundreds of times per second in the void loop.
So, this code almost certainly doesn’t belong in the void loop, and neither does the if (digitalRead(irPin)) line of code.
You should be polling the irPin using a BlynkTimer, and updating your LCD (and probably a widget in Blynk) if the value of that pin changes.
Also, you should NOT be using delays in your code at all, other than possibly short delays in your void setup.

Pete.

Go ahead and close this thread please.