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)
| Part | Manufacturer part number | Manufacturer | Qty | Function |
|---|---|---|---|---|
| STM32F103C8T6 (LQFP48) | STM32F103C8T6 | STMicroelectronics | 1 | Host 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) | ADS1115IDGST | Texas Instruments | 1 | External 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 1757242 | 1757242 | Phoenix Contact | 1 | 24 V DC supply entry terminal |
| 4-position DIP switch, SMD | CHS-04A | Nidec Components | 1 | Modbus slave address selection (4 bits, read at startup) |
| LED verde 0805 KP-2012CGCK Kingbright (indicatore di stato, impulso su ogni richiesta Modbus valida) | KP-2012CGCK | Kingbright | 1 | Status LED, pulsed on each valid Modbus request |
| Red LED 0805 (fault indicator) | LS R976-NR-1 | AMS OSRAM GROUP | 1 | Fault 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) | SN7002NH6327XTSA2 | Infineon Technologies | 1 | Low-side switch that lights the status LED only, on command from the MCU |
| 2N7002 N-channel MOSFET (fault LED low-side switch) | 2N7002 | onsemi | 1 | Low-side switch that lights the fault LED on command from the MCU |
| Analog Devices ADM3485E RS-485 transceiver | ADM3485EARZ | Analog Devices | 1 | RS-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 supply | LM2596SX-5.0/NOPB | Texas Instruments | 1 | Isolated-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 STM32 | MCP1826S-3302E/DB | Microchip Technology | 1 | 5 V to 3.3 V logic rail for the STM32, fed from the 5 V buck output |
| SMBJ24A TVS diode | SMBJ24A | Taiwan Semiconductor | 1 | Surge clamp on 24 V input |
| SS34 Schottky diode reverse-polarity protection | SS34 | onsemi | 1 | Reverse-polarity protection on 24 V input |
| TVS diode SM712 (RS-485 line surge clamp) | SM712 | SMC Diode Solutions | 1 | Surge 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 buck | SF-1206FP200-2 | Bourns | 1 | Fast-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) | BAT54WS | MULTICOMP PRO | 4 | Clamps 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/GND | 1752218 | Phoenix Contact | 1 | Field 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) | 1758021 | Phoenix Contact | 1 | parte di «Phoenix Contact 3-pole screw terminal block RS-485 A/B/GND» |
| Phoenix Contact 2-pole screw terminal block, transmitter loop 1 | 1792249 | Phoenix Contact | 1 | Field 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 plug | 1788538 | Phoenix Contact | 1 | parte di «Phoenix Contact 2-pole screw terminal block, transmitter loop 1» |
| Phoenix Contact 2-pole screw terminal block, transmitter loop 2 | 1911965 | Phoenix Contact | 1 | Field terminal for the loop 2 transmitter |
| Jumper shunt 2.54 mm 2 poles TE 2-881545-2, RS-485 termination select for R3 | 2-881545-2 | TE Connectivity | 1 | Jumper 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-485 | 5-146284-2 | TE Connectivity | 1 | parte 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 V | 1826636 | Phoenix Contact | 1 | 24 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) | 1923869 | PHOENIX CONTACT | 1 | Header 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 header | TC2030-IDC | Tag-Connect | 1 | SWD programming and debug port for the STM32 |
| Diodo Schottky 5 A 40 V catch (D1) del buck LM2596SX-5.0, dal pin Output a GND | 1 | parte 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 V | 1 | parte 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.0 | 1 | parte 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 2 | 2 | Converts 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) | 1 | Decoupling for the 3.3 V LDO input and output | ||
| Crystal 8 MHz HC-49S, 0603 | 1 | HSE clock for STM32 | ||
| Resistor 120 ohm 0805 (RS-485 termination) | 1 | Line termination across A/B, switched in by a jumper | ||
| Resistor 10k 0603 (DIP switch pull-ups, 4 pieces) | 4 | Pull-ups on the DIP switch inputs so each reads high when open | ||
| Resistor 1k 0603 (status LED current limit) | 1 | Series current limit for the status LED | ||
| Resistor 1k 0603 (fault LED current limit) | 1 | Series current limit for the fault LED | ||
| Resistor 10k 0603 (pull-down on status and fault driver gates) | 2 | Pull-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) | 2 | Pull-ups on SDA and SCL to 3.3 V for the ADS1115 bus | ||
| Output capacitor 33 uF 10V low-ESR (LDO output) | 1 | Output 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) | 1 | Input 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) | 4 | 100 nF on each VDD/VDDA pin pair of U3, one per pin pair | ||
| Bulk capacitor 4.7 uF 10V X5R 0805 (STM32 VDD3) | 1 | 4.7 uF bulk decoupling on VDD_3 of U3 | ||
| Decoupling capacitor 1 uF 10V X7R 0603 (STM32 VDDA) | 1 | 1 uF decoupling on VDDA of U3 for the ADC | ||
| Decoupling capacitor 10 nF 0603 X7R (STM32 VDDA) | 1 | 10 nF high-frequency decoupling on VDDA of U3 | ||
| NRST filter capacitor 100 nF 0603 X7R | 1 | 100 nF on the NRST line of U3, with its pull-up | ||
| NRST pull-up resistor 10k 0603 | 1 | 10k pull-up on NRST of U3 to 3.3 V | ||
| BOOT0 pull-down resistor 10k 0603 | 1 | 10k pull-down on BOOT0 of U3 so it boots from flash | ||
| HSE load capacitor 20 pF 0603 C0G (8 MHz crystal) | 2 | Two 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) | 1 | 0.1 uF decoupling between VDD and GND of U5 (ADS1115) | ||
| Series resistor 1 kohm 0603 (shunt input filter) | 2 | 1 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) | 2 | 100 nF filter from each ADS1115 shunt input to ground | ||
| Bias pull-up 680 ohm 0603, RS-485 A line to 3.3 V | 1 | Bias 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 ground | 1 | Bias pull-down on the RS-485 B line so the idle bus reads a defined state | ||
| Decoupling capacitor 100 nF 0603 X7R (ADM3485E VCC) | 1 | 100 nF decoupling between VCC and GND of the ADM3485E | ||
| Ceramic output capacitor 1 uF 10V X7R 0603 (LDO VOUT) | 1 | 1 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.