// New temperature readings – 0 ~ 100C
temp_value = analogRead(ANALOG_PIN_0);
temp_value = (temp_value/4096) * 100;
// New Pressure readings – 0 ~ 300 PSI
press_value = analogRead(ANALOG_PIN_1);
press_value = (press_value/4096) * 300;
data_send = “{\”temp_value\”:”&temp_value&”,\”press_value\”:”&press_value&”}”;
I am using Arduino IDE.
error: invalid operands of types ‘const char [15]’ and ‘float’ to binary ‘operator&’
data_send = “{\”temp_value\”:”&temp_value&”,\”press_value\”:”&press_value&”}”;
Hello,
Is that your exact code?
data_send = “{\”temp_value\”:”&temp_value&”,\”press_value\”:”&press_value&”}”;
What’s the data_send variable type? How are you trying to concatenate the values in that variable using a &?
Thanks for your patience, but I need a few more details to help you with this question..
Hello, good day,
data_send = string data type;
temp_value = float data type;
press_value = float data type;
I haven’t tested it, but I think I didn’t miss any characters if you do the following:
data_send = "{\"temp_value\":\"" + String(temp_value) + "\",\"press_value\":\"" + String(press_value) + "\"}";
Then, you print that String data_send in the serial monitor for debugging purposes:
Serial.println(data_send);
It should print something like this:
{"temp_value":"YOUR_VALUE","press_value:"YOUR_VALUE"}";
Then, you can send that String via MQTT. Does it work for you?