Go Down

Topic: dtostrf with 0 value give error when send http (Read 1 time) previous topic - next topic


Mar 11, 2013, 12:28 am Last Edit: Mar 11, 2013, 12:36 am by smallpoul Reason: 1
Hi again,
            could it be possible that when temperature is start with 0, it unable to send the url it give me a error?

Code: [Select]
if ((timing ==1) && (millis() > timer)) {
    timer = millis() + 5000;
    Serial.println("<<< REQ ");
    float sensor1 = (sensors.getTempCByIndex(1));
    char buffer[10];
    dtostrf(sensor1, 5, 2, buffer);
    Serial.println("Sensor2 temperature is:");
    timing = 0;
    ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=48&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="), buffer, website, my_callback);


Dare we ask what the error is?




Unless you actually tell us what is happening, we don't have a cat's chance in hell of helping you solve it.

Just saying "it give me an error" is like walking up to someone and saying "my car no go" and expecting them to tell you that the gear box is broken.

Please tell us at the very least what the error it gives you is.

For the last part of my answer, read some books.


If value of the sensor is more then 1 , data is send to the server and i receive a ok message. as soon as the temperature is 0, i receive a bad request error 400.


Maybe that when it convert the 0 in the first bytes, bytes is null? Could that be my problem and if so could a byte be 0 not null.


Have you sniffed the network packets to see if the URL being transmitted is properly formed?

Have you tried manually interacting with the website to send a URL with a 0 value to see if it throws an error?


Mistake by me i always have bad request event if temp is more the 1 degree, If i put it manually like this everything is find and update:
Code: [Select]
ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=48&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value=7"), "", website, my_callback);

How the do i include the temerature after the=


Code: [Select]

ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=48&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="), buffer, website, my_callback);

I don't recognise this browseUrl() method. I guess the first argument is a URL, and the URL you supply has a URL-encoded parameter ("Value") which does not have a value assigned, which could reasonably be deemed a bad request. You've put a value on the buffer variable. Was that supposed to be appended to your URL? If so, where do you think that happens?
I only provide help via the forum - please do not contact me for private consultancy.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131