Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback was not declared in this scope #7

Open
malebuffy opened this issue Apr 30, 2017 · 3 comments
Open

callback was not declared in this scope #7

malebuffy opened this issue Apr 30, 2017 · 3 comments

Comments

@malebuffy
Copy link

Hi,

i copy paste your code and change the mqtt and ssid and password info. however when i try to compile with the latest arduino ide i get the following error althoug it is on the code:

mqtt:25: error: 'callback' was not declared in this scope
 PubSubClient client(MQTT_SERVER, 1883, callback, wifiClient);
                                        ^
exit status 1
'callback' was not declared in this scope
@Harvsch
Copy link

Harvsch commented May 30, 2017

You need to add the "callback function header" before the line that first calls it. I copied the header along with surrounding code for you to see. This information is in the example code for the pubsubclient library.

char* lightTopic = "/test/light1";

// Callback function header
void callback(char* topic, byte* payload, unsigned int length);

WiFiClient wifiClient;
PubSubClient client(MQTT_SERVER, 1883, callback, wifiClient);

void setup() {

@malebuffy
Copy link
Author

Thanks..
that worked

@brekl
Copy link

brekl commented Apr 1, 2021

Estou com esse problema na ide callback not declaret script ,,
Oque devo fazer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants