You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • You can't just replace the pinMode(ht.pin,'input_pullup'); with a digitalPulse (which it seems you've done). It'll mean the DHT22 is fighting against the Espruino board to pull the signal line low and something might get damaged.

    As far as I can tell, the marker isn't fired late. It should immediately set the pin low, then set it to 'input_pullup' after 1ms. It then waits 5ms for the response.

    My guess is that on ESP8266, it often messes up the timing (maybe WiFi needs to process something for a few ms) and executes the pinMode and the other timeout right after each other, so there is no time for the result to appear.

    I guess you could work around this by just nesting the timeouts?

      setTimeout(function() {pinMode(ht.pin,'input_pullup');},1);
      setTimeout(function() {
    

    to:

      setTimeout(function() {
        pinMode(ht.pin,'input_pullup');
        setTimeout(function() {
        // ...
        }, 6);
      },1);
    
About

Avatar for Gordon @Gordon started