MS8607 setI2Cports for ESP32C3 Dev Board

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
waszee
 
Posts: 2
Joined: Sun May 21, 2023 2:16 pm

MS8607 setI2Cports for ESP32C3 Dev Board

Post by waszee »

I am trying to run the MS8607 test examples using the Arduino IDE. My microcontroller is an ESP32-C3-DevKitM-1U. It has one available I2C port using port 5 for the SDA line and port 6 for the CLK. I found that if I select the "ESP3C3 DEV Board" as my attached board, I can download to it but have problems finding the attached sensor. I tried several of the other available selections for ESP C3 chips but none worked better and several just crashed.

If I do a simple I2C detect sketch using wire.begin(5,6) instead of the normal wire.begin(), I can detect the MS8607 sensors for humidity(x40) and pressure/temperature(x76). But if I run the MS8607 simple test example I get the "MS8607 not found!" message. I suspect the program is looking at another set of ports for the I2C lines by default. There are several ESP32C3 boards that use a different set of ports. I would like to modify the program but do not know where to look or how best to tell the MS8607 library or the test sketch which ports to use for my dev board. The sketch just calls MS8607.begin() to get started. I did not see a wire.begin() in the MS8607.h or MS8607.c files. Any suggestions would be appreciated. I suspect this might be a fairly common problem for MS8607 users or ESP microcontrollers using sensors.

User avatar
waszee
 
Posts: 2
Joined: Sun May 21, 2023 2:16 pm

Re: MS8607 setI2Cports for ESP32C3 Dev Board

Post by waszee »

Well spent a lot time trying to figure the out solution which was in front of my face and clear to my mind after writing the post. Just needed to add Wire.begin(5,6) to the setup. The sketch should probably be modified to use something like:
#define SDA 5 // I2C data port to use or somehow pick up the sensor board defaults
#define CLK 6 // I2C clock port to use
and then add Wire.begin(SDA, CLK);
Maybe this post will help somebody. It was not obvious to me this would work but apparently does not begin in the hidden files if already begun at the beginning.
/*....*/
#include <Adafruit_MS8607.h>
#include <Adafruit_Sensor.h>

Adafruit_MS8607 ms8607;
void setup(void) {
Serial.begin(115200);
Wire.begin(5,6);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens

Serial.println("Adafruit MS8607 unified sensor test!");

...// program now runs and sensor returns Humidity, Temperture, and Pressure as hoped,

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”