Went through Web server tutorial from http://easycoding.tn/index.php/esp32/esp32-internet/
code I ended up with
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "Adafruit_MQTT_FONA.h";
#include <WiFi.h>
int i;
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883
#define AIO_USERNAME "rnborland"
#define AIO_KEY "ffe00a15e69a4c59890308a811faf8b3"
WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
boolean MQTT_connect();
boolean MQTT_connect() { int8_t ret; if (mqtt.connected()) { return true; } uint8_t retries = 3; while ((ret = mqtt.connect()) != 0) { mqtt.disconnect(); delay(2000); retries--;if (retries == 0) { return false; }} return true;}
Adafruit_MQTT_Publish Testing = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/Testing");
void setup()
{
Serial.begin(9600);
WiFi.disconnect();
delay(3000);
Serial.println("START");
WiFi.begin("Borland","d5cs7xk1");
while ((!(WiFi.status() == WL_CONNECTED))){
delay(300);
Serial.print("..");
}
Serial.println("Connected");
Serial.println("Your IP is");
Serial.println((WiFi.localIP()));
}
void loop()
{
i = (random(100,200));
if (MQTT_connect()) {
if (Testing.publish(i)) {
Serial.println("Random Data Sent");
Serial.println(i);
} else {
Serial.println("Problem Sending Data");
}
} else {
Serial.println("Connection Problem");
}
delay(10000);
}
Error script is
Arduino: 1.8.9 (Windows 7), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"
C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp: In member function 'virtual bool Adafruit_MQTT_Client::sendPacket(uint8_t*, uint16_t)':
C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:84:38: error: no matching function for call to 'min(uint16_t&, int)'
uint16_t sendlen = min(len, 250);
^
In file included from c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\algorithm:62:0,
from C:\Users\rborland\Documents\Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:148,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT.h:25,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.h:26,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:22:
c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algo.h:3451:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
min(initializer_list<_Tp> __l, _Compare __comp)
^
c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algo.h:3451:5: note: template argument deduction/substitution failed:
C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:84:38: note: mismatched types 'std::initializer_list<_Tp>' and 'short unsigned int'
uint16_t sendlen = min(len, 250);
^
In file included from c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\algorithm:62:0,
from C:\Users\rborland\Documents\Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:148,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT.h:25,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.h:26,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:22:
c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algo.h:3445:5: note: candidate: template _Tp std::min(std::initializer_list<_Tp>)
min(initializer_list<_Tp> __l)
^
c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algo.h:3445:5: note: template argument deduction/substitution failed:
C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:84:38: note: mismatched types 'std::initializer_list<_Tp>' and 'short unsigned int'
uint16_t sendlen = min(len, 250);
^
In file included from c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\algorithm:61:0,
from C:\Users\rborland\Documents\Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:148,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT.h:25,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.h:26,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:22:
c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algobase.h:243:5: note: template argument deduction/substitution failed:
C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:84:38: note: deduced conflicting types for parameter 'const _Tp' ('short unsigned int' and 'int')
uint16_t sendlen = min(len, 250);
^
In file included from c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\algorithm:61:0,
from C:\Users\rborland\Documents\Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:148,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT.h:25,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.h:26,
from C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:22:
c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algobase.h:195:5: note: candidate: template const _Tp& std::min(const _Tp&, const _Tp&)
min(const _Tp& __a, const _Tp& __b)
^
c:\users\rborland\documents\arduino\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algobase.h:195:5: note: template argument deduction/substitution failed:
C:\Program Files (x86)\Arduino\libraries\Adafruit_MQTT_Library-master\Adafruit_MQTT_Client.cpp:84:38: note: deduced conflicting types for parameter 'const _Tp' ('short unsigned int' and 'int')
uint16_t sendlen = min(len, 250);
^
Multiple libraries were found for "WiFi.h"
Used: C:\Users\rborland\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
Error compiling for board ESP32 Dev Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.