Coder Social home page Coder Social logo

mqtt-gpio-monitor's Introduction

THIS REPOSITORY IS NO LONGER SUPPORTED OR MAINTAINED

mqtt-gpio-monitor

Python 3 script for sending/receiving commands to/from GPIO pins via MQTT messages.

This was written for use on a RaspberryPi, with either the PiFace extension board, or just raw access to the GPIO pins.

The example INI file contains the only configuration required. You must define the module to use, either GPIO or PFIO. Depending on which you will need to ensure the appropriate Python module is installed.

If using the PiFace extension board you will need to follow the instructions here to install the digital IO libraries;

sudo apt-get install python3-pifacedigitalio

If just using the raw GPIO pins then the RPi.GPIO module should be installed as part of Raspbian.

You will also need an MQTT client, in this case Paho. To install;

sudo pip3 install paho-mqtt

On Rapsbian Stretch, the kernel's SPI driver changed the default serial speed from 500Khz to 125Mhz. The pifacedigitalio SPI doesn't initialize the SPI speed or ioctl() option so we have to to edit the spi.py file manually.

sudo nano /usr/lib/python3/dist-packages/pifacecommon/spi.py

Change the spi transfer struct section to match the following.

# create the spi transfer struct
    transfer = spi_ioc_transfer(
        tx_buf=ctypes.addressof(wbuffer),
        rx_buf=ctypes.addressof(rbuffer),
        len=ctypes.sizeof(wbuffer),
        speed_hz=ctypes.c_uint32(15000)
    )

You should now be ready to run the script. It will listen for incoming messages on {topic}/in/+ (where {topic} is specified in the INI file). The incoming messages need to arrive on {topic}/in/{pin} with a value of either 1 or 0.

E.g. a message arriving on {topic}/in/3 with value 1 will set pin 3 to HIGH.

Depending on what is set for MONITOR_PINS in the INI file, the script will also monitor these pins and if there are any changes publish a message on {topic}/out/{pin} with a value of either 1 or 0.

E.g. if pin 7 changes from 1 to 0 a message would be published to {topic}/out/7 with a value of 1.

So you are able to both monitor pins as well as set pins HIGH/LOW. Obviously you can't do both monitor and update for the same pin.

Control the pull up resistors using MONITOR_PINS_PUD set to either UP, DOWN or nothing.

Set the pin numbering to either BOARD or BCM (broadcom) using MONITOR_PIN_NUMBERING.

Invert the output of pins using MONITOR_OUT_INVERT. i.e. high is read as 0 instead of 1 and vice-versa.

The last option in the INI file is MONITOR_REFRESH, which is a special topic the script will subscribe to if specified. Any message arriving on that topic will trigger the script to re-send publishes with the current state of all monitored pins. This is useful for requesting the current state of all pins if the calling system is restarted for example.

mqtt-gpio-monitor's People

Contributors

filcole avatar marianblazicek avatar rupert-sch avatar sumnerboy12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mqtt-gpio-monitor's Issues

Debug relay action

Hi Ben,

I have it partly working now and can control the PiFace module with Python using pfd.output_pins[7].value = 1. Below is my ini file and the log file. It is connected to my broker but when I publish a message to /piface/out/0 with a payload of 1, the broker reports the action on /piface/# but the relay does not change state. I'm using tail -F to track the log and it is not updating past the data below after running the script.

How do I debug this?

[global]
MODULE             = pfio
DEBUG              = True

MQTT_HOST          = [ip.of.my.nas.broker]
MQTT_PORT          = 1883
MQTT_USERNAME      = 
MQTT_PASSWORD      = 
MQTT_CLIENT_ID     = mqtt-gpio-monitor
MQTT_QOS           = 2
MQTT_RETAIN        = False
MQTT_CLEAN_SESSION = True

MQTT_TOPIC         = /piface
MQTT_LWT           = /clients/piface

