Hello everyone,
I have been trying to setup a esp8266 with a 4x4 Keypad Matrix (they cost around 0,50€ on AliExpress) to publish which key is being pressed to a MQTT broker.
I plan to use it for example with a LCD for Alarm Control Panel component and maybe a inwall multi-switches.
With Home-Assistant automations package or Node-RED I can decide what each key will do.
My current sketch is here and when I try to compile on Arduino IDE I get this msg:
/MQTT-Keypad/MQTT-Keypad.ino: In function 'void setup()':
MQTT-Keypad:40: error: no matching function for call to 'PubSubClient::setCallback(void (&)())'
client.setCallback(callback);
^
/MQTT-Keypad/MQTT-Keypad.ino:40:30: note: candidate is:
In file included from /MQTT-Keypad/MQTT-Keypad.ino:12:0:
/arduino-1.8.5/libraries/pubsubclient/src/PubSubClient.h:121:18: note: PubSubClient& PubSubClient::setCallback(std::function<void(char*, unsigned char*, unsigned int)>)
PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE);
^
/arduino-1.8.5/libraries/pubsubclient/src/PubSubClient.h:121:18: note: no known conversion for argument 1 from 'void()' to 'std::function<void(char*, unsigned char*, unsigned int)>'
/MQTT-Keypad/MQTT-Keypad.ino: In function 'void callback()':
MQTT-Keypad:67: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
client.publish(mqtt_state, myKey);
^
In file included from /MQTT-Keypad/MQTT-Keypad.ino:12:0:
/arduino-1.8.5/libraries/pubsubclient/src/PubSubClient.h:130:12: error: initializing argument 2 of 'boolean PubSubClient::publish(const char*, const char*)' [-fpermissive]
boolean publish(const char* topic, const char* payload);
^
MQTT-Keypad:70: error: a function-definition is not allowed here before '{' token
void loop() {
^
MQTT-Keypad:96: error: expected '}' at end of input
}
^
exit status 1
no matching function for call to 'PubSubClient::setCallback(void (&)())'
I “know” it is something wrong with the Callback function but I have no idea what it is and how to fix it.
Maybe someone could help me and and guide me in the correct way.
Thanks in advance