Display Power Expander Battery Level to LCD

I am trying to display my power expander battery voltage onto my LCD screen, with this code:

clearLCDLine(0);			//Clear LCD Lines
clearLCDLine(1);

//Display (Primary) Battery Voltages
displayLCDString(0, 0, "ShooterBat:");
sprintf(ShooterBat,"%1.2f%c", (SensorValue[Expander]/70), 'V');	//Builds Value Displayed
displayNextLCDString(ShooterBat);

//Short delay for refresh rate
wait1Msec(100);

However, RobotC tells me that there is an error in my code. When I switched out


sprintf(ShooterBat,"%1.2f%c", (SensorValue[Expander]/70), 'V');

to


sprintf(ShooterBat,"%1.2f%c", (nImmediateBatteryLevel/1000), 'V');

the code works fine. Any ideas why the code for power expander isn’t working?

Thanks

Have you tried SensorValue[in1] (or whichever port the power expander status line is plugged into)?

You will also need to change the scale factor from 70 to 280. When the wiki page was created it was assumed that analog sensor readings were all 10 bit resolution, with current versions of ROBOTC and the cortex everything is 12 bit, ie. numbers are 4 x larger than the wiki page expected. Also check you power expander version, look on the bottom for its revision, depending on the age you may need to use the alternate scale factor, it’s all explained on the wiki.