In this post we show you how to use a XBee S2B ZB module with a current shunt monitor chip (INA209) from Texas Instruments.
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.
To test the INA209 sample you need to install Codewarrior 10.2 (download from Digi), Programmable XBee SDK from (download from Digi) and this file. They are all Windows programs.
When you download the attached files you need to copy them into these paths:
- current.png to: C:Program FilesDigiPXBeev1.5pxbee_api1.5.2.utilsxml_componentsicons
- i2c_current_sensor.xml to: C:Program FilesDigiPXBeev1.5pxbee_api1.5.2.utilsxml_componentscommon
- Ina209.h to : C:Program FilesDigiPXBeev1.5pxbee_api1.5.2srcheaders
- Ina209.c to: C:Program FilesDigiPXBeev1.5pxbee_api1.5.2srcdriversi2c
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