Hi, I hope this is the correct forum to post this.
You may have dealt with this issue before. I am a newbie to this environment and struggling to resolve this issue. I have implement a DHT22 temperature sensor. I used platformio from the beginning and I find a good environment to work with.
I am using the example code below but I am unable to resolve it. I get this compilation error: All I am looking for is a clean compile. Maybe you can try it on your environment to see if you get the same error.
BasicOTA.ino:18:21: error: ‘MQTT’ does not name a type
BasicOTA.ino:18:34: error: expected unqualified-id before ‘&’ token
BasicOTA.ino:18:34: error: expected ‘)’ before ‘&’ token
BasicOTA.ino:18:36: error: expected initializer before 'pub’
BasicOTA.ino:23:36: error: no matching function for call to ‘PubSubClient::PubSubClient(WiFiClient&, IPAddress&)’
Your help would really be appreciated.
Cheers Bruno
I have these two libraries installed:
[ 89 ] PubSubClient
[ 127 ] ESP8266
platformio.ini:
[env:nodemcu]
platform = espressif
framework = arduino
board = nodemcu
This is the code
/*
Basic MQTT example
- connects to an MQTT server
- publishes "hello world" to the topic "outTopic"
- subscribes to the topic "inTopic"
*/
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char *ssid = "xxxxxxxx"; // cannot be longer than 32 characters!
const char *pass = "yyyyyyyy"; //
// Update these with values suitable for your network.
IPAddress server(172, 16, 0, 2);
void callback(const MQTT::Publish& pub) {
// handle message arrived
}
WiFiClient wclient;
PubSubClient client(wclient, server);
void setup() {
// Setup console
Serial.begin(115200);
delay(10);
Serial.println();
Serial.println();
client.set_callback(callback);
}