Git Product home page Git Product logo

unicorn-mqtt's Introduction

unicorn-mqtt

MQTT通信を使い、TouchPhatを刺したRaspberryPiでUnicornHatHDを刺したRaspberryPiの表示を制御するサンプル。

概要

このスクリプトはMQTT通信を用いてTouchPhatのボタン操作でUnicornHatHDの表示を時計、天気予報と切り替え動作を行うサンプルです。

MQTTブローカーは別途用意する必要がありますが、CoudMQTTサービスを使うことを推奨します。 https://www.cloudmqtt.com

環境構築

それぞれ以下のコマンドを使用して必須パッケージをインストールします。 インストールスクリプトを使用するか、マニュアルで設定します。

UnicornHatHD側

スクリプトを使用する場合

$ ./pre-install-unicorn.sh

手動で行う場合

$ sudo raspi-config # SPIを有効にする
$ sudo apt-get install python3-pip python3-dev python3-spidev python3-pil python3-numpy -y
$ sudo apt-get install ttf-dejavu fonts-takao -y
$ sudo pip3 install unicornhathd paho-mqtt requests

ライブラリ内の unicorn_mqtt_display/display ディレクトリ上に公式ライブラリの examples 上にある weather-icons ディレクトリをコピーする必要があります

https://github.com/pimoroni/unicorn-hat-hd/tree/master/examples/

TouchPhat側

スクリプトを使用する場合

$ ./pre-install-touchphat.sh

手動で行う場合

$ sudo raspi-config # I2Cを有効にする
$ sudo apt-get install python3-pip python3-dev python3-smbus -y
$ sudo pip3 install touchphat paho-mqtt

起動コマンド

これらの起動はそれぞれ下記のようなコマンドを使ってください。

touchphat_main側

$ MQTT_TARGET_NAME=nagoya \
MQTT_NAME=matsumoto \
MQTT_HOST={mqtt broker hostname} \
MQTT_USER={mqtt user} \
MQTT_PASSWORD={mqtt password} \
MQTT_PORT={mqtt port} \
python3 touchphat_main.py

unicornhat_main側

$ MQTT_NAME=nagoya \
MQTT_HOST={mqtt broker hostname} \
MQTT_USER={mqtt user} \
MQTT_PASSWORD={mqtt password} \
MQTT_PORT={mqtt port} \
OPENWEATHER_API_KEY={openWeather api key} \
WEATHER_CITY={天気予報を行う地域} \
python3 unicornhat_main.py

ライブラリへのリンク

unicorn-mqtt's People

Contributors

nc30 avatar

Watchers

 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.