Pls Help expression cannot be used as a function

String httpRequestData = "api_key=" + apiKeyValue + "&sensor=" + sensorName + "&location=" + sensorLocation + "&value1=" + String(mpu.temperature());

I cant compile it. It says "expression cannot be used as a function". Can anyone help me

Welcome

Show full code (in code tags)

Possibly (if there error is really there) use


String httpRequestData;

httpRequestData.reserve(50); // give a size that makes sense to prevent too many alloc requests when building€ up the request

httpRequestData = "api_key=";
httpRequestData += apiKeyValue;
httpRequestData += "&sensor=";
httpRequestData += sensorName;
httpRequestData += "&location=";
httpRequestData += sensorLocation;
httpRequestData += "&value1=";
httpRequestData += String(mpu.temperature(), 2); // 2 digits after decimal point

It’s more robust to use += as it will support more data types and not confuse things with precedence of C++ types and operations
But may be there is no need to build up the URL and you can send it piece by piece…

You are using "mpu.temperature" as a function. IS it a function? Check the documentation or source.

Thank you, I will try it

Thank you, I will look it up and try it

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.