BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Connecting over USB

#21

I was able to run normally. You need start blynk-ser.bat from cmd.exe.

  1. Open cmd.exe
  2. write : (you way from blynk-ser.bat) example: " cd C:\blynk-library-0.2.1\blynk-library-0.2.1\scripts "
  3. write: " blynk-ser.bat -c COM4 -b 9600 -s cloud.blynk.cc -p 8442 " (only write your com-port number)
  4. And press “Enter” , press “Enter” and press “Enter”
0 Likes

#22

Hi Blynk team. Very very nice app. Looking forward for more updates and new widgets. Thanx guys.

At the moment I’m running blynk witch USB connection and I have some difficulties to make the connection stable.
After everything is connected I run blynk-ser.bat in numerous different ways : CMD.exe; run; and normal windows open. I set also set com port in server-sh. Everything is running but only for max 1 minute. Than server-sh output this:

Connecting device at COM6 to cloud.blynk.cc:8442…
OpenC0C("\.\COM6", baud=9600, data=8, parity=no, stop=1) - OK
Connect(“cloud.blynk.cc”, “8442”) - OK
InOut() START
DSR is OFF
Received EOF
EVENT_CLOSE
InOut() - STOP
Disconnect() - OK
Connect(“cloud.blynk.cc”, “8442”) - OK
InOut() START
DSR is OFF
Received EOF
EVENT_CLOSE
InOut() - STOP
Disconnect() - OK
Connect(“cloud.blynk.cc”, “8442”) - OK
InOut() START
DSR is OFF

The app shows arduino is offline.
I have tried holding reset button than lunching server-sh and realising after that. After some time it breaks the connection.

Please help as I’m still waiting for Ethernet shield to arrive.

It is similar problem to xc0de.

Best regards.

0 Likes

#23

@Claude

Hi, please show your code. Most probably you creating flood.

0 Likes

#24

Hi Dmitriy.

I was trying to implement some of Blynk functionality in to my recently developed Aquarium Sunrise Control Light based on WS2812B. Basically I tried to send values for each color RGB as they change with time and it is working for short amounts of time :slight_smile:

As the code for whole project is quite large I’m sending the code with involves Blynk part only. I tried to prevent flooding the server by using simple timer library.

THANK YOU FOR YOUR SUPPORT.

0 Likes

#25

Code seems ok. What email do you use, so I could check in server logs.

0 Likes

#26

I sent the email on PRV.

0 Likes

#27

Nothing in logs. I don’t know what problem is, above code work fine for me. @vshymanskyy any suggestions?

0 Likes

#28

Maybe the main code is the problem. I’m using two devices on i2c witch are : LCD 20x4 and DS3232RTC clock, plus PWM pin to drive WS2812B LEDs. So there is a bunch of library’s used in the project. So far I had no issues.

I have noticed that when it is actually working there are no issues witch time shown on LCD but when the connection is lost the clock do not display time every second instead it updates time every 10 seconds or so.
Maybe this will be a clue for you.

BIGGEST THANKYOU FOR GREAT SUPPORT.

0 Likes

#29

I’m still not have very good luck with this working, once in a blue moon I can get it working. Most of the time it starts then just repeats what I posted before. Very frustrating. Below is the code I tried to hook up. Can you look it over? I’m using Codebender if that matter. I wasn’t able to get Blynk to compile till I uploaded the lib.

Guess I’ll see if I can have better luck getting my spark core working. Hope that works…

/*
  AM2302 Temperature / Humidity Sensor (DHT22)
  Blynk
*/

#include <DHT.h>
//#include <SoftwareSerial.h>
//#include <Blynk.h>
//#include <BlynkSimpleSerial.h>
#include <SimpleTimer.h>

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11);
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>

#define DHTPIN      2
#define DHTTYPE     DHT22

DHT dht(DHTPIN, DHTTYPE);
WidgetLED led1(1);
SimpleTimer timer;

char auth[] = "cbf156b989564f0eaccedf0f500f0f3d";
double temperatureSetPoint = 22;
float humidity = 0;
float temperatureC = 0;
float temperatureF = 0; // (1.8 * dht.readTemperature()) + 32; // Convert C to F
float heatIndex = 0;
bool DHT_PRESENT = true;

void setup()
{
	//Serial.begin(9600);
    SwSerial.begin(9600);
    Blynk.begin(auth);
    
	// Wait 3 seconds
	//delay(3000);
	SwSerial.println(F("DHT test with Blynk"));
	SwSerial.println("Blynk connected: " + boolToString(Blynk.connect()));
	//delay(5000);

	dht.begin();
	timer.setInterval(1000, blinkLedWidget);
	
}

void blinkLedWidget()
{
  if (led1.getValue()) {
    led1.off();
    BLYNK_LOG("LED1: off");
  } else {
    led1.on();
    BLYNK_LOG("LED1: on");
  }
}

