Mqtt connect not declared in this scope

i am running this code but i am getting error mqtt_connect not declared in this scope.
#include <ESP8266WiFi.h>
#include “Adafruit_MQTT.h”
#include “Adafruit_MQTT_Client.h”

#define WLAN_SSID “ACT104439774982”
#define WLAN_PASS “91282654”

#define AIO_SERVER “io.adafruit.com
#define AIO_SERVERPORT 1883 // use 8883 for SSL
#define AIO_USERNAME “sasi_mohith”
#define AIO_KEY “aio_aMAF37IBXkCJOI9bLuI6iUrX6iH1”

WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME “/feeds/power”);

const int sensorIn = A0;
int mVperAmp = 66;
double Vpp=0;
double Vp=0;
double Vrms = 0;
double Irms=0;

void setup() {
Serial.begin(9600);
WiFi.begin(WLAN_SSID, WLAN_PASS);
while(WiFi.status()!=WL_CONNECTED)
{
Serial.println(“Connecting…”);
delay(1000);
}
Serial.println(“Connected”);
}

void loop() {
MQTT_connect();
Vpp = getVPP();
Vp=Vpp/2.0;
Vrms=Vp0.707;
Irms=((Vrms
1000)/mVperAmp)-0.09;
Serial.print(Irms);
Serial.println(“Amps”);
if(!photocell.publish(Irms))
{
Serial.println(“Failed”);
}
else
{
Serial.println(“OK!”);
}
delay(2000);
}

double getVPP()
{
double result;

int readValue;
int maxValue = 0;
int minValue = 1024;

uint32_t start_time = millis();
while((millis()-start_time)<1000)
{
readValue = analogRead(sensorIn);

if (readValue > maxValue)
{
    maxValue = readValue;
}
if (readValue < minValue)
{
    minValue = readValue;
}

}
result = ((maxValue - minValue) * 5.0)/1024.0;
return result;
}

Welcome th openHAB :wave:

That doesn’t sound like your are using the MQTT binding of openHAB at all. Such question is better placef in a developer forum.

And in addition, that seems to be Arduino code. Probably the correct call would be Adafruit_MQTT_Client.connect.

But if you have troubles with the code, your should consult the Arduino community

1 Like

Please note that this is a public forum, so everyone with an account can see your credentials.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.