ADS1115 for voltage and current reading

Hi everyone,

I would like to use the ADS1115 (from Texas Instruments) to send the voltage and current readings from my copter to the flight controller. The ADS1115 has to communicate over I2C with the flight controller (that is running PX4).

The ADS1115 library is already included in the PX4 code. If I’m right, the ADS1115 can be configured using the MavLink shell inside QGC ( Modules Reference: Driver | PX4 User Guide ). Please let me know if this isn’t right.

I’m quite new to PX4 (before I used ArduPilot a lot) and I’m wondering how I can configure PX4 in a way that the voltage and current is communicated over I2C using the ADS1115. Do I need to build a whole new firmware or can I just adjust some parameters/use the MavLink shell?

Thanks in advance!

Kind regards,

Which flight controller do do you plan to connect ADS1115 to? Normally you’d need to modify the startup scripts of your board to get ADS1115 driver working, as System Startup | PX4 User Guide told.

The case if your board hasn’t compiled the driver by default, then you need to manually include it in your config and build from the scratch.

BUT, due to the unimplemented device_id usage on PX4-Autopilot/src/modules/battery_status at master · PX4/PX4-Autopilot · GitHub and other modules, the on-chip ADC publishes ADC reports which most likely will collision with ADS1115’s data and cause undefined behavior. Sorry but that means on a normal available FC you cannot use this driver…

Hi @SalimTerryLi ,

Thanks for your quick response!

The flight controller I’m using, does have an onboard ADC. However it’s only used on startup of the system, so I will turn it off after the startup and that shouldn’t cause any problem.

I’m going to build a custom firmware version for this. Which function(s) should I call to start/configure the ADS1115? And which function(s) do I need the call to read an input from the ADS1115?

No you don’t need to do any coding but just configuring the system to use that.

To enable ADS1115 in your build you need to set Kconfig flag as

To start the driver you can add ads1115 start in which should located in your dir structure.

Make sure board_adc is stopped before ads1115 starts in the previous step.

Then you can get ADC results from uORB message of type adc_report.

Note that onboard_adc also provides some extra channel for board safety and stability such as the status of onboard 5V rails named system_power. Please understand what you may lose when disabling board_adc here

Hi @SalimTerryLi ,

Thanks for the information!

I have three additional questions:

Does the library configure the ADS1115 in the +/- 6.144 V mode (after the ADS1115 is initialized)?

Does the library uses the default I2C address of the ADS1115? It’s possible to choose between 4 different I2C addresses, the default address is selected when the ADR pin (of the ADS1115) is connected to GND.

Do I need to write some code that makes sure that the ADS1115 measurements are used for voltage and current reading (after I initialized the ADS1115)?

Thanks in advance!