DH22 w/MKR1000 not working

I am really struggling getting the DH22 working with the MKR1000. It seems the serial port just stops or turns off as soon as the program gets to the loop. I used almost identical code with a UNO and it works. Only difference was pins used. Below is a copy of my code. What am I doing wrong?!


#include <dhtnew.h>


DHTNEW mySensor(5);   // ESP 16    UNO 5    MKR1010 5
float TempF;

uint32_t lastTime = 0;

void setup()
{
  while(!Serial);        // MKR1010 needs this
  
  Serial.begin(9600);
  Serial.println(__FILE__);
  Serial.print("DHTNEW_LIB_VERSION: ");
  Serial.println(DHTNEW_LIB_VERSION);
  
  // MKR1010 needs this
   //mySensor.setDisableIRQ(false);

}


void loop()

{
 
  if (millis() - lastTime > 2000)
  {
    lastTime = millis();
    for (int pin = 6; pin < 15; pin++)
    {
      DHTNEW sensor();
      sensor.read();
      TempF = sensor.getTemperature() * 1.8 + 32;
      Serial.print("Humidity");
      Serial.print("  ");
      Serial.print(sensor.getHumidity(), 1);
      Serial.print("Rh");
      Serial.print("  ");
      Serial.print("Temperature");
      Serial.print("  ");
      Serial.print(sensor.getTemperature(), 1);
      Serial.print("C");
      Serial.print("  ");
      Serial.print(TempF, 1);
      Serial.println("F");
    }
  }

  // Do other things here
 }

Remove that line and try again.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.