Skip to content

Commit ab00c2b

Browse files
pyhyskartben
authored andcommitted
boards: shields: Add Adafruit 8-channel solenoid shield
Tested with the commands mentioned in index.rst The product photo is from https://learn.adafruit.com/assets/137335 with the license CC BY-SA 3.0 Signed-off-by: Jonas Berg <[email protected]>
1 parent 9e42f0c commit ab00c2b

File tree

5 files changed

+139
-0
lines changed

5 files changed

+139
-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_8CHAN_SOLENOID
5+
def_bool $(shields_list_contains,adafruit_8chan_solenoid)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
mcp23017_adafruit_8chan_solenoid: mcp23017@20 {
11+
compatible = "microchip,mcp23017";
12+
reg = <0x20>;
13+
gpio-controller;
14+
#gpio-cells = <2>;
15+
ngpios = <16>;
16+
};
17+
};
36.1 KB
Loading
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
.. _adafruit_8chan_solenoid:
2+
3+
Adafruit I2C to 8 Channel Solenoid Driver Shield
4+
################################################
5+
6+
Overview
7+
********
8+
9+
The `Adafruit I2C to 8 Channel Solenoid Driver Shield`_ features
10+
a `Microchip MCP23017 GPIO expander`_, eight MOSFETs and two STEMMA QT connectors.
11+
12+
.. figure:: adafruit_8chan_solenoid.webp
13+
:align: center
14+
:alt: Adafruit 8 Channel Solenoid Driver Shield
15+
16+
Adafruit 8 Channel Solenoid Driver Shield (Credit: Adafruit)
17+
18+
There are indication LEDs for each output channel. Note that the solenoid power supply
19+
must be connected for these LEDs to work.
20+
21+
22+
Requirements
23+
************
24+
25+
This shield can be used with boards which provide an I2C connector, for example STEMMA QT
26+
or Qwiic connectors. The target board must define a ``zephyr_i2c`` node label.
27+
See :ref:`shields` for more details.
28+
29+
30+
Pin Assignments
31+
===============
32+
33+
+--------------+--------------------------------+
34+
| Shield Pin | Function |
35+
+==============+================================+
36+
| SDA | MCP23017 I2C SDA |
37+
+--------------+--------------------------------+
38+
| SCL | MCP23017 I2C SCL |
39+
+--------------+--------------------------------+
40+
| INT | MCP23017 interrupt out |
41+
+--------------+--------------------------------+
42+
| A0 - A2 | MCP23017 I2C address selection |
43+
+--------------+--------------------------------+
44+
45+
The SDA and SCL signals are also available in the two STEMMA QT connectors.
46+
47+
In order to use interrupts you need to connect a separate wire from the shield to a GPIO pin
48+
on your microcontroller board. See :dtcompatible:`microchip,mcp23017` for documentation on
49+
how to adjust the devicetree overlay file.
50+
51+
By default are the I2C address selection pins pulled down to GND, resulting in a
52+
7-bit I2C address of 0x20. Remember to modify the devicetree overlay file if you change
53+
the address.
54+
55+
56+
Programming
57+
***********
58+
59+
Set ``--shield adafruit_8chan_solenoid`` when you invoke ``west build``. For example
60+
when running the :zephyr:code-sample:`sensor_shell` sample:
61+
62+
.. zephyr-app-commands::
63+
:zephyr-app: samples/sensor/sensor_shell
64+
:board: adafruit_qt_py_rp2040
65+
:shield: adafruit_8chan_solenoid
66+
:gen-args: -DCONFIG_GPIO=y -DCONFIG_GPIO_SHELL=y -DCONFIG_I2C=y
67+
:goals: build
68+
69+
To configure and turn on solenoid 0 (label A0 on board backside):
70+
71+
.. code-block:: shell
72+
73+
gpio conf mcp23017_adafruit_8chan_solenoid 0 o
74+
gpio set mcp23017_adafruit_8chan_solenoid 0 1
75+
76+
Turn off the solenoid:
77+
78+
.. code-block:: shell
79+
80+
gpio set mcp23017_adafruit_8chan_solenoid 0 0
81+
82+
Use pin B0 as an output, and set it high:
83+
84+
.. code-block:: shell
85+
86+
gpio conf mcp23017_adafruit_8chan_solenoid 8 o
87+
gpio set mcp23017_adafruit_8chan_solenoid 8 1
88+
89+
Set it low:
90+
91+
.. code-block:: shell
92+
93+
gpio set mcp23017_adafruit_8chan_solenoid 8 0
94+
95+
Use pin B0 as an input with pullup:
96+
97+
.. code-block:: shell
98+
99+
gpio conf mcp23017_adafruit_8chan_solenoid 8 iu
100+
gpio get mcp23017_adafruit_8chan_solenoid 8
101+
102+
103+
.. _Adafruit I2C to 8 Channel Solenoid Driver Shield:
104+
https://learn.adafruit.com/adafruit-i2c-to-8-channel-solenoid-driver
105+
106+
.. _Microchip MCP23017 GPIO expander:
107+
https://www.microchip.com/en-us/product/mcp23017
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_8chan_solenoid
7+
full_name: Adafruit I2C to 8 Channel Solenoid Driver Shield
8+
vendor: adafruit
9+
supported_features:
10+
- gpio

0 commit comments

Comments
 (0)