Code Monkey home page Code Monkey logo

Comments (2)

Opulence avatar Opulence commented on September 25, 2024 1

Say please... I can't give you the exact answer because it requires time and you need to know how to handle the sensors output result. ...but, please find below an example implementation for a node.js 1-wire sensor. A ds18b20 temperature sensor to be exact.

function readTemp(callback){
fs.readFile('/sys/bus/w1/devices/28-00000400a88a/w1_slave', function(err, buffer)
{
if (err){
console.error(err);
process.exit(1);
}

  // Read data from file (using fast node ASCII encoding).
  var data = buffer.toString('ascii').split(" "); // Split by space

  // Extract temperature from string and divide by 1000 to give celsius
  var temp  = parseFloat(data[data.length-1].split("=")[1])/1000.0;

  // Round to one decimal place
  temp = Math.round(temp * 10) / 10;

  // Add date/time to temperature
var data = {
        temperature_record:[{
        unix_time: Date.now(),
        celsius: temp
        }]};

  // Execute call back with data
  callback(data);

});
};

Hope this helps you on your way. All you need to do is modify the code above and write the socket.io adapters and views. If you're lucky you might find your 1-wire sensors already implemented through the npm. ...also you must run 'sudo mod-probe w1-gpio' and 'sudo mod-probe w1-therm' to enable 1-wire drivers. Sorry I couldn't be of more help.

from heimcontrol.js.

NicoJuicy avatar NicoJuicy commented on September 25, 2024

Respect for @Opulence ! Because how maverik23 asks his question is just plain rude, i wouldn't have answered him :) !

from heimcontrol.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.