Raspberry with node.js - how to run a Terminal command and display the output

Hello everyone this is my first project and what I am trying to do is running a command with a button press(virtual) and display the output on another virtual. Is this possible or do I have to read directly through the 1wire expansion module, in that case use this(dont know how at all to do with this, library?i2c DS2482

Or even easier maybe - have a widget always display the latest graph/temperature all the time :slight_smile:

My setup:

R-pi i2c 1wire expansion module[v1.1 (DS2482-100+) where I got all my temp-meters connected to.
I read my temperatures through this commands and get the output for example 15.8125 right now
cat /mnt/1wire/28.D8F92F040000/temperature
cat /mnt/1wire/28.B11BBB030000/temperature
cat /mnt/1wire/28.88DB2F040000/temperature

My thougts is that a button/widget is getting the temperature and another widget is posting the temperature/output from the command…

var Blynk = require('blynk-library');

var AUTH = 'zzzyyxx';

var blynk = new Blynk.Blynk(AUTH);
var v1 = new blynk.VirtualPin(1);
var v5 = new blynk.VirtualPin(5);

var process = require('child_process').exec,

v1.on('read', function(param) {                 // Watches for V1 Button
        console.log('V1:', param[0]);           // prints value to CLI

// "run the command ifconfig"
v5.on('write', function(param) {                // Watches for V5 Button
        console.log('V5:', param[0]);           // prints value to CLI
                if (param == 1) {                               // Runs the CLI command ifconfig if the button on V5 is pre$
                        process.exec('cat /mnt/1wire/28.D8F92F040000/temperature',function (err,stdout,stderr) {
                                if (err) {
                                } else {

For the moment the code isn’t working at all. I think it has something to do with “process.exec” regarding the error I get, combined with child_process… Something :slight_smile:

I am hoping there is a simple, and totally another type of, solution, for my function

(Secondary it would be awesome if I could move my rrddata in to Blynk (as I have stored many years of data in my rrddata files. for the moment I’m running it all in Apache as a webpage

Thank you!

@Jonaa please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:


1 Like

It is possible (although I don’t use NodeJs as a Blynk client, so I can’t tell you how), but the normal process would be to use a timer to take readings on a regular basis (say every 5 or 10 seconds), and push the results to Blynk.

Have you looked at the NodeJs examples on the Blynk GitHub site?

Blynk doesn’t have a mechanism for uploading/importing historical data. I guess that if you’re running a local server and you’re experienced with PostgreSQL then you could try populating the database with your old records.


I guess “use a timer to take readings” is what I need to do - but how still remain then!

I use a DS2482 board and I found out something lika “library” but I don’t know what to do with this… can I use it some way? i2c DS2482

Have you read this:


Yes I have read all but they all refer to “pgio pin” but I guess the problem is that none of my sensors is directly connected to my rpi but through the i2c 1wire breakout board / expansion module so Blynk can’t reach them.

AFAIK Blynk doesn’t read anything directly on the RPi GPIO (and only rudimentary GPIO control with other Arduino based MCUs).

One best uses whatever library works with the sensors and your choice of programming language, then utilize Blynk to control/display across that libraries commands.

What you need to do is find a suitable library to support your i2c device directly in NodeJS.

Hmmm ok…

I’ve found something, is this librarys?

Here for example is this c++?
Is this node and libraries to use?

They all explaining “Usage” but I suck too hard on programming and unfortunately I don’t have the time this time in life… I whish someone already have done the whole chain with this ds2482 bridge/controller step by step explaining it for me and I just change to my setup :innocent:

You can’t ruin C++ on your Pi unless you use WiringPi, which is now no longer supported.

Is there a reason why you’re running this on a Pi under NodeJS rather than a NodeMCU and C++ ?


Ok then… Neh I don’t have a clue… I can’t even identify the programming langue when I see it, and therefore I also don’t know how to use what I see… I dont know what I am looking at… as the libraries… dunno what to do with then, use them etc.

Giving this thread a few more days and then leaving Blynk it seems :slight_smile: not skilled enough to use it.

Blynk is not the real issue… Yes, it advertises (or did at one time) as “programming free” but that is only for the bare “Blinkin’ an LED” basics. But it does make a good starting ground, particularly as a GUI.

All DIY projects involving some form of MCU or SOC board, require a learning curve on the programming side. I am still (slowly) learning how to program my RPi’s with Python (My prefered choice after trying a few). They can be very powerful devices with a little effort and the plentiful info/training resources on the web.

I think your main problem is that you’ve chosen the wrong hardware with the Pi.
Blynk’s ideal hardware platform is probably the ESP8266 based NodeMCU or the ESP32, and the best programming language for these boards is C++
These boards cost bust a few Dollars/Euros/Pounds each and you don’t have to mess around with operating systems and cope with long boot times the same way you do with the Pi. They obviously have much less processing power, memory and storage than the Pi, but are perfect for having a few sensors attached to them, connecting to WiFi and pushing data to the Blynk app.

Because most Blynk users use this type of hardware there are lots of ready-made examples in the Sketch Builder and many more in the forum topics. Even if you can’t find examples in these locations, there are a great many forum users who can easily point you in the right direction to get your code working. Very few forum users use NodeJS, so there is a much smaller pool of examples and experience to help out.

Blynk is an extremely powerful, flexible and affordable way of achieving the sort of results that you seem to be looking for, and it’s worth sticking with it - but with the right hardware.

Take a read of this topic if you want more info about hardware choices…


Might be so but I have build everything around Pi and hoped Blynk could work with the setup but the conclusion seems to be it isn’t so I will go try something else in the future if I run into something :slight_smile: it was worth a try though.

Thanks for answering in the thread anyway, happy blynking to you all :slight_smile: signing out

Well, the OP seems to have given up… unfortunately, while still under the impression that the issue is Blynk related, rather then his needing to learn how to program a little with either NodeJS or Python.

You can lead a :horse: to :potable_water:

1 Like