ESP32 Thing Plus C peripheral modules lose power when COM port is accessed

Hi Everyone,

When I connect to my ESP32 Thing Plus’s COM port via MotionCal (I’m in the process of calibrating an Adafruit LIS3MDL magnetometer) everything but the ESP32 loses power. When I dsconnect via MotionCal, power returns to eveything. When I’m connected to the COM port via Arduino IDE everything has power.

Setup:

PC → 200mm USB cable → ESP32 Thing Plus C → 500mm Qwiic Cable → Sparkfun ZED-F9P module → 50mm Qwiic cable → Adafruit LIS3MDL magnetometer.

Any ideas on how to resolve this would be appreciated!

Thanks :smiley:

I would guess it’s either a setting in Motioncal that needs to be changed (disable auto-reset, or similar?), or the device is browning out (USB can provide ~500mA)

Try hooking up just the F9P and see if it still behaves the same way (or the LIS3MDL); also try using shorter cables

Strange that it works in Arduino IDE…

Now using ESP32 Thing Pus with a 50mm Qwiic cable to the LIS3MDL. Still losing power :frowning:

How do I change the setting you mentioned? I see no option to do so. I’m on Windows 10.

Check IOA0, I suspect something in your code is pulling that low and doing that kills power to the qwiic bus.

I’m not sure what you mean when you say “check IOA0”. I only have pins soldered on 3V3, GND, and 19/POCI, but they’re not connected to anything right now. Power is coming from USB and the LIS3MDL is connected via Qwiic cable.

Here’s my code. Let me know if you see anything problematic. It’s a trimmed down version (to remove the accelerometer and gyro stuff) of imucal_nosave from the Adafruit Sensorlab library.

/***************************************************************************
  This is an example for the Adafruit SensorLab library
  It will look for a supported magnetometer and output
  PJRC Motion Sensor Calibration Tool-compatible serial data

  PJRC & Adafruit invest time and resources providing this open source code,
  please support PJRC and open-source hardware by purchasing products
  from PJRC!

  This "nosave" version does not save any calibration information, which
  means it can be used on boards without an SD card or EEPROM. It sends
  raw IMU data to the serial console to be read by the PJRC MotionCal 
  software (https://www.pjrc.com/store/prop_shield.html) or the Jupyter 
  Notebook in the SensorLab repository:
  https://github.com/adafruit/Adafruit_SensorLab/blob/master/notebooks/Mag_Gyro_Calibration.ipynb.
  
  Written by PJRC, adapted by Limor Fried for Adafruit Industries.
  Modified by Shawn Hymel (January 30, 2022).
 ***************************************************************************/

#include <Adafruit_SensorLab.h>
#include <Adafruit_Sensor_Calibration.h>

Adafruit_SensorLab lab;

Adafruit_Sensor *mag = NULL;
sensors_event_t mag_event;
int loopcount = 0;

void setup(void) {
  Serial.begin(115200);
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens
  
  Serial.println(F("Sensor Lab - IMU Calibration!"));
  lab.begin();

  Serial.println("Looking for a magnetometer");
  mag = lab.getMagnetometer();
  if (! mag) {
    Serial.println(F("Could not find a magnetometer, skipping!"));
  } else {
    mag->printSensorDetails();
  }
}

void loop() {
  if (mag && ! mag->getEvent(&mag_event)) {
    return;
  }
  // 'Raw' values to match expectation of MOtionCal
  Serial.print("Raw:");
  Serial.print(int(mag_event.magnetic.x*10)); Serial.print(",");
  Serial.print(int(mag_event.magnetic.y*10)); Serial.print(",");
  Serial.print(int(mag_event.magnetic.z*10)); Serial.println("");

  // unified data
  Serial.print("Uni:");
  Serial.print(mag_event.magnetic.x); Serial.print(",");
  Serial.print(mag_event.magnetic.y); Serial.print(",");
  Serial.print(mag_event.magnetic.z); Serial.println("");
}

IOA0 is an I/O pin on the ESP23 Thing Plus that controls power to everything on the qwiic bus. Check the schematics to see which pin on the ESP32 it’s on.

You need a multimeter or oscilloscope connected to that pin to see if it’s changing state when you run the software that’s killing power. If it is changing state something in your code or in one of the libraries you’re using is messing with that pin.

You will either need to modify that piece of code or you will need to clip the power wire off the qwiic connector and connect it to another 3.3 volt power source bypassing the 3.3 volt supply that’s on the things qwiic socket.

It might be easier to use another power source than to modify libraries if that’s the cause.

You need to enable the QWICC power from the sketch.

See https://learn.sparkfun.com/tutorials/es … t-sketches and then select the stetch : I2C_Scanner_PowerControl

Thanks everyone,

Using paulvha’s suggestion:

Using [that example I took:

Lines 7-9

Lines 16-19

Line 25

and inserted them in the appropriate sections of the “imucal” example of the Adafruit Sensor Lab library (Adafruit Sensor Lab → calibration → imucal)

I put line 25 at the beginning and end of the loop section.](SparkFun_Thing_Plus_ESP32_WROOM_C/Firmware/Test Sketches/I2C_Scanner_PowerControl/I2C_Scanner_PowerControl.ino at main · sparkfun/SparkFun_Thing_Plus_ESP32_WROOM_C · GitHub)

good to hear it works.

There is actually no need to line 25 at the beginning & end of the loop. That was just to demonstrate. Enable the QWIIC power only needs to be set once and it is already done in ‘line 17’ in setup.