JChristensen / DS3232RTC

Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks
GNU General Public License v3.0
392 stars 135 forks source link

processing conflict with Adafruit_NeoPixel library on a an Espressif ESP32-S2-SAOLA-1 dev board #81

Closed roblatour closed 4 years ago

roblatour commented 4 years ago

I am developing with an Espressif ESP32-S2-SAOLA-1 dev board on the arduino platform.

The dev board has a built-in Neo Pixel LED, which can be controlled via the Adafruit_NeoPixel library.

However, for whatever reason, the rtc.get(); command causes the NeoPixel LED to light up bright green.

Other than that your RTC library works absolutely great. Thank you for that!

I have coded a workaround to reset the NeoPixel to the state I need following an rtc.get command. But thought I would report it here all the same. Sample code showing the problem below:

// connect pin 8 on the esp32-s2-SAOLA-1 board to the sda pin on the rtc // connect pin 9 on the esp32-s2-SAOLA-1 board to the slc pin on the rtc

include "DS3232RTC.h" //https://github.com/JChristensen/DS3232RTC

include //https://github.com/adafruit/Adafruit_NeoPixel

DS3232RTC rtc;

define PIN 18 //Pin 18 is used on the ESP32-S2-SAOLA-1 board to address the NeoPixel

define BRIGHTNESS 5

Adafruit_NeoPixel pixels(1, PIN, NEO_GRB + NEO_KHZ800);

enum colours { Off, Red, Green, Blue, Yellow };

void setNeoPixelColour(colours choosenColour) {

byte red, green, blue;

switch (choosenColour) {

case Red:
    red = 255; green = 0; blue = 0;
    break;

case Green:
    red = 0;  green = 255; blue = 0;
    break;

case Blue:
    red = 0; green = 0; blue = 255;
    break;

case Yellow:
    red = 255; green = 255; ; blue = 0;
    break;

case Off:
    red = 0; green = 0; blue = 0;
    pixels.clear();
    break;

default:
    break;
}

pixels.setPixelColor(0, red, green, blue);
pixels.show();

}

//----------------------------------------------------------------

void setup() {

delay(3000);  //saftey delay at start-up

pixels.begin();

pixels.setBrightness(0);
pixels.show();
setNeoPixelColour(Off);
pixels.setBrightness(BRIGHTNESS);

// setup RTC
rtc.begin();

}

void loop() {

setNeoPixelColour(Red);
delay(1000);

setNeoPixelColour(Green);
delay(1000);

setNeoPixelColour(Blue);
delay(1000);

setNeoPixelColour(Yellow);
delay(1000);

    setTime(rtc.get());  // <<< causes the NeoPixel to go bright green

setNeoPixelColour(Red);
delay(1000);

setNeoPixelColour(Green);
delay(1000);

setNeoPixelColour(Blue);
delay(1000);

setNeoPixelColour(Yellow);
delay(1000);

}

JChristensen commented 4 years ago

I don't have that hardware so not able to recreate the issue, etc. Hard to imagine what it could be. The DS3232RTC library just uses standard I2C calls via the Wire library, nothing tricky going on. The ESP32 has a couple I2C interfaces, yes? Maybe it's some sort of pin mapping issue. Sorry I can't be of more help than that. If you do find an actual problem with the library, post code to demonstrate it and we can reconsider.