Giter VIP home page Giter VIP logo

gpio2mqtt's Introduction

GPIO2MQTT

This is just simple script that allow you to rule your low-level triggered relay module with gpio of Raspberry Pi, Banana Pi, Orange Pi or some other Pi board. It does not send back to mqtt server status if relay state will changed by some other reasons (for example other script that working with gpio).

Requirements

You need at least pgrep and builded wiringPi library or analog for your *Pi.

Raspberry Pi:

sudo apt-get install wiringpi

Orange Pi:

http://www.orangepi.org/Docs/WiringPi.html

Banana Pi:

http://wiki.lemaker.org/BananaPro/Pi:GPIO_library

Installing

At first you should checkout repository to the /opt/gpio2mqtt folder:

[ -d /opt ] || sudo mkdir -p /opt # if not exists
cd /opt
sudo git clone https://github.com/alive-corpse/gpio2mqtt.git

At second you should copy gpio2mqtt.conf_example to gpio2mqtt.conf and change values for your mqtt connection. If your mqtt connection haven't user and password - just leave variables empty.

At third probably you'll want to change pin numbers connection list in the beginning of file relay.sh. Default pinout for my BPi R1 is below:

                +3.3v  1 2  +5v
                  SDA  3 4  +5v -> RELAY MODULE POWER
                  SCK  5 6  GND -> RELAY MODULE GND
                  PWM  7 8  UART3_TX -> RELAY CH1
                  GND  9 10 UART3_RX -> RELAY CH2
 RELAY CH3 <- UART2_RX 11 12 GPIO_PH2
 RELAY CH3 <- UART2_TX 13 14 GND
  ....................................               
                   GND 25 26 SPIO_CS1
   
Pin type Pi pin Relay module pin
+5v 4 +5v
GND 5 GND
U2_TX 8 Ch1
U2_RX 10 Ch2
U3_RX 11 Ch3
U3_TX 13 Ch4

Notice: For your particular board pinout can differ. Check it in documentation.

Then if you're using old sysvinit:

sudo ln -s /opt/gpio2mqtt/gpio2mqtt-init /etc/init.d/gpio2mqtt
sudo ln -s /etc/init.d/gpio2mqtt /etc/rc2.d/S06gpio2mqtt
sudo ln -s /etc/init.d/gpio2mqtt /etc/rc3.d/S06gpio2mqtt
sudo ln -s /etc/init.d/gpio2mqtt /etc/rc4.d/S06gpio2mqtt
sudo ln -s /etc/init.d/gpio2mqtt /etc/rc5.d/S06gpio2mqtt
sudo /etc/init.d/gpio2mqtt start
# Also you can check status if you want: /etc/init.d/gpio2mqtt status

In case of you're using new systemd:

cd /etc/systemd/system
ln -s /opt/gpio2mqtt/gpio2mqtt.service
systemctl daemon-reload
systemctl enable gpio2mqtt
systemctl start gpio2mqtt
# Status checking: systemctl status gpio2mqtt 

Appending

Also you obliviously can use script "relay.sh" for any your purposes.

gpio2mqtt's People

Contributors

alive-corpse avatar

Watchers

James Cloos 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.