This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO ##GPIO library | |
from ubidots import ApiClient ##Ubidots Library | |
import time ##time library for delays | |
GPIO.setmode(GPIO.BCM)##set up BCM as numbering system for inputs | |
GPIO.setup(7,GPIO.IN)##Declaring GPIO7 as input for the sensor | |
try: | |
api=ApiClient("75617caf2933588b7fd0da531155d16035138535")##put your own apikey | |
people= api.get_variable("53b9f8ff76254274effbbace")##put your own variable's id | |
except: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. | |
import random | |
# Set up the SPI interface pins. Through SPI we can connect to the ADC MCP3008 | |
SPICLK = 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pifacedigitalio #Library for pifacedigitalio #Library for delays | |
from ubidots import ApiClient #Library for Ubidots | |
pifacedigital = pifacedigitalio.PiFaceDigital() #Declare piface object | |
##Connect to Ubidots | |
try: | |
api = ApiClient("1fc7a56bf4b539725ace7a3f4aa623e9e9620612") #Don't forget to put your own Apikey | |
valve = api.get_variable('53cd4cb07625425b70f5c21e') #Put here your valve ID's | |
valveState = api.get_variable("53ce95547625420403d81468") #Put here your realy state ID's |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SPICLK = 937.5; | |
// Class to read the DHT11 temperature/humidity sensor | |
// These sensors us a proprietary one-wire protocol. The imp | |
// emulates this protocol with SPI. | |
// To use: | |
// - tie MOSI to MISO with a 10k resistor | |
// - tie MISO to the data line on the sensor | |
class DHT11 { | |
static STARTTIME_LOW = 0.001000; // 1 ms low time for start | |
static STARTTIME_HIGH = 0.000020; // 20 us min high time for start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
device.on("temp", function(value) { | |
server.log("Trying to post to Ubi the value:"); | |
server.log(value); | |
local headers = { "Content-Type": "application/json", "X-Auth-Token": "NBbF3PWPxWc2IaO40aXOKnhIu8tOv92rYN3ibiEc7Jh6GV3KZUUCHtXuNz7Y" }; // Replace the token with yours | |
local url = "http://things.ubidots.com/api/v1.6/variables/53d2beb37625424630223dac/values"; // Replace the Variable ID with yours | |
local string = {"value": value}; | |
local request = http.post(url, headers, http.jsonencode(string)); | |
local response = request.sendsync(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFiShieldOrPmodWiFi_G.h> // This is for the MRF24WGxx on a pmodWiFi or WiFiShield | |
#include <DNETcK.h> | |
#include <DWIFIcK.h> | |
//Wifi Variables | |
char * server = "things.ubidots.com"; // server to connect to | |
unsigned short portServer = 80; | |
const char * szSsid = "Atom House Medellin";// Specify the SSID | |
#define USE_WPA2_PASSPHRASE | |
#if defined(USE_WPA2_PASSPHRASE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
device.on("temp", function(value) { | |
//server.log("Trying to post to Ubi the value:"); | |
//server.log(value); | |
local headers = { "Content-Type": "application/json", "X-Auth-Token": "NBbF3PWPxWc2IaO40aXOKnhIu8tOv92rYN3ibiEc7Jh6GV3KZUUCHtXuNz7Y" }; // Replace the token with yours | |
local url = "http://things.ubidots.com/api/v1.6/variables/53d2beb37625424630223dac/values"; // Replace the Variable ID with yours | |
local string = {"value": value}; | |
local request = http.post(url, headers, http.jsonencode(string)); | |
local response = request.sendsync(); | |
}); | |
device.on("hum", function(value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SPICLK = 937.5; | |
// Class to read the DHT11 temperature/humidity sensor | |
// These sensors us a proprietary one-wire protocol. The imp | |
// emulates this protocol with SPI. | |
// To use: | |
// - tie MOSI to MISO with a 10k resistor | |
// - tie MISO to the data line on the sensor | |
class DHT11 { | |
static STARTTIME_LOW = 0.001000; // 1 ms low time for start | |
static STARTTIME_HIGH = 0.000020; // 20 us min high time for start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This #include statement was automatically added by the Spark IDE. | |
#include "Adafruit_DHT/Adafruit_DHT.h" | |
// This #include statement was automatically added by the Spark IDE. | |
#include "HttpClient/HttpClient.h" | |
HttpClient http; | |
#define VARIABLE_ID "53f6caea76254277ef8837cd" | |
#define VARIABLE_ID2 "53f63fa576254235bec59148" | |
#define TOKEN "cfaI5R1bcr7wlwf58hAnNZNNvfSoUk" | |
int lightLevel = 0; |
OlderNewer