A DDP Connector to call remote functions of a Meteor server from an Arduino sketch.
You can install Ciao in your Arduino following this guide
-
Insert the host address and port of your Meteor server in the file ddp/ddp.json.conf
-
Copy the DDP Connector folder named ddp to the Arduino Ciao connectors folder (/usr/lib/python2.7/ciao/connectors)
-
Copy the DDP Connector configuration file named ddp.json.conf to the Arduino Ciao conf folder (/usr/lib/python2.7/ciao/conf)
In all examples you need to include the Arduino Ciao Library and start it on the setup():
#include <Ciao.h>
void setup() {
Ciao.begin();
}
- Insert a document into a collection named "Sensors"
void loop() {
int val = analogRead(0);
String id = "ArduinoSensor";
String remoteFunction = "/Sensors/insert";
String parameter = "[{\"_id\": \""+id+"\", \"value\": \""+val+"\"}]";
Ciao.write("ddp", remoteFunction, parameter);
delay(500);
}
- Update a document with id "ArduinoSensor" into a collection named "Sensors"
void loop() {
int val = analogRead(0);
String id = "ArduinoSensor";
String remoteFunction = "/Sensors/update";
String parameter = "[{\"_id\": \""+id+"\"}, {\"$set\": {\"value\": \""+val+"\"}}]";
Ciao.write("ddp", remoteFunction, parameter);
delay(500);
}
- Update or Insert a document with id "ArduinoSensor" into a collection named "Sensors"
void loop() {
int val = analogRead(0);
String id = "ArduinoSensor";
String remoteFunction = "/Sensors/update";
String parameter = "[{\"_id\": \""+id+"\"}, {\"$set\": {\"value\": \""+val+"\"}}, {\"upsert\": true}]";
Ciao.write("ddp", remoteFunction, parameter);
delay(500);
}
- Remove a document into with id "ArduinoSensor" into a collection named "Sensors"
void loop() {
int val = analogRead(0);
String id = "ArduinoSensor";
String remoteFunction = "/Sensors/remove";
String parameter = "[{\"_id\": \""+id+"\"}]";
Ciao.write("ddp", remoteFunction, parameter);
delay(500);
}
Version 0.0.1
- Initial implementation, add ability to remote call
- Add implementation of read method to receive information from Meteor