This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import RPi.GPIO as GPIO | |
from time import sleep | |
# Setup Gpio | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(3, GPIO.OUT) # Pin 3 (Gpio 2). To Esp Gpio0. | |
GPIO.setup(5, GPIO.OUT) # Pin 5 (Gpio 3). To Esp reset ("RST"). | |
# Set D0 low |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Test three leds connected to Raspberry Pi Gpio. | |
import RPi.GPIO as GPIO | |
from time import sleep | |
# Setup Gpio | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BOARD) # Use actual pin numbers on the board | |
GPIO.setup(32, GPIO.OUT) | |
GPIO.setup(36, GPIO.OUT) | |
GPIO.setup(38, GPIO.OUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pigpio | |
from time import sleep | |
pi = pigpio.pi() | |
# Output is Broadcom Gpio12 (physical pin 32) | |
pi.hardware_PWM(12, 2000, 250000) # 2000Hz 75% dutycycle | |
sleep(1) | |
pi.hardware_PWM(12, 2000, 500000) | |
sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pigpio | |
from time import sleep | |
pi = pigpio.pi() | |
# Leds on Gpio 13, 19, 26 | |
while 1: | |
# On Broadcom Gpio12 (physical pin 32) we have a analog gauge | |
pi.hardware_PWM(12, 2000, 250000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from time import time, sleep | |
import datetime | |
import os # For running external commands | |
import RPi.GPIO as GPIO | |
import urlparse | |
import paho.mqtt.client as paho | |
# Time to wait (in seconds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import urllib | |
import json | |
from time import sleep | |
import os | |
# Used to control Gpios | |
import pigpio | |
pi = pigpio.pi() | |
pi.set_mode(13, pigpio.OUTPUT) # GPIO as output Green led |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# tvonoff.py | |
# This script uses a Pir sensor and a IR diode to turn on a tv when motion is detected. | |
# It uses time to only turn on tv at daytime. | |
# It also has a time out, if no motion is detected for a set period the tv is turned off. | |
# Another function is to send Mqtt messages when tv is turned on or off. | |
# | |
# The software irsend from Lirc is used to send codes. | |
# /usr/bin/irsend SEND_ONCE Samsung_BN59-00685A KEY_POWER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/41531412/nodemcu-auto-join-open-wifi | |
#include <ESP8266WiFi.h> | |
/* Serial Baud Rate */ | |
#define SERIAL_BAUD 9600 | |
/* Delay paramter for connection. */ | |
#define WIFI_DELAY 500 | |
/* Max SSID octets. */ | |
#define MAX_SSID_LEN 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Read a Pir-sensor and send a Mqtt message when motion detected | |
# Uses edge detection to limit the rate of Mqtt-messages | |
import paho.mqtt.client as paho | |
import time | |
import urlparse | |
import RPi.GPIO as GPIO | |
import datetime | |
# Mqtt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
This code reads weather data from a Rflink (http://www.rflink.nl) and sends out data via Mqtt. | |
''' | |
import time | |
import serial | |
import paho.mqtt.client as mqtt | |
import json |
OlderNewer