Hi there! I’m new in the usage of blynk, im coming from Cayenne, but the lack of control about the addition of new devices has forced me to seek for another options, thats how I ended up using Blynk.
Now, I would like to present my project and then ask some questions that I have been unable to solve by searching the forums, please feel free to call me whatever you want if my questions have already been answered in other posts.
What I am aiming to achieve is a set of thermometers and relays that control the temperature of a room. In the process of making home-brew beer the management of temperatures is a key part to obtain something drinkable and not some pee-like beverage, so, mainly I would like to see two ds18b20 sensors and control some relays (this is something that will come in the future, first the temps)
The things I’ve done:
Follow this instructions h ttp://docs.blynk.cc/#hardware-set-ups-raspberry-pi and successfully connect to my raspberry pi using my token.
Thats where things got messy, I’m not able to instance the sensor and obtain the temperature by using the example provided in the github README and the code posted by @fisero in the above mentioned post.
To finish my endless set of questions, how do I link the graphs in blynk on my smartphone to the data obtained by the .js file? once I am able to instance the sensor and obtain the numeric value of the temp, I think is by using virtual pins, so i guess I write the themp on V0 for instance, and then get in the blynk graph the V0 pin.
Thanks in advance for such great platform and community
Welcome to Blynk. First of all, you should know that Cayenne used a lot of Blynk open-source code to build their platform, so you came to “the roots”
I can’t recommend anything for the sensor part yet, but I’m sure there are plenty good folks here who know how to resolve it.
You are absolutely right, virtual pins is a concept of the channel between hardware and the app. Basically, you push something from harrdware to Vpin and then set the widget on the app side to the same Vpin, and it creates a channel between these 2 points, where data flows.
I see, I had no idea, their app and web are worst implemented that yours, it is far from smooth, I like your design too, more “materialized”.
Happy to contribute to the origin of everything.
Nice to see that you also take part in the forums.
Cheers!
@raul we use w1temp and DS18B20’s attached to our Pi’s. Works fine but we did find the different options a bit confusing when it came to setting up w1temp (modprobe, edit SD card entries, wiringPi etc).
Our code is classified top secret by the KGB so we can’t publish it here but presumably yours isn’t.
Perhaps if you provide details of what bits of the w1temp guide you followed, which bits you skipped and your code as you have it now someone might be able to point you in the right direction.
Hmm, I had you pegged as MI6… but then since I work for IDK, I could have been mislead
@raul I too wouldn’t mind seeing some code, not that I drink beer (darn gluten) but I am always interested in a little code snatching for use on that elusive RPi/Blynk combo.
I only installed w1temp library and followed the modprobe steps showed in github, no wiringPi installed.
I get an error when running this code:
var blynkLib = require('blynk-library');
var W1Temp = require('w1temp');
var AUTH = 'HERE_COMES_YOUR_TOKEN';
// Setup Blynk (SSL)
var blynk = new blynkLib.Blynk(AUTH);
// Automatically update sensors value every 5 minutes
setInterval(function() {
W1Temp.getSensor('28-0000045c34f2').then(function (sensor) {
// print actual temperature
var temp = sensor.getTemperature();
console.log('Actual temp:', temp, '°C');
//Report it to server
blynk.virtualWrite(0, temp);
});
}, 50000);
Terminal says, filed to instance
Obviously i change 28-0000045c34f2 to the identifier of one of my sensors, and my AUTH var to my token.
Sorry for the delay, above is the code I run with node and throws me a cant get sensor instance error.
Thats something I notice, I also have an arduino one, but without any wifi shield/esp8266, thats why I went with the raspberry to make this little proyect.
So, this is what raspi shows after running the above mentioned code:
pi@raspberrypi:/usr/local/lib/node_modules/blynk-library $ node TestTemp
[ '00-c00000000000', '00-200000000000' ]
(node:907) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Could not set data gpio pin
(node:907) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Cant get sensor instance
pi@raspberrypi:/usr/local/lib/node_modules/blynk-library $ node TestTemp
[ '00-200000000000', '00-a00000000000' ]
(node:922) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Could not set data gpio pin
(node:922) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Cant get sensor instance
Notice that the array of connected devices changes in each call, something that I dont fully understand.
Hope your code is not classified as top secret
Cheers!
I’m not entirely sure wiringPi is required but it’s probably worth installing just for the graphical display of the pin settings.
For reference the 5 minutes is actually 50s in the code extract.
We have some problems with the path on our Pi so all require statements show the full path for example: var W1Temp = require('/opt/nodejs/bin/node_modules/w1temp');
Your path is likely to be different unless you used the latest guide for setting up the Pi as a client for Blynk.
You are missing the pin setting and you should display the sensor address with this code between the require and the setInterval(function(){});
W1Temp.setGpioData(7);
console.log('using BCM GPIO 7, physical pin 26 on a Model B Pi');
W1Temp.getSensorsUids().then(function (sensorsUids) {
console.log('DS18B20 address is: ' + sensorsUids);
})
About the 50 seconds, totally correct, I made a typo.
Will check the rest of your steps as soon as I can, I will update this post once I tested your changes.
Thanks!!
Edit: after placing the full path of the modules, the can´t get sensor instance error and the ids of the sensors keep changing, Anyone knows why they change on each call?
Cheers!
Also, my relays came, already set up and functioning flawlessly, one more problem I faced is the disconnection from the server on raspberry pi, forcing me to run again the command blynk-client.
Will investigate more once I finished the setup of the temperatures.
Cheers!
Really considering removing the sd and making a wipe, to start again everything. Quite reluctant tho, I would’t like to see my problem unsolved after all the process
I just disconnected everything and changed the setGpioData to 24.
I haven’t installed wiringPi.
I will test know and post my results
Cheers
Edit: addresses keep changing in each call, making me impossible to set one in my .js.
This is the output of the command
pi@raspberrypi:/usr/local/lib/node_modules/blynk-library $ sudo node TestTemp
using BCM GPIO 7, physical pin 26 on a Model B Pi
DS18B20 address is: 00-800000000000,00-400000000000
(node:925) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Cant get sensor instance
pi@raspberrypi:/usr/local/lib/node_modules/blynk-library $ sudo node TestTemp
using BCM GPIO 7, physical pin 26 on a Model B Pi
DS18B20 address is: 00-c00000000000,00-200000000000
(node:974) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Cant get sensor instance
pi@raspberrypi:/usr/local/lib/node_modules/blynk-library $
This is my runned code once more
var W1Temp = require('/usr/local/lib/node_modules/blynk-library/node_modules/w1temp');
// turn on gpio pin 13 as W1 power if you want to
// set gpio pin 6 to use as W1 data channel
// if is not set by instructions above (required root permissions)
W1Temp.setGpioData(24);
console.log('using BCM GPIO 7, physical pin 26 on a Model B Pi');
W1Temp.getSensorsUids().then(function (sensorsUids) {
console.log('DS18B20 address is: ' + sensorsUids);
})
// get instance of temperature sensor
W1Temp.getSensor('00-f84000000000').then(function (sensor) {
// print actual temperature
var temp = sensor.getTemperature();
console.log('Actual temp:', temp, '°C');
});