• Driver module implementation matters... see Edit: towards the bottom of my previous post.

    Unfortunately this is not helpful in explaining what is going on...

    It just seems to me that no measurement / conversion / scratchpad writing takes place after powering up. Verifying the connectivity on the sensor's power line to 3.3V should be checked.

    I would try implement some 'self-monitoring',... for example - you be the judge if it is 'totally out of mind':

    Apply the following changes to

    • the wiring: Place a 180R (180 Ohm Resistor) between 3.3V supply and power line of the sensor, and make a wire connection from power line of the sensor to a free 'sense' pin on your processor board.
    • the code: The 'sense' pin you configure as plain input (or - in a second round - with pulldown) as first in your code. As last in your code you put a setWatch on it with repeat on falling edge option and a function function() { console.log('watch fired'); }. Put all code except the sense pin initialization and first two lines from very first code post into a function which you call startMeasuring (or what ever name you like).

    Upload the code (from within the edit pane) and invoke the function from console by entering startMeasuring(). Doing so, you separate the upload and module load from actual run time (containing potential interference). You may go even a step further and separate the module load from the connect...

    pinMode(A1, "input");
    var ow = new OneWire(A0);
    var sensorMod = require("DS18B20");
    function startMeasuring() {
      var sensor = sensorMod.connect(ow);
      setInterval(function() {
        sensor.getTemp(function (temp) {
          console.log("Temp is "+temp+"°C"); 
        });
      }, 1000);
      setWatch(function(){ console.log('watch fired'); },
          A1, { repeat: true, edge:'falling', debounce:0 });
    }
    

    When the console shows 'watch fired', it is an indicator that power failed... due to a too weak supply... if not, you may weakening/increasingly limiting the supply by increasing the resistor in the powering path to 330R / 470R / 680R / 1K / 2.2K / 3.3K / 4.7k / ... At one point you should get the 'watch fired' message... caused by the sensor performing the power hungry convert / copy to scratch pad operation, tearing/pulling down the power line and getting not enough power anymore - especially when choosing the highest conversion resolution which takes about 3/4 of a second. The 180R in the powering path still allows 1.6[mA] and 3.0V for the sensor when supply - the 3.3V board pin - is 'exactly' 3.3V and able to provide 1.67[mA]. (Did you ever check this 3.3V board pin's properties/abilities/behavior?)

About

Avatar for allObjects @allObjects started