c++ - how to send float value in url , im sending float value but getting Null values -
i want send values , insert values database, im getting null values.
float phvalue = value/10; float dovalue= 12.22; gprsserial.println("at+httppara=\"url\",\"http://itempurl.com/smartpond/addtemprature?watertemperature=""+celsius+""&phvalue=""+phvalue+""&dovalue=""+dovalue+""¤ttime=06-30-2016\"");
you can send separately using print() like:
int n_decimals = 3; float phvalue = value/10; float dovalue= 12.22; gprsserial.print("at+httppara=\"url\",\"http://itempurl.com/smartpond/addtemprature?watertemperature="); gprsserial.print(celsius, n_decimals); gprsserial.print("&phvalue="); gprsserial.print(phvalue, n_decimals); gprsserial.print("&dovalue="); gprsserial.print(dovalue, n_decimals); gprsserial.println("¤ttime=06-30-2016\"");
with n_decimals
number of decimal places want printed.
or @stark says in comments can use snprintf
generate @ command:
char command[256]; float phvalue = value/10; float dovalue= 12.22; snprintf(command, sizeof(command), "at+httppara=\"url\",\"" "http://itempurl.com/smartpond/addtemprature?" "watertemperature=%f&phvalue=%f&dovalue=%f" "¤ttime=06-30-2016\"", celsius, phvalue, dovalue); gprsserial.println(command);
note: wasn't sure if want values in url go between quotes, left them without.
Comments
Post a Comment