Raspberry Pi soil moisture monitoring

USB port is common way to attach external devices to you computer or micro computer like Raspberry Pi. There is no need for any interface device like arduinno.

USB soil moisture sensor uses USB CDC-ACM virtual com port with 115200 baudrate and on connection to Raspberry Pi USB interface will appear as /dev/ttyACM0 device. You may access sensor for example using minicom serial terminal application.

This simple script setups sensor clock time and writes sensor output to CSV file to Raspberry Pi device’s disk.



#sensor serial port name


sudo stty -F $PT speed 115200 cs8 -cstopb -parenb -echo raw

#setup current time

echo -ne “time $(date +%s)\r” > $PT

#set time period 5 seconds in milliseconds and start logging

echo -ne “millis 5000\r” > $PT

#flush some output

timeout 2s cat $PT

#print output to file

cat $PT > swout.csv 2>&1 &


Leave a Reply

Your email address will not be published. Required fields are marked *