PanderMusubi / pine64-temp-humidity

Read the temperature and relative humidity from a Pine64 PMSD001 sensor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pine 64 - Temperature / Humidity Reader

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.

Building

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

Usage

sudo ./pmsd001

returns e.g. 1612530062 21.21 70.11 48.11 where the tab-separated values are:

  1. timestamp in UTC
  2. temperature in °C
  3. temperature in °F
  4. relative humidity in %

Note that one decimal is significant for applications, however, using two decimals results in smoother data.

Plotting

When concatenating measurements to pmsd001.log, a PNG graph can be plotted with

gnuplot pmsd001.plt

Useful Resources

About

Read the temperature and relative humidity from a Pine64 PMSD001 sensor

License:MIT License


Languages

Language:Go 59.1%Language:Gnuplot 40.9%