Analog Front End device operation sample code for Arduino
An Arduino library for NXP Analog Front End device with sample code.
This library provides simple API to get analog input channels.
Include device name header file (NAFE13388_UIM.h) to use those class libraries.
This repo shoiws some basic operations of AFE as well as practical samples to work with RTD, thermocouple and loadcell.
3 types of Arduino UNO boards: R3, R4 Minima and R4 WiFi are supported.
Example sketches can be built and run on any of those boards.
Next is a sample of the basic operation of measureing analog voltage on AI1P and AI1N terminal.
#include <NAFE13388_UIM.h>
NAFE13388_UIM afe;
void setup() {
Serial.begin(115200);
Serial.println("\n***** Hello, NAFE13388! *****");
SPI.begin();
afe.begin();
afe.blink_leds();
afe.logical_channel[0].configure(0x1710, 0x00A4, 0xBC00, 0x0000);
afe.logical_channel[1].configure(0x2710, 0x00A4, 0xBC00, 0x0000);
Serial.println("\nlogical channel 0 (AI1P-GND) and 1 (AI2P-GND) voltages are shown in ADC readout value [V]");
}
void loop() {
Serial.print((NAFE13388_UIM::microvolt_t)afe.logical_channel[0] * 1e-6);
Serial.print(", ");
Serial.println((NAFE13388_UIM::microvolt_t)afe.logical_channel[1] * 1e-6);
}To try this sample code, set jumper plug on J91 to short AICOM and GND.
The analog input terminals are available as picture below.
Followings are pictures of UIM with UNO R3, UNO R4 Minima and UNO R4 WiFi boards.
On every picture, showing the hardware setting of..
- 3.3V are disconnected by using pin extender
- A jumper plug is set on J91
- D2 and D4 pins are shorted to enable to use DRDY signal

NAFE13388-UIM 8 Channels Universal Input AFE Evaluation Board with Arduino UNO R3

NAFE13388-UIM 8 Channels Universal Input AFE Evaluation Board with Arduino UNO R4 Minima

NAFE13388-UIM 8 Channels Universal Input AFE Evaluation Board with Arduino UNO R4 WiFi
Note
For proper voltage signal interfacing, connection between Arduino MCU board and NAFE13388-UIM board need to be modified. Remove 3.3V supply pin to let UIM to support 5V signaling.
3.3V supply pin is lifted at pin extender
Diagram of 3.3V and 5V supply rails on NAFE13388-UIM board's schematic

NAFExx388-EVB 8 Channels Universal Input AFE Evaluation Board with Arduino UNO R3
Analog-Front-End chip: NAFE13388
| Type# | Features | Interface |
|---|---|---|
| NAFE13388 | Highly Configurable 8 Channel ±25 V Universal Input Low Power Analog Front-End | SPI (mode1) |
| NAFE73388 | Highly Configurable 8 Channel ±25 V Universal Input Low Power Analog Front-End | SPI (mode1) |
| NAFE33352 | Software Configurable Input and Output Analog Front End | SPI (mode1) |
| NAFE93352 | Software Configurable Input and Output Analog Front End | SPI (mode1) |
| Name | Header file | Features | Interface | Evaluation board |
|---|---|---|---|---|
| NAFExx388-EVB | NAFE13388.h |
General purpose evaluation board for NAFE13388 | SPI (mode1) | NAFE13388-UIM 8-Channel Universal Input AFE Arduino® Shield Board |
| NAFE13388-UIM | NAFE13388_UIM.h |
AFE Arduino shield type evaluation board | SPI (mode1) | NAFE13388-UIM 8-Channel Universal Input AFE Arduino® Shield Board |
| NAFE33352-EVB | NAFE13388_UIM.h |
AFE Arduino shield type evaluation board | SPI (mode1) | Software Configurable Universal AIO-AFE Evaluation Board |
| NAFE33352-UIOM | NAFE13388_UIM.h |
AFE Arduino shield type evaluation board | SPI (mode1) | NAFE33352-UIOM Universal Input/OUTPUT AFE Arduino® Shield Board |
How to setup? --> https://youtu.be/UEOFC0TwA6c

Examples are provided as scketch files.
After library install, Choose menu on Arduino-IDE: File→Examples→AFE_NXP_Arduino→ sketch for your try
| Sketch | Target | Feature | NOTE |
|---|---|---|---|
| NAFE13388_1_0_simple_SCSR | NAFE13388-UIM | Simple sample to get 2ch inputs | |
| NAFE13388_1_1_simple_SCSR_using_DRDY_signal | NAFE13388-UIM | Simple sample to get 2ch inputs using DRDY signal | Need to short pins between D2 and D4 |
| NAFE13388_2_0_multichannel_read_MCMR | NAFE13388-UIM | Get 8ch inputs using Multi-Channel Multi-Read command | |
| NAFE13388_2_1_multichannel_read_MCMR_using_DRDY | NAFE13388-UIM | Get 8ch inputs using Multi-Channel Multi-Read command | Need to short pins between D2 and D4 |
| NAFE13388_3_0_multichannel_read_MCCR_using_DRDY | NAFE13388-UIM | Get 8ch inputs using Multi-Channel Continuous-Read command | Need to short pins between D2 and D4 |
| NAFE13388_4_0_LVMUX_multichannel_read_MCCR_using_DRDY | NAFE13388-UIM | Get 8ch inputs and LVMUX inputs (supply voltage, etc) | Need to short pins between D2 and D4 |
| NAFE13388_5_0_RTD_4_wire | NAFE13388-UIM | Practical sample to measure temperature by 2 RTDs using internal current excitation source | Need to short pins between D2 and D4 |
| NAFE13388_6_0_Thermocouple | NAFE13388-UIM | Practical sample to measure temperature by thermocouple with on-board RTD | Need to short pins between D2 and D4 |
| NAFE13388_7_0_LoadCell | NAFE13388-UIM | Practical sample to measure loadcell output using internal voltage excitation source | Need to short pins between D2 and D4 |
| Sketch | Target | Feature | NOTE |
|---|---|---|---|
| NAFE33352_1_0_ADC_and_DAC | NAFE33352-UIOM | A sample of ADC and DAC operation | Need to short pins between D2 and D4 |
| NAFE33352_2_0_AIO_input | NAFE33352-UIOM | A sample of AIO (Analog Input/Output) channel used as an input | Need to short pins between D2 and D4 |
For details of the library, please find descriptions in this document.



