Correct MQTT API usage

This commit is contained in:
Mathieu Maret 2019-05-03 00:35:24 +02:00
parent 922b66cae2
commit b19406af98
1 changed files with 5 additions and 5 deletions

View File

@ -19,7 +19,7 @@ extern "C" {
#define DHT_POWER_PIN 13
DHT dht(DHTPIN, DHTTYPE);
#define FPM_SLEEP_MAX_TIME 0xFFFFFFF
#define FPM_SLEEP_MAX_TIME 0xFFFFFFF // Could be replace by ESP.deepSleepMax() -> https://thingpulse.com/max-deep-sleep-for-esp8266/
#define MQTT_SERVER "192.168.0.250"
#define MQTT_USERNAME "XXXXXX"
@ -35,15 +35,15 @@ Adafruit_MQTT_Publish *mqtt_temp;
Adafruit_MQTT_Publish *mqtt_pressure;
Adafruit_MQTT_Publish *mqtt_voltage;
const char *ssid = "XXXXXX";
const char *password = "XXXXXX";
const char *ssid = "XXXXX";
const char *password = "XXXXX";
ADC_MODE(ADC_VCC);
void setup()
{
// Power on DHT11
pinMode(DHT_POWER_PIN, OUTPUT);
digitalWrite(DHT_POWER_PIN, HIGH);
//digitalWrite(DHT_POWER_PIN, HIGH);
// put your setup code here, to run once:
Serial.begin(115200);
Serial.print("\nRunning\n");
@ -79,7 +79,7 @@ int WiFiOff() // vs WiFi.forceSleepBegin();
int mqttConnect(float h, float t)
{
mqtt = new Adafruit_MQTT_Client(&client, MQTT_SERVER, MQTT_PORT,
MQTT_USERNAME, MQTT_PASSWD);
MQTT_USERNAME, MQTT_USERNAME, MQTT_PASSWD);
uint8_t retries = 3;
Serial.println("Connecting to mqtt");
while ((mqtt->connect()) != 0) { // connect will return 0 for connected