MONITOR_PINS       = 0, 1, 2, 3, 4, 5, 6, 7
MONITOR_POLL       = 0.1
MONITOR_REFRESH    = /piface/refresh
2016-08-01 16:40:59,598 INFO  Starting mqtt-gpio-monitor
2016-08-01 16:40:59,601 INFO  INFO MODE
2016-08-01 16:40:59,605 DEBUG DEBUG MODE
2016-08-01 16:40:59,608 DEBUG INIFILE = mqtt-gpio-monitor.ini
2016-08-01 16:40:59,611 DEBUG LOGFILE = mqtt-gpio-monitor.log
2016-08-01 16:40:59,706 INFO  PiFace.PFIO module detected...
2016-08-01 16:40:59,710 DEBUG Monitoring pins [0, 1, 2, 3, 4, 5, 6, 7]
2016-08-01 16:41:00,028 DEBUG Connecting to 10.0.2.8:1883...
2016-08-01 16:41:00,040 DEBUG Pin 0 changed from -1 to 0
2016-08-01 16:41:00,048 INFO  Connected to 10.0.2.8:1883
2016-08-01 16:41:00,052 DEBUG Pin 1 changed from -1 to 0
2016-08-01 16:41:00,069 DEBUG Pin 2 changed from -1 to 0
2016-08-01 16:41:00,080 DEBUG Pin 3 changed from -1 to 0
2016-08-01 16:41:00,086 DEBUG Refreshing the state of all monitored pins...
2016-08-01 16:41:00,091 DEBUG Pin 4 changed from -1 to 0
2016-08-01 16:41:00,095 DEBUG Refreshing pin 0 state -> 0
2016-08-01 16:41:00,103 DEBUG Pin 5 changed from -1 to 0
2016-08-01 16:41:00,107 DEBUG Refreshing pin 1 state -> 0
2016-08-01 16:41:00,116 DEBUG Pin 6 changed from -1 to 0
2016-08-01 16:41:00,120 DEBUG Refreshing pin 2 state -> 0
2016-08-01 16:41:00,129 DEBUG Pin 7 changed from -1 to 0
2016-08-01 16:41:00,133 DEBUG Refreshing pin 3 state -> 0
2016-08-01 16:41:00,141 DEBUG Refreshing pin 4 state -> 0
2016-08-01 16:41:00,148 DEBUG Refreshing pin 5 state -> 0
2016-08-01 16:41:00,153 DEBUG Refreshing pin 6 state -> 0
2016-08-01 16:41:00,165 DEBUG Refreshing pin 7 state -> 0

Add ability to run in non-blocking/background thread

Currently the script is designed as a standalone application with a blocking loop for polling. To make for easier inclusion into other projects (e.g., IoT creations), consider a variation/adjustment that would allow the monitoring to instead occur in a background thread. Users of this script would then be able to include it in their apps--while still having some control of settings, looping/polling, etc. during startup.

Please Help me

I become this error:

root@raspberrypi:/mqtt2gpio# python mqtt-gpio-monitor.py
Traceback (most recent call last):
File "mqtt-gpio-monitor.py", line 344, in
init_gpio()
File "mqtt-gpio-monitor.py", line 281, in init_gpio
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
ValueError: The channel sent is invalid on a Raspberry Pi

Some errors with the program...

Hi, summerboy

I was making some testing with this code, and find some errors on my application.

Was only two errors that RPi showed to me.

Line 73, 82, and 272. You named the object "logger" but in all of your code you use the object "logging". And because of this the program doesn't was working until I change "logger" for "logging".

Then on line 264. The terminal every time I run the program, show me a message that GPIO was not iniziated and there is nothing to cleanup. I delete this Line and then the program works like a charm.

I can upload the code I modified but I'm not in my computer right now.

I'm very new on this portal and sorry if isn't the correct way to review an issue.

Add a frequency counter mode

Hi Sumnerboy,

I use your script in my sprinkler automation, works like a charm!

For water flow meters which give a linear frequency of up to 100Hz when the water flows I want to add a frequency counter mode like in this code snippet:

http://stackoverflow.com/a/23188184

Could you please help me out with my poor Python skills?

To support

  • io write
  • monitor status
  • monitor frequency

Sounds good, right?

Autostart mqtt

Hello,
is there any way to start the mqtt monitor when rpi boot?

ty

mosquitto.py is outdated

You should start using the Paho Python client (paho-mqtt) instead of mosquitto.py. It's the same client, just a slightly different name space and is the future of that Python client.

configparser

For the sake of sharing I'm leaving this here:

To get the script to work I replaced 'configparser' with 'ConfigParser' in mqtt-gpio-monitor.py

This was needed due to wrong Python version installed on my end. Which for the life o me I could not get fixed.

Cheers!

How many GPIO

Assuming I have a very powerful embedded SOM running Linux (Artik 710) with 8 cores running fedora with python: how many gpio could this monitor and how much "traffic" could it handle? Could it monitor 100 gpio/pins and 10 messages per second with 10 onboard subscribers? Just trying to understand if I can use this for managing onboard interprocess communication.

Cert_Path Errors

Bit of a python n00b so I'm sure this is pretty simple, but I don't see this in the Readme so figured I'd ask.

