SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions about carrier boards have here!
User avatar
By seanhagen
Now that I got past the signup, I can move this from Twitter to here :D


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?
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, 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:
Code: Select all
#define RAIN_PIN 27
In some setup code I'm calling:
Code: Select all
  // input from wind meters rain gauge sensor

  // 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 :(
I think I figured out what was causing the resets, but not why:

In the board JSON for PlatformIO, I had the following:
Code: Select all
"extra_flags": [
I replaced that with:
Code: Select all
"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]
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum