0

I trying to send data temperature from Arduino to data base... I've finished the connection, but I need replace a part of String, that is the static URL:

SIM900.println("AT+HTTPPARA=\"URL\",\"http://mail.interseccion.com.mx:8901/dbTemperatura?Id_temp=0&Id_Device=1&Valor=-127.7&Temperatura_Action=Insert\"");

and this is my variable:

float = tmp;
tmp = sensor.getTempCByIndex(0);

And the URL I need replace the "-127.7" for the variable... but remember, the URL it's a String. I hope you can help me, thanks!

Maclos
  • 7
  • 1
  • 3
  • I've try to use the dtostrf() funtion, but I don't know how to use... I had though introduce url with the parameter into another String, but not.. that wasn't works. – Maclos Jul 26 '16 at 02:18

2 Answers2

0

I don't use Arduino very much, but maybe this could help:

http://playground.arduino.cc/Main/FloatToString

https://www.arduino.cc/en/Tutorial/StringAdditionOperator

Federico
  • 55
  • 1
  • 7
0

I got the solution...

This is my URL SIM900.println("AT+HTTPPARA=\"URL\",\"http://mail.interseccion.com.mx:8901/dbTemperatura?Id_temp=0&Id_Device=1&Valor=-127.7&Temperatura_Action=Insert\"");

and the parameter to replace is the "-127.7"

I divided the URL on two parts into Strings...

String stringvar = String(tmp);
String stringurl1 = String("AT+HTTPPARA=\"URL\",\"http://mail.interseccion.com.mx:8901/dbTemperatura?Id_temp=0&Id_Device=1&Valor=);
String stringurl2 = String("&Temperatura_Action=Insert\"");
String urlfinal = String(String(url1) + String(strinvar) + String(stringurl2));

For anyone has the same kind url...

Maclos
  • 7
  • 1
  • 3