Ejemplo n.º 1
0
                    timeout=1)

instance = dht11.DHT11(pin=17)
ser.reset_input_buffer()
buzzer = 23
relay = 27  #device connected to normally closed terminal
count = 0
count1 = 0
flag = 0
GPIO.setup(buzzer, GPIO.OUT)
GPIO.setup(relay, GPIO.OUT)
lcd.clear()
GPIO.output(buzzer, GPIO.LOW)
GPIO.output(relay, GPIO.LOW)
authtoken = '2c6909a5c93d433aa1baf7c0ce06c444'
powerswitchpin = Blynk(authtoken, pin="V6")
startpin = Blynk(authtoken, pin="V7")
stoppin = Blynk(authtoken, pin="V8")
timercontrol = Blynk(authtoken, pin="V9")
blynk = BlynkLib.Blynk(authtoken)


#Timer settings for device off duration
def timecomp(start, stop):
    currentDT = datetime.datetime.now()
    currenthour = currentDT.hour
    if (start < stop):
        if (start <= currenthour and currenthour < stop):
            return True

        else:
from blynkapi import Blynk 
import RPi.GPIO as GPIO 
import os                                                   
import glob                                                 
os.system('modprobe w1-gpio') 
os.system('modprobe w1-therm')                                                  
base_dir = '/sys/bus/w1/devices/'                           
device_folder = glob.glob(base_dir + '28*')[0]              
device_file = device_folder + '/w1_slave'                   
GPIO.setmode(GPIO.BCM) 
GPIO.setmode(GPIO.BOARD) 
auth_token = "YOUR TOKEN" 
  
temp = Blynk(auth_token, pin = "V3") 
  
def read_temp_raw(): 
   f = open(device_file, 'r') 
   lines = f.readlines()                                    
   f.close() 
   return lines 
  
def read_temp(): 
   temp = read_temp_raw() 
   while lines[0].strip()[-3:] != 'YES': 
       temp = read_temp_raw() 
   equals_pos = lines[1].find('t=')                         
   if equals_pos != -1: 
      temp_string = lines[1][equals_pos+2:] 
      temp_c = float(temp_string) / 1000.0                  
                          
      return temp_c 
Ejemplo n.º 3
0
GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)

GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)

GPIO.setup(18, GPIO.OUT)
GPIO.setup(19, GPIO.OUT)

p = GPIO.PWM(19, 50)
p1 = GPIO.PWM(18, 50)
p.start(0)
p1.start(0)

auth = "f1f169ef17fa45b0824b085f42c1e4ec"
Blynk(auth, )

print(Blynk(auth).app_status())
print(Blynk(auth).hw_status())


def SetAngle1(angle):
    print("Angle: ")
    print(angle)
    duty_cycle = (angle / 18) + 2
    GPIO.output(19, True)
    p.ChangeDutyCycle(duty_cycle)
    GPIO.output(19, False)


def SetAngle2(angle):
Ejemplo n.º 4
0
'''-----------------------------------------
This is the original script to test the ability to get data from the Blynk controller in real time.

Please install Blynk API first. https://github.com/xandr2/blynkapi

Will get values from the "virtual pins" made on the Blynk controller
-----------------------------------------'''

from blynkapi import Blynk
from time import sleep

auth_token = "340c28ef62d94a998855b7c8d4b89651"

# create the blynk object
blynk = Blynk(auth_token)

# print the status to ensure it is connected to Blynk server
print blynk.app_status()

# create virtual pin objects
height = Blynk(auth_token, pin="V0")
x_pos = Blynk(auth_token, pin="V1")
y_pos = Blynk(auth_token, pin="V2")

# get current status of each pin
while (1):
    curr_height = height.get_val()
    curr_x_pos = x_pos.get_val()
    curr_y_pos = y_pos.get_val()

    print curr_height, curr_x_pos, curr_y_pos
Ejemplo n.º 5
0
def checkResetCounterButton():
    ResetButtonState = Blynk(BLYNK_AUTH, pin="V0")
    result = ResetButtonState.get_val()
    if result[0] == "1":
        return True
Ejemplo n.º 6
0
import time
from gpiozero import MCP3008, LED
from blynkapi import Blynk
from time import sleep
from rpi_lcd import LCD

auth_token = "1letPRLrzfboQtbakpFaOk2dX_vc-xCg"

led = LED(21)
adc = MCP3008(channel=0)
lcd = LCD()

while True:
    try:

        button = Blynk(auth_token, pin="V0")
        button_val = str(button.get_val()[0])
        print("Button value is %s" % (button_val))
        if button_val == "1":
            led.on()
            lcd.text('Classroom is open', 1)
        else:
            led.off()
            lcd.text('', 1)

        light = Blynk(auth_token, pin="V1")
        light_sensor_value = adc.value * 1024
        s_light_sensor_value = str(light_sensor_value)
        fs_light_sensor_value = "[\"" + s_light_sensor_value + "\"]"
        print("Light sensor value is %s" % (fs_light_sensor_value))
        light.set_val_old(fs_light_sensor_value)
Ejemplo n.º 7
0
#!/usr/bin/env python3
# if you install it from pip, else use `from Blynk import *`
from blynkapi import Blynk
import time

