37
David @David_SanFal www.biicode.com

internet of things day 2014 (taller)

Embed Size (px)

DESCRIPTION

Talleres IoT Days. Biicode como respositorio para proyectos IoT.

Citation preview

Page 1: internet of things day 2014 (taller)

David @David_SanFal

www.biicode.com

Page 2: internet of things day 2014 (taller)

Biicode:

1. Empezar con Arduino.

2. Crear un proyecto.

3. Biicode & Eclipse.

4. Reutilizacion de codigo.

5. Publica de manera rápida.

Internet of Things:

1. Ethernet / WiFi.

2. Temboo.

3. Carriot.

4. C/C++ & IoT: Desktop apps.

5. GTest: prueba tu código.

Índice

Page 3: internet of things day 2014 (taller)
Page 4: internet of things day 2014 (taller)

Como empezar: Arduino

1. Registro en la web

2. Descarga e instalación del cliente bii https://www.biicode.com/downloads

$ bii init

$ bii setup:arduino

$ bii new

Code as usual

$ bii arduino:upload

Page 5: internet of things day 2014 (taller)

Regístrate

Page 6: internet of things day 2014 (taller)

https://www.biicode.com/downloads

Descarga el cliente

Page 7: internet of things day 2014 (taller)

La carpeta donde se colocan todos tus proyectos.

En biicode los proyectos se denominan hives.

Workspace

Page 8: internet of things day 2014 (taller)

$ mkdir biicode_workspace

$ cd biicode_workspace

~/biicode_workspace$ bii initUsername:

your_user_namePassword for your_user_name:

your_password

Initialization correct, now you can create your first

hive

$ bii setup:arduino

Crea tu Workspace

Page 9: internet of things day 2014 (taller)

Instala todo con un comando

$ bii setup:arduino

Page 10: internet of things day 2014 (taller)

Hive

Son los proyectos en biicode.

Puedes tener tantos hives como quieras.

Page 11: internet of things day 2014 (taller)

$ bii new iot_day

Select language: (java/node/fortran/python/cpp/arduino/None)

Introduce lang: arduino

How would you like to name your first block?

Introduce block name: my_blink

INFO: Selected block name: my_blink

Generate default firmware? (YES/no): [ENTER]

Introduce board: uno

Arduino detected on port COM17

Select IDE: (eclipse/none)

Introduce ide (default:None) (/o list options): [ENTER]

Crea tu Hive

Page 12: internet of things day 2014 (taller)

Blink & biicode

#include "Arduino.h"

int led = 13;

void setup(){

pinMode(led, OUTPUT);

}

void loop(){

digitalWrite(led, HIGH);

delay(1000);

digitalWrite(led, LOW);

delay(1000);

}

Única diferencia

$ cd iot_day

~/iot_day$ bii arduino:build

...

~/iot_day$ bii

arduino:upload

Page 13: internet of things day 2014 (taller)

Tus settings

$ cd iot_day

~/iot_day$ bii arduino:settings

Introduce board: uno

Arduino detected on port COM17

Select IDE: (eclipse/none)Introduce ide

(default:None) (/o list options): eclipse

~/iot_day$ bii arduino:configure

Page 14: internet of things day 2014 (taller)

https://www.eclipse.org/downloads

Usemos Eclipse

Page 15: internet of things day 2014 (taller)

Importa tu hive en Eclipse

Page 16: internet of things day 2014 (taller)

Importa tu hive en Eclipse

Page 17: internet of things day 2014 (taller)

Vamos a programar#include "Arduino.h"

int led = 13;

void setup(){

Serial.begin(9600);

pinMode(led, OUTPUT);

}

void loop(){

Serial.println(F("Led ON"));

digitalWrite(led, HIGH);

delay(1000);

Serial.println(F("Led OFF"));

digitalWrite(led, LOW);

delay(1000);

}

Page 18: internet of things day 2014 (taller)

$ cd iot_day

~/iot_day$ bii

arduino:monitor

