Closed OmarGC closed 6 years ago
What error exactly are you getting?
/home/omargc/Escritorio/NodeMCU/funcinales/SocketIO_BasicExample/SocketIO_BasicExample.ino: In function 'void setup()': SocketIO_BasicExample:46: error: no matching function for call to 'SocketIoClient::emit(const char [10], StringSumHelper&)' webSocket.emit ( "Esp8866_1" , "\" Cisterna: "+String(dis)+"\" " ); ^ /home/omargc/Escritorio/NodeMCU/funcinales/SocketIO_BasicExample/SocketIO_BasicExample.ino:46:70: note: candidate is: In file included from /home/omargc/Escritorio/NodeMCU/funcinales/SocketIO_BasicExample/SocketIO_BasicExample.ino:2:0: /home/omargc/Arduino/libraries/SocketIoClient/SocketIoClient.h:39:7: note: void SocketIoClient::emit(const char*, const char*) void emit(const char* event, const char * payload = NULL); ^ /home/omargc/Arduino/libraries/SocketIoClient/SocketIoClient.h:39:7: note: no known conversion for argument 2 from 'StringSumHelper' to 'const char*' exit status 1 no matching function for call to 'SocketIoClient::emit(const char [10], StringSumHelper&)'
Then I converted to char and sent me this error. what I want is to send sensor variable by emit
/home/omargc/Escritorio/NodeMCU/funcinales/SocketIO_BasicExample/SocketIO_BasicExample.ino: In function 'void setup()': SocketIO_BasicExample:46: error: invalid operands of types 'const char*' and 'const char [3]' to binary 'operator+' webSocket.emit ( "Esp8866_1" , "\" Cisterna: "+char(dis)+"\" " ); ^ exit status 1 invalid operands of types 'const char*' and 'const char [3]' to binary 'operator+'
The concatenation results in a String object. You have to convert it to char *.
Try
webSocket.emit ( "Esp8866_1" , ("\" Cisterna: "+String(dis)+"\" ").c_str() );
Perfect now he does not send me error Thank you
You're welcome!
How to concatenate variable double or int to socket.emit ("event name", "\" CHAIN TO SEND \ "")
Achieve send the normal chain, but the ideal is to send the variable that comes from the sensor. the question is that I put the structure + String (dataInteger) + but that sends me error.
example