MCUcraft · Example project, made with MCUcraft

Industrial sensor node

The idea

Industrial sensor node on an STM32, for a DIN-rail enclosure. It reads two 4-20 mA pressure transmitters and exposes the values as a Modbus RTU slave over RS-485, with the slave address set by DIP switches. A status LED blinks on each valid request, and a fault LED turns on if a loop current is below 3.6 mA (broken wire). Powered from 24 V DC. I want a custom PCB.

Firmware

Firmware builds, not tested yet

it compiles, and what the device does for R-ca58, R-8a59, R-96f9, R-6a6d and 5 more rule(s) was not verified

Bill of materials (55 lines)

PartManufacturer part numberManufacturerQtyFunction
STM32F103C8T6 (LQFP48)STM32F103C8T6STMicroelectronics1Host microcontroller: 12-bit ADC for two shunts, USART for Modbus RTU, GPIO for DIP switches and LEDs
ADS1115 16-bit I2C ADC (shunt voltage digitizer)ADS1115IDGSTTexas Instruments1External 16-bit ADC for the two shunt voltages, read by the STM32 over I2C for resolution beyond the internal 12-bit ADC
Morsettiera a 2 poli passo 5,08 mm 24 V, header PCB Phoenix Contact 17572421757242Phoenix Contact124 V DC supply entry terminal
4-position DIP switch, SMDCHS-04ANidec Components1Modbus slave address selection (4 bits, read at startup)
LED verde 0805 KP-2012CGCK Kingbright (indicatore di stato, impulso su ogni richiesta Modbus valida)KP-2012CGCKKingbright1Status LED, pulsed on each valid Modbus request
Red LED 0805 (fault indicator)LS R976-NR-1AMS OSRAM GROUP1Fault LED, lit when a loop current is below 3.6 mA
N-channel MOSFET 60 V 0.2 A SOT-23 (LED low-side switch)SN7002NH6327XTSA2Infineon Technologies1Low-side switch that lights the status LED only, on command from the MCU
2N7002 N-channel MOSFET (fault LED low-side switch)2N7002onsemi1Low-side switch that lights the fault LED on command from the MCU
Analog Devices ADM3485E RS-485 transceiverADM3485EARZAnalog Devices1RS-485 half-duplex transceiver for Modbus RTU, direction controlled by a GPIO
Buck converter 24 V to 5 V 1.5 A, input 40 V or more (non-isolated) for the logic and transceiver supplyLM2596SX-5.0/NOPBTexas Instruments1Isolated-free 24 V to 5 V DC-DC for the logic and transceiver supply
LDO 3.3 V 1 A, ingresso 5 V, corrente di riposo ridotta, rail 3.3 V per STM32MCP1826S-3302E/DBMicrochip Technology15 V to 3.3 V logic rail for the STM32, fed from the 5 V buck output
SMBJ24A TVS diodeSMBJ24ATaiwan Semiconductor1Surge clamp on 24 V input
SS34 Schottky diode reverse-polarity protectionSS34onsemi1Reverse-polarity protection on 24 V input
TVS diode SM712 (RS-485 line surge clamp)SM712SMC Diode Solutions1Surge clamp on RS-485 A/B lines
Fusibile SMD 1206 2 A rapido 63 V (saldato, senza portafusibile) in ingresso +Vin 24 V del convertitore buckSF-1206FP200-2Bourns1Fast-blow 2 A fuse in series with the +Vin of the 24 V to 5 V converter
Diodo Schottky di clamp a 3.3 V, SOD-323, per ingresso shunt ADS1115 (BAT54WS)BAT54WSMULTICOMP PRO4Clamps each ADS1115 shunt input to the 3.3 V rail against surge and overvoltage
Phoenix Contact 3-pole screw terminal block RS-485 A/B/GND1752218Phoenix Contact1Field RS-485 bus terminal (A, B, shield/GND)
Morsettiera header maschio verticale THT 3 poli 5.08 mm su PCB, RS-485 A/B/GND (accoppia la morsettiera innestabile 1752218)1758021Phoenix Contact1parte di «Phoenix Contact 3-pole screw terminal block RS-485 A/B/GND»
Phoenix Contact 2-pole screw terminal block, transmitter loop 11792249Phoenix Contact1Field terminal for the loop 1 transmitter (loop +24 V in, loop return to shunt)
Phoenix Contact 2-pole PCB header 5.08 mm, for the transmitter loop 1 screw terminal plug1788538Phoenix Contact1parte di «Phoenix Contact 2-pole screw terminal block, transmitter loop 1»
Phoenix Contact 2-pole screw terminal block, transmitter loop 21911965Phoenix Contact1Field terminal for the loop 2 transmitter
Jumper shunt 2.54 mm 2 poles TE 2-881545-2, RS-485 termination select for R32-881545-2TE Connectivity1Jumper that switches the 120 ohm termination R3 across A and B
Connettore header 2 pin passo 2.54 mm (TE 5-146284-2) per shunt R3 di terminazione RS-4855-146284-2TE Connectivity1parte di «Jumper shunt 2.54 mm 2 poles TE 2-881545-2, RS-485 termination select for R3»
Connettore a vite innestabile 2 poli 5.08 mm Phoenix Contact 1826636, spina per l'header J1 24 V1826636Phoenix Contact124 V DC screw plug for the J1 header: the supply wires enter here
PCB header 2-pole 5.08 mm, right angle, for loop 2 screw terminal plug (1911965)1923869PHOENIX CONTACT1Header on the PCB that mates the loop 2 screw terminal plug (1911965), MVSTBU 2,5/2-GB-5,08 family, 5.08 mm pitch
Tag-Connect TC2030-IDC SWD programming headerTC2030-IDCTag-Connect1SWD programming and debug port for the STM32
Diodo Schottky 5 A 40 V catch (D1) del buck LM2596SX-5.0, dal pin Output a GND1parte di «Buck converter 24 V to 5 V 1.5 A, input 40 V or more (non-isolated) for the logic and transceiver supply»
Induttore 33 uH 3 A di uscita (L1) del buck LM2596SX-5.0, tra pin Output e uscita 5 V1parte di «Buck converter 24 V to 5 V 1.5 A, input 40 V or more (non-isolated) for the logic and transceiver supply»
Condensatore 220 uF 25 V low-ESR elettrolitico di uscita 5 V (COUT) del buck LM2596SX-5.01parte di «Buck converter 24 V to 5 V 1.5 A, input 40 V or more (non-isolated) for the logic and transceiver supply»
Precision shunt resistor 124 ohm 0603 0.1% 0.125 W (rating unconfirmed), 4-20 mA to 0.5-2.5 V, 3.6 mA fault at 0.446 V, loop 1 and loop 22Converts loop 1 and loop 2 current into voltage for the ADC (124 ohm x 4-20 mA = 0.5-2.5 V; 3.6 mA fault level = 0.446 V)
Capacitor 10uF 16V X7R 1206 (LDO input/output)1Decoupling for the 3.3 V LDO input and output
Crystal 8 MHz HC-49S, 06031HSE clock for STM32
Resistor 120 ohm 0805 (RS-485 termination)1Line termination across A/B, switched in by a jumper
Resistor 10k 0603 (DIP switch pull-ups, 4 pieces)4Pull-ups on the DIP switch inputs so each reads high when open
Resistor 1k 0603 (status LED current limit)1Series current limit for the status LED
Resistor 1k 0603 (fault LED current limit)1Series current limit for the fault LED
Resistor 10k 0603 (pull-down on status and fault driver gates)2Pull-down so each LED driver stays off during boot, before the MCU drives its GPIO
Resistor 4.7k 0603 (I2C pull-up pair for ADS1115)2Pull-ups on SDA and SCL to 3.3 V for the ADS1115 bus
Output capacitor 33 uF 10V low-ESR (LDO output)1Output capacitor 33 uF low ESR between VOUT and GND of the 3.3 V LDO, as the LM3940 needs for stability
Input capacitor 22 uF 50V ceramic 1210 (24 V input of the buck converter)1Input capacitor 10-22 uF 50 V between +Vin and Common of the 24 V to 5 V converter
Decoupling capacitor 100 nF 0603 X7R (STM32 VDD/VDDA pin pairs)4100 nF on each VDD/VDDA pin pair of U3, one per pin pair
Bulk capacitor 4.7 uF 10V X5R 0805 (STM32 VDD3)14.7 uF bulk decoupling on VDD_3 of U3
Decoupling capacitor 1 uF 10V X7R 0603 (STM32 VDDA)11 uF decoupling on VDDA of U3 for the ADC
Decoupling capacitor 10 nF 0603 X7R (STM32 VDDA)110 nF high-frequency decoupling on VDDA of U3
NRST filter capacitor 100 nF 0603 X7R1100 nF on the NRST line of U3, with its pull-up
NRST pull-up resistor 10k 0603110k pull-up on NRST of U3 to 3.3 V
BOOT0 pull-down resistor 10k 0603110k pull-down on BOOT0 of U3 so it boots from flash
HSE load capacitor 20 pF 0603 C0G (8 MHz crystal)2Two 20 pF load capacitors, one from OSC_IN and one from OSC_OUT to GND, for crystal Y1
Decoupling capacitor 0.1 uF 0603 X7R (ADS1115 VDD)10.1 uF decoupling between VDD and GND of U5 (ADS1115)
Series resistor 1 kohm 0603 (shunt input filter)21 kohm series resistor between each shunt node and its ADS1115 input, with the 100 nF filter
Filter capacitor 100 nF 0603 X7R (shunt input, per channel)2100 nF filter from each ADS1115 shunt input to ground
Bias pull-up 680 ohm 0603, RS-485 A line to 3.3 V1Bias pull-up on the RS-485 A line so the idle bus reads a defined state
Bias pull-down 680 ohm 0603, RS-485 B line to ground1Bias pull-down on the RS-485 B line so the idle bus reads a defined state
Decoupling capacitor 100 nF 0603 X7R (ADM3485E VCC)1100 nF decoupling between VCC and GND of the ADM3485E
Ceramic output capacitor 1 uF 10V X7R 0603 (LDO VOUT)11 uF ceramic output capacitor on VOUT of the 3.3 V LDO, the minimum the LDO needs for output stability, in parallel with C4

The schematic, the PCB, the firmware and the chat that produced them open in the MCUcraft workspace, read-only and without an account: Industrial sensor node.