Skip to content

Instantly share code, notes, and snippets.

@AgustinPelaez
AgustinPelaez / wifly_http_ubi.ino
Created May 7, 2015 19:17
This is a test of the HTTP client code of the Seeedstudio Library for the RN171 Arduino Shield: https://github.com/Seeed-Studio/WiFi_Shield/tree/master/Examples/wifly_http
#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
@AgustinPelaez
AgustinPelaez / ubi-provisioning-example.ino
Last active August 29, 2015 14:19
This script gets your Spark Core's ID and creates a Ubidots data source with name = SparkID, so it can be later recognized. It's useful to provision hundreds or thousands of devices, without having to flash a different firmware to each device.
/*
This script gets the Spark Core's ID and creates a Ubidots data source with name = SparkID, so it can be later recognized.
Depending on the application, this code may be extended to:
- Create variables within the data source and get its IDs to post data to them later:
- Use the function "get_id" to get the Ubidots ID inside an API response
- See "Create a variable within a Data source" http://ubidots.com/docs/api/v1_6/data/post_datasources_id_variables.html
- Add the code inside the loop() function to read sensor data, send it to Ubidots, etc.
@AgustinPelaez
AgustinPelaez / CC3000_Ubidots.ino
Last active August 29, 2015 14:14
This code was made by Charles McClelland as an improvement for the Ubidots example for the CC3000 Breakout Board (http://ubidots.com/docs/devices/cc3000.html)
/* Chip McClelland - CC3000 Data Logger
BSD license, Please keep my name and credits in any redistribution
Requirements:
- Account on Ubidots. http://www.ubidots.com
- Sparkfun CC3000 Breakout Board - https://www.sparkfun.com/products/12072
- I used a 3.3V 8MHz Sparkfun Pro Micro - https://www.sparkfun.com/products/12587
Credits:
- Sparkfun Library and Example code from Shawn Hymel: https://github.com/sparkfun/SFE_CC3000_Library
- Ubidots Demo Code from: Mateo Velez for Ubidots,Inc. Modified 15 Nov 2014
@AgustinPelaez
AgustinPelaez / post.ino
Created December 22, 2014 16:51
A people counter using Spark Core, Ubidots, and a manual DNS resolution (as some Spark Cores have a known issue when resolving DNS).
// This #include statement was automatically added by the Spark IDE.
#include "dnsclient/dnsclient.h"
// This #include statement was automatically added by the Spark IDE.
#include "HttpClient/HttpClient.h"
HttpClient http;
#define VARIABLE_ID "544e4a8f7625426e332bxxxx"
#define TOKEN "pSZJt9W7v5W3fpUsxxxxiDMgJ770NK"
int people = 0;
@AgustinPelaez
AgustinPelaez / get_users.py
Created October 3, 2014 14:04
A custom script to pull data from Hubspot and send it to Ubidots
#!/usr/bin/python
"""
Get number of REAL users from Hubspot API, then post this data to Ubidots
"""
__author__ = "Agustin Pelaez"
from sys import argv
import ubidots
@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 / 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 / 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
#!/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 / 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