Skip to content

Instantly share code, notes, and snippets.

local conf = {
variables = {
['hashidvariable'] = 'ipaddress',
}, -- Table related to vars identificators
apikey = 'myapikey', -- User apikey to get token to post values
host = 'localhost', -- Host to stablish connection
port = '8001', -- Port where service is listening
}
#!/usr/bin/env lua
-- Loading main configuration
local config = require "conf"
-- Library to read commando output
local io = require "io"
-- Load the http module
local http = require "socket.http"
@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
@AgustinPelaez
AgustinPelaez / get_product_mercadolibre.py
Created March 30, 2014 04:42
Get product list for a specific search query in MercadoLibre.com, post the number of new items to the Ubidots Cloud
#!/usr/bin/python
"""
Get product list for a specific search query in MercadoLibre.com, post the number of new items to the Ubidots Cloud
"""
__author__ = "Agustin Pelaez"
from sys import argv
import ubidots
@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
#!/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 / wifly_http_test.ino
Created July 21, 2014 21:58
This script is based on the original wifly_http example contained in the library: https://github.com/Seeed-Studio/WiFi_Shield - It should send the value "1" to a variable in Ubidots, using the "Short Token" created in Ubidots' "My Profile" Section
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <WiFly.h>
#include "HTTPClient.h"
#define SSID "SEEED-MKT"
#define KEY "depot0510"
// WIFLY_AUTH_OPEN / WIFLY_AUTH_WPA1 / WIFLY_AUTH_WPA1_2 / WIFLY_AUTH_WPA2_PSK
#define AUTH WIFLY_AUTH_WPA2_PSK
@AgustinPelaez
AgustinPelaez / config.lua
Last active November 12, 2015 18:31
A config file to store some parameters of a program that measures Internet latency in an Openwrt router and sends this value to the Ubidots cloud.
local conf = {
variables = {
['52d481d9f91b284cd22af757'] = '8.8.8.8',
}, -- Add one variable id per each site to check the ping
token = '9xtbvHL8hFKxfkmlXUW3qNoUpOEZAtp0qkkwPqffbn6DiR3ElRJ4B5m1hZMs', --Replace with your own token
host = 'things.ubidots.com', -- Host to establish connection
port = '80', -- Port where service is listening
}
return conf
@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"