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 https://github.com/cybergibbons/DS2482_OneWire

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 blynk.servebeer.com/daily.png)

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 https://github.com/cybergibbons/DS2482_OneWire

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++? https://github.com/cybergibbons/DS2482_OneWire
Is this node and libraries to use? https://www.npmjs.com/search?q=ds2482

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 npmjs.com 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

I agree with you, my setup requires too much programming than I can handle. I will try docker and Home Assistans as I run Synology NAS too, and try that setup with my pi’s

I just want something more graphical that this :slight_smile: and something with the possibility to put more stuff in the future in there.

Welcome back :slight_smile:

Blynk is a fairly nice GUI/HMI, but some degree of programming will always be essential for custom projects that do real work. Start small, and learn a bit at a time. I didn’t know any programming when I started with Blynk (I don’t think BASIC, from waaay back when counts :stuck_out_tongue: )

PS, here is a simple Python tutorial with RPi, for reading a temperature sensor like what I think you are using…

Then once you have that figured out, it should be a bit easier to integrate that code into a Blynk Python sketch using SuperChart.

Before you go down the Home Assistant route, why not try a different approach…
Have you ever heard of Node-Red? It’s a graphical programming/workflow system that runs beautifully on an RPI and has a Blynk plug-in. It can access the ports on your RPI (GPIO pins, SPI, I2C etc) and doesn’t need any real programming skills. If you want to write custom functions you can do, but most of the time you can achieve what you want using the existing nodes and additional plug-ins.
There’s a large community of developers who contribute plug-ins (known as ‘Contribs’ in Node-Red speak) and an active Node-Red support forum.

This is what I use as the heart of my home automation system and it’s great. Personally, I don’t attach any sensors directly to the RPI (although that can be done). Instead I use ESP8266/NodeMCU type devices and get them to exchange data with the RPI via MQTT messages. This data can be things like temperature, pressure and humidity readings, or commands to activate relays etc attached to the NodeMCU devices.
Node-Red also has a built-in dashboard which can be used to display data, and provide widgets to control devices. Personally, I don’t like the dashboard, so use Blynk instead.

I recently decided to try exploring a Home Assistant. It has a massive learning curve, and the Docker version is crippled in a way which makes it almost impossible to use. I quickly switched to a conventional install on an RPI4 (which requires you to burn the image files to an SD card rather than do a conventional install from Buster etc) and spent around 3 full days evaluating it. Although it clearly has some nice features, but for me it was too far outside of my comfort zone to be worth the additional investment in time that would be needed to become fully comfortable with it, and migrate my systems to it.

If you want to know more about the way I use Node-Red in our Spanish holiday home then have a read of this…