Blynk 2.0 Arduino USB device always offline

Hello,
I used Blynk legacy before and connecting an arduino with USB cable without wifi was very simple.

I am using Arduino UNO with no pins used, directly connected to a laptop on the same wifi, i followed these steps:

  1. Download and install blynk library on arduino.
  2. Download and install the new blynk app.
  3. From the app → +add a new device → arduino and connection as other
  4. Seems to be a bug that the link that is sent to me selects Arduino uno ethernet shield. but i change it to USB.
  5. upload the code to arduino.
  6. Run the bash file and change blynk-cloud.com to blynk.cloud
  7. On the app or the web dashboard i see the device offline

Any advice? Thank you so much.

Posting your sketch might help.

I am using the arduino uno USB Blynk blink code:

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

  You’ll need:
   - Blynk IoT app (download from App Store or Google Play)
   - Arduino Uno board
   - Decide how to connect to Blynk
     (USB, Ethernet, Wi-Fi, Bluetooth, ...)

  There is a bunch of great example sketches included to show you how to get
  started. Think of them as LEGO bricks  and combine them as you wish.
  For example, take the Ethernet Shield sketch and combine it with the
  Servo example, or choose a USB sketch and add a code from SendData
  example.
 *************************************************************/

// 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           "TMPLL4ptBs3H"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "MyAuth"


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


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

#include <BlynkSimpleStream.h>

char auth[] = BLYNK_AUTH_TOKEN;


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

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

void loop()
{
  Blynk.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!
}

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

What are you seeing in your terminal window when you run the Blynk script (the bash file as you call it)?

What OS are you running on your computer?

What does your modified Blynk script file look like?

Pete.

No, nothing is connected to any pins of Arduino, should i connect it for the software serial ?

In the terminal window i see connection established and seems identical to blynk (legacy):

I’m running Windows, and this is the batch file:


@echo off
setlocal EnableDelayedExpansion

REM === Edit these lines to match your need ===

set COMM_PORT=COM1
set COMM_BAUD=9600
set SERV_ADDR=blynk.cloud
set SERV_PORT=8080

REM === Edit lines below only if absolutely sure what you're doing ===

rem Get command line options
set SCRIPTS_PATH=%~dp0

:loop
IF NOT "%1"=="" (
    IF "%1"=="-c" set COMM_PORT=%2& SHIFT & SHIFT & GOTO :loop
    IF "%1"=="-b" set COMM_BAUD=%2& SHIFT & SHIFT & GOTO :loop
    IF "%1"=="-s" set SERV_ADDR=%2& SHIFT & SHIFT & GOTO :loop
    IF "%1"=="-p" set SERV_PORT=%2& SHIFT & SHIFT & GOTO :loop

    CALL :usage
    GOTO :eof
)

rem Find ports
set PORTS=
for /f "tokens=4 delims=: " %%A in ('mode^|findstr "COM[0-9]*:"') do IF not [%%A] == [] set PORTS=!PORTS! %%A
set PORTS=!PORTS:~1!

rem Check port
rem Skip check if no ports at all - Windows bug?
if not "x%PORTS%"=="x~1" (
    if "x!PORTS:%COMM_PORT%=!"=="x%PORTS%" (
        echo %COMM_PORT% not found, or may be busy.
        set /p COMM_PORT="Select serial port [ %PORTS% ]: "
    )
)

rem Create exe
if not exist "%SCRIPTS_PATH%\com2tcp.exe" (
    copy "%SCRIPTS_PATH%\com2tcp.bin" "%SCRIPTS_PATH%\com2tcp.exe" > NUL
)

rem Do the job
echo Connecting device at %COMM_PORT% to %SERV_ADDR%:%SERV_PORT%...

rem Try resetting board
rem mode %COMM_PORT%:%COMM_BAUD%,N,8,1 >nul

:restart
  "%SCRIPTS_PATH%\com2tcp.exe" --baud %COMM_BAUD% --ignore-dsr \\.\%COMM_PORT% %SERV_ADDR% %SERV_PORT%
  echo Reconnecting in 3s...
  timeout /T 3
goto restart


goto:eof

:usage
    echo.
    echo.   This script redirects serial communication to the server.
    echo.
    echo.   You can specify port, baud rate, and server endpoint like this:
    echo.     blynk-ser.bat -c ^<serial port^> -b ^<baud^> -s ^<server^> -p ^<port^>
    echo.
    echo.   The defaults are:
    echo.     -c    /dev/ttyUSB0       (on Linux)
    echo.           COM1               (on Windows)
    echo.           /dev/tty.usbserial (on OSX)
    echo.     -b    9600
    echo.     -s    blynk.cloud
    echo.     -p    80
    echo.
    echo.   If the specified serial port is not found, it will ask to enter another one.
    echo.   The script also tries to reestablish connection if it was lost.
goto:eof

Not really sure what that means.
The idea behind those line of code is to create an additional serial port that can be used to view the debug serial output from the device (which can’t be done via the regular serial port, as it’s being used for your Blynk connection).
To view this you need an FTDI adapter, and you would also need to decrease the baud rate of that SoftwareSerial port, as you hardware isn’t powerful enough to simulate a serial port using software with baud rates any higher than 9600 baud.

More info here…

Without sight of that debug serial data it’s difficult to know what’s happening.

I would suggest changing the port to 80 rather than 8080 though.

Pete.