Giter Site home page Giter Site logo

controlling-raspberry-pi-using-alexa's Introduction

Controlling-Raspberry-Pi-using-Alexa

Being able to control Raspberry Pi via voice commands is always amazing. I have demonstrated how you can control your Raspberry Pi using Amazon Alexa. For establishing connection between Raspberry Pi and Alexa, we are going to use certain open-source services and sdk. Logic for controlling Alexa commands and Raspberry Pi will be hosted on local server on Raspberry Pi. As you will require SSL certificates for 'endpoint' in Amazon Alexa, you can use certain open source services to establish tunneling from your Raspberry Pi to Amazon Alexa.

The skill for Alexa will be made using Flask-Ask. For establishing connection we will be using ngrok. ngrok establishes a HTTP tunnel from Raspberry Pi to Alexa. The endpoint url will change every time ngrok is restarted, as an alternative you can use pagekite.

For detailed information visit https://www.hackster.io/nishit-patel/controlling-raspberry-pi-using-alexa-33715b.

controlling-raspberry-pi-using-alexa's People

Contributors

nishitpatel28 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

Watchers

 avatar  avatar  avatar

controlling-raspberry-pi-using-alexa's Issues

SyntaxError in Code.py

I've just cloned the repo and ran the code, as this error appeared: ( File "/home/admin/Controlling-Raspberry-Pi-using-Alexa/Code.py", line 25)elif status in STATUSOFF : GPIO.output(17,GPIO.LOW) ^ SyntaxError: invalid syntax

Establish connection between raspberry pi and Alexa Skill using java

I would like to control a LED connected to raspberry pi using Alexa and java. I have successfully achieved it following your tutorial https://www.hackster.io/nishit-patel/controlling-raspberry-pi-using-alexa-33715b. Now I would like to have access and modify mysql database and that required a java code. So I am trying to convert this following python code to java. Any idea, please?
Thanks in advance.

import logging
import os
import MySQLdb

from flaskext.mysql import MySQL
from flask import Flask, render_template
from flask_ask import Ask, request, session, question, statement
import RPi.GPIO as GPIO

db=MySQLdb.connect(host='xxx.xxx.xxx.x',user='xxxx',passwd='xxxxxx',db='xxxxx')
cursor=db.cursor()

app = Flask(name)
ask = Ask(app, "/")
logging.getLogger('flask_ask').setLevel(logging.DEBUG)

STATUSON = ['on','high']
STATUSOFF = ['off','low']

@ask.launch
def launch():
speech_text = 'Welcome to Raspberry Pi Automation.'
return question(speech_text).reprompt(speech_text).simple_card(speech_text)

@ask.intent('GPIOControlIntent', mapping = {'status':'status'})
def Gpio_Intent(status,room):
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.OUT)
if status in STATUSON:
GPIO.output(17,GPIO.HIGH)
cursor.execute("INSERT INTO led (Etat) VALUES ('1')")
db.commit()
return statement('turning {} lights'.format(status))

elif status in STATUSOFF:
GPIO.output(17,GPIO.LOW)
cursor.execute("INSERT INTO led (Etat) VALUES ('0')")
db.commit()
return statement('turning {} lights'.format(status))
else:
return statement('Sorry not possible.')
@ask.intent('AMAZON.HelpIntent')
def help():
speech_text = 'You can say hello to me!'
return question(speech_text).reprompt(speech_text).simple_card('HelloWorld', speech_text)

@ask.session_ended
def session_ended():
return "{}", 200

if name == 'main':
if 'ASK_VERIFY_REQUESTS' in os.environ:
verify = str(os.environ.get('ASK_VERIFY_REQUESTS', '')).lower()
if verify == 'false':
app.config['ASK_VERIFY_REQUESTS'] = False
app.run(debug=True)

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.