The INA209 chip is a high-side current shunt and power monitor with an I2C interface. The INA209 monitors both shunt drop and shunt bus voltage. A programmable calibration value, combined with an internal multiplier, enables direct readouts in amperes.
We have to choose the current that we want to measure, in our case 2A, and apply this formula:
Rshunt = Vshunt / Max current.
Vshunt = 0,32V
Max current = 2 A
With this data we get a 0.16 Ω resistor.
When you download the attached files you need to copy them into these paths:
current.png to: C:\Program Files\Digi\PXBee\v1.5\pxbee_api\1.5.2\.utils\xml_components\icons
i2c_current_sensor.xml to: C:\Program Files\Digi\PXBee\v1.5\pxbee_api\1.5.2\.utils\xml_components\common
Ina209.h to : C:\Program Files\Digi\PXBee\v1.5\pxbee_api\1.5.2\src\headers
Ina209.c to: C:\Program Files\Digi\PXBee\v1.5\pxbee_api\1.5.2\src\drivers\i2c
To test this example we are going to use the S2B isolation board to connect the INA209 Board.
Here the schematic for this board:
Here the final result, with all the items connected.
Now, we need to make a new project: New-> Xbee Application Project, then set the name and accept.
Now open config.xml, add the i2c current sensor, and disable the watchdog. The config.xml after these steps should look like this:
The final step is replace the main.c in the project, with the attached file.
You should see this output in the serial console.
It´s the same as power supply!
The API gives us some functions for controlling the basic functions of the current sensor
Initialize ina209 with default config
Return the actual current
Return the max value of the current since last reset
Reset the sensor
Happy prototyping! Questions or comments? Let us know!