/Linux-driver-for-sht20

SHT20 Linux driver, include device tree, driver module.

Primary LanguageC

Linux-driver-for-sht20

Test Environment:

  • OS: ubuntu 20.04 Server 64bits LTS
  • Board: Raspberry pi 4b

Install guide:

  1. Compile device tree
  dtc -@ -I dts -O dtb -o sht20-i2c.dtbo sht20-i2c.dti
  1. Move device tree binary code to /boot/firmware/overlays/
  2. Add line on /boot/firmware/config.txt
+ dtoverlay=sht20-i2c  
  1. reboot
  2. Compile driver
make
  1. Load module
sudo insmod sht20_i2c_drv.ko
  1. Compile test program
make test
  1. Give permission
sudo chmod 666 /dev/sht20
  1. Excute test
./test

Data format

0xa 0xb 0xc 0xb

Temperature(°C) = 0xa0b / 100

Humidity(RH %) = 0xc0b / 100