"ise_id=" is the ID of the variable and "new_value=" is the value - nothing special so far.
the code look like this (i enter a fixed value 1005 just for testing).
Sending the values through webbrowser is working perfect. If the code is send from Arduino it cut's off everything behind the ID. So the Arduino is sending the following request only:
"/config/xmlapi/statechange.cgi?ise_id=15324" - &new_value=... is completely missing in the request! I don't know why. If i change the & character with any other it sends the complete request, only the & is not working. What's going on here? Do i miss something?
below is the complete code. I have made a new sketch with the air pressure value only - just to keep it simple. It's still not working.
I get the correct reading / values at the serial interface - only the GET request is not working.
How have you verified that the request is being cut? Did you check the server logs or did you use a network monitor/sniffer?
Is there any way to monitor the GET Request in order to see what the arduino is send to the server?
#include <Wire.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BMP085.h>
// I2C
BMP085 dps = BMP085(); // Digital Pressure Sensor
long Temperature = 0, Pressure = 0, Altitude = 58800;
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x2D, 0xF9 };
IPAddress server(192,168,178,21);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
}
else {
Serial.println("connection failed");
}
// start I2C für BMP085
Wire.begin();
delay(1000);
dps.init(MODE_ULTRA_HIGHRES, 58800, true); // 588 meters, true = using meter units
}
void loop()
{
// Get Altitude and air pressure
dps.getPressure(&Pressure);
dps.getAltitude(&Altitude);
delay(2000);
Serial.print(" Alt(cm):");
Serial.print(Altitude);
Serial.print(" Pressure(mbar):");
Pressure = Pressure / 100;
Serial.println(Pressure);
client.print("GET /config/xmlapi/statechange.cgi?ise_id=15324&new_value=");
client.print(Pressure);
client.println();
}
What goes in the GET request, and what you type in a browser window, are not the same thing.
The GET request implies an http protocol, so that does not belong in the request string. You have already connected to the server, so the server IP does not belong in the string.
Spaceduck:
below is the complete code. I have made a new sketch with the air pressure value only - just to keep it simple. It's still not working.
I get the correct reading / values at the serial interface - only the GET request is not working.
How have you verified that the request is being cut? Did you check the server logs or did you use a network monitor/sniffer?
Is there any way to monitor the GET Request in order to see what the arduino is send to the server?
Yes, easiest is to check the server's access log. It should show the GET request that the Arduino has sent. Or if for some reason you can't read the access log, you can use a network monitor (i.e. a sniffer) such as wireshark. You can't run the network monitor on the Arduino but you may be able to run it on the web server (if you have required privileges) or on some other network element on the route (on a firewall, router etc).
But did you test the request using telnet as I suggested? Had you done that you would have immediately noticed that the server replies with redirect message (probably with http status code 302 or 303). As I said before and PaulS repeated, testing with the browsers is not the same as sending the request from the Arduino. The browser may do several things behind the curtain that you may not be aware of, such as handles the redirects.