problem in concatenation between strings and variables

Hello everyone,

i want to send some data to my web page using GET METHOD. I am using a gsm shield to accomplish that and in a way it works, but only if i put the url with the values prefixed in the arduino code myself.

this is the code i am currently using to send the data in my db


My goal though is to replace these values with variables. I've written this code but it doesn't seem to work.

  int dat=5;
  float temp=100;
  float hum=200;
  int soil=300;
  String last = "NOW()";
  String stringOne = "";
  String stringTwo = stringOne + dat + "&temp=" + temp + "&hum=" + hum + "&soil=" + soil + "&last=" + last;
  mySerial.println("AT+HTTPPARA=\"URL\",\"strinOne,stringTwo \"");

Can anyone help me with this? thanks in advance!

you need to convert int and float to string type, you cant do ‘add’ operation with String and numerals.

You could try the below approach.

String two = stringOne + String(hum);

Check this link about String constructor.

It's a common mistake. You DON'T need to concatenate it first and then send it out. You can just send it out in the order you want. This will save you time and a lot of memory.

Also added the F macro :)

thanks guys i will try what you suggest me to do..

This will save you time and a lot of memory.

Unless you are sending the data to a server, using client.print(). In that case, every print() sends a packet. Sending fewer packets is faster than sending lots of packets.

There is NO need to use Strings for this. sprintf(), dtostrf() and char arrays were invented for a reason.

But I don't think it does. Except from a bit more time between the parts there is no way for the device to see the difference between a single print and multiple prints. Most devices are simply triggered by the new line, which is only send after the last bit.