Skip to content

Instantly share code, notes, and snippets.

@AgustinPelaez
AgustinPelaez / zwave_hem_to_ubidots.py
Created June 5, 2015 03:22
A Python Script to read a Z Wave Home Energy Meter using the library: http://github.com/OpenZWave/python-openzwave
#!/usr/bin/env python
import logging
import ubidots
import sys, os
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('openzwave')
@AgustinPelaez
AgustinPelaez / ubidots_ping.lua
Created July 24, 2014 14:59
A Lua code to measure the latency from an Openwrt router and send this value to the Ubidots Cloud.
#!usr/bin/env lua
-- Loading main configuration
local config = require "config"
-- Library to read command output
local io = require "io"
-- Load the http module
local http = require "socket.http"
@AgustinPelaez
AgustinPelaez / MQTT_pubsub_example.ino
Last active February 5, 2020 04:53
MQTT nodeMCU with Ubidots
// MQTT-Ubidots example using Grove Temperature Sensor v1.2 in A0 and Grove Relay on D6 (pin 12)
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#define WIFISSID "wifi-ssid"
#define PASSWORD "IOT2016"
#define TOPIC1 "/v1.6/devices/motor/relay/lv"
#define TOPIC2 "/v1.6/devices/motor/temp"
@AgustinPelaez
AgustinPelaez / geo_to_address.py
Last active August 27, 2017 05:09
A Dockerfile compatible Python script to be used with Openwhisk
#!/usr/bin/env python
from geopy.geocoders import Nominatim
import sys
import json
def main():
geolocator = Nominatim()
params = json.loads(sys.argv[1])
location = geolocator.reverse((params['lat'],params['lng']))
@AgustinPelaez
AgustinPelaez / ISS.py
Last active February 27, 2017 19:59
Get the ISS position, calculate the distance to a specific place and post the value to Ubidots
from ubidots import ApiClient
import requests,time
from math import *
#Connect to Ubidots
api = ApiClient('a21ebaf64e14d195c0044fcxxb9f6dab9d653af3')
#Instantiate local variable from Ubidots
@AgustinPelaez
AgustinPelaez / http_get_ubidots_py2-4.py
Last active November 29, 2016 21:24
HTTP GET and POST example requests, compatible with Python 2.4. The GET request lists the user's data sources in Ubidots. The POST request sends the value "33" to the variable "51eded72f91b285266ba30e9" in Ubidots.
import urllib2
response = urllib2.urlopen('http://things.ubidots.com/api/v1.6/datasources?token=9xtbvHL8hFKxfkmlXUW3qNoUpOEZAtp0qkkwPqffbn6DiR3ElRJ4B5m1$
data = response.read()
print data
#!/usr/bin/env python
import time # Library for delays
import RPi.GPIO as GPIO # Library for using the GPIO ports
from math import log1p,exp,log10 # Library for math functions. No need for it if you'll get the raw data from the sensors
from ubidots import ApiClient # Ubidots Library
import Adafruit_DHT # Library from Adafruit to simplify the use of DHT sensor.
# Set up the SPI interface pins. Through SPI we can connect to the ADC MCP3008
SPICLK = 18
@AgustinPelaez
AgustinPelaez / SendValues_MQTT_LinkitOne.ino
Created October 5, 2016 22:15
A simple MQTT sketch to upload values to Ubidots
#include <LWiFi.h>
#include <LWiFiClient.h>
#include <PubSubClient.h>
// These are the variables you will want to change based on your IOT data streaming account / provider
#define TOPIC "/v1.6/devices/YOUR-DEVICE-LABEL"
#define TOKEN "YOUR-UBIDOTS-TOKEN
#define WIFI_AP "UBIWIFI"
#define WIFI_PASSWORD "clave123456789ubi"
/*
Web client
This sketch connects to a website through GPRS on LinkIt platform.
Specifically,
this example downloads the URL "http://arduino.cc/asciilogo.txt" and
prints it to the Serial monitor.
created 8 Mar 2012
by Tom Igoe
@AgustinPelaez
AgustinPelaez / post_rsvp_meetup.py
Created April 3, 2014 21:01
A Python script to get the RSVPs for a Meetup event, and the post this number to the Ubidots API
#!/usr/bin/python
"""
Get number of RSVPs for #Iot Day and send them to Ubidots
"""
__author__ = "Agustin Pelaez"
from sys import argv
import ubidots