Skip to content

Instantly share code, notes, and snippets.

@iBobik
Created August 29, 2016 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iBobik/f30f6f23c0ce7a7ce877290e38baf5d5 to your computer and use it in GitHub Desktop.
Save iBobik/f30f6f23c0ce7a7ce877290e38baf5d5 to your computer and use it in GitHub Desktop.
Arduino Uno Wifi sketch for sending HTTP request based on humidity and temperature
#include <Wire.h>
#include <Ciao.h>
#define CONNECTOR "rest"
#define SERVER_ADDR "" // gateway from https://gist.github.com/jnv/27666983e88fb271e1528b5e538b2f2a
#define SMS_LOGIN ""
#define SMS_PASSWORD ""
#define TEL_NUM ""
#include <dht.h>
dht DHT;
#define DHT22_PIN 9
struct
{
uint32_t total;
uint32_t ok;
uint32_t crc_error;
uint32_t time_out;
uint32_t connect;
uint32_t ack_l;
uint32_t ack_h;
uint32_t unknown;
} stat = { 0,0,0,0,0,0,0,0};
void setup() {
Serial.begin(9600);
Ciao.begin(); // CIAO INIT
sendmessage();
}
void sendmessage() {
int chk = DHT.read22(DHT22_PIN);
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.print(DHT.temperature, 1);
Serial.println();
String humidily_cat;
if (DHT.humidity > 60) {
humidily_cat = "1";
}
else {
humidily_cat = "2";
}
/*String uri = "/apilite30/sms?text=";
uri += message;
uri += "&number=";
uri += TEL_NUM;
uri += "&login=";
uri += SMS_LOGIN;
uri += "&password=";
uri += SMS_PASSWORD;*/
//Serial.println(uri);
CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, "/?h=" + humidily_cat + "&t=" + String(round(DHT.temperature)));
//if (!data.isEmpty()) {
Serial.println( "State: " + String (data.get(1)) );
Serial.println( "Response: " + String (data.get(2)) );
//}
//else {
// Serial.println("Write Error");
//}
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment