I am using Arduino Yun for development. I want to use a MQTT client and a HTTP client in the same code but only one works at a time. I think its some sort of library conflict in both of them. When I remove MQTT client library the HTTP client works and vice versa but I am unable to use both at the same time. Has anyone ever encountered such a problem ?
What makes you say it doesn't work? Does it compile? If not, what errors?
If it compiles but fails to do what it's supposed to, despite that both libraries work alone, that might very well be a memory problem, so you should fix the issue Paul pointed out!
DrAzzy:
Please give links to the non core libraries.
What makes you say it doesn't work? Does it compile? If not, what errors?
If it compiles but fails to do what it's supposed to, despite that both libraries work alone, that might very well be a memory problem, so you should fix the issue Paul pointed out!
I have fixed what Paul pointed but it still doesn't work. The code compiles perfect and works fine apparently but the http request just doesn't work good. It doesn't get the json correctly.
UmerF92:
I have fixed what Paul pointed but it still doesn't work. The code compiles perfect and works fine apparently but the http request just doesn't work good. It doesn't get the json correctly.
Does it get anything? For that matter... how long is that response you're expecting to get?
Based on how much you're using String, and how things work individually, but not when you put them together, I'd suspect you're running out of ram. String is the sort of thing you want to avoid at all costs.
The Arduino only has 2048 bytes of RAM, which is a tiny amount of data by modern general purpose computer standards...
#include <Process.h>
void setup() {
Bridge.begin(); // Initialize Bridge
}
void loop() {
int temperature = random(0, 100);
Process p; // Create a process and call it "p"
p.begin("/root/mqtt.py"); // Process that launch the command
p.addParameter(temperature); // pass parameter
p.run(); // Run the process and wait for its termination
delay(5000);
}