Arduino Soil NPK Sensor with RS485 Modbus and MAX485 Module
Build a soil nutrient meter: ask an RS485 soil sensor for nitrogen, phosphorus and potassium with Modbus, show the numbers and the fertiliser the field needs.

Your project challenge
Show Press TEST. On each TEST press, ask the sensor for nitrogen, phosphorus and potassium, then switch the MAX485 to listen. Show N90 P18 K140 style numbers on row 1 and one advice on row 2: Add UREA, Add DAP, Add MOP or SOIL OK. No reply within 1 second: show NO SENSOR.
Components you’ll use
- Arduino Uno
- Soil NPK Sensor (JXBS-3001)
- RS485 Module (MAX485)
- Battery
- I²C LCD (16×2)
- Pushbutton
What you’ll build
A soil report card. A farmer pushes the probe into a field, presses TEST and reads the nitrogen, phosphorus and potassium in the soil, with the fertiliser to add. India’s Soil Health Card gives farmers the same advice from a laboratory.
How it works
The sensor talks RS485, a two-wire line that works over long cables. The MAX485 module turns it into the Arduino’s serial signal. The Arduino asks with eight bytes: address 1, function 3, the register, how many, and two CRC check bytes. The sensor answers 30 ms later with seven bytes. The number is bytes 3 and 4. Pick the soil with the sensor’s field buttons.
The key idea
RS485 is one line for both ways. Set DE and RE HIGH to talk, send the question, then set them LOW at once to listen. Wait at most one second for the reply.
⚠ Watch out
A wrong CRC byte or A and B swapped: the sensor stays silent. Without a time limit, your sketch waits for ever.
Make it yours: read all three registers in one question (count 3) and add pH from a seven-in-one sensor.
The editor has the wiring guide, the code and the simulator.
Build this project