Skip to content
This repository was archived by the owner on Jul 22, 2022. It is now read-only.
This repository was archived by the owner on Jul 22, 2022. It is now read-only.

MQTT CONNECT NOT DECLARED IN THIS SCOPE #137

Open
@sasimohith

Description

@sasimohith

I am trying to compile a code but getting this error 'MQTT_connect()' was 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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions