EthernetIP-Scale
EtherNet/IP adapter for ESP32-P4 with NAU7802 scale, Modbus TCP, and OTA
Status: This project is a proof-of-concept implementation and requires further development, testing, and validation before production use.
Overview
A comprehensive EtherNet/IP communication adapter for the ESP32-P4 microcontroller, integrating NAU7802 precision scale support, Modbus TCP, and web-based configuration. The device serves as a bridge between EtherNet/IP networks and industrial scale applications, providing real-time weight data via EtherNet/IP assemblies and Modbus TCP.
This project implements a full-featured EtherNet/IP adapter device on the ESP32-P4 platform using the OpENer open-source EtherNet/IP stack. The device has been tested with Waveshare ESP32-P4-ETH, SparkFun Qwiic Scale (NAU7802), and S‑type load cells.
Hardware Platform
Development Board: Waveshare ESP32-P4-ETH
The Waveshare ESP32-P4-ETH development board provides the core processing and Ethernet connectivity:
- Microcontroller: ESP32-P4 dual-core RISC-V processor (Espressif)
- Ethernet: 100 Mbps RJ45 Ethernet port with IP101 PHY
- Connectivity: USB-C interface for programming and power
- Expansion: 2×20-pin headers for peripheral integration
- GPIO: Multiple configurable GPIO pins for I2C, SPI, UART, and other interfaces
Ethernet Configuration: PHY Address: 1 (default), MDC/MDIO pins configurable via menuconfig
Scale Module: SparkFun Qwiic Scale - NAU7802
The SparkFun Qwiic Scale - NAU7802 breakout board provides high-precision weight measurement capabilities:
- ADC: 24-bit dual-channel analog-to-digital converter
- Interface: I2C communication (Qwiic connector compatible)
- I2C Address: 0x2A (default, configurable)
- Programmable Gain: PGA with gains from x1 to x128
- Sample Rates: 10, 20, 40, 80, or 320 samples per second (SPS)
- Channels: Dual-channel support (Channel 1 and Channel 2)
- Calibration: Hardware AFE (Analog Front End) calibration and software weight calibration
Connection: Connect to ESP32-P4-ETH via I2C bus (default GPIO7 SDA, GPIO8 SCL). External pull-up resistors (4.7kΩ) required.
Load Cell: S-Type Beam High-Precision Load Cell
Tested with S-type (S-beam) strain gauge load cells:
- Type: S-type (S-beam) strain gauge load cell
- Design: Suitable for both tension and compression measurements
- Protection: IP67 rated for environmental protection
- Accuracy: High linearity, low hysteresis, excellent repeatability (±0.02% F.S.)
- Output: Analog differential signal (millivolt output)
- Wiring: 4-wire configuration (Excitation+, Excitation-, Signal+, Signal-)
EtherNet/IP Protocol Support
Core Functionality
- Full OpENer Stack: Complete EtherNet/IP adapter implementation
- Input Assembly 100: 32-byte assembly containing NAU7802 scale data and sensor information
- Output Assembly 150: 32-byte assembly for control commands and output data
- Configuration Assembly 151: 10-byte assembly for device configuration parameters
- Connection Types: Exclusive Owner, Input Only, and Listen Only connections
CIP File Object Integration
The device implements the CIP File Object (Class 0x37) to serve the EDS file and icon directly from the device:
- Automatic EDS Download: RSLinx can download the EDS file from the device
- Instance 200: Serves the EDS file as "EDS.txt" with Binary encoding
- Instance 201: Serves the device icon as "EDSCollection.gz" with CompressedFile encoding
- Compatibility: Compatible with Rockwell Studio 5000, RSLinx, and EtherNet/IP Explorer
LLDP Support
IEEE 802.1AB compliant Link Layer Discovery Protocol support:
- LLDP Management Object (Class 0x109) for configuration and status management
- LLDP Data Table Object (Class 0x10A) for neighbor information storage
- CIP Identification TLV transmission in outgoing LLDP frames
- Automatic neighbor discovery and topology mapping
Modbus TCP Server
Standard Modbus TCP/IP server (port 502) provides additional protocol access:
- Input Registers 0-15: Map to Input Assembly 100 (32 bytes = 16 registers)
- Holding Registers 100-115: Map to Output Assembly 150 (32 bytes = 16 registers)
- Holding Registers 150-154: Map to Configuration Assembly 151 (10 bytes = 5 registers)
All assembly data is stored in little-endian format (Modbus converts to big-endian for transmission).
NAU7802 Scale Integration
The device provides comprehensive NAU7802 scale support:
- Configurable Gain: x1 to x128 programmable gain amplifier
- Sample Rates: 10, 20, 40, 80, or 320 samples per second (SPS)
- Channel Selection: Channel 1 or Channel 2
- Unit Selection: Grams, lbs, kg with scaled integer storage (no floating point)
- Reading Averaging: 1-50 samples for stable measurements
- Calibration: Software calibration (tare, known-weight) and hardware AFE calibration
- Real-time Data: Weight data mapped to EtherNet/IP Assembly 100 (configurable byte offset)
- Status Flags: Available, connected, initialized flags included in assembly data
Dedicated web-based configuration page (/nau7802) and REST API are provided for scale configuration and monitoring.
Network Configuration
The device includes RFC 5227 compliant Address Conflict Detection (ACD):
- RFC 5227 compliant static IP assignment (implemented in application layer)
- ACD probe sequence runs before IP assignment (deferred assignment) when enabled
- Natural ACD state machine flow (PROBE_WAIT → PROBING → ANNOUNCE_WAIT → ANNOUNCING → ONGOING)
- Probe sequence: 3 probes from
0.0.0.0+ 4 announcements (~6-10 seconds total) - IP assigned only after ACD confirms no conflict
- Active IP defense with periodic ARP probes
- EtherNet/IP conflict reporting in TCP/IP Interface Object Attribute #11
Web-Based Configuration Interface
Essential device management via web interface:
- Network Configuration: Main page (
/) - DHCP/Static IP configuration - Firmware Updates: Firmware page (
/ota) - OTA firmware update capability - NAU7802 Scale Configuration: Scale page (
/nau7802) - Scale configuration and monitoring - REST API: All other configuration and monitoring available via REST API
OTA Firmware Updates
Firmware updates can be performed via:
- Web Interface: Upload binary file directly
- REST API: POST to
/api/ota/updatewith file or URL - Automatic rollback on failure
- Maintains two OTA partitions for safe updates
Software Requirements
- ESP-IDF: Version 5.5.1 or compatible
- Python: 3.x (for build scripts)
- CMake: 3.16 or higher