GPS speedometer and clock
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Shop by category
Shop all componentsFactories, farms and buildings use RS485 sensors because the bus runs hundreds of metres and carries many devices on two wires. Modbus RTU is the usual protocol. An ESP32 with a 3.3 V RS485 transceiver can poll these sensors, and a serial server or 4G router can bring the same bus onto Ethernet or the internet.
Keep 12 to 24 V sensor power away from the ESP32's 3.3 V pins.
Tick anything you already have and the total updates.
RS485 Modbus temperature and humidity sensor
Another device on the same bus: non-contact water level sensor
Another device on the same bus: dual-axis tilt sensor
Puts the whole bus on your network (Modbus TCP)
Industrial 4G router for remote sites
For machines that speak CAN instead of RS485
Industrial pH/ORP controller with RS485 Modbus for water treatment
Follow the colours: red is power, dark grey is ground, blue is a signal.
Most industrial sensors need 10 to 30 V DC; power them from a 12 V supply and share its ground with the ESP32.
modbus_reader.inoVerify & upload in Electrolark#include <ModbusMaster.h>
const int DE_RE = 4;
ModbusMaster node;
void preTx() { digitalWrite(DE_RE, HIGH); }
void postTx() { digitalWrite(DE_RE, LOW); }
void setup() {
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, 16, 17); // match the sensor's baud rate
pinMode(DE_RE, OUTPUT); postTx();
node.begin(1, Serial2); // sensor address 1
node.preTransmission(preTx);
node.postTransmission(postTx);
}
void loop() {
// Many SHT20-based RS485 sensors keep temperature x10 in input register 1 and humidity x10 in register 2.
// Check your sensor's datasheet and change the function and registers if they differ.
uint8_t r = node.readInputRegisters(1, 2);
if (r == node.ku8MBSuccess) {
float t = (int16_t) node.getResponseBuffer(0) / 10.0;
float h = node.getResponseBuffer(1) / 10.0;
Serial.printf("%.1f C %.1f %%RH\n", t, h);
} else {
Serial.printf("Modbus error 0x%02X\n", r);
}
delay(2000);
}
The sketch above runs here on a simulated ESP32. Move the sliders for the sensors and buttons it reads, and watch the Serial monitor, display and outputs change.
Swap A and B, check the baud rate and address, and that DE/RE switches.
The register number is wrong; some datasheets count from 1, the library from 0.
Add 120 Ω termination at both ends and use shielded twisted pair.
Up to 32 standard loads, each with its own address.
RTU runs over serial lines; TCP carries the same registers over Ethernet.
Yes, with a USB to RS485 adapter and a Modbus tool.
9 parts: ESP32-WROOM-32 38-Pin Development Board, MAX3485 TTL to RS485 Converter Module – 3.3V Logic, Seeed Studio Industrial RS485 Modbus Temperature and Humidity Sensor, XKC-Y25-V Intelligent Non-Contact Liquid Water Level Sensor – RS485, IP67, SN-3001-DIP-N01 Dual-Axis Tilt Sensor – RS485 Output, Metal Housing, Waveshare 24962 Dual-Channel RS485 to Ethernet Serial Server, Teltonika RUT200 Industrial Cellular Router w/ 4G LTE, Wi-Fi & Dual ETH, Waveshare CAN FD to RS232/RS485 Bidirectional Protocol Converter – DIN-Rail Mount and SN-300WQC-DC-PH/ORP-N01-201T Industrial pH/ORP Controller – RS485 Modbus, 4-20mA Output. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 3 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (modbus_reader.ino).
Yes. The Run it panel under the code runs this exact sketch on a simulated board. Move the sliders or press the buttons for the sensors it reads, and the Serial monitor, display and outputs react as they will on the real build. It is a simulation, so real readings depend on your parts and wiring.
About ₹34,202 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
RS485 A/B wiring, termination and grounds; Modbus RTU function codes and registers; Moving a serial bus onto Ethernet.
Keep 12 to 24 V sensor power away from the ESP32's 3.3 V pins.
Ideas that reuse this build: Water pipe pressure and tank level monitor. They are listed under Take it further on this page.
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Records where you went every five seconds, ready to open on a map.
Two boards, two radios: press the button at the gate and it rings indoors.
Check temperature, humidity and pressure from any phone on your Wi-Fi.
Learning project. Check every circuit and the datasheet of each part before you power it up.
Modbus error 0x00 Modbus error 0x00
A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.