String boolToString(bool val){
	if(val)
	   return "True";
	else
	   return "False";
}
void loop()
{
	Blynk.run();
	// Reading temperature or humidity takes about 250 milliseconds!
	// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
	humidity = dht.readHumidity();
	temperatureC = dht.readTemperature();
	temperatureF = dht.readTemperature(true); // (1.8 * dht.readTemperature()) + 32; // Convert C to F
    heatIndex = dht.computeHeatIndex(temperatureF, humidity);

	// check if returns are valid, if they are NaN (not a number) then something went wrong!
	if (isnan(temperatureC) || isnan(humidity))
	{
		SwSerial.println(F("Failed to read from DHT"));
	}
	else
	{


	}

	//delay(3000);
}


// BLYNK functions
BLYNK_READ(0){
    Blynk.virtualWrite(0, DHT_PRESENT);
}

// Temp SetPoint - Data from App
BLYNK_WRITE(1){
  BLYNK_LOG("Got a value: %s", param.asStr());
  // You can also use: asInt() and asDouble()
}

// Temp SetPoint - Data to App
BLYNK_READ(2){
    Blynk.virtualWrite(2, temperatureSetPoint);
}

BLYNK_READ(3){
    Blynk.virtualWrite(3, temperatureC);
}

BLYNK_READ(4){
    Blynk.virtualWrite(4, temperatureF);
}

BLYNK_READ(12){
    Blynk.virtualWrite(12, humidity);
}

BLYNK_WRITE(10) {
    //if (param.asInt()) {
    //    Spark.connect();
    //} else {
    //    Spark.disconnect();
    //}
}
0 Likes

#30

Yesterday I started using Ethernet shield therefore USB connection in no longer my concern. Arduino Mega + W5100 shield. So far it works very well. Great job I can now monitor my lights anywhere in the world. Next step is to implement some controll.

Great job Guys.
I think you on to something BIG.
You are going to be some sort of Facebook for “Intrnet of Things”
Good luck.

0 Likes

#31

Hi,

I’m trying to get my UNO working via USB on Windows 8.1 using the Arduino 1.6.5r2 IDE (from the ZIP file - not installed)

I’m getting this error when running blynk-ser.bat

Waiting for 0 seconds, press a key to continue …
OpenC0C(): CreateFile("\.\4") ERROR No such file or directory (2)
Reconnecting in 3s…

I guess I’m doing something wrong, but don’t know what :smile:

Thanks
Nico

0 Likes

#32

Problem solved

I entered only 4 when running the script and not COM4 :frowning:

Works now very nicely!

1 Like

#33

@nvddussen

Glad you resolved it by yourself =).

0 Likes

#34

What program can i use to run the script? i have a mac…if that helps. Someone please help. I got the library up and running but what do i do with the script.

0 Likes

#35

@Ivan

Did you read sketch comments?

 * 1. Optional, but recommended.
 *    Connect additional USB-serial adapter to see the prints.
 *
 * 2. Edit auth token and upload this sketch.
 *
 * 3. Run the script (script located in "scripts" folder of library root,
 *    e.g. 'blynk-library/scripts') for redirecting traffic to server:
 *
 *      for Windows:         blynk-ser.bat
 *      for Linux and OSX:   ./blynk-ser.sh (may need to run with sudo)
 *
 *    You can specify port, baud rate, and server endpoint like this:
 *      ./blynk-ser.sh -c <serial port> -b <baud rate> -s <server address> -p <server port>
 *
 *    For instance :
 *      ./blynk-ser.sh -c /dev/ttyACM0 -b 9600 -s cloud.blynk.cc -p 8442
 *
 *    Run blynk-ser.sh -h for more information
 *
 *    Be sure to select the right serial port (there may be multiple).
 *
 *    Attention!
 *        Arduino IDE may complain with "programmer is not responding".
 *        You need to terminate script before uploading new sketch.
 *
 * 4. Start blynking! :)
0 Likes

Setting up with USB on Mac - SO CLOSE!
#36

Yes, but im still confused. Do i change something in the script? im not sure how sudo works either. any other tips will help. i have been at this for several hours i really want to get this working

0 Likes

#37

@Ivan

You don’t have to change something in the script. You run it as it is. So just go to library folder and than go to scripts folder. And run

sudo ./blynk-ser.sh

That’s it. Or you getting some errors when running it?

0 Likes

#38

Alright, after i run it it asks me for a password?

0 Likes

#39

Sudo command means you’ll run a command having the privileges of the root user(administrator)

You should input your Mac user account password. The one that you use to login to mac.

0 Likes

#40

i tried putting my password but it does not work.Also sometimes the sudo command will not work , it will say “no such file or directory”

0 Likes