itkindaworks / esphelper Goto Github PK
View Code? Open in Web Editor NEWA library to make using WiFi & MQTT on the ESP8266 easy.
License: GNU General Public License v3.0
A library to make using WiFi & MQTT on the ESP8266 easy.
License: GNU General Public License v3.0
Metro said in their github that they have moved to chrono
https://github.com/thomasfredericks/Metro-Arduino-Wiring/blob/master/README.md
The main reason I care is that it would be easier to add it as a dependency in platformio.ini if it was using a library like chrono, which is in the list of libraries.
Good day, looking for some help. Im trying to manager a remote with this sketch but although it connects to the Wifi it seems to jam the switch in HA and not operate the remote.
Any guidance is welcome. Thank you.
SomfyControlTest.docx
Hi,
Firstly thanks a ton for the Library, you have done an amazing job.
Just a quick one MQTT over TLS supported?
if yes could you please provide an example?
if no any plans or ETA on your roadmap?
Cant convince my brain to use unencrypted mqtt? All brokers and other devices use encrypted.
one again thanks a lot for all the hardwork!!
Was making some improvement to one of my home projects and while it compiles and upload just fine (with ArduinoJson.h at version 6.14, cause newer versions aren't compatible anymore) the ESP just keeps resetting itself every 15 seconds through hardware WDT.
It reaches till the end of the void setup() with no problems (connects to WiFi, enables OTA and sets up MQTT connection) and then after a few seconds it resets.
I replaced the ESPHelper with standard ESP8266, PubSubClient and Arduino OTA and everything works fine again
Doing some debugging I've found out that the issue belongs to ESPHelper::loop() method.
I see there are some compiler warnings, about sending string constants as char*'s. I think this is an easy fix, just using "const char *" instead.
Not a big deal, but might be a useful issue to have, when you feel like fixing it.
It's useful to have information when connection succesefuly made. So you can display IP address (for example if I have LED display)
Fantastic work! Do you plan to make it compatible with arduinojson 6 ?
Hi,
Thank you for this library I love It. When you have time please add:
Would be really nice if there was installation instructions for PlatformIO. I've setup a project for the Adafruit Feather Huzzah32 to play around with and was able to find most dependencies for ESPHelper. But i cannot get it to work properly.
Note: Also downgraded ArduinoJson to version 6.14.1
.
see my paltformio.ini
file
[env:featheresp32]
platform = espressif32
board = featheresp32
framework = arduino
monitor_speed = 115200
lib_deps =
itkindaworks/ESPHelper@^1.7.4
knolleary/PubSubClient@^2.8
bblanchon/[email protected]
I'm not sure i've installed installed metro correctly. What i did was to download the latest version here : https://github.com/thomasfredericks/Metro-Arduino-Wiring/archive/master.zip. And added the folder to lib
folder in my project. So once that was done it seemed to be working for me, no errors saying it can't find Metro.h
.
But even after this. I'm stuck with the same errors mentioned in this issue #35.
Posting them here too: (All errors seems to be located in the ShardedData.h
header file)
compilation terminated.
*** [.pio/build/featheresp32/libdb3/ESPHelper/ESPHelperWebConfig.cpp.o] Error 1
In file included from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.h:44:0,
from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.cpp:23:
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
const char* pass;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'int netInfo::mqttPort' [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:57:2: error: when initialized here [-Werror=reorder]
netInfo(const char* _name,
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:42:14: error: 'const char* netInfo::mqttUser' [-Werror=reorder]
const char* mqttUser;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:57:2: error: when initialized here [-Werror=reorder]
netInfo(const char* _name,
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
const char* pass;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'int netInfo::mqttPort' [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:76:3: error: when initialized here [-Werror=reorder]
netInfo(const char* _mqttHost,
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:42:14: error: 'const char* netInfo::mqttUser' [-Werror=reorder]
const char* mqttUser;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:76:3: error: when initialized here [-Werror=reorder]
netInfo(const char* _mqttHost,
^
In file included from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.h:44:0,
from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.h:27,
from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp:22:
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
const char* pass;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'int netInfo::mqttPort' [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:57:2: error: when initialized here [-Werror=reorder]
netInfo(const char* _name,
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:42:14: error: 'const char* netInfo::mqttUser' [-Werror=reorder]
const char* mqttUser;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:57:2: error: when initialized here [-Werror=reorder]
netInfo(const char* _name,
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
const char* pass;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'int netInfo::mqttPort' [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:76:3: error: when initialized here [-Werror=reorder]
netInfo(const char* _mqttHost,
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:42:14: error: 'const char* netInfo::mqttUser' [-Werror=reorder]
const char* mqttUser;
^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:76:3: error: when initialized here [-Werror=reorder]
netInfo(const char* _mqttHost,
^
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.cpp: In member function 'void ESPHelper::setMQTTCallback(std::function<void(char*, unsigned char*, unsigned int)>)':
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.cpp:832:16: error: cannot convert 'std::function<void(char*, unsigned char*, unsigned int)>' to 'void (*)(char*, uint8_t*, unsigned int) {aka void (*)(char*, unsigned char*, unsigned int)}' in assignment
_mqttCallback = callback;
^
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp: In member function 'bool ESPHelperFS::addKey(const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp:329:19: warning: comparison with string literal results in unspecified behaviour [-Waddress]
if(_filename != ""){
^
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp: In member function 'String ESPHelperFS::loadKey(const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp:397:19: warning: comparison with string literal results in unspecified behaviour [-Waddress]
if(_filename != ""){
^
cc1plus: some warnings being treated as errors
*** [.pio/build/featheresp32/libdb3/ESPHelper/ESPHelper.cpp.o] Error 1
cc1plus: some warnings being treated as errors
*** [.pio/build/featheresp32/libdb3/ESPHelper/ESPHelperFS.cpp.o] Error 1
Error compiling
In file included from /home/qinghuang.chan/Arduino/libraries/ESPHelper/src/ESPHelper.cpp:25:0: /home/qinghuang.chan/Arduino/libraries/ESPHelper/src/ESPHelperFS.h:93:10: error: 'StaticJsonBuffer' does not name a type static StaticJsonBuffer<JSON_SIZE> *_tmpBufPtr; ^ exit status 1 Error compiling for board Generic ESP8266 Module
Any ideia what can be causing this error?
Arduino: 1.8.1 (Windows 10), Placa:"Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None"
C:\Users\Francisco\Documents\Arduino\libraries\ESPHelper-master\src\ESPHelper.cpp: In member function 'void ESPHelper::publish(const char*, const char*, bool)':
C:\Users\Francisco\Documents\Arduino\libraries\ESPHelper-master\src\ESPHelper.cpp:223:39: error: invalid conversion from 'const char*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]
client.publish(topic, payload, retain);
^
In file included from C:\Users\Francisco\Documents\Arduino\libraries\ESPHelper-master\src\ESPHelper.h:31:0,
from C:\Users\Francisco\Documents\Arduino\libraries\ESPHelper-master\src\ESPHelper.cpp:23:
C:\Users\Francisco\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:114:12: error: initializing argument 2 of 'boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int)' [-fpermissive]
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
^
exit status 1
Erro ao compilar para a placa Generic ESP8266 Module.
Please update your https://raw.githubusercontent.com/ItKindaWorks/ESPHelper/master/library.json file to include an "Author" reference. I have started using Platformio.org (http://docs.platformio.org/en/latest/userguide/lib/cmd_register.html) for development and it requires that key to be able to register your library as importable through its IDE. - It may require more than that, but its the first error I've landed on.
Edit: I see the library.properties file contains the required fields and have submitted that to Platformio for review - This issue could be closed now. Thank you.
Hello Friends,
I'm trying to compile anyone of the exemples of the library and always get the same error:
ESPHelper.h:106:19: error: 'MQTT_CALLBACK_SIGNATURE' has not been declared
bool setCallback(MQTT_CALLBACK_SIGNATURE);
Please, can you help me?
Hi
I am using esphelper library in my project which is using pir sensor which lights up the bulb
When I use esphelper till wifi connection it's OK when I start raspberry pi which runs mqtt server the connection to wifi gets lost and ip is unset and set again at regular intervals (mostly within 15 Sec or so)
Maybe I'm missing it, but it would be nice to be able to getIp() and it would return a string, "192.168.1.105" or whatever.
Also, a boolean, that would be connected()? Might be nice. Just something so that I know when it's connected, and how to get to it.
If this is an failure because of my lack of knowledge I apologize in advance.
I tried to run the relayControl example, but I get this error:
In file included from C:\Users\.....\Documents\Projects\Arduino\IOThing_D1\IOThing_D1.ino:25:0:
C:\Users\.....\Documents\Arduino\libraries\ESPHelper\src/ESPHelper.h: In function 'void callback(char*, byte*, unsigned int)':
C:\Users\.....\Documents\Arduino\libraries\ESPHelper\src/ESPHelper.h:166:15: error: 'PubSubClient ESPHelper::client' is private
PubSubClient client;
^
IOThing_D1:93: error: within this context
myESP.client.publish(statusTopic, "0", true);
^
exit status 1
within this context
I Installed the pubsub library (today) via the library manager. (also installed metro library)
Line 25: #include "ESPHelper.h
Line 93: myESP.client.publish(statusTopic, "0", true);
tested boards: D1 mini
NodeMCU v3 LOLin
Do you have any plans to implement MQTT Last Will and Testament functionality?
Hello there
I would like to use this nice library but got stuck when trying to compile one of the examples on platformIO
Can you help me?
This is the output;
In file included from .pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/ESPHelper.h:44:0,
from D:/Documents/PlatformIO/Projects/ESP helper test/src/main.ino:22:
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*)':
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
const char* pass;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:44:6: error: 'int netInfo::mqttPort' [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:57:2: error: when initialized here [-Werror=reorder]
netInfo(const char* _name,
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:42:14: error: 'const char* netInfo::mqttUser' [-Werror=reorder]
const char* mqttUser;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:57:2: error: when initialized here [-Werror=reorder]
netInfo(const char* _name,
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*, const char*)':
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
const char* pass;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:44:6: error: 'int netInfo::mqttPort' [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:76:3: error: when initialized here [-Werror=reorder]
netInfo(const char* _mqttHost,
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
int mqttPort;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:42:14: error: 'const char* netInfo::mqttUser' [-Werror=reorder]
const char* mqttUser;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/sharedData.h:76:3: error: when initialized here [-Werror=reorder]
netInfo(const char* _mqttHost,
^
In file included from D:/Documents/PlatformIO/Projects/ESP helper test/src/main.ino:23:0:
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/ESPHelperFS.h: At global scope:
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/ESPHelperFS.h:97:10: error: 'StaticJsonDocument' does not name a type
static StaticJsonDocument<JSON_SIZE> *_tmpBufPtr;
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/ESPHelperFS.h:99:46: error: 'JsonDocument' has not been declared
static bool loadFile(const char* filename, JsonDocument* buffer);
^
.pio/libdeps/esp32doit-devkit-v1/ESPHelper_ID1556/src/ESPHelperFS.h:120:26: error: 'JsonDocument' has not been declared
static bool saveConfig(JsonDocument json, const char* filename);
^
cc1plus.exe: some warnings being treated as errors
*** [.pio\build\esp32doit-devkit-v1\src\main.ino.cpp.o] Error 1
edit: inserted the right output
Can't compile scatch anymore.
Arduino update 6.15.2 breaks it
What command do I use to check if I'm connected to mqtt server as I'm trying to set up error indicates and i need a different one for wifi and MQTT
Hi there!
Just had a look at your source code as I want to give ESPHelper a try after playing around with storing config data on SPIFFS.
The advantage of having data/netConfig.json as part of the repository and upload it as SPIFFS would be that there is no need to create a sketch with real life data to upload / run it to / on the ESP (and maybe ending up having the real life access data in the repository which utilises ESPHelper). Of course the data/netConfig.json should not be part of the repository, rather some file like data/netConfig.json_example or so which shows the structure of the file accompanied maybe with a README.
Separating credentials and source code has also the advantage that the program does not need to be touched in case the credentials change.
I use PlatformIO where one can have several targets of compilation with different settings and it seems possible to execute a script before compiling which even could create the data/netConfig.json file on the fly.
Just my 2 cents...
Greetings, Uwe
Nice package to get ArduinoOTA and MQTT working together. But some features are still missing. I miss the ability to specify a will for the MQTT client most at the moment.
Thank you for the great work!
This example suitable for new esp unit or location change scenario.
But, in regular using situation, wifi signal unstable or AP temporary offline will cause
esp falling into broadcasting mode and stay offline forever.
So, I thought esp should be auto back online or auto reconnect, in order to maintain normal operation.
below is my enhancements
Metro broadcastModeTimeout = Metro(180000);
if ((wifiStatus == BROADCAST) && broadcastModeTimeout.check())
{
Serial.println("BROADCAST mode timeout and reset ESP");
ESP.reset();
delay(5000);
}
broadcastModeTimeout.reset();
In my simple test, it's ok.
I hope someone can make it better.
I had try updateNetwork(), but i failed.
I got the Metro.h (No such file or directory error) when I first tried out ESPHelper basicUse project. Any idea if the custom Metro.h file should be included into the project?
i compiled the code with #include "ESPHelper.h" . it state the error because of ESPHelper.h: No such file or directory. compilation terminated.
Error compiling. Help me please i have installed the Metro library, what else should be included?
Hello,
Thanks for the library. I was using it with a Wemos D1 Mini, and had the following issue after OTA uploading: I got the message " [ERROR} No Answer" and did not get the message "Done uploading"...
And then got asked to upload again.
Found a solution (I do not know if is ideal, but worked for me):
Hi there amazing job with the library been using it for a long time, my current project requires users to set there own SSID, Wifi PWS, MQTT IP, MQTT User Name, MQTT PWS which I have worked using WIFI Manager. i was wondering how i could update all of these settings while in the Void Setup(); section, as i have to run some code to retrieve it out of flash before being able to give it the ESPHelper was wondering if you could help.
Many thanks
I have several esp devices around the house, and the Arduino sketch is essentially similar except for the nodename and connectname. I can upload to any of them except one. In that case (a Sonoff Switch), I get this error:
esphelper error No Answer to our Authentication
Early in my sketch I define the nodename:
#define NODENAME "counter"
And in my setup()
//espHelper
myESP.OTA_enable();
myESP.OTA_setPassword(NODENAME);
myESP.OTA_setHostname(NODENAME);
myESP.begin();
I am pretty certain that espHelper is running because I see the hostname in the IDE Port: dropdown, and with the correct IP.
I have two other Sonoff switches and they are also running the same code except NODENAME is different for each of them. I even tried loading 'counter.ino' through the com port on a different Sonoff Switch- same results. I restart the IDE and the node "counter" is in the Port list, but I still get the same error.
Any help you could offer would be appreciated.
Is there a way to utilize a static IP address when connection to a WiFi network instead of using a DHCP server?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.