I'm making a js-based clock on a Raspberry Pi. It runs in chromium & displays the time & weather (using simpleWeather
). I've connected a ds18b20
and I want to display the temperature too. The device is working, I can read the temperature from the command line but I want to read it and display it in my js script.
I'm using w1temp
. I'm getting the require part wrong and not managing to load w1temp properly, but I don't understand where I'm going wrong. Could someone please point me in the right direction?
I'm using require like this:
require(['../../node_modules/w1temp'], function (W1Temp) {
});
Then
setInterval( function () {
W1Temp.getSensor('28-0414609d26ff').then(function (sensor) {
// get inside temperature
var temp = sensor.getTemperature();
$("#inside_temp").html(temp);
});
},1000);
In doing this I get a js error when I load the page & my temperature isn't displayed. The error is:
Not allowed to load local resource:
home/pi/node_modules/w1temp.js
I guess this is because their isn't a home/pi/node_modules/w1temp.js
, but what do I require to get the temp out of w1temp?
I know I'm making a simple error based on a simple misunderstanding, & I've read the w1temp docs but I can't see where I'm going wrong. I hope someone can point me in the right direction.