# vars
auth_token = "dc1c083949324ca28fbf393231f8cf09"

# create objects
v0 =  Blynk(auth_token, pin = "V0" )
v10 = Blynk(auth_token, pin = "V10")

# get current status
res = v0.get_val()
print(res)

# set pin value to 1
print("V10 on")
v10.set_val(255)
# set pin value to 0
time.sleep(10)

print("V10 off")
v10.off()
Ejemplo n.º 8
0
import time
from blynkapi import Blynk
from gpiozero import LED
from time import sleep
import sys

auth_tokens = sys.argv[1]
led = LED(4)

def airconOn():
    led.on()

def airconOff():
    led.off()

for auth_token in auth_tokens:
    try:
        button = Blynk(auth_token, pin = "V0")
        button_val = str(button.get_val()[0])
        if button_val=="1":
            airconOn()
        else:
            airconOff()
    except Exception:
        sys.exit(1)
Ejemplo n.º 9
0
from pyA20.gpio import gpio
from pyA20.gpio import port
from time import sleep
from blynkapi import Blynk
#from Blynk import *
import time

gpio.init()
led_1 = port.PA12
auth_token = "6550d659b4bb4d189509a09e6f7f61ff"
room_light = Blynk(auth_token, pin="V0")
gpio.setcfg(led_1, gpio.OUTPUT)
while True:
    res = room_light.get_val()
    print res

    if res[0] == u'0':
        gpio.output(led_1, 1)
        print res
        print "xxxx"
    if res[0] == u'1':
        gpio.output(led_1, 0)
        print res
        print("YYYYY")

# set pin value (one)
#amp_power.set_val(["120"])

# set pin value to 1
#room_light.on()
# set pin value to 0
Ejemplo n.º 10
0
#!/usr/bin/env python3
# if you install it from pip, else use `from Blynk import *`
from blynkapi import Blynk
import time

# vars
auth_token = "dc1c083949324ca28fbf393231f8cf09"

# create objects
v0 = Blynk(auth_token, pin="V0")
v10 = Blynk(auth_token, pin="V10")

# get current status
res = v0.get_val()
print(res)

# set pin value to 1
print("V10 on")
v10.set_val(255)
# set pin value to 0
time.sleep(10)

print("V10 off")
v10.off()
Ejemplo n.º 11
0
from blynkapi import Blynk
import time
import unicodedata
import thread

files = '/home/pi/hinh/{0}.jpeg'
f = open('/home/pi/config/auth.txt', 'r')
auth = f.read(32)
f.close()
e = open('/home/pi/config/email.txt', 'r')
em = e.read().strip()
e.close()
#auth="5308db499c81455cac655562ba5967f0"
notification = 'The door is open, Image Link send to email'

notify = Blynk(auth)
sendmail = Blynk(auth)
led = Blynk(auth, pin='V5')
device1 = Blynk(auth, pin='V3')
std1 = Blynk(auth, pin='V2')
###########################################################
# create IO
io.setmode(io.BCM)
io.setup(4, io.IN, pull_up_down=io.PUD_DOWN)  # Sensor input
io.setup(16, io.OUT)
# configarution dropbox
dbx = dropbox.Dropbox(
    '58tDXm_qTmAAAAAAAAAAEmntpAVf_FVI3S2DtJvR8zKBLy_eNuz9rB2TmCOREfiX')
link = 'https://www.dropbox.com/sh/yzlaq6k5oicazzu/AAA83ia5wBg4UzqATkR3EPbTa?dl=0'

Ejemplo n.º 12
0
import telegram
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, InlineQueryHandler, CallbackQueryHandler
from blynkapi import Blynk
import logging

# Vars 
# your telegram bot token id
tokenid = '251sdbrmvorfiojoeirjgoejfwcwlclrlGxAqQUpnc'

# Blynk projects id
my_project = "fe4ab7fe7aawfd3qffervw45t2sdferrf34e"
my_project2 = "sbvhcaci34hwch8qghdhp8csdnci0jvhd39s"

# create a blynk objects with you want to work
k_amp_power = Blynk(my_project, pin = "V3")
k_light = Blynk(my_project, pin = "V4")
k_amp_src = Blynk(my_project2, pin = "V2")

# begin of program
logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.INFO)

def start(bot, update):
	"""Base menu with all available commands"""
	bot.sendMessage(chat_id=update.message.chat_id, text="""
		I'm a bot, please talk to me!
		You can:

		/amplifier	turn On/Off amp on kitchen
Ejemplo n.º 13
0
def turn_on(pin):
    machine = Blynk(token=BLYNK_TOKEN, server=blynk_server, protocol=blynk_protocol, port=blynk_port, pin=pin)
    machine.off()
    time.sleep(1)
    machine.on()
Ejemplo n.º 14
0
from blynkapi import Blynk
import time

#Sensor number 4 with DHT22
token = 'e6532120260e4cc68318831d146b2c51'

#Pin 1 is LED,5 is humidity,6 is temperature
sensor_reading = Blynk(token,
                       pin="V5",
                       server="blynk.bitville.com",
                       port="8080")

while True:
    result = sensor_reading.get_val()
    print result
    time.sleep(1)