So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By i7i5
#62745 Hi there,
I try to build a solution that wateres my plants based on their humidity. Therefore I first used an UNO, till I wanted to expand it with Wifi. I bought a Wemos D1 mini that is based on an ESP8266, but now parts of my code doesn't work anymore.
As humidity sensor I use the following sensor: http://www.mikrocontroller.net/topic/335407 and I try to fetch the information with interrupts. The following code worked on the UNO, but doesn't with the ESP:
Code: Select allvolatile unsigned int pulse;
void setup()
{
   // ESP > 115200
   Serial.begin(9600);
}

void loop()
{
    interrupt(0);
    Serial.println(pulse);

    delay(1000);

    interrupt(1);
    Serial.println(pulse);

    delay(2000);
}

void count()
{
  pulse++;
}

void interrupt(int pin)
{
      pulse = 0;
      attachInterrupt(pin, count, RISING);
      delay(20 * 10);
      detachInterrupt(pin);
      pulse = pulse / 20;
}


The problem is, that the wdt resets with the error code 4 and I dont know how to avoid that. I basically want to get the humidity from this sensor.
I already tried:
- deactivate wdt with ESP.wdtDeactivate()
- comment out the delay, but the result is always 0
- comment out detachInterrupt
- added attachInterrupt into setup

Has anyone a clue how to get this work on ESP?

Thanks a lot!