Reference   Language | Libraries | Comparison | Changes

Ciao

Ciao.begin()

Description

Initializes the Ciao communication.

Syntax

Ciao.begin();

Returns

None

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);
}
Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

Share