June 19, 2013

Reading temperature with WR703N and Dallas DS18B20 on OpenWrt

Reading temperature with WR703N and Dallas DS18B20 on OpenWrt

You can easily get temperature readings from external Dallas DS18S20 sensors (1-wire protocol) on your TP-Link WR703N.

First things first, grab your credit card and order few Dallas DS18S20 sensors and usb to serial adapters. Now you need to connect Dallas DS18S20 sensor to USB to serial adapter.

After you got hardware part sorted now you need to setup software part. Main tool for reading temperature from 1-wire sensors is digitemp. Digitemp uses bit-banging to emulate 1-wire protocol over serial port.

opkg install digitemp

You also need usb to serial kernel module (driver) so install that also:

opkg install kmod-usb-serial-cp210x

After digitemp is installed you need to search 1-wire bus for all connected sensors, each sensor has it's unique address so is has to be discovered and added to config file with this command:

digitemp_DS9097 -s /dev/ttyUSB0 -i

Now you can read temperature from your sensor:

digitemp_DS9097 -a -q