Node and NPM Issues

Yeah, by simple script I am just generalizing.

I was just talking about the “simple” script that was contained on here in the DOCS section:

blynk-client <AUTH_TOKEN>

I went through the setup for WiringPi and everything seemed to go through without any errors, but still my scripts do not run :sweat:

Do I run blynk-client any different now that I have WiringPi installed?

I am not running a server yet, I just wanted to keep things simple at first and make sure everything will run on the command line, then on startup through a cronjob, then work on getting the server up and running.

I am starting to think I have a micro_controller curse, and I might just have to go back to using PLC’s and ladder logic.

I really don’t remember how the NODE method worked, as I was never able to get it running properly. But with the wiringPi method, first make sure you are in the correct directory (or include it in the command - see how I have done both, for reference, in the picture below) and then run sudo ./blynk --token=<AuthToken> (don’t include the <>) when using cloud server. I am unsure if you need the ./ or just / before blynk… probably depends on the directory or path.

If you have your own Local Server then you need to add the IP and port.

This is what it should roughly look like on the terminal:

So do I skip installing these packages altogether, and just go through with the walk-through you provided?

sudo apt-get install -y build-essential nodejs
sudo npm install -g npm
sudo npm install -g onoff
sudo npm install -g blynk-library

Just rebuilt and got to this point:

All Done.

NOTE: To compile programs with wiringPi, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).

do I need to add any of these?

Yes, those are only for the NODE method… which for all I know, could probably be run simultaneously (assuming someone figures out the ONOFF issue).

I haven’t progressed that far myself… but yes they are added to the “custom script” portion (i.e. making your own code, using virtual pins, etc).

They do not get directly added to the terminal window… I believe you can think of them as including libraries.

Then I got here…with some problems

pi@raspberrypi:~/blynk-library/linux $ make clean all target=raspberry
rm main.o BlynkDebug.o ../src/utility/BlynkHandlers.o blynk
rm: cannot remove ‘main.o’: No such file or directory
rm: cannot remove ‘BlynkDebug.o’: No such file or directory
rm: cannot remove ‘../src/utility/BlynkHandlers.o’: No such file or directory
rm: cannot remove ‘blynk’: No such file or directory
Makefile:63: recipe for target 'clean' failed
make: [clean] Error 1 (ignored)
g++ -I ../src/ -I ./ -DLINUX -c -O3 -w -DRASPBERRY main.cpp -o main.o
g++ -I ../src/ -I ./ -DLINUX -c -O3 -w -DRASPBERRY BlynkDebug.cpp -o BlynkDebug.o
g++ -I ../src/ -I ./ -DLINUX -c -O3 -w -DRASPBERRY ../src/utility/BlynkHandlers.cpp -o ../src/utility/BlynkHandlers.o
g++ main.o BlynkDebug.o ../src/utility/BlynkHandlers.o -lrt -lpthread -s -lwiringPi -o blynk

Try this (warning, this has all been quickly cut and pasted… I have installed this before, but I might have made a typo here):

Start with running these commands, one after another, in a terminal window of your RPi - if one fails, then precede it with sudo

sudo apt-get update
sudo apt-get install git-core
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build

To make sure the library has been installed, run the gpio -v command, which should return the version information.

----------------- for visual example -----------------

pi@raspberrypi:/blynk-library/linux $ gpio -v
gpio version: 2.25
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Model B, Revision: 2, Memory: 512MB, Maker: Egoman

----------------- end visual example -----------------

To compile the Blynk library, use the following commands:

git clone https://github.com/blynkkk/blynk-library.git
cd blynk-library/linux
make clean all target=raspberry

Then In a Terminal window on your Raspberry Pi, switch to the blynk-library/linux directory

cd/ blynk-library/linux

and start the server using the command below (replace AuthToken with the actual token generated by the Blynk app):

sudo ./blynk --token=AuthToken

That command connects to Blynk’s default Cloud Server, so if you are running your own Local Server, you need to specify its address and port manually; for example:

sudo ./blynk --server=192.168.1.101 --port=8555 --token=AuthToken

