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

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

//Short delay for refresh rate

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');


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

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


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.