MicroMod Weather Station Carrier Board - rain switch resets board

Now that I got past the signup, I can move this from [Twitter to here :smiley:

Setup

I’m trying to build a weather station with the Weather Station Carrier Board and the ESP32 MicroMod controller. The end goal is to have this station set up to send data via MQTT. I’m writing all my code using PlatformIO ( it lets me write and build from Emacs! ), which can be found [here. I’ve added support for the ESP32 MicroMod to PlatformIO with two different PRs – [one for PlatformIO here, and [one for the espressif/arduino-esp32 repo here. Everything compiles and runs on the board just fine – I can get readings from almost all the sensors and can send info over Wifi.

Except for the rain sensor.

Reset By Rain

I finally got around to testing the rain sensor this week, and ran into an interesting problem: every time the rain switch triggers, it resets the board. Same as if I had pressed the reset button. Kind of an issue here in Vancouver, BC ( well, usually, we’ve had an unusually dry summer this year ).

Is this an issue with the Weather Carrier Board + ESP32 MicroMod combo? Just the carrier board? Just the ESP32 MicroMod?

What I’ve Tried

When I initially started coding this I had set up PlatformIO to use the ESP32 Thing, which worked fine for compiling and uploading and reading the sensors. The pin definitions didn’t work but that was easy to work around. When I ran into the “rain reset” issue, that’s when I dived into trying to get PlatformIO set up to use the board config from [the SparkFun ESP32 v1.0.1 tarball.

However, I got that working ( hence the two PRs to add proper support for the ESP32 MicroMod to those two repos ), and even with PlatformIO using the (as far as I can tell) proper settings the board still resets when the rain switch is triggered.

I don’t have any other MicroMod controllers I could use to check, so that’s out for now. A visual inspection of both the carrier board and the ESP32 board don’t show any obvious defects or solder mistakes – but I’m not exactly an expert on either of these boards so I may have missed something.

Any suggestions on what I should do? Anything I can do to test the board, or figure out why the rain switch triggers the reset?](https://github.com/sparkfun/Arduino_Boards/raw/main/IDE_Board_Manager/sparkfun-esp32-1.0.1.tar.bz2)](Add SparkFun ESP32 MicroMod microcontroller by seanhagen · Pull Request #5556 · espressif/arduino-esp32 · GitHub)](Add SparkFun ESP32 MicroMod by seanhagen · Pull Request #605 · platformio/platform-espressif32 · GitHub)](https://github.com/seanhagen/weather_station)](x.com)

We haven’t had any reports of this happening, it could be a code issue that’s causing it.

Not sure how you have that pin setup. In our example code we have the rain pin setup as an input pullup but the board itself has a pullup resistor and there’s a chance that could be an issue. You might try just setting the pin up as in input without pullup and see if that helps.

We’ve also not tested anything on platform.io, you might try the Arduino IDE and see if that makes the issue go away.

The code I’m using to set up the rain switch is basically a modified version of [the “MM_WeatherMeter_Alt.ino” example in the MicroMod Weather Carrier Board repo.

In a header I’ve got:

#define RAIN_PIN 27

In some setup code I’m calling:

  // input from wind meters rain gauge sensor
  pinMode(RAIN_PIN, INPUT_PULLUP);

  // attach external interrupt pins to IRQ functions
  attachInterrupt(RAIN_PIN, rainIRQ, FALLING);

And that rainIRQ function is copied from the example in the repo.

I’ll try changing INPUT_PULLUP to just INPUT, and I’ll also try out the example using the Arduino IDE later today and see if that solves the issue. If setting the pin mode to input fixes it, awesome! If it’s a PlatformIO vs Arduino IDE thing that’s going to suck, as I’m really not a fan of having to switch to another IDE to get work done :(](MicroMod_Weather_Carrier_Board/Examples/MM_WeatherMeter_Alt/MM_WeatherMeter_Alt.ino at master · sparkfun/MicroMod_Weather_Carrier_Board · GitHub)

I tested with the [MM_Weather_CB_Test in the Arduino IDE and it worked. Tested the rain sensor, no resets.

So now I’ve got to figure out why this is happening, because as I mentioned I’m not a fan of the Arduino IDE when I could be using Emacs instead :D. If I’m able to sort out what the issue is I’ll let you know!](MicroMod Weather Carrier Board Hookup Guide - SparkFun Learn)

I think I figured out what was causing the resets, but not why:

In the board JSON for PlatformIO, I had the following:

"extra_flags": [
      "-DESP32_MICROMOD",
      "-DBOARD_HAS_PSRAM",
      "-mfix-esp32-psram-cache-issue"
],

I replaced that with:

"extra_flags" : "-DESP32_MICROMOD"

And it seems to work fine when I test the rain sensor, with a basic blink sketch or a more complicated one ( like the brains of the weather station I’m building ). I guess one of those two flags caused the board to reset when the rain switch got toggled.

I am running into the same issue. I am using the MM_WeatherMeter_alt.ino in the Arduino IDE. The fix that I was able to do was changing the rainHour[60] to a non-volatile variable. I essentially trimmed the code back till I stopped getting the reset then figured out it was the volatiles that were causing it. The code still works by changing the variable type by removing the volatile tag on just the rainHour[60]

FWIW - I was also having the same problem, and changing the rainHour[60] variable to remove the volatile bit worked for me as well