Input-Logger-OrangeZero

Log inputs status on a Orange Pi zero and plot graphs of your data. Its been verified to work with a orange pi zero with simple 8 inputs module (coming soon PCB). By changing the inputspins.yml file and making a corresponding GPIO inputs relation.

Requirements

Hardware

  • Orange Pi Zero
  • 8 inputs module (coming soon PCB) or other module DIY

Software

Installation

Install InfluxDB*

Step-by-step instructions
  • Add the InfluxData repository
    $ curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
    $ source /etc/os-release
    $ test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
  • Download and install
    $ sudo apt-get update && sudo apt-get install influxdb
  • Start the influxdb service
    $ sudo service influxdb start
  • Create the database
    $ influx
    CREATE DATABASE db_inputs
    exit

*source

Install Grafana*

Step-by-step instructions
  • Add APT Repository
    $ echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
  • Add Bintray key
    $ curl https://packages.grafana.com/gpg.key | sudo apt-key add -
  • Now install
    $ sudo apt-get update && sudo apt-get install grafana
  • Start the service using systemd:
    $ sudo systemctl daemon-reload
    $ sudo systemctl start grafana-server
    $ systemctl status grafana-server
  • Enable the systemd service so that Grafana starts at boot.
    $ sudo systemctl enable grafana-server.service
  • Go to http://localhost:3000 and login using admin / admin (remember to change password) *source

Install Input-Logger-OrangeZero:

  • Download and install from Github and install pip3

    $ git clone https://github.com/GuillermoElectrico/Input-Logger-OrangeZero.git
    $ sudo apt-get install python3-pip
  • Run setup script (must be executed as root (sudo) if the application needs to be started from rc.local, see below)

    $ cd Input-Logger-OrangeZero
    $ sudo python3 setup.py install
  • Make script file executable

    $ chmod 777 read_input_orangezero.py
  • Edit inputs.yml to match your configuration

  • Test the configuration by running:

    ./read_input_orangezero.py
    ./read_input_orangezero.py --help # Shows you all available parameters

    If the error appears:

     /usr/bin/env: ‘python3\r’: No such file or directory
    

    Use dos2unix to fix it.

     $ sudo apt install dos2unix
     $ dos2unix /PATH/TO/YOUR/FILE
    
  • To run the python script at system startup. Add to following lines to the end of /etc/rc.local but before exit:

    # Start Logger
    /home/pi/Input-Logger-OrangeZero/read_input_orangezero.py --interval 10 > /var/log/inputs-logger.log &

    Log with potential errors are found in /var/log/inputs-logger.log