I've copied your example .ini file and made changes, i'm working in a test enviroment first so I don't have any security while I get things figured out to see if a Pi will do what I need. So I have left the TLS and CERT_PATH options commented out in the .ini file. However the script seems to still be looking for them when I run it?

Traceback (most recent call last): File "mqtt-gpio-monitor.py", line 37, in <module> MQTT_CERT_PATH = config.get("global", "mqtt_cert_path") File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 803, in get raise NoOptionError(option, section) backports.configparser.NoOptionError: No option 'mqtt_cert_path' in section: 'global'

Same with Python3

Traceback (most recent call last): File "/usr/lib/python3.5/configparser.py", line 786, in get value = d[option] File "/usr/lib/python3.5/collections/__init__.py", line 881, in __getitem__ return self.__missing__(key) # support subclasses that define __missing__ File "/usr/lib/python3.5/collections/__init__.py", line 873, in __missing__ raise KeyError(key) KeyError: 'mqtt_cert_path'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "mqtt-gpio-monitor.py", line 37, in <module> MQTT_CERT_PATH = config.get("global", "mqtt_cert_path") File "/usr/lib/python3.5/configparser.py", line 789, in get raise NoOptionError(option, section) configparser.NoOptionError: No option 'mqtt_cert_path' in section: 'global'

log file

Hello,
is it possible to change the default log-file target?
Thanks!

problem with the new version...

Hi,
i use your old version and this works very well :)
Now i copy the new version and i have the following mistake:

sudo ./mqtt-gpio-monitor.py Traceback (most recent call last): File "./mqtt-gpio-monitor.py", line 14, in <module> import paho.mqtt.client as mqtt ImportError: No module named 'paho'

python --version
Python 2.7.9

What can i do?

ERROR Error connecting to localhost:1833: [Errno 97] Address family not supported by protocol

Hi Sumnerboy,

i am trying to use your code for my idea of garden water management with a pi and some stuff like magnetic valves and flow meters connected to the gpio.

That error message appears in the logfile and doesn't mean anything to me, can you tell something about it?

2015-06-04 21:41:07,980 INFO Starting mqtt-gpio-monitor
2015-06-04 21:41:07,983 INFO INFO MODE
2015-06-04 21:41:07,985 DEBUG DEBUG MODE
2015-06-04 21:41:07,987 DEBUG INIFILE = mqtt-gpio-monitor.ini
2015-06-04 21:41:07,989 DEBUG LOGFILE = mqtt-gpio-monitor.log
2015-06-04 21:41:08,007 INFO RPi.GPIO module detected...
2015-06-04 21:41:08,010 DEBUG Monitoring pins [21, 22, 23, 24]
2015-06-04 21:41:08,021 DEBUG Initialising GPIO input pin 21...
2015-06-04 21:41:08,025 DEBUG Initialising GPIO input pin 22...
2015-06-04 21:41:08,028 DEBUG Initialising GPIO input pin 23...
2015-06-04 21:41:08,030 DEBUG Initialising GPIO input pin 24...
2015-06-04 21:41:08,032 DEBUG Connecting to localhost:1833...
2015-06-04 21:41:08,072 ERROR Error connecting to localhost:1833: [Errno 97] Address family not supported by protocol

Thank you very much!

Run as .service

Hi,
Im trying to run mqtt-gpio-monitor as service on boot @ rasbian (latest)

.service file (/lib/systemd/system/mqtt-gpio-monitor-service.service)

[Unit]
Description=MQTT Buttons
After=multi-user.target

[Service]
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=MQTTGPIOMon
User=pi
Group=pi
WorkingDirectory=/home/pi/gregorb/mqtt-gpio-monitor/
ExecStart=/usr/bin/python3 /home/pi/gregorb/mqtt-gpio-monitor/mqtt-gpio-monitor.py

[Install]
WantedBy=multi-user.target

when i run enable and then status I get

