Reading Supply Voltage W/ Arduino

I am building an electric vehicle involving an O-Drive and a 36V 10s4p battery pack, and would be nice to know the battery voltage for range estimation. The only voltage sensors I can find go up to 36V, which will fry when the battery is fully charged (42V). I couldn’t find anywhere in the Arduino library for the Odrive to read supply voltage, but found that the Odrive can sense supply voltage, and can output with the Odrive tool. Is there anyone who has figured out how to read the supply voltage with I2C or UART with an Arduino?

Hello CrispyFungus, is there any reason you can’t use a voltage divider like ODrive does? The schematic of the ODrive board can be found here

Is this what you’re looking for? Taken from the ODriveArduinoTest.ino example:

SoftwareSerial odrive_serial(8, 9)
ODriveArduino odrive(odrive_serial);

odrive_serial << "r vbus_voltage\n";
float voltageIn = odrive.readFloat();

Sidenote, from my experience, I’ve had to add a delay of a half second or so in the Arduino’s setup before reading floats from the ODrive (it returns 0 otherwise).

This is exactly what I need thank you! Also, that delay is fine, since it will only be reading it every 30 seconds or so to display on an OLED

Isabel, although this worked, I have a very weird issue. I have an OLED screen connected to my arduino, which is connected to odrive. I can send commands to odrive to control the motors as usual. However, not sure if you have encountered this, but I can only display the bus voltage on my OLED when my arduino is connected via USB. When the arduino is diconnected from usb to my computer, I get 0.00 (when dumped to a float)

The boards have their GND pins connected, yes?

Also try communicating with the Odrive using the hardware Serial instead of a SoftwareSerial instance. SoftwareSerial has specific requirements for receiving data on certain Arduino boards, check the Limitations section of to make sure that the pins you’re using support it.

I’ll have to give that a shot, thank you for the info. I am using pins 8 and 9 just as the odrive test sketch uses. I am hesitant to use pins 0 and 1, since it will botch my ability to upload sketches (adafruit metro mini)