GithubHelp home page GithubHelp logo

niklasberlin / temp2osc Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 9 KB

small script to read the CPU temp on an raspberry Pi and send it to an instance of companion via OSC

License: MIT License

Python 100.00%

temp2osc's Introduction

temp2OSC

This script will continously read the CPU Temperature of an RaspberryPi and send it to an instance of Companion by Bitfocus [1]. At the beginning of the file are some variables to configure IP-address and port of the companion instance as well as the page and button on which the temperature should be displayed. At defined thresholds (default 60°C) the background-color will be set to orange and at another treshold (75°C) the background-color will be turned red, otherwise the background will be black(all colors can be configured at the beginning of the script).

installing needed tools

To run this script you need to have python3 installed, to do so use the following command:

sudo apt-get install python3

To install the used libraries pip is used, therefor we need to install pip:

sudo apt-get install pip3

Now you can install the used libraries, for OSC Python-OSC [2] is used:

pip3 install python-osc

To get the temperature the gpiozero [3] library is used:

pip3 install gpiozero

Configure the script

By Default the script assumes that it runs on the same pi as companion and that the CPU Temperature should be displayed on button 21 on page 99 (bottom right Button on the last page of a 15-key streamdeck), if this is OK for you, you can skip this step.

To change the page change the following line

targetPage = 99

To change the button change the following line

targetButton = 21

If companion does not run on the same raspberryPi you can define the IP of the companion computer in the following line:

targetIP = "127.0.0.1"

run the script

to start the script navigate to the folder with the script and type:

python3 temp2OSC.py

if you want to run it in the background use this:

python3 temp2OSC.py &

enable auto start

This step is based on the instructions on how to auto start companion on a Linux system [4]

first we need to create a UNIT-File at /etc/systemd/system/temp2osc.service

sudo nano /etc/systemd/system/temp2osc.service

copy the below code into this file, adjust the path to the script depending on your setup and save the file

[Unit] Description=Temp2OSC
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/scripts
ExecStart=python3 /home/pi/scripts/temp2OSC.py
Restart=on-failure
KillSignal=SIGINT
TimeoutStopSec=60

[Install]
WantedBy=multi-user.target

now we need to enable this service with the following command

sudo systemctl enable temp2osc.service

and after this we reboot

sudo reboot

Links

[1] Companion: https://bitfocus.io/companion/
[2] Python-OSC: https://pypi.org/project/python-osc/
[3] gpiozero: https://github.com/gpiozero/gpiozero
[4] https://github.com/bitfocus/companion/wiki/Auto-Start-Companion-on-Linux-Using-systemd

temp2osc's People

Contributors

niklasberlin avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.