Skip to content

Instantly share code, notes, and snippets.

@matbor
matbor / 00readme.md
Last active April 23, 2017 18:03
Onewire Temperatures to mqtt broker server.Have modified the onewire example program so that no mater how many sensors u have plugged in it will always publish each reading to my MQTT broker server. It will use the onewire sensor ROM ID as part of the topic, ie. /house/arduino/[DEVICE ID/temperature/current and the message payload will be the Ce…
@matbor
matbor / mqttitudeTOmysql.py
Last active September 3, 2022 13:32
Simple Python script (v2.7x) that subscribes to a MQTT broker topic and inserts the data into a mysql database for later querying. This is designed to be used with the http://mqttitude.org/
#!/usr/bin/env python
# September 2013
# by Matthew Bordignon, @bordignon on Twitter
#
# Simple Python script (v2.7x) that subscribes to a MQTT broker topic and inserts the topic into a mysql database
# This is designed for the http://mqttitude.org/ project backend
#
import MySQLdb
import mosquitto
@matbor
matbor / getlocations.php
Created September 13, 2013 04:39
Mysql -> Google Maps for mqttitude (using my mysql script). You need to add your google api key below to make it work.
<?php
$conn = mysql_connect("thebeast.localdomain", "root", "") or die(mysql_error());
mysql_select_db("mqtt") or die(mysql_error());
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps</title>
<style type="text/css">
@matbor
matbor / gauge-mqtt-websockets.html
Created September 25, 2013 12:31
Steelseries gauge displaying temperature live using websockets from a mqtt/mosquitto broker.
<head>
<title>Testing Temp Gauge</title>
</head>
<body onload="init();">
<canvas id=gaugeCanvas width=200 height=200>No canvas in your browser...sorry...</canvas>
</body>
<script type="text/javascript" src="mosquitto-1.1.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type=text/javascript src=http://dl.dropbox.com/u/128855213/SteelSeries/tween-min.js></script>
<script type=text/javascript src=http://dl.dropbox.com/u/128855213/SteelSeries/steelseries-min.js></script>
@matbor
matbor / mqttitude-gmaps.html
Last active January 6, 2017 17:15
To be used with the http://mqttitude.org/ project, mqtt broker, websockets and google maps. Subscribes to a topic and plots the mqttitude in realtime using websockets. NOTE: you need a google map api.
<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&sensor=false"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="mqttws31.js" type="text/javascript"></script>
<TITLE>MQTTitude - find my family & friends</title>
<style type="text/css">
@matbor
matbor / Distance.py
Created October 5, 2013 07:21
Simple python script to find the line of sight distance between two sets of latitude and longitude points. Will modified later for geofencing with mqttitude.org backend server.
import math
def distance_on_unit_sphere(lat1, long1, lat2, long2):
# by Matthew Bordignon @bordignon Oct 2013
#
# handy example for finding distance between two sets of co-oridinates
# modified from http://www.johndcook.com/python_longitude_latitude.html
# Convert latitude and longitude to
# spherical coordinates in radians.
degrees_to_radians = math.pi/180.0
@matbor
matbor / DistanceLatLon.py
Last active December 26, 2015 12:39
Handy example for working out distance between two sets of latitude and longitude points.... The start of a geo fence!
import math
def distance_on_unit_sphere(lat1, long1, lat2, long2):
# modified by Matthew Bordignon @bordignon Oct 2013
#
# handy example for finding distance between two sets of co-oridinates
# modified from http://www.johndcook.com/python_longitude_latitude.html
# handy tool to chk calculations, http://www.johndcook.com/lat_long_distance.html
# Convert latitude and longitude to
# spherical coordinates in radians.
@matbor
matbor / lwtnotfy.py
Created October 25, 2013 11:34
last will and testament notify when one of them goes offline. for MQTT.
#!/usr/bin/python
#
# October 2013
# Subscribes to multiple topics (and will also block sub-topics, based on keywords) and if it see's the work
# 'offline' it sends a notification to the pushingbox topic. Mainly using this to track if a program goes offline
#
# by Matthew Bordignon / @bordignon
#
@matbor
matbor / sabnzbd.py
Created October 28, 2013 22:19 — forked from kylef/sabnzbd.py
import urllib, json
class SABnzbd(object):
"""
Usage:
>>> from sabnzbd import SABnzbd
>>> s = SABnzbd('sakar.local', 8080, '4488f2881b90d7753bef8fb9e1bc56b3')
>>> s.pause() # Pauses the downloads
>>> s.shutdown() # Shut's down SABnzbd+
"""
@matbor
matbor / switch.py
Last active December 28, 2015 22:59
testing wemo ouimeaux script to get the state of my belkin wemo device
from ouimeaux.environment import Environment
def on_switch(switch):
print ('******** Switch found:', switch.name)
def on_change(value):
print('******** light has changed state and has been switched!')
env = Environment(switch_callback=on_switch, with_cache=False)