M5Stamp C3 - I2C interface
-
Does the M5Stamp C3 have an I2C interface? I do not see any reference to it on the pinout.
-
-
Thank you, that is good news.
Now I just have to find out how to configure and access it from the Arduino IDE :) -
@didier9 said in M5Stamp C3 - I2C interface:
Now I just have to find out how to configure and access it from the Arduino IDE :)
Good luck! I've had a dilly of a time trying to consistently get something (useful!) loaded to the device. Generic Micropython for ESP32 doesn't work, the generic Micropython builds for the ESP32-C3 don't work, not does building the package from scratch and loading it. I thought perhaps it was faulty, but I did get the below sketch to load and run, giving me functional serial output...so I know it's not dead, but I'm glad I bought multiple devices.
Examples for STAMP-C3 -> ESP32 -> ChipID -> GetChipID
FYI, on the STAMP-PICO, I used the below in Arduino to run I2C on the Grove port, to talk with an adapter cable to Adafruit StemmaQT sensors. Obviously it doesn't DO anything, but it's what was required to use specific pins for I2C.
#include <Wire.h>
// Declare alternate I2C pins
#define I2C_SDA 32
#define I2C_SCL 33
void setup(void) {// Initialize I2C using alternate pins
I2CMS.begin(I2C_SDA, I2C_SCL, 400000);
} -
@mlindholm I appreciate your posting this, but I'm unable to make it work. First off:
I2CMS.begin()is not actually a thing? Unless you're importingI2CMSfrom somewhere I'm not aware of?I've tried with
#define I2C_SDA 8 // pin 8 #define I2C_SCL 7 // pin 7 setup(){ Wire.begin(I2C_SDA, I2C_SCL); }But I'm still unable to read from the I2C device. I've got other stuff working on the board (like a fan-control, and a water pump) but I2C and Servos are steadfastly refusing to function.
Ideas?
dg
-
Hello @davidgs
Hmm, I can scan the I2C bus just fine using port A (GPIO0 and GPIO1):
Wire.begin(GPIO_NUM_1, GPIO_NUM_0);I2C requires pull-up resistors on both lines. GPIO8 already has a 10k pull-up resistor. Did you add a pull-up resistor to GPIO7 as well? Some I2C slave devices might already have pull-up resistors in place tough.
Edit: I've just tried with GPIO7 and GPIO8. The I2C scan works with those two GPIOs for me as well.
Thanks
Felix -
@felmue @mlindholm
I recently had the same problem with I2C on an M5STAMP C3U.
The appropriate solution seems to be the @mlindholm one, but its sample code was a bit incomplete
Here is a working example in the context of a DS3231 RTC
A TwoWire structure needs to be inititalised specifically, then referenced by the used I2C library (if any ; RTC library in my case).
No need for pullup resistor (in my case)#include <Wire.h>
// Declare alternate I2C pins
#define I2C_SDA 5
#define I2C_SCL 4// Setup the TwoWire instance (static memory !)
TwoWire I2CM5 = TwoWire(0);void setup ()
{
...
// Initialise the TwoWire instance
I2CM5.begin(I2C_SDA, I2C_SCL, 400000);// Ask the library to use this setting
// (most I2C libraries accept a TwoWire object as argument of begin)
rtc.begin(&I2CM5);
...