Sunteți pe pagina 1din 61

INTERNET DAS COISAS

COM ARDUINO
Ronivaldo Sampaio
Mestre em Mecatrnica
ronivaldo@gmail.com

ARPANET
Computadores
Centros de Pesquisa

Internet
Rede de Pessoas e
Comunidades

Internet das Coisas


Interliga dispositivos

Internet das Coisas


Uma rede de objetos (coisas) dotadas de
sensores e/ou atuadores que se comunicam
com outros objetos, sistemas e pessoas
-Torna mais fcil a vida das pessoas
-Mudana definitiva

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas


Mquina de Vendas Automtica

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

Internet das Coisas

2008

O Que Arduino?
Plataforma para a
criao de
prototipos
Hardware Livre
Fcil de Usar
Origem em
Wiring
C/C++
Imagem: http://arduino.cc/

O Que Arduino?

um dispositivo que conecta o


mundo fsico com o mundo
virtual!

@plantaiot
Plantas do uma sensao de
leveza e vida
Isso - claro - quando voc
no se esquea de reg-las
elas murcham e morrem
As plantas no falam!
Ainda..

@plantaiot

Ento vamos dar voz a esta nova


planta:
Ela vai poder dizer o que est
sentindo
Esta no vai morrer por falta
de gua!

@plantaiot
Uma frase para cada nvel de
gua no solo:
Sem gua (Totalmente
seco)
Mnimo (Nvel crtico)
Pouca gua (Nvel baixo)
Intermedirio (Nvel
suficiente)
Cheio (Molhado acabou
de ser regada)

@plantaiot

@plantaiot

Cdigo @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) {
...

Esquemtico @plantaiot

Objetivo da @plantaiot
Muito fcil extrair
dados do mundo real e
transformar em
informaes teis que
podem ser usadas
diretamente para o
controle e automao
das coisas.

Planta IoT com Regador


Melhoranda a soluo:
Planta IoT
Regador IoT
Dados na Nuvem
Histrico dos Eventos
Autnomia

Plataforma IoT

Plataforma IoT

Plataforma IoT
Lugar centralizado com:
Armazenamento de dados de
sensores
Visualizao de Dados
Gerenciamento remoto
Tecnologias de computao
em nuvem
Envio/Recebimento de dados
atravs de API (Application
Program Interface)
Armazenamento seguro
Acessado de qualquer lugar

Principais Plataformas

Xively
Xively
Produto
Device
Feed
Data Stream
Data Point

Esquemtico Sensor de Nvel

Esquemtico Regador

Cdigo Planta IoT com Xively


...
// Xively key para
char xivelyKey[] =
// xively feed ID
#define xivelyFeed
// datastreams
char nivelAguaID[]
char regadorID[] =

upload e download de dados


"fNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0c";
899999994
= "nivel_agua";
"regador";

#define CHANNEL_NIVEL_AGUA 0
#define CHANNEL_REGADOR 1
...

Cdigo 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 /* nmero de
datastreams */);
EthernetClient client;
XivelyClient xivelyclient(client);
...

Cdigo Planta IoT com Xively


...
void loop() {
processaSensorNivelAgua();
processaRegador();
// delay de 15s entre chamadas
delay(15000);
}
...

Cdigo 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("");
}
...

Cdigo 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");
}
...

Cdigo 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);
...

Cdigo 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("");
...

Monitoramento com Xively

Fcil Integrao com Xively

Outras Plataformas
...
// this method makes a HTTP connection to the server:
void sendData(int thisData) {
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.pachube.com");
client.print("X-PachubeApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);
client.print("Content-Length: ");
// calculate the length of the sensor reading in bytes:
// 8 bytes for "sensor1," + number of digits of the data:
int thisLength = 8 + getLength(thisData);
client.println(thisLength);
// last pieces of the HTTP PUT request:
client.println("Content-Type: text/csv");
client.println("Connection: close");
client.println();
// here's the actual content of the PUT request:
client.print("sensor1,");
client.println(thisData);
}
...

Outras Plataformas
podem ser utilizadas
com Arduino sem
Biblioteca Especfica.

Deve-se montar a
requisio HTTP e
enviar atravs do
Ethernet Shield

Rede de Sensores
Um n responsvel pela conexo com a
nuvem

Integraes

Dever de casa
Vamos desenvolver
um novo Produto?

Fim
Valorize suas ideias, mesmo que elas paream
simples e com fcil implementao. O que
importa uma ideia legal, no quanto complexa
ela .
Vamos tirar as idias da cabea e torn-las
realidade.
IoT j est aqui, presente. Vamos aproveitar!

Fim

Muito Obrigado!

Ronivaldo Sampaio
ronivaldo@gmail.com

https://github.com/ronivaldo/plantaIoT

Referncias
http://www.buildinginternetofthings.com
http://www.independent.co.uk/life-style/gadgets-and-tech/researchers-hack-cars-to-remotely-control-steering-and-brakes-8733723.html
http://blog.kaspersky.com/internet-of-crappy-things/
http://blogs.sap.com/innovation/big-data/what-is-complex-event-processing-031470
https://blog.adafruit.com/2012/09/17/ask-an-educator-how-can-i-get-my-arduino-to-use-ipv6/
http://www.wired.com/2011/10/nest_thermostat/
http://fortune.com/2014/06/12/tony-fadell-nest/
http://playground.arduino.cc/code/exosite
http://postscapes.com/what-exactly-is-the-internet-of-things-infographic
http://arduino-tweet.appspot.com/
http://xively.com/
http://open.sen.se/
http://go.sap.com/solution/internet-of-things.html
http://www.youtube.com/user/NICbrvideos
http://www.youtube.com/user/fwthinking
http://www.theinternetofthings.eu/sebastian-lange-iot-project-proud-present-you-iot-movie-%E2%80%9C-internet-things-architecture%E2%80%9D
https://software.intel.com/en-us/iot
http://www-01.ibm.com/software/info/internet-of-things/
cla.calpoly.edu
http://pixgood.com/arpanet.html
http://www.businessinsider.com/growth-in-the-internet-of-things-2013-10
http://postscapes.com/glowcaps
http://www.supplymanagement.com/news/2014/internet-of-things-will-significantly-alter-supply-chains
http://www.engadget.com/2014/06/03/apple-connected-homekit/
http://www.cin.ufpe.br/~kiev/IF682/02_MotivacaoProjeto_IoT.pdf
http://www.youtube.com/watch?v=9rvu453WtME
http://www.cisco.com/web/about/ac79/docs/innov/IoT_IBSG_0411FINAL.pdf
http://arduino.cc/
http://br.freepik.com/fotos-gratis/planta-em-vaso_522235.htm
http://twitter.com/
http://www.electronics-eetimes.com
http://thingspeak.com/
https://www.exosite.com/
http://www.nimbits.com/
http://nest.com
http://www.wired.com/2014/01/googles-3-billion-nest-buy-finally-make-internet-things-real-us/
http://postscapes.com/wi-fi-plant-sensor-koubachi
http://pt-br.facebook.com/hackerspace.ce

S-ar putea să vă placă și