upm icon indicating copy to clipboard operation
upm copied to clipboard

ds18b20 issue

Open cristina21r opened this issue 6 years ago • 5 comments

var sensor = new sensorObj.DS18B20(0); ^ Trying to run this code:

var sensorObj = require('jsupm_ds18b20');

/************** Main code **************/

console.log("Initializing...");

// Instantiate an DS18B20 instance using the default values (uart 0) var sensor = new sensorObj.DS18B20(0);

console.log("Found", sensor.devicesFound(), "device(s)"); console.log("");

if (!sensor.devicesFound()) { process.exit(1); }

// update and print available values every 2 seconds setInterval(function() { // update our values for all of the detected sensors sensor.update(-1);

// we show both C and F for temperature for the sensors
for (var i=0; i<sensor.devicesFound(); i++)
{
    console.log("Device:", i, "Temperature:", sensor.getTemperature(i),
                "C /", sensor.getTemperature(i, true), "F");
}

console.log();

}, 2000);

process.on('SIGINT', function() { sensor = null; sensorObj.cleanUp(); sensorObj = null; console.log("Exiting..."); process.exit(0); });

And i get this error:

Error: Illegal arguments for construction of _exports_DS18B20 at Error (native) at Object. (/server/ds18.js:9:14) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:441:10) at startup (node.js:139:18) at node.js:968:3

Some help??

cristina21r avatar Mar 14 '18 00:03 cristina21r

Hi @cristina21r, you need to use an external circuit with the ds18b20 sensor and it only works on UART pins. There's a handy diagram in our known limitations section and you might find some additional details here: #421.

Propanu avatar Mar 14 '18 23:03 Propanu

Were you able to get it to work?

Propanu avatar May 25 '18 18:05 Propanu

No..still no luck

cristina21r avatar May 26 '18 06:05 cristina21r

and I tried what you told me

cristina21r avatar May 26 '18 06:05 cristina21r

What board are you trying this on, do you get any error messages from MRAA in the system log (journalctl)?

Propanu avatar May 28 '18 01:05 Propanu