Incorporar apresentação
Transferir como PDF, PPTX


































![Código @plantaiot
...
int valorSensorAgua = analogRead(sensorAguaPin);
int nivelAgua = map(valorSensorAgua, 0, 1023, 0, 4);
Serial.print("Nivel de Água [0..4]=");
Serial.println(nivelAgua);
if (nivelAgua < NIVEL_SEM_AGUA) {
postToTwitter("@ronivaldops Estou morrendo de sede!!");
beep();
delay(20000);
} else if (nivelAgua < NIVEL_MINIMO_AGUA) {
postToTwitter("@ronivaldops Preciso de Água Urgente!");
delay(21000);
} else if (nivelAgua < NIVEL_POUCA_AGUA) {
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-35-320.jpg)










![Código Planta IoT com Xively
...
// Xively key para upload e download de dados
char xivelyKey[] = "fNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0c";
// xively feed ID
#define xivelyFeed 899999994
// datastreams
char nivelAguaID[] = "nivel_agua";
char regadorID[] = "regador";
#define CHANNEL_NIVEL_AGUA 0
#define CHANNEL_REGADOR 1
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-46-320.jpg)
![Código Planta IoT com Xively
...
// Define o nome dos datastreams do feed
XivelyDatastream datastreams[] = {
XivelyDatastream(nivelAguaID, strlen(nivelAguaID),
DATASTREAM_INT),
XivelyDatastream(regadorID, strlen(regadorID),
DATASTREAM_INT),
};
// Liga os datastreams no feed
XivelyFeed feed(xivelyFeed, datastreams, 2 /* número de
datastreams */);
EthernetClient client;
XivelyClient xivelyclient(client);
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-47-320.jpg)

![Código Planta IoT com Xively
...
// le sensor da planta e salva na nuvem
void processaSensorNivelAgua() {
int valorSensorAgua = analogRead(sensorAguaPin);
int nivelAgua = map(valorSensorAgua, 0, 1023, 0, 4);
Serial.print("Nivel de Água [0..4]=");
Serial.println(nivelAgua);
// guarda o valor na nuvem
datastreams[CHANNEL_NIVEL_AGUA].setInt(nivelAgua);
// send value to xively
Serial.println("Nivel de Agua");
Serial.println("Uploading it to Xively");
int ret = xivelyclient.put(feed, xivelyKey);
// return message
Serial.print("xivelyclient.put returned ");
Serial.println(ret);
Serial.println("");
}
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-49-320.jpg)
![Código Planta IoT com Xively
...
// liga regador de acordo com o nivel de agua na
planta
void processaRegador() {
// otem dados do feed na nuvem
int getReturn = xivelyclient.get(feed, xivelyKey);
if(getReturn > 0){
Serial.print("Datastream Nivel de Agua: ");
Serial.println(feed[CHANNEL_NIVEL_AGUA]);
} else {
Serial.println("HTTP Error");
}
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-50-320.jpg)
![Código Planta IoT com Xively
...
// guarda o nivel da agua do feed obtido
int nivelAgua = feed[CHANNEL_NIVEL_AGUA].getInt();
// calcula quanto tempo o regado deve ficar ligado
int segundosRegadorDeveLigar = 0;
if (nivelAgua < NIVEL_SEM_AGUA) {
// liga regador por 5 segundo
segundosRegadorDeveLigar = 5;
} else if (nivelAgua < NIVEL_MINIMO_AGUA) {
// liga regador por 3 segundo
segundosRegadorDeveLigar = 3;
} else if (nivelAgua < NIVEL_POUCA_AGUA) {
// liga regador por 1 segundo
segundosRegadorDeveLigar = 1;
}
// liga ou desliga o regador de acordo com o nivel da agua
controlaRegador(segundosRegadorDeveLigar);
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-51-320.jpg)
![Código Planta IoT com Xively
...
// guarda o valor do regador a ser salvo na nuvem
datastreams[CHANNEL_REGADOR].setInt(segundosRegadorDeveLigar);
Serial.print("Datastream Regador: ");
Serial.println(feed[CHANNEL_REGADOR]);
// send value to xively
Serial.println("Regador");
Serial.println("Uploading it to Xively");
int ret = xivelyclient.put(feed, xivelyKey);
// return message
Serial.print("xivelyclient.put returned ");
Serial.println(ret);
Serial.println("");
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-52-320.jpg)









O documento discute a Internet das Coisas usando Arduinos. Inclui exemplos de um sistema de rega inteligente para plantas monitorado via Xively e redes de sensores sem fio. O objetivo é tornar dispositivos do mundo real acessíveis online e automatizar processos com base nos dados coletados.


































![Código @plantaiot
...
int valorSensorAgua = analogRead(sensorAguaPin);
int nivelAgua = map(valorSensorAgua, 0, 1023, 0, 4);
Serial.print("Nivel de Água [0..4]=");
Serial.println(nivelAgua);
if (nivelAgua < NIVEL_SEM_AGUA) {
postToTwitter("@ronivaldops Estou morrendo de sede!!");
beep();
delay(20000);
} else if (nivelAgua < NIVEL_MINIMO_AGUA) {
postToTwitter("@ronivaldops Preciso de Água Urgente!");
delay(21000);
} else if (nivelAgua < NIVEL_POUCA_AGUA) {
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-35-320.jpg)










![Código Planta IoT com Xively
...
// Xively key para upload e download de dados
char xivelyKey[] = "fNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0c";
// xively feed ID
#define xivelyFeed 899999994
// datastreams
char nivelAguaID[] = "nivel_agua";
char regadorID[] = "regador";
#define CHANNEL_NIVEL_AGUA 0
#define CHANNEL_REGADOR 1
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-46-320.jpg)
![Código Planta IoT com Xively
...
// Define o nome dos datastreams do feed
XivelyDatastream datastreams[] = {
XivelyDatastream(nivelAguaID, strlen(nivelAguaID),
DATASTREAM_INT),
XivelyDatastream(regadorID, strlen(regadorID),
DATASTREAM_INT),
};
// Liga os datastreams no feed
XivelyFeed feed(xivelyFeed, datastreams, 2 /* número de
datastreams */);
EthernetClient client;
XivelyClient xivelyclient(client);
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-47-320.jpg)

![Código Planta IoT com Xively
...
// le sensor da planta e salva na nuvem
void processaSensorNivelAgua() {
int valorSensorAgua = analogRead(sensorAguaPin);
int nivelAgua = map(valorSensorAgua, 0, 1023, 0, 4);
Serial.print("Nivel de Água [0..4]=");
Serial.println(nivelAgua);
// guarda o valor na nuvem
datastreams[CHANNEL_NIVEL_AGUA].setInt(nivelAgua);
// send value to xively
Serial.println("Nivel de Agua");
Serial.println("Uploading it to Xively");
int ret = xivelyclient.put(feed, xivelyKey);
// return message
Serial.print("xivelyclient.put returned ");
Serial.println(ret);
Serial.println("");
}
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-49-320.jpg)
![Código Planta IoT com Xively
...
// liga regador de acordo com o nivel de agua na
planta
void processaRegador() {
// otem dados do feed na nuvem
int getReturn = xivelyclient.get(feed, xivelyKey);
if(getReturn > 0){
Serial.print("Datastream Nivel de Agua: ");
Serial.println(feed[CHANNEL_NIVEL_AGUA]);
} else {
Serial.println("HTTP Error");
}
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-50-320.jpg)
![Código Planta IoT com Xively
...
// guarda o nivel da agua do feed obtido
int nivelAgua = feed[CHANNEL_NIVEL_AGUA].getInt();
// calcula quanto tempo o regado deve ficar ligado
int segundosRegadorDeveLigar = 0;
if (nivelAgua < NIVEL_SEM_AGUA) {
// liga regador por 5 segundo
segundosRegadorDeveLigar = 5;
} else if (nivelAgua < NIVEL_MINIMO_AGUA) {
// liga regador por 3 segundo
segundosRegadorDeveLigar = 3;
} else if (nivelAgua < NIVEL_POUCA_AGUA) {
// liga regador por 1 segundo
segundosRegadorDeveLigar = 1;
}
// liga ou desliga o regador de acordo com o nivel da agua
controlaRegador(segundosRegadorDeveLigar);
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-51-320.jpg)
![Código Planta IoT com Xively
...
// guarda o valor do regador a ser salvo na nuvem
datastreams[CHANNEL_REGADOR].setInt(segundosRegadorDeveLigar);
Serial.print("Datastream Regador: ");
Serial.println(feed[CHANNEL_REGADOR]);
// send value to xively
Serial.println("Regador");
Serial.println("Uploading it to Xively");
int ret = xivelyclient.put(feed, xivelyKey);
// return message
Serial.print("xivelyclient.put returned ");
Serial.println(ret);
Serial.println("");
...](https://image.slidesharecdn.com/internetdascoisascomarduinoronivaldo-150330123035-conversion-gate01/85/Internet-das-coisas-com-Arduino-52-320.jpg)








