Ronivaldo Sampaio
Mestre em Mecatrônica
ronivaldo@gmail.com
INTERNET DAS COISAS
COM ARDUINO
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 fácil a vida das pessoas
-Mudança 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
Máquina de Vendas Automática
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
criação de
prototipos
– Hardware Livre
– Fácil de Usar
– Origem em
Wiring
• C/C++
Imagem: http://arduino.cc/
É um dispositivo que conecta o
mundo físico com o mundo
virtual!
O Que é Arduino?
@plantaiot
Plantas dão uma sensação de
leveza e vida
– Isso é - é claro - quando você
não se esqueça de regá-las
– elas murcham e morrem
As plantas não falam!
Ainda..
@plantaiot
Então vamos dar voz a esta nova
planta:
– Ela vai poder dizer o que está
sentindo
– Esta não vai morrer por falta
de água!
@plantaiot
Uma frase para cada nível de
água no solo:
– Sem água (Totalmente
seco)
– Mínimo (Nível crítico)
– Pouca Água (Nível baixo)
– Intermediário (Nível
suficiente)
– Cheio (Molhado – acabou
de ser regada)
@plantaiot
@plantaiot
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) {
...
Esquemático @plantaiot
Objetivo da @plantaiot
Muito fácil extrair
dados do mundo real e
transformar em
informações úteis que
podem ser usadas
diretamente para o
controle e automação
das coisas.
Planta IoT com Regador
Melhoranda a solução:
– Planta IoT
– Regador IoT
– Dados na Nuvem
– Histórico dos Eventos
– Autônomia
Plataforma IoT
Plataforma IoT
Plataforma IoT
Lugar centralizado com:
– Armazenamento de dados de
sensores
– Visualização de Dados
– Gerenciamento remoto
– Tecnologias de computação
em nuvem
– Envio/Recebimento de dados
através de API (Application
Program Interface)
– Armazenamento seguro
– Acessado de qualquer lugar
Principais Plataformas
Xively
Xively
– Produto
– Device
– Feed
• Data Stream
• Data Point
Esquemático Sensor de Nível
Esquemático Regador
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
...
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);
...
Código Planta IoT com Xively
...
void loop() {
processaSensorNivelAgua();
processaRegador();
// delay de 15s entre chamadas
delay(15000);
}
...
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("");
}
...
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");
}
...
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);
...
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("");
...
Monitoramento com Xively
Fácil Integração 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 Específica.
•
Deve-se montar a
requisição HTTP e
enviar através do
Ethernet Shield
Rede de Sensores
Um nó responsável pela conexão com a
nuvem
Integrações
Dever de casa
Vamos desenvolver
um novo Produto?
Fim
Valorize suas ideias, mesmo que elas pareçam
simples e com fácil implementação. O que
importa é uma ideia legal, não quanto complexa
ela é.
Vamos tirar as idéias da cabeça e torná-las
realidade.
IoT já está aqui, é presente. Vamos aproveitar!
Fim
Muito Obrigado!
Ronivaldo Sampaio
ronivaldo@gmail.com
https://github.com/ronivaldo/plantaIoT
Referências
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

Internet das coisas com Arduino