RP2040 current sensing

I am trying to use the inline current_sense example provided by in the SimpleFOC library using the Arduino IDE but am receiving many error codes that are preventing an upload. I’ve attached a .png file that includes the error codes, most if not all are due to the included rp2040_mcu.cpp file.

It sounds like you are declaring some variables in the wrong order/place, since “XXX was not declared in this scope” is the main error message. If you share your code and the IDE you’re using, maybe we can figure out what’s going on.

Hey @Whaley,

Which version of SimpleFOC are you using? Is this on the newest version? I think this problem has been fixed in the newest version…

And which RP2040 Arduino framework are you using, is it the official one?

I am using the Arduino IDE, and SimpleFOC version 2.3 (latest release) and the official RP2040 framework. I’ve attached the source code below, I only care about the DC current value, so I have commented out everything related to the phase currents.

 * Testing example code for the Inline current sensing class
#include <SimpleFOC.h>

// current sensor
// shunt resistor value
// gain value
// pins phase A,B, (C optional)
InlineCurrentSense current_sense = InlineCurrentSense(0.01f, 50.0f, A0, A2);

void setup() {
  // initialise the current sensing

  // for SimpleFOCShield v2.01/v2.0.2
  current_sense.gain_b *= -1;
  Serial.println("Current sense ready.");

void loop() {

    //PhaseCurrent_s currents = current_sense.getPhaseCurrents();
    float current_magnitude = current_sense.getDCCurrent();

    // Serial.print(currents.a*1000); // milli Amps
    // Serial.print("\t");
    // Serial.print(currents.b*1000); // milli Amps
    // Serial.print("\t");
    // Serial.print(currents.c*1000); // milli Amps
    // Serial.print("\t");
    Serial.println(current_magnitude*1000); // milli Amps

I will check it again…

Thanks for reporting it