This code reads the temperature and relative humidity from a Pine64 I2C PMSD001 sensor.
It's wired up via the Pi 2 bus as follows:
- Pin 3 - SDA
- Pin 4 - DC 5V
- Pin 5 - SCL
- Pin 6 - GND
Note that this I2C sensor can function also 3.3V, however, it is dangerous to use that pin on the GPIO as a pull up to 5V on a 3.3V pin can destroy the entire board. Use well-insulated connectors when connecting I2C this way.
sudo apt-get -y install golang
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
. ~/.bashrc
go get golang.org/x/exp/io/i2c
go build pmsd001.go
sudo ./pmsd001
returns e.g. 1612530062 21.21 70.11 48.11
where the tab-separated values are:
- timestamp in UTC
- temperature in °C
- temperature in °F
- relative humidity in %
Note that one decimal is significant for applications, however, using two decimals results in smoother data.
When concatenating measurements to pmsd001.log
, a PNG graph can be plotted with
gnuplot pmsd001.plt
- https://www.pine64.org/devices/single-board-computers/pine-a64/
- https://pine64.com/product/pine-a64-1gb-board/?v=0446c16e2e66
- https://en.wikipedia.org/wiki/Pine64
- https://web.archive.org/web/20180414015203/https://www.pine64.org/?product=pine64-humidity-temperature-sensor
- http://files.pine64.org/doc/Pine%20A64%20Schematic/Pine%20A64%20Pin%20Assignment%20160119.pdf
- http://wiki.pine64.org/index.php/POT
- https://dave.cheney.net/2014/08/03/tinyterm-a-silly-terminal-emulator-written-in-go