Correct MQTT API usage
This commit is contained in:
parent
922b66cae2
commit
b19406af98
@ -19,7 +19,7 @@ extern "C" {
|
|||||||
#define DHT_POWER_PIN 13
|
#define DHT_POWER_PIN 13
|
||||||
DHT dht(DHTPIN, DHTTYPE);
|
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_SERVER "192.168.0.250"
|
||||||
#define MQTT_USERNAME "XXXXXX"
|
#define MQTT_USERNAME "XXXXXX"
|
||||||
@ -35,15 +35,15 @@ Adafruit_MQTT_Publish *mqtt_temp;
|
|||||||
Adafruit_MQTT_Publish *mqtt_pressure;
|
Adafruit_MQTT_Publish *mqtt_pressure;
|
||||||
Adafruit_MQTT_Publish *mqtt_voltage;
|
Adafruit_MQTT_Publish *mqtt_voltage;
|
||||||
|
|
||||||
const char *ssid = "XXXXXX";
|
const char *ssid = "XXXXX";
|
||||||
const char *password = "XXXXXX";
|
const char *password = "XXXXX";
|
||||||
|
|
||||||
ADC_MODE(ADC_VCC);
|
ADC_MODE(ADC_VCC);
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
// Power on DHT11
|
// Power on DHT11
|
||||||
pinMode(DHT_POWER_PIN, OUTPUT);
|
pinMode(DHT_POWER_PIN, OUTPUT);
|
||||||
digitalWrite(DHT_POWER_PIN, HIGH);
|
//digitalWrite(DHT_POWER_PIN, HIGH);
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.print("\nRunning\n");
|
Serial.print("\nRunning\n");
|
||||||
@ -79,7 +79,7 @@ int WiFiOff() // vs WiFi.forceSleepBegin();
|
|||||||
int mqttConnect(float h, float t)
|
int mqttConnect(float h, float t)
|
||||||
{
|
{
|
||||||
mqtt = new Adafruit_MQTT_Client(&client, MQTT_SERVER, MQTT_PORT,
|
mqtt = new Adafruit_MQTT_Client(&client, MQTT_SERVER, MQTT_PORT,
|
||||||
MQTT_USERNAME, MQTT_PASSWD);
|
MQTT_USERNAME, MQTT_USERNAME, MQTT_PASSWD);
|
||||||
uint8_t retries = 3;
|
uint8_t retries = 3;
|
||||||
Serial.println("Connecting to mqtt");
|
Serial.println("Connecting to mqtt");
|
||||||
while ((mqtt->connect()) != 0) { // connect will return 0 for connected
|
while ((mqtt->connect()) != 0) { // connect will return 0 for connected
|
||||||
|
Loading…
Reference in New Issue
Block a user