Skip to content

Small command line interface for Waveshare PoE HAT B with OLED Display

Notifications You must be signed in to change notification settings

pietmacom/waveshare-poe-hat-b-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Image Build Docker Image Size

Waveshare PoE HAT CLI (Command Line Interface)

Small command line interface for Waveshare PoE HAT B with OLED Display.

doc/PoE-HAT-B-details-5.png

Find this project on GitHub https://github.com/pietmacom/waveshare-poe-hat-b-cli and on DockerHub https://hub.docker.com/r/pietmacom/waveshare-poe-hat-b-cli

Features

  • Docker Image
  • Command line interface
    • Turn fan on and off
    • View up to four lines on your OLED Display (size and positions are adapted automatically)
  • Binary does not have to be recompiled to view different content
  • Almost no dependencies

Docker

Run command

foo@bar:~$ docker run --privileged -it pietmacom/waveshare-poe-hat-b-cli /root/waveshare-poe-hat-b-cli oled "Hello World!"
foo@bar:~$ docker run --privileged -it pietmacom/waveshare-poe-hat-b-cli /root/waveshare-poe-hat-b-cli fan on

Run simple script simple.sh

foo@bar:~$ docker run --privileged -it pietmacom/waveshare-poe-hat-b-cli
#!/bin/sh -e

_fanState="off"
_fanOnTemperature="40000"
_fanOffTemperature="35000"

while true; do
    _temperature="$(cat /sys/class/thermal/thermal_zone0/temp)"

    _temperatureViewAwk="BEGIN { printf \"%.2f C\", (${_temperature}/1000) }"
    _temperatureView=$(awk "${_temperatureViewAwk}";)

    if [[ "${_temperature}" -gt "${_fanOnTemperature}" ]]; then
        _fanState="on"
    elif [[ "${_temperature}" -lt "${_fanOffTemperature}" ]]; then
        _fanState="off"
    fi

    ./waveshare-poe-hat-b-cli fan ${_fanState}
    ./waveshare-poe-hat-b-cli oled "T: ${_temperatureView}" "F: ${_fanState}"
    sleep 3
done

doc/example-bash.png

Run your own script

Copy simple.sh, make your changes and mount it into your new container.

foo@bar:~$ docker run --privileged -it -v yourscript.sh:/root/script.sh pietmacom/waveshare-poe-hat-b-cli

Docker Compose

version: '3'

services:
  waveshare-poe-hat-b-cli:
    image: pietmacom/waveshare-poe-hat-b-cli:latest
    privileged: true
    restart: "unless-stopped"

Command Line (Shell)

Control FAN

foo@bar:~$ sudo ./waveshare-poe-hat-b-cli fan on
Fan turned on!

foo@bar:~$ sudo ./waveshare-poe-hat-b-cli fan off
Fan turned off!

Control OLED

foo@bar:~$ sudo ./waveshare-poe-hat-b-cli oled "row1"
row 1: row1

doc/example-1rows.png

foo@bar:~$ sudo ./waveshare-poe-hat-b-cli oled "row1" "row2"
row 1: row1
row 2: row2

doc/example-2rows.png

foo@bar:~$ sudo ./waveshare-poe-hat-b-cli oled "row1" "row2" "row3"
row 1: row1
row 2: row2
row 3: row3

doc/example-3rows.png

foo@bar:~$ sudo ./waveshare-poe-hat-b-cli oled "row1" "row2" "row3" "row4"
row 1: row1
row 2: row2
row 3: row3
row 4: row4

doc/example-4rows.png

Enable I2C Interface

I2C interface is required for the OLED display, you need to first enable the i2c interface for properly work. Open a terminal of Raspberry Pi and configure:

foo@bar:~$ sudo raspi-config
Interfacing Options -> I2C -> Yes

doc/enable-i2c.png

And then reboot the system.

foo@bar:~$ sudo reboot

Compile

foo@bar:~$ ./make clean
foo@bar:~$ ./make

References

Documentation https://www.waveshare.com/wiki/PoE_HAT_(B)

About

Small command line interface for Waveshare PoE HAT B with OLED Display

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages