I am trying to run Blynk on an Arduino, hooked up to a Raspberry Pi. I want to use it to control a RGB led strip, but the Raspberry Pi only has one pwm pin. I have uploaded the sketch to the Arduino, but I cannot get the Pi to run ./blynk-ser.sh.
pi@raspberrypi ~/blynk-library/scripts $ sudo ./blynk-ser.sh
[ Press Ctrl+C to exit ]
Canât detect OS type!
pi@raspberrypi ~/blynk-library/scripts $
It was saying something about socat utility, so I ran sudo apt-get install socat, and it went through normally.
I have commented out where I think the problem was, now it gives a different result:
pi@raspberrypi ~/blynk-library/scripts $ sudo ./blynk-ser.sh
[ Press Ctrl+C to exit ]
Resetting device /dev/ttyUSB0âŚ
Connecting: <-> openssl-connect:cloud.blynk.cc:8441,cafile=/home/pi/blynk-library/scripts/certs/server.crt,nodelay
2015/07/13 17:59:50 socat[9216] E exactly 2 addresses required (there are 1); use option â-hâ for help
2015/07/13 17:59:50 socat[9216] N exit(1)
Reconnecting in 3sâŚ
Connecting: <-> openssl-connect:cloud.blynk.cc:8441,cafile=/home/pi/blynk-library/scripts/certs/server.crt,nodelay
2015/07/13 17:59:53 socat[9219] E exactly 2 addresses required (there are 1); use option â-hâ for help
2015/07/13 17:59:53 socat[9219] N exit(1)
Reconnecting in 3sâŚ
^CExited!
pi@raspberrypi ~/blynk-library/scripts $
I am new to this and running into a similar problem trying to get an Arduino Mega with USB connection to a Raspberry Pi 2 to connect to Blynk. I follow instructions and only get the following on Terminal:
@lfbaron did you modify the script as indicated by @Minocc?
The script is for pure linux and Macâs. If you look through the script there are about 3 references to OSTYPE.
When I used USB on my Pi I changed the = âsomeosnamelikedarwinformacsâ to != ⌠and it worked fine.
If you have already done this let us know and we will advise further.
bastiaan@legotrainz:~/blynk-library/scripts $ sudo ./blynk-ser.sh
[ Press Ctrl+C to exit ]
/dev/tty.usbmodem not found.
Select serial port [ ]: /dev/ttyACM0
Resetting device /dev/ttyACM0...
stty: invalid argument '-f'
Try 'stty --help' for more information.
Warning: Server connection may be insecure!
Connecting: GOPEN:/dev/ttyACM0,raw,echo=0,clocal=1,cs8,nonblock=1,ixoff=0,ixon=0,ispeed=9600,ospeed=9600,crtscts=0 <-> TCP:192.168.0.25:8442,nodelay
2016/02/10 19:41:10 socat[26294] N opening character device "/dev/ttyACM0" for reading and writing
2016/02/10 19:41:10 socat[26294] N opening connection to AF=2 192.168.0.25:8442
2016/02/10 19:41:10 socat[26294] N successfully connected from local address AF=2 192.168.0.53:49631
2016/02/10 19:41:10 socat[26294] N starting data transfer loop with FDs [5,5] and [6,6]
Change every occurence in blynk-ser.sh of == âdarwinâ to != âdarwinâ (I think there three or four).
edit-
Actually, donât do that, replace the âlinux-gnuâ with âlinux-gnueabihfâ, which is actually the OS type for the RasPi. My hardware was offline, but now it is online. Since RaspBian etc is more compatible with Linux than Mac (which is BSD), it actually works.
Thanks both. I made the change and now get the following over and over:
Connecting: FILE:/dev/ttyACM0,raw,echo=0,clocal=1,cs8,nonblock=1,b9600 <-> openssl-connect:cloud.blynk.cc:8442,cafile=/home/pi/sketchbook/libraries/Blynk/scripts/certs/server.crt,nodelay
2016/02/10 15:05:55 socat[3302] N opening character device â/dev/ttyACM0â for reading and writing
2016/02/10 15:05:55 socat[3302] N opening connection to AF=2 45.55.195.102:8442
2016/02/10 15:05:55 socat[3302] N successfully connected from local address AF=2 192.168.1.98:41319
2016/02/10 15:05:56 socat[3302] E SSL_connect(): socket closed by peer
2016/02/10 15:05:56 socat[3302] N exit(1)
Reconnecting in 3sâŚ
I donât remember changing SSL to TCP but port 8442 is tcp for sure so reference to SSL does suggest a change is required. If itâs not this are you sure you have the Blynk token in your sketch?
I am positive I have the token in the sketch. Still get this:
Connecting: FILE:/dev/ttyACM0,raw,echo=0,clocal=1,cs8,nonblock=1,b9600 <-> TCP:cloud.blynk.cc:8442,nodelay
2016/02/10 15:36:44 socat[3525] N opening character device â/dev/ttyACM0â for reading and writing
2016/02/10 15:36:44 socat[3525] N opening connection to AF=2 45.55.195.102:8442
2016/02/10 15:36:45 socat[3525] N successfully connected from local address AF=2 192.168.1.98:41232
2016/02/10 15:36:45 socat[3525] N starting data transfer loop with FDs [3,3] and [4,4]
2016/02/10 15:36:45 socat[3525] E read(3, 0x19ae778, 8192): Resource temporarily unavailable
2016/02/10 15:36:45 socat[3525] N exit(1)
Sorry to be a pest. I setup an Arduino Uno with an ethernet shield without issues. This is different.
Also, when I run the script, Arduino IDE will timeout and will not upload script unless I reboot the Pi. Something about avrdude
// You could use a spare Hardware Serial on boards that have it (like Mega) #include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX #define BLYNK_PRINT SwSerial #include <BlynkSimpleSerial.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = â9107e9542b144af18db0xxxxxxxxxxâ;
void setup()
{
SwSerial.begin(9600);
Blynk.begin(auth);
// Default baud rate is 9600. You could specify it like this: //Blynk.begin(auth, 57600);
}
Iâm not sure about the software serial, this is my working sketch:
#include <BlynkSimpleSerial.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "blablabla";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
// Default baud rate is 9600. You could specify it like this:
//Blynk.begin(auth, 57600);
}
void loop()
{
Blynk.run();
}
you could also try running the script with elevated rights, a.k.a. sudo ./blynk-ser.sh
Software Serial gets a bad press, well it does in my book.
You will notice in the sample systems there is no Pi with USB, although it has been used by many. That is why the script has to be manually changed but also Software Serial wouldnât really apply to the Pi.
I guess you could hook up the Arduino to the tx / rx pins on the Pi but most people are not doing that. You could also hook up the Software serial pins on the Arduino to a regular computer but this is all overkill.
Suggest you change your sketch to the one provided by @Lichtsignaal. I donât have mine handy so I canât say what is in my sketch. Without Software Serial you donât get any feedback from the Arduino other than what you are seeing in the script but once it is set up that should be enough.
I have changed the blink-ser.sh script line 10 from"SSL" to âTCPâ. Replaced âlinux-gnuâ with âlinux-gnueabihfâ in 4 instances. Uploaded the sample script: