Arduino Function: Ciao.begin

Description

Ciao.begin is used to initialize the Ciao communication.

Syntax

Ciao.begin();

Examples

/*MQTT example*/
#include <Ciao.h>

int ctrl=0;
void setup()
{
Ciao.begin(); //Start the serial connection with the computer
//to view the result open the serial monitor
pinMode(9,OUTPUT);
}

void loop() // run over and over again
{
//getting the voltage reading from the temperature sensor
int readingTemp = analogRead(A0);
// converting readingTemp to voltage
float voltage = readingTemp * 4.56;
voltage /= 1024;
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ;
int readingLum = analogRead(A2);

analogWrite(9,map(readingLum,0,1023,0,255));

if (ctrl>=10){
Ciao.write("mqtt","iot-2/evt/status/fmt/json","{\"d\": {\"temperature\":"+String(temperatureC)+",\"luminosity\":"+String(readingLum)+"}}");
ctrl=0;
}
ctrl++;
delay(100);

}

Written by arduino.org