Hello,
I have download the library of arduinoYUN from your site, and I try the example of SaveValue, however, I could not comply the code.
The error messages are
Arduino: 1.7.11 (Mac OS X), Board: "Arduino Yún"
In file included from UbidotsGetValue.ino:1:0:
/Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.h:29:21: fatal error: Process.h: No such file or directory
#include <Process.h>
^
compilation terminated.
Error compiling..
Could you please tell me what to resole this problem, please?
My arduino Yun is arduino.org with linino, I don’t know is that related with this problem? Thank you for your attention.
Best regards,
He
hello @imhenri that error is an error in YUN library, and i can see that you are using a Beta version of Arduino, try to download the stable version for MAC.
I have changed to another arduino version (one of arduino.cc), but it does not work neither.
Could you please let me know your version?
Arduino: 1.6.12 (Mac OS X), Board: "Arduino Yún"
/Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.cpp:31:1: error: prototype for 'Ubidots::Ubidots(char*)' does not match any in class 'Ubidots'
Ubidots::Ubidots(char* token) {
^
In file included from /Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.cpp:26:0:
/Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.h:42:7: error: candidates are: constexpr Ubidots::Ubidots(Ubidots&&)
class Ubidots {
^
/Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.h:42:7: error: constexpr Ubidots::Ubidots(const Ubidots&)
/Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.h:44:16: error: Ubidots::Ubidots(char*, char*)
explicit Ubidots(char* token, char* server = SERVER);
^
/Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.cpp: In member function 'void Ubidots::sendAll()':
/Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.cpp:148:41: error: too few arguments to function 'int snprintf(char*, size_t, const char*, ...)'
snprintf(buffer, "(sleep 1\necho \"");
^
In file included from /Applications/Arduino.cc.app/Contents/Java/hardware/arduino/avr/cores/arduino/Print.h:24:0,
from /Applications/Arduino.cc.app/Contents/Java/hardware/arduino/avr/cores/arduino/Stream.h:26,
from /Applications/Arduino.cc.app/Contents/Java/hardware/arduino/avr/cores/arduino/HardwareSerial.h:29,
from /Applications/Arduino.cc.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:232,
from /Applications/Arduino.cc.app/Contents/Java/libraries/Bridge/src/Bridge.h:26,
from /Applications/Arduino.cc.app/Contents/Java/libraries/Bridge/src/Process.h:22,
from /Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.h:28,
from /Users/HE/Documents/Arduino/libraries/ubidots-arduino-yun-master/UbidotsYUN.cpp:26:
/Applications/Arduino.cc.app/Contents/Java/hardware/tools/avr/avr/include/stdio.h:687:12: note: declared here
extern int snprintf(char *__s, size_t __n, const char *__fmt, ...);
^
exit status 1
Error compiling for board Arduino Yún.
We fixed a problem in compilation in some pc’s, now it will working fine.
You can download the latest version of the library from github and upload it to YUN.
I apologize for the error it will not happen again.
Thanks very much Metavix.
it works now with arduino 1.6.12, but not with the arduino 1.7.11 of arduino.org. it’s really ugly about the separation of these two parts.
Hi, I have tried with the method you indicated. But I do not know how to apply the different parameters (broker, topic, data, token…). Do you have some examples to explain how to update the data to ubidots with MQTT and the pubsubclient library, please?
actually, in the arduino.org. they propose the ciao library for different internet connection protocols which contains MQTT. I tried this library with IBM bluemix, but I can’t reach the function with Ubidots.
Here is my configuration of ubidots for update data.
Here is my code, I have a problem that I applied.
I could create the data source and the variables (however only last variable “humidity”), but there is not update data activities for the variables.
Thanks very much for your help.
here is my code for arduino YUN
/*
MQTT IOT Example
- formats the results as a JSON string for the Ubidots example
- connects to an MQTT server (either local or at the Ubidots Cloud)
- and publishes the JSON String to the topic named quickstart:MY_MAC_ADDRESS
*/
#include <SPI.h>
#include <YunClient.h>
#include <PubSubClient.h>
#include <Console.h>
#define TOKEN "my token"
// Note this next value is only used if you intend to test against a local MQTT server
byte localserver[] = {192, 168, 1, 98 };
// Update this value to an appropriate open IP on your local network
byte ip[] = {172, 20, 10, 20 };
char servername[]="things.ubidots.com";
char labelDS[]= "MQTTTEST";
String pubTopic = String("/v1.6/devices/")+labelDS;
float tempF = 0.0;
float tempC = 0.0;
float humidity = 0.0;
YunClient yunClient;
// Uncomment this next line and comment out the line after it to test against a local MQTT server
//PubSubClient client(localserver, 1883, 0, ethClient);
PubSubClient client(servername, 1883, 0, yunClient);
void setup()
{
// Start the ethernet client, open up Console port for debugging, and attach the DHT11 sensor
Bridge.begin();
Console.begin();
// Wait for the Console port to connect
while (!Console);
}
void loop()
{
// char clientStr[34];
// clientName.toCharArray(clientStr,34);
char topicStr[26];
pubTopic.toCharArray(topicStr,26);
getData();
if (!client.connected()) {
Console.print("Trying to connect to: ");
Console.println(TOKEN);
client.connect(labelDS,TOKEN,"");
}
if (client.connected() ) {
String json = buildJson();
char jsonStr[200];
json.toCharArray(jsonStr,200);
boolean pubresult = client.publish(topicStr,jsonStr);
Console.print("attempt to send ");
Console.println(jsonStr);
Console.print("to ");
Console.println(topicStr);
if (pubresult)
Console.println("successfully sent");
else
Console.println("unsuccessfully sent");
}
delay(5000);
}
String buildJson() {
String data = "{";
data+="\n";
data+="\"temperature (F)\": ";
data+=(int)tempF;
data+= ",";
data+="\n";
data+="\"temperature (C)\": ";
data+=(int)tempC;
data+= ",";
data+="\n";
data+="\"humidity\": ";
data+=(int)humidity;
data+="\n";
data+="}";
return data;
}
void getData() {
humidity = 20;
tempF = 30;
tempC = 40;
}
here is the console monitor
attempt to send {
"temperature (F)": 30,
"temperature (C)": 40,
"humiity": 20
}
to /v1.6/devices/MQTTTES
successfully sent