Hello,
For my project, I am trying to integrate 2 pressure sensors to Raspberry Pi 3 Model B and displaying it in Blynk app using iPhone. I am using Blynk cloud server. The pressure sensor I am using are a BMP180 and BMP085.
My problem is I haven’t be able to display the data from the sensors to my Blynk app.
I have tried tweaking Javascript codes from http://www.instructables.com/id/Raspberry-Pi-Nodejs-Blynk-App-DHT11DHT22AM2302/ to adjust with my BMP180 sensors but I’m not sure how to adjust it further with the Virtual Pins in Blynk.
I am very sorry if this question seems dumb because I’m a total newbie.
This is the snippet of my code:
var Blynk = require('blynk-library');
var BMP085 = require('bmp085-sensor');
var sensor = BMP085({address: 0x77, mode:3, units: 'metric'});
var AUTH = 'a4b6c8e72e7e4e199a7c221333fcb400';
//Setup Blynk
var blynk = new Blynk.Blynk(AUTH);
var V7 = new blynk.VirtualPin(7);
//var v3 = new blynk.VirtualPin(3);
sensor.read(function (err,data) {
//data is { pressure: 1014135.9, temp: 20.5 }
console.log(data);
});
//Automatically update sensor value every 2 seconds
setInterval(function() {
sensor.read(function (err,data){
console.log(data); });
var readout = sensor.read();
blynk.virtualWrite(7, readout);
console.log('Pressure:', readout + 'Hg');
//console.log('Pressure:', readout.pressure.toFixed(1) + 'C');
//console.log('Humidity: ', readout.temperature.toFixed(1) + '%');
}, 2000);
The results:
pi@raspberrypi:~/myCAS $ sudo node k.js
OnOff mode
Connecting to: blynk-cloud.com 8441
{ pressure: 122028.769153819, temperature: 9 }
SSL authorization...
Connected
Authorized
Pressure: undefinedHg
{ pressure: 122016.72138044662, temperature: 9 }
/home/pi/myCAS/node_modules/bmp085-sensor/index.js:145
call(err, {pressure:p,
^
TypeError: call is not a function
at /home/pi/myCAS/node_modules/bmp085-sensor/index.js:145:7
at /home/pi/myCAS/node_modules/bmp085-sensor/index.js:78:11
at Immediate.<anonymous> (/home/pi/myCAS/node_modules/i2c/lib/i2c.coffee:85:9)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
I would be glad for any assistance and help from experienced Blynkers. Thanks!