DS18B20
[
Пред. ] [ Содержание ] [
След. ]
DS18B20
Created Воскресенье 20 октября 2019
Считывание температуры с помощью датчика DS18B20 и Orange Pi PC (ARMBIAN 5.35) Подключение датчика температуры DS18B20 к Orange Pi, Banana Pi, Raspberry Pi 1-Wire http://linux-sunxi.org/1-Wire Linux kernel 4.14
You don't have to edit the fex-file, but the
/boot/armbianEnv.txt and add the lines:
overlays=w1-gpio
param_w1_pin=PI3 # OPi pin7 gpio269 PWM1
param_w1_pin_int_pullup=1 # internal pullup-resistor: 1=on, 0=off
Connect the data pin of devices to gpio pin PI3 and proceed like Kernel 3.4 with
nano /etc/modules w1-sunxi w1-gpio w1-therm modprobe w1-gpio w1-therm ls -la /sys/bus/w1/devices/ total 0 drwxr-xr-x 2 root root 0 Feb 7 12:02 . drwxr-xr-x 4 root root 0 Feb 7 11:52 .. lrwxrwxrwx 1 root root 0 Feb 7 12:01 28-0316819dedff -> ../../../devices/w1_bus_master1/
28-0316819dedff lrwxrwxrwx 1 root root 0 Feb 7 11:52 w1_bus_master1 -> ../../../devices/w1_bus_master1 cat /sys/bus/w1/devices/28-0316819dedff/w1_slave 45 01 4b 46 7f ff 0b 10 84 : crc=84 YES
45 01 4b 46 7f ff 0b 10 84 t=20312 Read Data Sensor
simple bash script for read 1-wire temp sensor
#!/bin/bash
file="/sys/bus/w1/devices/28-0316819dedff/w1_slave"
function find(){
[[ "$1" =~ "$2" ]] && true || false
}
while :
do
DATE=$(date +"%d-%m-%Y-%H:%M:%S")
#read device
CRC=false
while read curline; do
#check crc
if( find "$curline" "crc" && find "$curline" "YES" ) then
CRC=true
DEVICE=`echo $curline|cut -d':' -f 1`
fi
if($CRC && find "$curline" "t=") then
TEMP=`echo $curline|cut -d'=' -f 2`
echo $DEVICE ";" $DATE ";" `echo "scale=3;$TEMP/1000"|bc -l`
fi
done <$file
sleep 10
done
28-0316819dedff 28-0516826434ff 28-0516823175ff 28-031681aa62ff 28-031681bb49ff rpimonitor config
dynamic.1.name=living_room_temp
dynamic.1.source=/sys/devices/w1_bus_master1/28-031681bb49ff/w1_slave
dynamic.1.regexp=t.(\d+)
dynamic.1.postprocess=sprintf("%.2f", $1/1000)
dynamic.1.rrd=GAUGE
Содержание