Connecting esp32-S2 dev board to DS3231 clock

RobLatour
Posts: 9
Joined: Mon Dec 30, 2019 4:23 am

Connecting esp32-S2 dev board to DS3231 clock

Postby RobLatour » Sun Jul 05, 2020 7:54 pm

I have an expressif esp32-s2-wroom dev board and I would very much appreciate some help with respect to connecting it to an external battery-powered clock (DS3231).

More specifically, which pins on the board to connect the clock's SDA and SC1 pins to?

On an esp32 dev kit 1, I connected them to D21 (I2C SDA) and D22 (I2C SLC) respectfully and that worked fine.

Not sure how I set up for the equivalent on the esp32-s2-wroom dev board.

There is some related documentation here: https://docs.espressif.com/projects/esp ... s/i2c.html under 'Customized Configuration'. However, unfortunately, I don't really 'get it' and I can't seem to find other documentation or examples.

The DS3232 also has pins labeled 32K and SQW but they aren't needed for just accessing the basic clock functionality (setting and retrieving time) which I would like to do.

Again, would very much appreciate some additional guidance.

ESP_Sprite
Posts: 3910
Joined: Thu Nov 26, 2015 4:08 am

Re: Connecting esp32-S2 dev board to DS3231 clock

Postby ESP_Sprite » Mon Jul 06, 2020 8:41 am

The ESP32-S2, like the ESP32, doesn't have dedicated I2C pins; you use route any (output-capable, but on the -S2 they all are) GPIO that is not e.g. already occupied by the flash.

RobLatour
Posts: 9
Joined: Mon Dec 30, 2019 4:23 am

Re: Connecting esp32-S2 dev board to DS3231 clock

Postby RobLatour » Mon Jul 06, 2020 11:10 pm

Thank you but I really don't understand.

Are you saying I can use any two GPIO pins?

If yes, how do I tell the ESP32-S2 dev board ( ESP32-S2-Saola-1) which GPIO I am using for SDA and SCL?

For example, on a ESP32 Dev Kit 1, GPIO21 is SDA and GPIO22 is I2C SCL - so I just use those two pins.

But I don't know which GPIOs to use on the ESP32-S2 dev board, and if I can use any two what additional coding in my Arduino sketch is required to identify the GPIOs I use.

I am working with this library: https://github.com/JChristensen/DS3232RTC

Thanks to anyone that can help further.

usulrasolas
Posts: 26
Joined: Tue Jun 09, 2020 5:27 pm

Re: Connecting esp32-S2 dev board to DS3231 clock

Postby usulrasolas » Mon Jul 06, 2020 11:20 pm

I use headers with code blocks like

[Codebox]
#define GPIO_HANDSHAKE 2
#define GPIO_MOSI 9
#define GPIO_MISO 8
#define GPIO_SCLK 10
#define GPIO_CS 21

#ifdef CONFIG_IDF_TARGET_ESP32
#define SENDER_HOST HSPI_HOST
#define DMA_CHAN 2

#elif defined CONFIG_IDF_TARGET_ESP32S2
#define SENDER_HOST SPI2_HOST
#define DMA_CHAN SENDER_HOST

#endif

#define MCP_MCLK_TIMER LEDC_TIMER_1
#define MCP_MCLK_MODE LEDC_LOW_SPEED_MODE
#define MCP_MCLK_GPIO (18)
#define MCP_MCLK_CHANNEL LEDC_CHANNEL_0
#define MCP_MCLK_DUTY (8)
#define MCP_CH_EN[/Codebox]

then point my function the the definitions

ESP_Sprite
Posts: 3910
Joined: Thu Nov 26, 2015 4:08 am

Re: Connecting esp32-S2 dev board to DS3231 clock

Postby ESP_Sprite » Tue Jul 07, 2020 8:43 am

RobLatour wrote:
Mon Jul 06, 2020 11:10 pm
Thank you but I really don't understand.

Are you saying I can use any two GPIO pins?
Yes, you can.
If yes, how do I tell the ESP32-S2 dev board ( ESP32-S2-Saola-1) which GPIO I am using for SDA and SCL?

For example, on a ESP32 Dev Kit 1, GPIO21 is SDA and GPIO22 is I2C SCL - so I just use those two pins.
The I2C pins 'aren't' anything. The hardware does not define any pins as 'i2c pins'.
But I don't know which GPIOs to use on the ESP32-S2 dev board, and if I can use any two what additional coding in my Arduino sketch is required to identify the GPIOs I use.

I am working with this library: https://github.com/JChristensen/DS3232RTC

Thanks to anyone that can help further.
Aaah, you're using Arduino, that explains. Arduino indeed uses a default set of pins for I2C, although I think it is changable by specifying the correct pins in i2cBegin().

By default (as specified in variants/esp32s2/pins_arduino.h):

Code: Select all

static const uint8_t SDA = 8;                                                                             
static const uint8_t SCL = 9;   
So seemingly, SDA and SCL are GPIO8 and GPIO9.

RobLatour
Posts: 9
Joined: Mon Dec 30, 2019 4:23 am

Re: Connecting esp32-S2 dev board to DS3231 clock

Postby RobLatour » Wed Jul 08, 2020 1:42 am

ESP_Sprite: thank you very much, that was exactly what I needed to know - indeed pins 8 and 9 are the two to use.

Who is online

Users browsing this forum: No registered users and 12 guests