Skip to content

Instantly share code, notes, and snippets.

View dave-malone's full-sized avatar

Dave Malone dave-malone

  • Amazon Web Services
  • Tampa, FL
View GitHub Profile
@dave-malone
dave-malone / auto_topoff.py
Last active June 30, 2022 20:21
A simple Python program for Raspberry Pi that initiates a pump to deliver water from a reservoir when a water sensor reading returns a value indicating that the water level is running low
import RPi.GPIO as GPIO
import time
WATER_SENSOR_PIN = 23
RELAY_CONTROL_PIN = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(WATER_SENSOR_PIN, GPIO.IN)
GPIO.setup(RELAY_CONTROL_PIN, GPIO.OUT)
@dave-malone
dave-malone / gstreamer-pipeline-examples.sh
Created June 28, 2022 18:03
Gstreamer pipeline examples
## View the video feed on the Rasperry Pi itself
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, width=1280, height=720, framerate=30/1 ! videoflip method=rotate-180 ! videoconvert \
! videoscale ! clockoverlay time-format="%D %H:%M:%S" ! video/x-raw, width=640, height=360 ! autovideosink
## Start the video stream from the Rasperry Pi
export HOST_IP=192.168.1.100
gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=-1 ! video/x-raw, width=640, height=480, framerate=30/1 ! \
@dave-malone
dave-malone / mcp23017.py
Created April 8, 2021 21:05
Raspberry Pi GPIO LED Binary Clock driven by the MCP23017 port expander
import smbus
import time
from datetime import datetime
bus = smbus.SMBus(1)
DEVICE = 0x20 # Device address (A0-A2)
IODIRA = 0x00
OLATA = 0x14
GPIOA = 0x12
@dave-malone
dave-malone / echo.sh
Last active March 24, 2021 14:51
Just a simple echo script
#!/bin/bash
RUN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "installing amazon-kinesis-video-streams-webrtc-sdk-c build dependencies"
sudo apt-get install -y \
pkg-config \
cmake \
zip \
libssl-dev \
@dave-malone
dave-malone / cardboard_cruiser.py
Created November 21, 2020 15:57
cardboard_cruiser.py
import time
import logging
import threading
import atexit
from adafruit_crickit import crickit
format = "%(asctime)s: %(message)s"
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
# make two variables for the motors to make code shorter to type
@dave-malone
dave-malone / gg-upgrade.md
Created November 9, 2020 16:23
AWS CLI Commands to upgrade the GG software on a specific GG core

TARGET_ARCHITECTURE=armv7l TARGET_OPERATING_SYSTEM=raspbian S3_URL_SIGNER_ROLE_ARN="arn:aws:iam:::role/AllowAccessToGreengrassOTAUpdateArtifacts" GG_UPDATE_TARGET="arn:aws:iot:us-east-1::thing/<GG_CORE_THING_NAME>"

aws greengrass create-software-update-job
--update-targets-architecture $TARGET_ARCHITECTURE
--update-targets "${GG_UPDATE_TARGET}"
--update-targets-operating-system $TARGET_OPERATING_SYSTEM
--software-to-update core \

@dave-malone
dave-malone / dropin.sh
Created September 23, 2020 20:51
Drop into a running Lambda function container on Greengrass
ps aux | grep lambda_runtime
sudo nsenter -t $PID -m /bin/bash
@dave-malone
dave-malone / gist:9ddb7fed7405d09a158bfb3fcfe258db
Created September 1, 2020 12:53
remount read-only, completely full filesystem
I was unable to free up disk space on my Raspberry Pi recently, and I kept getting a "cannot remove... Read-only file system" error when attempting to run the `rm` command. The following step was necessary prior to then removing uncessary files and freeing up space on the filesystem.
`sudo mount -o remount,rw /`
@dave-malone
dave-malone / multi-attribute-things.md
Last active February 11, 2020 12:57
An example of how to create AWS IoT Things with more than three attributes
THING_TYPE_NAME=multi-attribute-type
THING_NAME=multi-attribute-thing
DYNAMIC_GROUP_NAME=multi-attribute-dynamic-group

aws iot create-thing-type --thing-type-name $THING_TYPE_NAME

aws iot create-thing \
  --thing-name $THING_NAME \
 --thing-type-name $THING_TYPE_NAME \
const AWS = require('aws-sdk')
AWS.config.region = process.env.AWS_REGION
const kinesisvideo = new AWS.KinesisVideo({
})
function getStreamingSessionURL(){
return new Promise((resolve, reject) => {
var getEndpointParams = {