Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

INA219 Sensor wrong data display

Hello Community,

I'm using the current sensor INA219 with NRF5340dk.
Communication is through i²c protocol and using nrf SDK v1.7.0 .
I'm trying to get the data output (Voltage, Current, Power).
i worked on the sample linked on Zephyr Lib. the problem is that i'm always getting the same output which i liked below

the wiring of the sensor is like below :

Vin->VDD nrf
GND->GND
SCL->P0.26
SDA->P0.25

I'm always getting the current and power to Null values and both voltage values don't change no matter what !
do i need to change the calibration values or do i need to do something else ?
i don't get what's wrong with the data output so i need your help please
can you help me get the right values and get the data displayed out from the sensor correctly, please

Kindly,
Many thanks
 

Parents
  • Hi,

    INA219 examle in Zephyr writes very strange (IMHO incorrect) value into configuration register. Try to replace it with default one:

    	/* Configurate the chip using default values */
    	data[0] = 0x39;
    	data[1] = 0x9f;

  • i already changed that before i putted the message on the forum 
    for now i changed the pins and changed my overlay file according to the new pin numbers 
    and i always took the comment of Dmitry in consideration and i changed the addresses and now it's being so strange 

  • I see that there is a new INA219 driver and sample code in NCS v1.8.0.

    Is it important to stay on v1.7.0, or can you upgrade to v1.8.0 and try the new implementation?

  • this project depends from another project which is done with V1.7.0 
    i don't know if it will be very safe if upgrade ! what do you think 
    meanwhile i will try the version of INA219 on V1.8.0 
    can you tell me if it will be safe if i upgrade my second project to the version V1.8.0 please ?

    Kindly 
    Many thanks

  • How difficult it will be to port your other project to v1.8.0 entirely depends on how big it is, and how affected it is by the changes between the versions. If it's not too big, there shouldn't be much of an issue porting it.

  • My project is about 4 assembled sensors that work when a button is pressed 
    the project recover data each 5s and then it stores it somewhere on the cloud 
    here's a snip from the project properties 

    do you think it's easy to migrate on the V1.8.0 or will it be complicated ? 

  • It doesn't sound like it should pose much of an issue.

    Those numbers aren't really helpful as most of it is the build folder.

    You can make a new private ticket about upgrading your project to v1.8.0, and I can help you with that there.

    Were you able to get the v1.8.0 version of the INA219 sample working? You probably need to add an overlay file with a "ti,ina219" node to get the driver working.

Reply
  • It doesn't sound like it should pose much of an issue.

    Those numbers aren't really helpful as most of it is the build folder.

    You can make a new private ticket about upgrading your project to v1.8.0, and I can help you with that there.

    Were you able to get the v1.8.0 version of the INA219 sample working? You probably need to add an overlay file with a "ti,ina219" node to get the driver working.

Children
  • ok thanks for the suggestion 
    well i just finished downloading and searching but in fact under: ncs\v1.8.0\zephyr\samples\drivers\current_sensing 
    there's only the CMakeLists.txt 
    should i import the rest from the old version ? 

  • The new sample is zephyr/samples/sensor/ina219

    I think if you add this to an overlay file and add it to the sample, it should work:

    &i2c1 {
    
    	ina219@40 {
    		status = "okay";
    		compatible = "ti,ina219";
    		reg = <0x40>;
    		label = "INA219";
    		brng = <0>;
    		pg = <0>;
    		sadc = <13>;
    		badc = <13>;
    		shunt-milliohm = <100>;
    		lsb-microamp = <10>;
    	};
    };

  • Hello, 
    thank you for the suggestion 
    i did my overlay file and it looks like this 

    &i2c1 {
    	status = "okay";
    	sda-pin = < 34 >;
    	scl-pin = < 35 >;
        clock-frequency = <100000>; 
    	
    	ina219@40 {
    		status = "okay";
    		compatible = "ti,ina219";
    		reg = <0x40>;
    		label = "INA219";
    		brng = <0>;
    		pg = <0>;
    		sadc = <13>;
    		badc = <13>;
    		shunt-milliohm = <100>;
    		lsb-microamp = <10>;
    	};
    };
    
    &uart1 {
        status = "disabled";
    };


    but i'm not able to open the project 

    is there an issue in the overlay file ?

  • Did you open SES using the button next to v1.8.0 in the Toolchain Manager?

  • yeah i did open it from the SES 
    and i clicked on open ide button

Related