Best solution for ESP32 + Neopixel and battery life

cybergogo
Posts: 3
Joined: Tue Jan 29, 2019 5:54 pm

Best solution for ESP32 + Neopixel and battery life

Postby cybergogo » Tue Jan 29, 2019 5:56 pm

Hi All,
I'm working on a little project involving an ESP32 devboard, powered on 4*AA 2400mA NiMH batteries, and equipped with neopixels (12 of them), and a capacitive soil sensor.

The idea is simple, have the best autonomy with those components. In order to do so, the ESP32 only wakes once every hours, make a soil humidity measurement, the leds light up with a color corresponding with the result obtained, the ESP send the result via wifi, and goes deepsleep for an hour, etc, etc,...
I've already replaced the onboard AMS1117 with a more efficient and capable AP2114H-3.3TRG1 LDO. So i don't burn that much current in deepsleep. I've also turned the USB IC off.

Now, from what i can see, the neopixels (WS2812B) have some pretty high quiescent current when OFF. Have tried to use a N-channel irlb8721pbf mosfet on the ground side. But weirdly it stills burns energy.

So i was wondering if you had any idea/proposition in order to solve that issue?

Thanks in advance !

boarchuz
Posts: 559
Joined: Tue Aug 21, 2018 5:28 am

Re: Best solution for ESP32 + Neopixel and battery life

Postby boarchuz » Wed Jan 30, 2019 4:03 am

Drive the data in pin HIGH on sleep.

Code: Select all

//on wakeup
rtc_gpio_hold_dis(rgb_data_pin);
//on sleep
digitalWrite(rgb_data_pin,HIGH);
rtc_gpio_hold_en(rgb_data_pin); //keep it high in deep sleep
I guess you'll need to make sure it's a RTC GPIO.

cybergogo
Posts: 3
Joined: Tue Jan 29, 2019 5:54 pm

Re: Best solution for ESP32 + Neopixel and battery life

Postby cybergogo » Wed Jan 30, 2019 10:19 am

boarchuz wrote:
Wed Jan 30, 2019 4:03 am
Drive the data in pin HIGH on sleep.

Code: Select all

//on wakeup
rtc_gpio_hold_dis(rgb_data_pin);
//on sleep
digitalWrite(rgb_data_pin,HIGH);
rtc_gpio_hold_en(rgb_data_pin); //keep it high in deep sleep
I guess you'll need to make sure it's a RTC GPIO.
Thank you for this remark.

Are those commands working on arduino IDE or ESD-IDF?

boarchuz
Posts: 559
Joined: Tue Aug 21, 2018 5:28 am

Re: Best solution for ESP32 + Neopixel and battery life

Postby boarchuz » Wed Jan 30, 2019 1:46 pm

Well they're not 'Arduino' functions but ESP-IDF functions are accessible within the Arduino framework. They will work fine in Arduino IDE, for example.

I forgot to mention you'll need this though: #include "driver/rtc_io.h"

cybergogo
Posts: 3
Joined: Tue Jan 29, 2019 5:54 pm

Re: Best solution for ESP32 + Neopixel and battery life

Postby cybergogo » Mon Feb 04, 2019 3:13 pm

boarchuz wrote:
Wed Jan 30, 2019 1:46 pm
Well they're not 'Arduino' functions but ESP-IDF functions are accessible within the Arduino framework. They will work fine in Arduino IDE, for example.

I forgot to mention you'll need this though: #include "driver/rtc_io.h"
Just tried with your advice on GPIO12, no change. With 12 ws2812b neopixels i get 78mA power usage when all leds ON at 50% brightness, 7mA when all OFF.

Here is my test-code:

Code: Select all

#include <Arduino.h>
#include "driver/rtc_io.h"
#include "NeoPixelBus.h"
const uint16_t PixelCount = 12; // this example assumes 3 pixels, making it smaller will cause a failure
const uint8_t PixelPin = 12;    // make sure to set this to the correct pin, ignored for Esp8266
const uint8_t mosfetLED = 22;
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
#define colorSaturation 128
RgbColor green(0, colorSaturation, 0);
RgbColor black(0);

void setup()
{
  Serial.begin(115200);
  Serial.println("Initializing...");
  pinMode(mosfetLED, OUTPUT);
  digitalWrite(mosfetLED, HIGH);
  strip.Begin();
  strip.Show();
}

void loop()
{
  Serial.println("LEDS ON");
  digitalWrite(mosfetLED, HIGH);
  rtc_gpio_hold_dis(GPIO_NUM_12);

  for (int a = 0; a < PixelCount; a++)
  {
    strip.SetPixelColor(a, green);
    strip.Show();
  }

  delay(1000);

  for (int a = 0; a < PixelCount; a++)
  {
    strip.SetPixelColor(a, black);
    strip.Show();
  }

  digitalWrite(mosfetLED, LOW);
  digitalWrite(PixelPin, HIGH);
  rtc_gpio_hold_en(GPIO_NUM_12);
  Serial.println("LEDS OFF");
  delay(2000);
}
Any other idea? (BTW, had to call GPIO_NUM_12 instead of PixelPin because the function didn't like it as an argument).

boarchuz
Posts: 559
Joined: Tue Aug 21, 2018 5:28 am

Re: Best solution for ESP32 + Neopixel and battery life

Postby boarchuz » Sun Feb 10, 2019 12:44 pm

That looks to be about the same as what I'm doing.

I'll have a think, but my first immediate thoughts are:

-Careful with pin 12. If you're using a Wrover, 12 is a strapping pin for internal ldo. In that case, you should be isolating it before sleep to reduce leakage. Use a different pin, and add the isolate code (something like "rtc_gpio_isolate(GPIO_NUM_12)", look it up).

-Do you have an external pulldown resistor on the MOSFET gate? Add one.

-And just to be clear, you have tested the sleep current with a basic deep sleep example and all LEDs disconnected, right? What was the current in that 'ideal' situation?

Who is online

Users browsing this forum: No registered users and 48 guests