Skip to content

Commit 6946ec9

Browse files
pyhyskartben
authored andcommitted
boards: shields: Add Adafruit INA237 current sensor shield
Product photo from https://learn.adafruit.com/assets/137463 with the license CC BY-SA 3.0 Tested with the command mentioned in the index.rst page. Signed-off-by: Jonas Berg <[email protected]>
1 parent 036ccc4 commit 6946ec9

File tree

6 files changed

+106
-0
lines changed

6 files changed

+106
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Jonas Berg
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SHIELD_ADAFRUIT_INA237
5+
def_bool $(shields_list_contains,adafruit_ina237)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2025 Jonas Berg
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&zephyr_i2c {
8+
status = "okay";
9+
10+
/* The shunt resistor on the board is 0.015 Ohm.
11+
* The default max shunt voltage is +/-163.84 mV,
12+
* resulting in a max current range of +/-10.92 Amps.
13+
* For this particular shield is the maximum current rated as 10 A.
14+
* Calculate the current LSB value as 10/2^15 A = 305 uA.
15+
* Round the current LSB value upwards to 500 uA.
16+
*/
17+
adafruit_ina237: ina237@40 {
18+
status = "okay";
19+
compatible = "ti,ina237";
20+
reg = <0x40>;
21+
rshunt-micro-ohms= <15000>;
22+
current-lsb-microamps = <500>;
23+
};
24+
};
33 KB
Loading
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _adafruit_ina237:
2+
3+
Adafruit INA237 Shield
4+
######################
5+
6+
Overview
7+
********
8+
9+
The `Adafruit INA237 DC Current Voltage Power Monitor Sensor Shield`_ features
10+
a `TI INA237 current sensor`_ and two STEMMA QT connectors.
11+
It measures current and bus voltage.
12+
13+
.. figure:: adafruit_ina237.webp
14+
:align: center
15+
:alt: Adafruit INA237 Shield
16+
17+
Adafruit INA237 Shield (Credit: Adafruit)
18+
19+
20+
Requirements
21+
************
22+
23+
This shield can be used with boards which provide an I2C connector, for
24+
example STEMMA QT or Qwiic connectors.
25+
The target board must define a ``zephyr_i2c`` node label.
26+
See :ref:`shields` for more details.
27+
28+
29+
Pin Assignments
30+
===============
31+
32+
+--------------+-------------------+
33+
| Shield Pin | Function |
34+
+==============+===================+
35+
| SDA | INA237 I2C SDA |
36+
+--------------+-------------------+
37+
| SCL | INA237 I2C SCL |
38+
+--------------+-------------------+
39+
| ALRT | INA237 ALERT out |
40+
+--------------+-------------------+
41+
42+
See :dtcompatible:`ti,ina237` for documentation on how to adjust the
43+
devicetree file, for example to adjust the sample averaging.
44+
45+
46+
Programming
47+
***********
48+
49+
Set ``--shield adafruit_ina237`` when you invoke ``west build``. For example
50+
when running the :zephyr:code-sample:`sensor_shell` sample:
51+
52+
.. zephyr-app-commands::
53+
:zephyr-app: samples/sensor/sensor_shell
54+
:board: adafruit_qt_py_rp2040
55+
:shield: adafruit_ina237
56+
:goals: build
57+
58+
.. _Adafruit INA237 DC Current Voltage Power Monitor Sensor Shield:
59+
https://learn.adafruit.com/adafruit-ina237-dc-current-voltage-power-monitor
60+
61+
.. _TI INA237 Current sensor:
62+
https://www.ti.com/product/INA237
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Copyright (c) 2025, Jonas Berg
4+
5+
shield:
6+
name: adafruit_ina237
7+
full_name: Adafruit INA237 Current Sensor Shield
8+
vendor: adafruit
9+
supported_features:
10+
- sensor

samples/sensor/sensor_shell/sample.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ tests:
2626
extra_args: DTC_OVERLAY_FILE=fake_sensor.overlay
2727
integration_platforms:
2828
- native_sim
29+
sample.sensor.shell.shields:
30+
platform_allow:
31+
- adafruit_qt_py_rp2040/rp2040
32+
extra_args:
33+
- platform:adafruit_qt_py_rp2040/rp2040:SHIELD="adafruit_ina237"

0 commit comments

Comments
 (0)