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 / rte2plot.py
Created November 28, 2017 17:05
Display french RTE data to matplotlib with pandas
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import dateutil.parser
import requests
import pandas as pd
import matplotlib.pyplot as plt
import time
@sourceperl
sourceperl / gas_network_graph.py
Created December 6, 2017 18:48
Test with networkx to emulate gas flow
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import networkx as nx
class GasGraph(nx.Graph):
def update(self):
for node in self:
# Valve
@sourceperl
sourceperl / modbus_map.py
Created December 20, 2017 08:45
Auto-build modbus flow map graph on a tk canvas (with scapy)
#!/usr/bin/env python3
# auto-build modbus flow map graph on a tk canvas
import threading
import tkinter as tk
from scapy.all import *
import networkx as nx
@sourceperl
sourceperl / esp8266_tspeak_lowpower.ino
Created January 5, 2018 12:34
ESP8266 periodic upload of a counter to thingspeak with HTTP or MQTT (use ESP deep sleep, RTC memory)
/*
ESP8266 periodic upload an integer to thingspeak, set ESP to deep sleep between sends
and use RTC memory for variable persistence. Use http and mqtt update.
For leave deep sleep mode we need a jumper between RST and D0 (GPIO16/WAKE) so don't uses LED_BUILTIN here.
Test on nodemcu v2.
This example code is in the public domain.
*/
@sourceperl
sourceperl / 1000_pulses.ino
Last active January 11, 2018 08:02
Super simple 1000 pulses generator.
/*
1000 pulses generator (100ms width/5 Hz)
Send pulseCount to MOSFET transitor connect to D2 pin.
Push FLASH button (link to D3) to start generator.
Push RST button to stop generator and clear counter.
Test with ESP-12 on nodemcu.
This example code is in the public domain.
@sourceperl
sourceperl / rn2483_rx.py
Created January 24, 2018 16:41
RN2483 LoRa point to point test
#!/usr/bin/env python3
# RN2483 point to point test
# open serial link, init and display rx frames
import argparse
import serial
# some functions
def send_cmd(cmd):
@sourceperl
sourceperl / lille_view_park.py
Created February 9, 2018 14:44
Python request of parking availability of the city of Lille (from MEL opendata platform)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import dateutil.parser
import requests
import pandas as pd
import datetime
# some consts
NAN = float('nan')
@sourceperl
sourceperl / pi-desktop-manager
Last active March 29, 2018 17:50
Pi Desktop manager
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import os, sys
import signal
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(31, GPIO.OUT)
@sourceperl
sourceperl / square_fft.py
Last active April 2, 2018 12:34
Square wave FFT
#!/usr/bin/env python3
# build a square signal from sum of sin
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
# number of samples
Ns = 2000
@sourceperl
sourceperl / ttn-build-key
Last active October 30, 2018 10:49
TTN utils
#!/usr/bin/env python3
import random
key8 = ''.join(random.choice('0123456789ABCDEF') for n in range(16))
key16 = ''.join(random.choice('0123456789ABCDEF') for n in range(32))
print("generate 8 bytes key: %s" % key8)
print("generate 16 bytes key: %s" % key16)