Soil NPK sensor can be connected to RPI4 UART to get N P K Values.
Buy link :
https://www.alselectro.in/product-page/soil-npk-sensorCode download :
https://99ba69f9-3a9c-49a1-8c2a-52df0ffe5f34.usrfiles.com/archives/99ba69_e09589e2ddaa4659a22d05660af96e3b.zipsudo nano /boot/firmware/config.txt
add following line after the enable_uart=1
dtoverlay=miniuart-bt
this overlay swaps the BT to use mini uart instead of UART0.
RS485-TTL Auto Direction model is used to connect with RPI. Connection is straight Tx-Tx, Rx-Rx
G-G
Always use Virtual Environment in RPI.
python3 -m venv --system-site-packages npkenv
confirm by checking home folder npkenv is created.
source npkenv/bin/activate
python3 -c "import serial; print(serial.VERSION)"
If it prints 3.5 without errors, pyserial is working, and you can continue with your script
nano npk_sensor.py
to execute
python3 npk_sensor.py