• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Roomtemperature with DS18B20

Scheduled Pinned Locked Moved Solved Troubleshooting
11 Posts 4 Posters 6.9k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    Chiggo
    last edited by Jul 6, 2016, 3:04 PM

    Thank you for fast reply.

    I will give it a try tomorrow and check if i get it.
    My first steps in JS :sweat_smile:

    1 Reply Last reply Reply Quote 0
    • C Offline
      Chiggo
      last edited by Jul 7, 2016, 9:46 AM

      Spend some time to figure out what you mean, but i stuck again.
      Now at this point picture

      Here is the MMM-Temperature.js

      Module.register('MMM-Temperature', {
      
              defaults: {
                      prependString: 'Raumtemperatur: '
              },
      
      
              start: function() {
                      this.temperature = 'fetching...';
                      this.sendSocketNotification('CONNECT');
              },
      
      
              socketNotificationReceived: function(notification, temp) {
                  if (notification === 'TEMPERATURE') {
                      this.temperature = temp;
                      this.updateDom();
                  }
              },
      
      
              // Override dom generator.
              getDom: function() {
                      var wrapper = document.createElement("div");
                      wrapper.innerHTML = this.config.prependString + this.temperature;
                      return wrapper;
              },
      
      });
      

      And here is the node_helper.js

      var NodeHelper = require("node_helper");
      var sensor = require('ds18x20');
      
      
       module.exports = NodeHelper.create({
              start: function function_name () {
                      var self = this;
                      setInterval(function() {
                              self.sendTemperature();
                      }, 10000);
              },
      
      
              sendTemperature: function() {
                      var self = this;
                      var temp = sensor.get('28-04163746c8ff');
                      self.sendSocketNotification('TEMPERATURE', temp);
              },
       });
      

      It seems that the MMM-Temperature module is not trying to call the node_helper.js
      Not sure why it doesn’t. Or even if, i don’t know why the node_helper.js doesn’t work.

      Maybe this has something to do with the "sendSocketNotification(‘CONNECT’) ???
      It’s never mentioned in the node_helper.

      1 Reply Last reply Reply Quote 0
      • C Offline
        Chiggo
        last edited by Jul 8, 2016, 9:51 AM

        It works!

        after testing some things PM2 didn’t work anymore, so i recovered from a backup, installed the drivers for the DS18B20 again, copied the scripts back, restarted and it works.

        Don’t know why and how, but it does :smile:

        Solved!

        P 1 Reply Last reply Jul 16, 2016, 7:16 PM Reply Quote 0
        • P Offline
          Phate @Chiggo
          last edited by Jul 16, 2016, 7:16 PM

          @Chiggo

          This sounds awesome…

          Is this downloadable from github?

          1 Reply Last reply Reply Quote 0
          • C Offline
            Chiggo
            last edited by Jul 22, 2016, 1:44 PM

            @Phate

            No, it’s not available on GitHub. But with the hints from @MichMich it was pretty easy to realize.

            To load the drivers for the DS18B20 I followed these instructions https://www.kompf.de/weather/pionewiremini.html

            To get the DS18B20 working with node.js I installed this https://www.npmjs.com/package/ds18x20

            And finaly I edited the scripts of the systemtemperature-module and it works.

            Step-by-Step

            • Add this line to your /boot/config.txt
            dtoverlay=w1-gpio,gpiopin=4,pullup=on
            
            • Add to your /etc/modules following and reboot the Pi
            w1-gpio pullup=1 
            w1-therm
            
            • Note the ID of your sensor (go to /sys/bus/w1/devices and list the files, the ID should look something like this 28-04163746c8ff
            • Got to /MagicMirror/modules and create a folder named MMM-Temperature
            • Create a file named MMM-Temperature.js and copy the code from my post for this script
            • Create a file named node_helper.js and copy the code from my post and change the ID of my sensor to yours (it’s in line 16)
            • Register this module in your /MagicMirror/config/config.js
            • Restart your MM and you are done :)

            Hope I could help. Let me know if it works.

            P 1 Reply Last reply Jul 22, 2016, 2:05 PM Reply Quote 1
            • P Offline
              Phate @Chiggo
              last edited by Phate Jul 22, 2016, 2:06 PM Jul 22, 2016, 2:05 PM

              @Chiggo

              Mate. That’s just awesome.

              Few worry spots but sure I can make that happen.

              I made sure to order the same temp module so hopefully I shouldn’t have trouble.

              Thanks mate. Awesome.

              May have questions tho so will yell out of i do when eBay comes thru lol

              Thanks again

              1 Reply Last reply Reply Quote 0
              • ? Offline
                A Former User
                last edited by Jan 1, 2017, 6:44 PM

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • K Offline
                  Kristianson
                  last edited by May 11, 2017, 2:38 PM

                  Excellent! Thanks for the code above, worked beautifully… :-)

                  1 Reply Last reply Reply Quote 0
                  • 1
                  • 2
                  • 1 / 2
                  • First post
                    Last post
                  Enjoying MagicMirror? Please consider a donation!
                  MagicMirror created by Michael Teeuw.
                  Forum managed by Sam, technical setup by Karsten.
                  This forum is using NodeBB as its core | Contributors
                  Contact | Privacy Policy