Hello to all forum,
I have the following line of code: client.println("GET /emoncms3/api/post.json?apikey=MyAPI&json={power:256} HTTP/1.0");
From what I know, the link above allows you to send data ... but how can I get the value of a variable? (not be always send the value 256)
I tried: client.println("GET /emoncms3/api/post.json?apikey=MyAPI&json={power:"variable"} HTTP/1.0");
Instead of sending 256, I replace it with "variable" that contains the value to send.
But without success, anyone can help me?
Since already thank you very much.
Re: how to put a variable on the link
The code you use shows you are not using a NaNode, rather an Arduino with Ethernet shield, right?
Try something like this
Ethernet.begin(mac, ip, gw, subnet);
Client client(server, 80);
Serial.println();
Serial.println("Initiates connection…");
Serial.println("Connecting…");
delay(1000); //This one keeps it from hanging
if (client.connect()) {
Serial.println("Connected!");
client.print("GET http://xxxx/PHPFile.php?level=");
client.print(level);
client.println(" HTTP/1.1");
client.println("Host: www.xxxx");
client.println();
}
else
{
Serial.println("Connection failed");
}
//}
//stop client
client.stop();
while(client.status() != 0)
{
delay(5);
}
Re: how to put a variable on the link
Hello mharizanov
I could not use your code, because I do not know what I should get in subnet.
I've tried, but without success.
I did:
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
(And also changed: )
(...)
client.print("GET http://vis.openenergymonitor.org/PHPFile.php?level=");
Re: how to put a variable on the link
I have the following code:
#include <SPI.h>
I tried to put between "" a variable, but without success!
Any idea to solve this problem?
Already thanks for any hint.
Re: how to put a variable on the link
I try to use this code to upload data to emoncms3:
https://github.com/openenergymonitor/WIZnet-Ethernet-Shield-emoncms-example
without success.
connection failed
:-(
Re: how to put a variable on the link
Hi Sidbin,
We have been having problems with that example, it has been removed from Github. We don't have an official Arduino Ethernet shield in which to test code. If you have a working demo of an official wiznet chip Ardino Etherent shield posting to emoncms please could you post up the code on the forum.
Cheers,
Re: how to put a variable on the link