If the connection has been established successfully, you should see the Blynk logo (in ASCII) and Ready! message.

1 Like

Looks more like there was nothing to clean up, not an actual error per se. Try the next steps in the quick-n-dirty guide I just previously posted.

make target=raspberry (clean all is removal for failed Make)

@Costas Great, another command I need to look up to actually understand :stuck_out_tongue: But thank you for pointing it out… sooo much to learn…

FYI, I just pasted it from the source. I had ran the full command on my install, and I think I had much the same messages as @BigP0P5, so I guess I also had no failed install parts to remove as it worked in the end :+1:

Guys the question of onoff is not actually related to blynk itself.
if write a simple Node script like

var onoff = require("onoff")

what do you get by running it?
If you get an error (and you have actually installed onoff) - look at the NODE_PATH variable, as stated in out articles…

Also, regarding the comparison Node.js vs C++:
Node.js is simpler to write scripts, update, and prototype. It also supports secure SSL connection.
Node.js has LOTS of modules for raspberry, ubuntu etc - so integration is easy.
Node.js has timers, async operations, etc - again this is cool

Now C++ version is very limited in that sense. If you want just to toggle a pin, this will work but if you want to add more functionality, you’re going to become a Linux system programming guru very soon :wink:

1 Like

Glorious!

I am now up and running back to where I was a week ago!

Nest step is to run this on startup with a cronjob, as I had no luck with editing the init.d or rc.local files.

Then for server setup…

And maybe simultaneously running both wiringPi for pin access and node for virtual pins and data logging.

But now I’m off to see what I can break next, as that is a speciality that I have truly mastered the art of.

Consider this issue solved.

I’d like to thank you peeps for holding my hand through this process as I am able to stand on my own two feet for now.

Cheers! :beers:

Drinks are on me tonight.

2 Likes

wiringPi (C++) client route doesn’t have the difficulties you faced with node.js regards bootup.

@vshymanskyy have you tested Blynk running node.js on a Raspberry Pi 3?

1 Like

For me, it isn’t a question of one or the other being better, stronger, faster… rather which one actually installed and worked as advertised.

Not contesting that… however if it doesn’t install, mesh, function, or whatever it needs to do with Blynk, then no blynky blinky worky. I don’t care who is at fault… I just wanted it to do what was claimed in the documentation.

And I tried this… no notable effect… Perhaps with a more in depth knowledge and effort, I might have figured it out, but by then I was already days (weeks if you count that that was my 2nd attempt) deep and very frustrated.

I agree… however my brain is simple… if it don’t see quick, and easy to start, shiny blinky things to entice it to learn more, it gives up too soon. But give it something to see and compare resulting action with the intangible code then it keeps it’s focus and plods on… good brains, now heal :stuck_out_tongue:

This is the path, command & placement of the startup line that I used for mine and it works… try again :slight_smile:

cough…:confused:

pi@raspberrypi:~ $ systemctl status rc-local.service
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; static)
  Drop-In: /etc/systemd/system/rc-local.service.d
           └─ttyoutput.conf
   Active: failed (Result: exit-code) since Tue 2017-02-07 04:30:09 UTC; 32s ago
  Process: 779 ExecStart=/etc/rc.local start (code=exited, status=1/FAILURE)

And when I execute it in the command line…

pi@raspberrypi:~ $ sudo  sh -x /etc/rc.local
+ sudo blynk-library/linux/blynk --      token=AuthToken
[0] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.5 on Linux

[5001] Connecting to blynk-cloud.com:8442
[5184] Ready (ping: 54ms).

So Iooked within the ttyoutput config file and I have this:

[Service]
StandardOutput=tty

I don’t know what I am looking at, so it looks abnormal to me :slight_smile:

Maybe you could make heads of this.

I had it boot to command line while waiting for network on boot, and still ha issues and now I am back here on the gui.

Please check our latest guide on Node.js installation for Linux: http://help.blynk.cc/hardware-and-libraries/node-js/how-to-install-nodejs-library-on-linux

A post was split to a new topic: NodeJS onoff issue