~/iot_day$ bii arduino:upload

Monitor serie

Page 19: internet of things day 2014 (taller)

Reuse code

hive_name$ bii find

hive_name$ bii arduino:update

www.biicode.com/fenix

main.cpp

Page 20: internet of things day 2014 (taller)

Reuse code

#include "fenix/blink/blink.h"

Blink my_blink;

void setup(){

my_blink.setup (13, 1000);

}

void loop(){

my_blink.loop();

}

blink.cpp

hive_name$ bii find

hive_name$ bii arduino:update

Page 21: internet of things day 2014 (taller)

iot_day$ bii publish

block: my_blinkIntroduce tag: STABLE

Introduce msg: My first block

INFO: Successfully published user_name/hello(user_name/master):

0

publica tu código

Page 22: internet of things day 2014 (taller)
Page 24: internet of things day 2014 (taller)

https://www.biicode.com/lasote

weather

• Arduino.h

• LiquidCrystal.h

• stdlib.h

• lasote/arduino_http/http_client.h

• lasote/stream_processor/stream_json_processor.h

• lasote/weather/weather_client.h

• ntruchsess/arduino_uip/uipethernet.h

HTTP Client: Weather

Page 25: internet of things day 2014 (taller)

bii deps --graph

Page 26: internet of things day 2014 (taller)

https://www.biicode.com/lasote

Cliente HTTP para el envío de la temperatura usando Carriots y

Ethernet.

Page 27: internet of things day 2014 (taller)

DEVICE_ID

Page 28: internet of things day 2014 (taller)

API_KEY

Page 29: internet of things day 2014 (taller)

Posibles errores

No envia el email:Error al escribir el listenera

Error 401: No tenemos vien puesto el ID o la

Key

Page 31: internet of things day 2014 (taller)

Créate una cuenta en Temboo https://www.temboo.com/

Page 32: internet of things day 2014 (taller)

Entra en tu cuenta en Temboo, y mira tus settings

TEMBOO_ACCOUNT

TEMBOO_APP_KEY_NAME

TEMBOO_APP_KEY

Page 33: internet of things day 2014 (taller)

Créate una nueva credencial en Temboo para enviar mensajes a tu cuenta de Gmail

Page 34: internet of things day 2014 (taller)

Vemos que nuestra nueva credencial está correctamente guardada:

TEMBOO_MYMAIL_CREDENTIAL

Page 35: internet of things day 2014 (taller)

Definimos las variables que son necesarias acerca del WiFi y de nuestra cuenta en Temboo

main.cpp

//This file, located in your hive root folder define your wifi settings. Do not publish it!

//mywifidetails.h

//#define WLAN_SSID "YOUR_SSID" // cannot be longer than 32 characters!//#define WLAN_PASS "your_password"//#define WLAN_SECURITY YOUR_WIFI_SECURITY //WLAN_SEC_UNSEC, WLAN_SEC_WEP,

WLAN_SEC_WPA or WLAN_SEC_WPA2

//This file will contain your TEMBOO_MYMAIL_CREDENTIAL, TEMBOO_ACCOUNT, TEMBOO_APP_KEY_NAME, TEMBOO_APP_KEY, do not publish it with your block

//tembooaccount.h

//#define TEMBOO_ACCOUNT "name_account"//#define TEMBOO_APP_KEY_NAME "application_account_name"//#define TEMBOO_APP_KEY "application_account_name_key"//#define TEMBOO_MYMAIL_CREDENTIAL "credential_name"

Page 36: internet of things day 2014 (taller)

Abrimos el arduino monitor y cargamos el código:

Page 37: internet of things day 2014 (taller)

GTest: Prueba tu código

#include "google/gtest/gtest.h"

int sum(int a, int b){

return a + b;

}

TEST(sum, Normal){

EXPECT_EQ(5, sum(2, 3));

}

void main(int argc, char **argv){

testing::InitGoogleTest(&argc,

argv);

return RUN_ALL_TESTS();

}