โ— mqtt-gpio-monitor-service.service - MQTT Buttons
   Loaded: loaded (/lib/systemd/system/mqtt-gpio-monitor-service.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-06-09 23:03:48 CEST; 24h ago
 Main PID: 899 (code=exited, status=2)

Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Unit entered failed state.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Failed with result 'exit-code'.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Service hold-off time over, scheduling restart.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: Stopped MQTT Buttons.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Start request repeated too quickly.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: Failed to start MQTT Buttons.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Unit entered failed state.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Failed with result 'exit-code'.

When i try to run it via terminal with command
/usr/bin/python3 /home/pi/gregorb/mqtt-gpio-monitor/mqtt-gpio-monitor.py
I get

Traceback (most recent call last):
  File "/usr/lib/python3.5/configparser.py", line 1135, in _unify_values
    sectiondict = self._sections[section]
KeyError: 'global'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/gregorb/mqtt-gpio-monitor/mqtt-gpio-monitor.py", line 30, in <module>
    MODULE = config.get("global", "module")
  File "/usr/lib/python3.5/configparser.py", line 778, in get
    d = self._unify_values(section, vars)
  File "/usr/lib/python3.5/configparser.py", line 1138, in _unify_values
    raise NoSectionError(section)
configparser.NoSectionError: No section: 'global'

when i cd to root dir of script, I can run it with python3 mqtt-gpio-monitor.py.

Any ideas how to run it as service?
Thanks,
G.

Having trouble with paho mqtt

Looks like I am having trouble with paho mqtt and I am hoping you can provide me with some pointers.

  • Program appears to connect and definitely monitoring configured pin --> 18, but I get no data published by mqtt.

2017-07-03 11:34:51,235 INFO Starting mqtt-gpio-monitor
2017-07-03 11:34:51,236 INFO INFO MODE
2017-07-03 11:34:51,236 DEBUG DEBUG MODE
2017-07-03 11:34:51,237 DEBUG INIFILE = mqtt-gpio-monitor.ini
2017-07-03 11:34:51,238 DEBUG LOGFILE = mqtt-gpio-monitor.log
2017-07-03 11:34:51,246 INFO RPi.GPIO module detected...
2017-07-03 11:34:51,247 DEBUG Monitoring pins [18]
2017-07-03 11:34:51,269 DEBUG Initialising GPIO using Board numbering
2017-07-03 11:34:51,270 DEBUG Initialising GPIO input pin 18...
2017-07-03 11:34:51,271 DEBUG Connecting to XXX.XXX.XXX.XXX:1883...
2017-07-03 11:34:51,276 DEBUG Pin 18 changed from -1 to 1
2017-07-03 11:40:42,930 DEBUG Pin 18 changed from 1 to 0
2017-07-03 11:41:11,193 DEBUG Pin 18 changed from 0 to 1

  • simple mosquitto_pub --> mosquitto_sub between nodes works without issue (bi-directional)

What version of python and paho-mqtt are you using?

Do you have any other advice? Here is the errors I see at startup....

$ sudo ./mqtt-gpio-monitor.py
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/pi/usr/local/lib/python3.4/threading.py", line 911, in _bootstrap_inner
self.run()
File "/home/pi/usr/local/lib/python3.4/threading.py", line 859, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/usr/local/lib/python3.4/site-packages/paho/mqtt/client.py", line 2606, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/home/pi/usr/local/lib/python3.4/site-packages/paho/mqtt/client.py", line 1470, in loop_forever
rc = self.loop(timeout, max_packets)
File "/home/pi/usr/local/lib/python3.4/site-packages/paho/mqtt/client.py", line 995, in loop
rc = self.loop_read(max_packets)
File "/home/pi/usr/local/lib/python3.4/site-packages/paho/mqtt/client.py", line 1273, in loop_read
rc = self._packet_read()
File "/home/pi/usr/local/lib/python3.4/site-packages/paho/mqtt/client.py", line 1838, in _packet_read
rc = self._packet_handle()
File "/home/pi/usr/local/lib/python3.4/site-packages/paho/mqtt/client.py", line 2291, in _packet_handle
return self._handle_connack()
File "/home/pi/usr/local/lib/python3.4/site-packages/paho/mqtt/client.py", line 2349, in _handle_connack
self.on_connect(self, self._userdata, flags_dict, result)
TypeError: on_connect() takes 3 positional arguments but 4 were given

Command syntax reference

When the Parameter is set like this
MQTT_TOPIC = /Gartenwasser

shouldn't this trigger PIN29 aka GPIO.21?
sudo mosquitto_pub -d -t '/Gartenwasser/out/29' -m '1'

Or did i misunderstood the command syntax?

(by the way: the connection is established and a synchronous mosquitto_sub on '/Gartenwasser/out/+' reports the events correctly! Don't ask me how i solved it - it runs now!)

MONITOR_OUT_INVERT will always invert

Thanks for the nice script. Works really well and very well written. One little thing I wanted to point out was ( probably a typo I guess )

config.get

should be config.getboolean(... instead of config.get(...

Cheers,
M.M

Get Status of out pins

When a pin is in Out mode it does not show the status to mqtt when changed from another source, let's say local script action or reboot.

Do you have a solution for this like polling the out pins and generating out messages on the bus?

Incoming message for pin #

This isn't an issue, the code is ace! as I'm sure you're aware, but I'm stuck and couldn't think of another way to ask.

No matter what I change, I always get a payload sent to the control GPIOs when my RPi Zero connects to the MQTT broker. I'm monitoring/controlling it from a RPi3 using Home Assistant. My MQTT switches in Hass have Retain set to False and Qos 0. The reason this is a problem for me is that I'm using your program to set the control GPIO to LOW, then on_message turn the GPIO HIGH, wait for 1 second then back to LOW. The GPIO pin is opening a transistor that is shorting out the Advance button on my central heating programmer, so it's simulating the button being pressed. Each time the button is pressed/shorted-out the heating either comes on or goes off. For this reason I have IN payload 0 and 1 doing the same thing (HIGH, wait 1 sec, LOW). When I reboot, I think the LWT function is sending a payload, which effectively toggles the state of my heating. I've tried a few things like: -

Set MQTT_LWT payload to '3' - and then have that just keep the GPIO pin LOW
Set MQTT_LWT Retain to False
Set MQTT_LWT blank - which just stops the program running

I know there's a few instances of LWT and so I've adjusted each of them. I don't suppose you have a suggestions? You can probably guess from my terminology that I'm not exactly a pro when it comes to this but anything you can suggest to point me in the right direction would be greatly appreciated.

Thanks for making this monitor available by the way. If I could only guarantee my RPi Zero wouldn't reboot I'd be laughing, cause it works a treat once it's running!

Add pin aliases as alternative to physical numbers

Consider creating an optional configuration section that allows for the specification of "aliases" for pins that are being monitored (or commanded). This would allow queue clients could speak in term of logical aliases (e.g., "led_red") instead of GPIO pin numbers and wouldn't preclude still having the original numeric scheme function.

Using meaningful pin aliases is consistent with the best practice of separating concerns and reduces the proliferation of magic pin #s throughout your queue publishers/subscribers. This also allows the node running the script to reassign/adjust pins as needed with less impact.

Set pull-up or pull-down resistor in config

I'm not a programmer, but I've looked through the code and can't see a way to set the pull up resistors. I see in line 272: GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP), but I don't see a way to set it.

I've done it manually on the command line by running 'gpio -g mode 17 up'.

Errors at start of script

I get an error when i start the script.

Traceback (most recent call last): File "./mqtt-gpio-monitor.py", line 330, in <module> poll() File "./mqtt-gpio-monitor.py", line 310, in poll if newstate != oldstate: UnboundLocalError: local variable 'newstate' referenced before assignment Exception in thread Thread-1 (most likely raised during interpreter shutdown): Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner File "/usr/lib/python2.7/threading.py", line 505, in run File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2287, in _thread_main File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1261, in loop_forever File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 811, in loop File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1073, in loop_read File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1475, in _packet_read File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1949, in _packet_handle File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2006, in _handle_connack File "./mqtt-gpio-monitor.py", line 129, in on_connect <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'subscribe'

in the log file :
2016-02-17 09:23:30,001 INFO Starting mqtt-gpio-monitor
2016-02-17 09:23:30,013 INFO INFO MODE
2016-02-17 09:23:30,021 DEBUG DEBUG MODE
2016-02-17 09:23:30,027 DEBUG INIFILE = mqtt-gpio-monitor.ini
2016-02-17 09:23:30,036 DEBUG LOGFILE = mqtt-gpio-monitor.log
2016-02-17 09:23:30,039 DEBUG Monitoring pins [9, 10]
2016-02-17 09:23:30,065 DEBUG Connecting to 192.168.178.17:1883...
2016-02-17 09:23:30,099 INFO Connected to 192.168.178.17:1883

What could be the problem ?

NOOB Question - Starting the script

Hi. Thanks for creating this. I'm going to use it with Home Assistant. Dumb question though. How do I start the script? Don't know where these things get installed as I'm a hardware guy and searching for pifacedigitalio or mqtt-gpio-monitor.ini with WinSCP did not yield any results.

OUTPUT pins also initialize as INPUT pins

I found that output pins also set as input pins by init_gpio() function , so I did modify below lines to get it work

        if pin not in GPIO_OUTPUT_PINS:
            logging.debug("Initialising GPIO input pin %d..." % (pin))
            if MONITOR_PINS_PUD == "UP":
                GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
            elif MONITOR_PINS_PUD == "DOWN":
                GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
            else:
                GPIO.setup(pin, GPIO.IN)
        else:
            logging.debug("Initialising GPIO output pin %d..." % (pin))
            GPIO.setup(pin, GPIO.OUT)

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.