Skip to content

Instantly share code, notes, and snippets.

View fisher0251's full-sized avatar

Dan Fisher fisher0251

  • Minneapolis, MN
View GitHub Profile
count1 = 0
count2 = 0
count3 = 0
while count3 < 100:
count1 = count1 + 1
count2 = count2 + 1
count3 = count3 + 1
if count1 == 3 and count2 == 5:
print 'fizzbuzz'
@fisher0251
fisher0251 / hablogger.py
Created June 24, 2015 04:02
Raspberry Pi High Altitude Balloon Datalogger Script 2015
#! /usr/bin/python
# Script to read gps data and log it to a file
# Must connect a gpsd socket on UART before running this script, using:
# sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock &
import os
from gps import *
from time import *
import time
import csv
@fisher0251
fisher0251 / weatherLogger.py
Created June 17, 2015 05:09
Raspberry Pi Weather Station
#!/usr/bin/python
# weatherLogger.py
# Updated 2015-06-16, by D. Fisher
# Weather station program for RPi
# Sensors: BMP180 air pressure, DHT humidity/temperature, TSL2561 luminosity
# Sends to wunderground.com for weather station KMNMINNE86, also records
# each measurement to a datafile
import urllib
import urllib2
// THIS IS A CODE SNIPPET ONLY AND WILL NOT RUN AT ALL ON ITS OWN!!
// Variables declared globally for interrupt use
// Start of channel interval
volatile uint16_t ch1_start = 0;
volatile uint16_t ch2_start = 0;
volatile uint16_t ch3_start = 0;
volatile uint16_t ch4_start = 0;
volatile uint16_t ch5_start = 0;
volatile uint16_t ch6_start = 0;
client_config_backend: file
client_config_file: client_secrets.json
save_credentials: True
save_credentials_backend: file
save_credentials_file: credentials.json
get_refresh_token: True
# patimelapse.py
# Timelapse script for taking and uploading images to Google Drive
# You must create the client_secrets.json file (see pydrive documentation)
# If you want to save your credentials for reuse, you must include the correct
# save_credentials values in settings.yaml
import time
from datetime import datetime, timedelta
import picamera
from pydrive.drive import GoogleDrive
@fisher0251
fisher0251 / fileexample.py
Created January 17, 2015 04:57
Example code to write data to a file, specifically a comma-separated value format
# fileexample.py
# Example code to write data to a file, specifically a comma-separated value format
# Dan Fisher, 2014-01-10
import csv
measurement1 = 98382.90239481
measurement2 = 79.28593289
# Open a file, then use the csv library to easily write a line of data to the file
@fisher0251
fisher0251 / sensorexample.py
Created January 17, 2015 04:54
Shows how to use the Adafruit library to read pressure and altitude from the BMP180
# sensorexample.py
# Shows how to use the Adafruit library to read pressure and
# altitude from the BMP180
import Adafruit_BMP.BMP085 as BMP085
import time
# This starts the pressure sensor
sensor = BMP085.BMP085()
@fisher0251
fisher0251 / displayexample.py
Created January 17, 2015 04:46
RPi 4-digit 7-segment LED display multiplexing example
# displayexample.py
# Example program showing how to use the ledmulti library functions
# Dan Fisher, 2014-01-10
# updated 2014-01-15
import ledmulti as led
import time
import RPi.GPIO as GPIO
# Displays a number for display_time in seconds, with up to 3 decimal places