Congratulations Richard R, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Battery Monitor

Assistance Requested

Help bhouston with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

bhouston claims to have checked these sources:

I want to set up a Battery Voltage Monitor script using the values from the EZ-B v4 Info control. Is this possible? If so, could someone please, give me some pointers to get a script started.


I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.

Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


Can you be more specific? There is a control called EZB info that you can add to monitor the battery.


Ya, sorry. I should have explained what I want to do. I have the EZB Info control running. I am looking to create a script that would monitor the voltage and when it gets to a certain voltage, it would do something. ie, warning the voltage is low or shut down scripts that are running, etc.


There is a script command GetVoltage() that does exactly that.



You can use an if statement in a slow looping script...


$con=IsConnected(0) #check ezb voltage only when connected board 0
if($con=1) #connected to the ezb
print("EZB Volts = "+$v+"v")
if($v<6) #low battery, use any value as the V threshold
saywait("Warning, E Z B Battery is low")
#start shutting things down
sleep(10000) #wait 10 seconds between checks


You can use this as a base. Remove the ADC stuff and the extra circuit etc. since it's all now within EZ-Builder/the EZ-B.

What you are left with are the IF and ElseIfs for different battery levels. Loop it with whichever method you prefer.


@Richard R, that was exactly what I was looking for, thanks.
Thanks to everyone else for your input.