Skip to content

Instantly share code, notes, and snippets.

@shijaz
shijaz / lambda_function.py
Last active October 6, 2018 09:59
Lambda function to toggle a TP-Link HS100 smart switch
import requests
import uuid
import json
import random
import os
USERNAME = 'your_kasa_user@email.com'
PASSWORD = os.environ['PASSWORD'] # not ideal but there aren't many options
def SwitchOn():
@shijaz
shijaz / shadow_listener.py
Last active September 30, 2020 12:55
shadow_listener.py to control the robot using AWS IoT and Amazon Lex using AWS Lambda functions
# shadow_listener.py - Looks for messages on the device shadow using MQTT and performs actions (move and see)
# Copyright (C) 2019 Shijaz Abdulla - www.awsomenow.com
#This bit runs on the RPi
import os, logging, subprocess, time, argparse, datetime
from bottle import route, request, response, redirect, hook, error, default_app, view, static_file, template, HTTPError
from gpiozero import CamJamKitRobot
import datetime, pygame, ssl
import paho.mqtt.client as mqtt
#from picamera import PiCamera
@shijaz
shijaz / shadow_updater.py
Created July 15, 2018 20:03
shadow_updater.py for the Lambda Function 'SeeRobot'
# shadow_updater.py for the Lambda Function 'SeeRobot'
# Updates the AWS IOT Shadow for the robot
# Shijaz Abdulla - www.awsomenow.com
import os
import time
import json
import boto3
@shijaz
shijaz / lambda_function.py
Created July 15, 2018 19:59
lambda_function.py for the Lambda Function 'SeeRobot'
# lambda_function.py for the Lambda Function 'SeeRobot'
# Shijaz Abdulla - www.awsomenow.com
import os
import logging
import shadow_updater
# Get the environment variables
clientId = os.environ.get('AWS_IOT_MQTT_CLIENT_ID')
thingName = os.environ.get("AWS_IOT_THING_NAME")
@shijaz
shijaz / shadow_updater.py
Last active July 15, 2018 19:56
shadow_updater.py for Lambda function 'MoveRobot'
# shadow_updater.py for Lambda function 'MoveRobot'
# Updates the AWS IOT Shadow for the robot
# Shijaz Abdulla - www.awsomenow.com
import os
import time
import json
import boto3
@shijaz
shijaz / lambda_function.py
Created July 15, 2018 19:22
lambda_function.py for AWS Lambda function - 'MoveRobot'
# lambda_function.py for AWS Lambda function - 'MoveRobot'
# Shijaz Abdulla - www.awsomenow.com
import os
import logging
import shadow_updater
# Get Environment Variables
clientId = os.environ.get('AWS_IOT_MQTT_CLIENT_ID')
thingName = os.environ.get("AWS_IOT_THING_NAME")
@shijaz
shijaz / index.html
Created July 6, 2018 14:33
Modified index.html for robot project at www.awsomenow.com
<html>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<div id="headWrapper"><h1>Robot Control Terminal</h1></div>
<div class="wrapper">
<div class="updownBtn"><button class="btn" onmousedown="robotMove(1)">Forward</button></div>
<div class="leftrightBtn"><button class="btn" onmousedown="robotMove(4)">Left</button></div>
<div class="leftrightBtn"><button class="btn" onmousedown="robotMove(2)">Right</button></div>
<div class="updownBtn"><button class="btn" onmousedown="robotMove(3)">Reverse</button></div>
@shijaz
shijaz / webbot.py
Last active July 16, 2018 08:32
Modified webbot.py for the robot project on www.awsomenow.com
#!/usr/bin/env python3
## webbot code modified by Shijaz Abdulla - www.awsomenow.com
## See the original project on GitHub: https://github.com/picymru/webbot
## This code is referenced in http://www.awsomenow.com/2018/07/06/building-a-robot-with-computer-vision-and-speech/
##
# Some of the code that controls the robot's movement is from the Webbot project by PiCymru. Including their copyright notice.
##
# Copyright (c) 2016 PiCymru
# Permission is hereby granted, free of charge, to any person obtaining a copy