I have the local server running correctly. I can log in from my iPhone, i’ve created a new project and added a Raspberry Pi. The problem I have is when I go to my Raspberry Pi and try to add it to the project here is the error I get. Below I’ve remove the token and substituted {my_token}. How do I tell it where to talk to the local blynk server and not the cloud?
root@garagepi:~# blynk-client {my_token}
OnOff mode
Connecting to: blynk-cloud.com 8441
SSL authorization…
Connected
Could not login: INVALID_TOKEN
events.js:165
throw err;
^
Error: Uncaught, unspecified “error” event. (INVALID_TOKEN)
at Blynk.emit (events.js:163:17)
at Blynk.onReceive (/usr/lib/node_modules/blynk-library/blynk.js:418:20)
at . (/usr/lib/node_modules/blynk-library/blynk.js:548:50)
at emitOne (events.js:96:13)
at emit (events.js:188:7)
at TLSSocket. (/usr/lib/node_modules/blynk-library/blynk-node.js:193:16)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
To someone new to the project and reading through the docs, there are lots of missing holes. What would be more helpful than RTFM, is an example of how the doc applies to what I’m trying to do. It’s not very clear beyond installing the software what to do next. What you linked to does not explain how to connect the RPi to the server with blynk-client?
No, I’d rather use a local server. I’m literally ~2 hours into trying to test out blynk. Installed the local server onto one RPi, trying to setup the second RPi as the client.
And no, from a newcomer perspective you didn’t answer the question. How does the link you gave me tell me how to connect to RPi. The link you shared has a section that talks about RPi and says:
Change your rasp PI javascript from
var blynk = new Blynk.Blynk(AUTH, options = {connector : new Blynk.TcpClient()});
to
var blynk = new Blynk.Blynk(AUTH, options= {addr:"xxx.xxx.xxx.xxx"});
How does that solve this step:
4. Run Blynk test script (put your auth token):
blynk-client 715f8cafe95f4a91bae319d0376caa8c
With this results:
root@garagepi:~# blynk-client {my_token}
OnOff mode
Connecting to: blynk-cloud.com 8441
SSL authorization...
Connected
Could not login: INVALID_TOKEN
events.js:165
throw err;
^
Error: Uncaught, unspecified "error" event. (INVALID_TOKEN)
at Blynk.emit (events.js:163:17)
at Blynk.onReceive (/usr/lib/node_modules/blynk-library/blynk.js:418:20)
at .<anonymous> (/usr/lib/node_modules/blynk-library/blynk.js:548:50)
at emitOne (events.js:96:13)
at emit (events.js:188:7)
at TLSSocket.<anonymous> (/usr/lib/node_modules/blynk-library/blynk-node.js:193:16)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
Again what would be more helpful is an example of getting up and running.
@costas yes, in the app I’m logged into my own server. I have verified this by looking at the server logs and I can see my account was created and each time I log in. I can also go to my server admin page, and I can see that I’m the only user and there are sections like hardware, stats & config.
I’m using two RPi’s because I can. Figured if I’m going to build a network of RPi’s in my house to control things, I’d have one dedicated as a server. May upgrade to a small linux server later if I need better performance, but for now I have plenty of RPi’s lying around.
Change your rasp PI javascript from
var blynk = new Blynk.Blynk(AUTH, options = {connector : new Blynk.TcpClient()});
to
var blynk = new Blynk.Blynk(AUTH, options= {addr:"xxx.xxx.xxx.xxx"});
There is no blynk command. Tried that with the blank-client and got the same error. There are only two executables on the system with the name blynk
root@garagepi:/usr/bin# ls -lasF | grep blynk
0 lrwxrwxrwx 1 root root 53 Mar 2 15:31 blynk-client -> ../lib/node_modules/blynk-library/bin/blynk-client.js*
0 lrwxrwxrwx 1 root root 51 Mar 2 15:31 blynk-ctrl -> ../lib/node_modules/blynk-library/bin/blynk-ctrl.js*
Here’s the result from running blank-client:
root@garagepi:~# blynk-client --server=192.168.1.161 --token={my_token} --port=8441
OnOff mode
Connecting to: blynk-cloud.com 8441
SSL authorization...
Connected
Could not login: INVALID_TOKEN
events.js:165
throw err;
^
Error: Uncaught, unspecified "error" event. (INVALID_TOKEN)
at Blynk.emit (events.js:163:17)
at Blynk.onReceive (/usr/lib/node_modules/blynk-library/blynk.js:418:20)
at .<anonymous> (/usr/lib/node_modules/blynk-library/blynk.js:548:50)
at emitOne (events.js:96:13)
at emit (events.js:188:7)
at TLSSocket.<anonymous> (/usr/lib/node_modules/blynk-library/blynk-node.js:193:16)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
So skip step 4 and go to 5!!! Not a single thing in any of the above conversations did anyone mention skipping step 4!!! I’m CLEARLY following the docs (as written) and trying to follow the steps by running blynk-client. If step 4 shouldn’t be done for a local server, it would have been nice to have that noted in the docs or you could have added that to all the other stuff you threw at me.
As I said earlier 90% are not doing what you are doing and your link is to use the Pi as a client to the cloud server. Nowhere does it mention local servers in your link and that’s why I took the time to direct you to the correct section of the docs.
Of the 10% of Blynkers that are using a local server, some are on Pi’s and some on the many other servers that are available.
Of those running local server almost all of them used the cloud server first and I would say it should be 100%. Why try to run before you can even walk!
So for 99% to 100% of Blynkers then step 4 is absolutely VITAL and written exactly where it should be in that section of the docs…
First… I understand and sympathize with you; The documentation and examples with referencing the RPi are currently limited (but getting better) and assume a much larger knowledge base with Java, Linux and probably even Python… or whatever the RPi natively works with.
However, @Costas has gone above and beyond in helping me in the past, just as he has with you here… but he DOES NOT WORK FOR BLYNK! He is a voluntary user, just helping other users like you and me, so badgering him about the documentation not being good enough is not fair to him.
There are TWO ways of running Blynk (Client) on RPI: The partially documented NODEJS (Java) and the less referenced wiringPi (C++ style)… and thus two completely differing methods of doing everything from linking to a specific server and writing scripts to control pins. There are more examples and such spread out on >github< , but personaly I find them random and confusing.
Since it appears you are using the NODEJS method, I have less experience with that (e.g. I gave up and went the wiringPi route )… However, unlike with the C++ method, I seem to recall you determine the server location, not via the command line, but by editing a file (or your actual script) to make the server address changes as @Costas pointed out.
Give me a little while to dig up the details… they are in the forum here somewhere… and I will pass the directions on to you (if someone else doesn’t do so first).
For some reason links posted in these forums stopped defaulting in a green colour, and are now only highlighted green when moused over… so any links I post now are usually bracketed between > <.
OK, in the >github< link I referenced above, you can compare these two scripts - >client-tcp.js< & >client-tcp-local.js< to see an example (I think?) on how to edit your own script from the default cloud server to your Local server.
Basicly, what was shown here…
I hope that this will make it a bit clearer for you