Skip to content

Instantly share code, notes, and snippets.

View sourceperl's full-sized avatar

l.lefebvre sourceperl

  • Hauts-de-France
View GitHub Profile
@sourceperl
sourceperl / bubble_panel.py
Created March 29, 2017 08:59
Spirit bubble with Rpi Sense Hat: use 8x8 LEDs and accelerometer
#!/usr/bin/env python3
# Spirit bubble with Rpi Sense Hat: use 8x8 LEDs and accelerometer
from sense_hat import SenseHat
import schedule
import time
# some const
RED = (255, 0, 0)
GREEN = (0, 255, 0)
@sourceperl
sourceperl / led_panel.py
Created May 26, 2017 07:43
Display refresh time of a thingspeak feed on a Rpi sense hat 8x8 LED matrix
#!/usr/bin/env python3
import http.client
from sense_hat import SenseHat
import dateutil.parser
import datetime
import schedule
import time
import threading
import json
@sourceperl
sourceperl / ds18b20_read
Created June 1, 2017 17:29
Temperature from DS18B20 on a Raspberry Pi
#!/bin/bash
# read DS18B20 (default is data connect on GPIO4)
# add 'dtoverlay=w1-gpio' to /boot/config.txt to load one-wire device tree and reboot
# test on Rpi with Raspbian Jessie
while [ true ]
do
cat /sys/bus/w1/devices/28-0000040de8f8/w1_slave | grep 't=' | awk -F 't=' '{printf("%.2f\n", $2/1000)}'
done
@sourceperl
sourceperl / thingspeak
Created June 2, 2017 07:10
Command line tool to update thingspeak
#!/bin/bash
# Update thingspeak from command line
# Usage : thingspeak WRITE_API_KEY DATA
# Example : thingspeak XXXXXXXXXXXX field1=11&field2=12
# consts
URL="https://api.thingspeak.com/update"
# vars
@sourceperl
sourceperl / relay_pulse.py
Created June 20, 2017 12:33
Command line utility to make a high pulse on relay attach to Rpi GPIO
#!/usr/bin/env python3
# make high pulse on relay attach to Rpi GPIO
# see REL_PIN_MAP to fix GPIO pin number
import time
import argparse
import RPi.GPIO as GPIO
# some const
@sourceperl
sourceperl / test_mkrfox.ino
Last active January 12, 2018 10:35
Test of Arduino MKRFox1200
/*
MKRFox1200 Test: send s counter every 15 min
Power with 2 AA battery: under 3.18v, avg current is 1.7 ma
*/
#include <ArduinoLowPower.h>
#include <SigFox.h>
// some vars
@sourceperl
sourceperl / test_aes128.py
Created August 3, 2017 14:26
Test of AES128 with python3
#!/usr/bin/env python3
from Crypto.Cipher import AES
import hashlib
import os
# message to crypt with AES-128
text = 'the secret message'
# define 128-bit key from a text password
@sourceperl
sourceperl / test_adafruit_io.py
Created August 6, 2017 12:38
MQTT adafruit.io test
#!/usr/bin/env python3
import paho.mqtt.client as mqtt
# import ssl
import time
# some const
# mqtt account
MQTT_HOST = 'io.adafruit.com'
MQTT_USER = '<USERNAME>'
@sourceperl
sourceperl / ir_motor_command.ino
Created October 7, 2017 07:17
IR robot : Pololu Zumo + DRV8835 + Arduino IRremote lib
// from https://github.com/pololu/drv8835-motor-shield
#include <DRV8835MotorShield.h>
// from https://github.com/z3t0/Arduino-IRremote/
#include <IRremote.h>
// some consts
#define RECV_PIN 5
#define PWR_IR_VCC 4
#define PWR_IR_GND 3
#define LED_PIN 13
@sourceperl
sourceperl / conv_gmap_address.py
Last active November 21, 2017 14:41
Convert Placemark from google address KML to CSV like output
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# KML converter for "google address"
import argparse
# from here https://github.com/martinblech/xmltodict
import xmltodict
# parse args