As of June 23rd, 2025 – By popular demand! We've updated this design to expose the 'second' ADC input (B+ and B-), so we've updated this PCB to now come with a 6-pin terminal block port, instead of 4-pin.
It's easy to use the NAU7802 with Python or CircuitPython, and the CedarGrove CircuitPython NAU7802 module. This module allows you to easily write Python code that reads the value from the NAU7802 ADC with a strain gauge.
You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.
Rev C of the Adafruit NAU7802 breakout uses both channels on the NAU7802. The previous version of the breakout only uses Channel 1.
CircuitPython Microcontroller Wiring
First, wire up a NAU7802 to your board exactly as shown below. Here's an example of wiring a Feather M4 to the sensor with I2C using one of the handy STEMMA QT connectors:
- Board 3V to ADC VIN (red wire)
- Board GND to ADC GND (black wire)
- Board SCL to ADC SCL (yellow wire)
- Board SDA to ADC SDA (blue wire)
- Strain gauge green wire to ADC A+
- Strain gauge white wire to ADC A-
- Strain gauge black wire to ADC E-
- Strain gauge red wire to ADC E+
You can also use the standard 0.100" pitch headers to wire it up on a breadboard:
- Board 3V to ADC VIN (red wire)
- Board GND to ADC GND (black wire)
- Board SCL to ADC SCL (yellow wire)
- Board SDA to ADC SDA (blue wire)
- Strain gauge green wire to ADC A+
- Strain gauge white wire to ADC A-
- Strain gauge black wire to ADC E-
- Strain gauge red wire to ADC E+
Python Computer Wiring
Since there's dozens of Linux computers/boards you can use, below shows wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported.
Here's the Raspberry Pi wired to the ADC using I2C and a STEMMA QT connector:
- Pi 3V to ADC VIN (red wire)
- Pi GND to ADC GND (black wire)
- Pi SCL to ADC SCL (yellow wire)
- Pi SDA to ADC SDA (blue wire)
- Strain gauge green wire to ADC A+
- Strain gauge white wire to ADC A-
- Strain gauge black wire to ADC E-
- Strain gauge red wire to ADC E+
Finally here is an example of how to wire up a Raspberry Pi to the ADC using a solderless breadboard:
- Pi 3V to ADC VIN (red wire)
- Pi GND to ADC GND (black wire)
- Pi SCL to ADC SCL (yellow wire)
- Pi SDA to ADC SDA (blue wire)
- Strain gauge green wire to ADC A+
- Strain gauge white wire to ADC A-
- Strain gauge black wire to ADC E-
- Strain gauge red wire to ADC E+
Python Installation of NAU7802 Library
You'll need to install the Adafruit_Blinka library that provides CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!
Once that's done, from your command line run the following command:
pip3 install cedargrove-nau7802
If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!
CircuitPython Usage
To use with CircuitPython, you need to first install the CircuitPython_NAU7802 library, and its dependencies, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder should contain the following folders and file:
- adafruit_bus_device/
- adafruit_register/
- cedargrove_nau7802.mpy
Python Usage
Once you have the library installed on your computer, copy or download the following example to your computer, and run the following, replacing code.py with whatever you named the file:
python3 code.py
If running CircuitPython: Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!
If running Python: The console output will appear wherever you are running Python.
# SPDX-FileCopyrightText: 2023 Cedar Grove Maker Studios
# SPDX-License-Identifier: MIT
"""
nau7802_simpletest.py 2023-01-13 2.0.2 Cedar Grove Maker Studios
Instantiates two NAU7802 channels with default gain of 128 and sample
average count of 2.
"""
import time
import board
from cedargrove_nau7802 import NAU7802
# Instantiate 24-bit load sensor ADC; two channels, default gain of 128
nau7802 = NAU7802(board.I2C(), address=0x2A, active_channels=2)
def zero_channel():
"""Initiate internal calibration for current channel.Use when scale is started,
a new channel is selected, or to adjust for measurement drift. Remove weight
and tare from load cell before executing."""
print(
"channel {0:1d} calibrate.INTERNAL: {1:5s}".format(
nau7802.channel, str(nau7802.calibrate("INTERNAL"))
)
)
print(
"channel {0:1d} calibrate.OFFSET: {1:5s}".format(
nau7802.channel, str(nau7802.calibrate("OFFSET"))
)
)
print(f"...channel {nau7802.channel:1d} zeroed")
def read_raw_value(samples=2):
"""Read and average consecutive raw sample values. Return average raw value."""
sample_sum = 0
sample_count = samples
while sample_count > 0:
while not nau7802.available():
pass
sample_sum = sample_sum + nau7802.read()
sample_count -= 1
return int(sample_sum / samples)
# Instantiate and calibrate load cell inputs
print("*** Instantiate and calibrate load cells")
# Enable NAU7802 digital and analog power
enabled = nau7802.enable(True)
print("Digital and analog power enabled:", enabled)
print("REMOVE WEIGHTS FROM LOAD CELLS")
time.sleep(3)
nau7802.channel = 1
zero_channel() # Calibrate and zero channel
nau7802.channel = 2
zero_channel() # Calibrate and zero channel
print("READY")
### Main loop: Read load cells and display raw values
while True:
print("=====")
nau7802.channel = 1
value = read_raw_value()
print(f"channel {nau7802.channel:1.0f} raw value: {value:7.0f}")
nau7802.channel = 2
value = read_raw_value()
print(f"channel {nau7802.channel:1.0f} raw value: {value:7.0f}")
Attach a strain gauge with four wires to the four terminal inputs. Now try applying force on the gauge to see the values change!
First you import the necessary modules and libraries. Then you instantiate the sensor on I2C.
Then you're ready to read data from the ADC, including the initial information printed to the serial console.
Finally, inside the loop, you check the value from the ADC.
The terminal inputs raw value will print to the REPL. You'll see the number increase or decrease depending on the amount of force you apply to the strain gauge.
That's all there is to using the NAU7802 with CircuitPython!
Page last edited June 24, 2025
Text editor powered by tinymce.