khoih-prog / BlynkGSM_Manager

Simple GSM shield Manager for Blynk and ESP32 / ESP8266 boards, with or without SSL, configuration data saved in SPIFFS / EEPROM. This library enables user to include both Blynk GSM/GPRS and WiFi libraries in one sketch, run both WiFi and GSM/GPRS simultaneously, or select one to use at runtime after reboot.
MIT License
22 stars 2 forks source link

Use SPIFFS to add more variables like in AutoConnect #5

Closed FRANAIRBUS closed 4 years ago

FRANAIRBUS commented 4 years ago

Hello congratulations, a great job and very interesting your bookstore for my project.

I really like that your code doesn't stop in the absence of a wifi hotspot, since in my project I would like it to also serve as a thermostat as a sensor, so it should continue to work in the absence of wifi or gprs.

My code, although I am relatively new to programming, is quite elaborate with the Hieromon / AutoConnect / mqttRSSI_FS library and has 39 variables among which there are probe calibration alarms, blynk, msql, high and low temperature and other configuration variables more by SPIFFS.

I would like to be able to integrate my code with your library and have the option of gprs as well as wifi in a ttgo call.

Could you tell me the easiest way to add variables to SPIFFS so you can use them in your library like AutoConnect / mqttRSSI_FS does? I would also like to know if there is a way to have an active html page for variable configuration once connected to wifi or gprs like this as the option to use static ip in wifi configuration.

thank you very much and forgive my english.

khoih-prog commented 4 years ago

Thanks for your nice and encouraging words which can help us, the library writers/maintainers, to continue to provide the free service to the community. I'm happy that you see one of the main purpose of the library is providing "non-blocking" service to let you to continue the loop jobs even without the WiFi.

For you requirements, you can use one of the many options as follows: 1) Use Blynk widgets. See SmartFarm DeepSleep Project in Blynk or SmartFarm DeepSleep Project in GitHub

2) I implemented several libraries providing similar dynamic parameter features (via dynamic HTML), such as: a) WiFiManager_NINA_Lite b) ESP_AT_WM_Lite

and will implement those features into those similar libraries, such as this BlynkGSM_Manager, etc. soon when I have time.

3) You can also write your own function to read/write the SPIFFS (see how I implemented in the library, certainly with different SPIFFS file name) and use corresponding data as you like.

4) It's totally possible you can run a WebServer from ESP32/8266 independently from GSM/GPRS (as you have seen by using the library) and let users to modify the parameters via HTML.

I certainly can not help you more in details. Please research, don't be afraid of errors from which you can learn a lot, then be a happy master quickly.

Regards,

FRANAIRBUS commented 4 years ago

Thanks to people like you who contribute their knowledge altruistically. The world can move a little faster and people like me with a little programming knowledge can make codes tailored to our needs.

I am not afraid of mistakes, as they say, they help us learn a lot.

1 interesting SmartFarm DeepSleep Project but I have already created a similar one and it is relatively easy to create and read variables with blynk. But I am sorry to say that I do not like to depend alone and exclusively on blynk and I like to use 2 roads to get to the same place. always having an option b, so that solution, although practical, is not what I want on my devices nor do I always want to depend on third parties. As I commented my code, although you can use the blynk app, it also sends all the data to a sql server allowing the use of its own app.

2 I will study the libraries to see how they work and the ease of adding custom variables. I eagerly await your updates from BlynkGSM_Manager a) WiFiManager_NINA_Lite b) ESP_AT_WM_Lite

3 and 4 I will try to better understand your BlynkSimpleEsp32_GSM_WFM.h file so that I can add custom variables and static ip settings without prior programming.

Thank you

khoih-prog commented 4 years ago

With your very good vision and the way you approach and solve the problem, I don't think you're just a person with a little programming knowledge. I believe you'll go very far in the future and be the thinker, not just the coder. If you can contribute anything to any of the libraries, I'm be honoured to receive the help and new ideas. I'll reopen this issue to put the dynamic params a higher priority in the bucket list.

Regards,

khoih-prog commented 4 years ago

Dear @FRANAIRBUS , I've just finished and already published the new version v1.0.6 to enable you to add dynamic parameters which can be stored in either SPIFFS or EEPROM. Please give it a try and your feedback will be very welcome. Your contribution has also been recognized by your enhancement request.

Regards,

FRANAIRBUS commented 4 years ago

Good morning @ khoih-prog thank you very much for the updates of BlynkGSM_Manager, the truth is that it works very well, it is checked and verified that it works well.

Also thank the support given and for the considerations to my person when seeing something more than a copy paste, thank you for the mention, the concern to improve the library on demand and your pleasant response.

Thanks to its update it is now very easy to add custom variables to the program.

Just one more thing... How can enter the variable configuration once connected to WF.

best regards.

khoih-prog commented 4 years ago

Hi, That's good to know it's working OK and somehow helpful. About still keeping the Config Portal opened in normal operation, could you clarify your use-case so that I know a little bit better before being able to think and do something. Pls also reply these questions and concerns:

  1. Do you still use WiFi to do something else, such as Blynk, Internet connection? Or just use that for Config Portal?
  2. Do you connect to Blynk only via GPRS and don't need WiFi to do that simultaneously?
  3. Do you like to have the Config Portal to open in AP, STA or both AP+STA mode? Please read these potential issues if AP or AP+STA mode is selected

Imagine you have 20 different devices, each running its own AP. There will be a lot of issues such as :

  • channel conflict => big issue for every board, even for your router if channel is duplicated.
  • unintended (re-)connection from other devices
  • the STA+AP mode is not as very reliable as STA only.
  • the Portal Webserver must be still running and not efficient to do so.
FRANAIRBUS commented 4 years ago

Hi there, Like STA, in other words that the configuration web serves on port 80 or another port to be able to change configuration variables once connected.

For example to change the server server name mqtt or a topic or any other dynamic parameter variable.

ejemplo

khoih-prog commented 4 years ago

How about questions 1. and 2. ?

FRANAIRBUS commented 4 years ago

Forgive me for just answering # 3 Looking at 1 and 2 I think one of the good things about BlynkGSM_Manager is that it can be used in one way or another.

In principle, I use WIFI for blynk or msql and to configure variables such as shipping time to servers or high and low temperature alarms, humidity, or select the pin where dht or ds will work or any type of probe.

In case of not having WIFI you must use GPRS. you will usually have a local ip to access port 80 on the same LAN and configure variables. but if we can also connect to the ip WAN it would be fantastic.

Have you thought about or have a library with modbus rtu protocol? on port 502 modbus-rtu-tcpip server;)

khoih-prog commented 4 years ago

I think your use-case is special but so interesting that I'll have to create a separate files for applications similar to yours, where persistent Config Portal is used.

The WiFi/Config Portal operation will be as follows:

  1. In case of WiFi router/network is present and WiFi Credentials are valid, the Config Portal IP will use local DHCP-IP:80 in STA mode (such as 192.168.x.x, etc.) and the normal Blynk/Internet operation is still OK, if still available.
  2. In case of no WiFi router/network presence and/or no valid WiFi Credentials, the WiFi will use the AP mode with configurable IP (192.168.4.1, etc.) to run Config Portal.

Any more idea?

In the bucket list again now.

khoih-prog commented 4 years ago

About

a library with modbus rtu protocol? on port 502 modbus-rtu-tcpip server

  1. What kind of device you're referring to?
  2. How popular and useful it is compared to using standard TCP/IP <-> ModBus RS-485?
  3. Or just the Modbus TCP/IP layer on top of TCP/IP layer, so that you can run a server on port 502 to send/receive ModBus command/requests? To write a TCP/IP wrapper around ModBus RTU message is simple enough and you can try.
  4. Is there any similar library available?
  5. Did you try something similar to the following hardware solution?

ModBus-TCP-RTU

I certainly need to know and have the device to test if I have time to write that kind of library. Without test device, it's impossible to write something reliably.

FRANAIRBUS commented 4 years ago
  1. In case of WiFi router/network is present and WiFi Credentials are valid, the Config Portal IP will use local DHCP-IP:80 in STA mode (such as 192.168.x.x, etc.) and the normal Blynk/Internet operation is still OK, if still available.
  2. In case of no WiFi router/network presence and/or no valid WiFi Credentials, the WiFi will use the AP mode with configurable IP (192.168.4.1, etc.) to run Config Portal.

Any more idea?

In the bucket list again now.

Thank you very much for reopening and I'm glad you find it interesting to work on the project.

1st Correct, this should work with the option to configure static ip or DHCP.

2nd Correct but remember that in this code AP IP is (192.168.100.1) or change information in readme.

khoih-prog commented 4 years ago
  1. AP IP is configurable, see example on README

(192.168.100.1) is configured by:

Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 100, 1));

default is (192.168.4.1) if setConfigPortalIP() not called.

FRANAIRBUS commented 4 years ago

Good morning @ khoih-prog.

It is indeed configurable but by default in the BlynkGSM_Manager examples has the line published. so the example in readme can cause confusion.

// Use channel = 0 => random Config Portal WiFi channel to avoid conflict Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 100, 1)); Blynk_WF.setConfigPortalChannel(0); Blynk_WF.begin("ESP32-WiFi-GSM");

Sin título-5

FRANAIRBUS commented 4 years ago

Hello Please check example ESP8266_GSM.ino

30 # define MODEM_RST D0 // Pin D0 asignado al pin GPIO16 por 30 # define MODEM_RST 16 // Pin D0 asignado al pin GPIO16

Thank you so much for everything.

can we talk about modbus privately?

khoih-prog commented 4 years ago
  1. Fixed in README and examples in master.

    // Use configurable AP IP, instead of default IP 192.168.4.1
    Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 100, 1));
    // Use channel = 0 => random Config Portal WiFi channel to avoid conflict
    Blynk_WF.setConfigPortalChannel(0);
    // Set personalized Hostname
    Blynk_WF.begin("ESP8266-WiFi-GSM");

    It is indeed configurable but by default in the BlynkGSM_Manager examples has the line published. so the example in readme can cause confusion.

  2. D0 is 16 (GPIO16) in ESP8266. Just an example. You can change according to your actual connection.

30 # define MODEM_RST D0 // Pin D0 asignado al pin GPIO16 por 30 # define MODEM_RST 16 // Pin D0 asignado al pin GPIO16

  1. OK. Just send PM or email me as this is unrelated topics.

can we talk about modbus privately?

FRANAIRBUS commented 4 years ago

D0 is 16 (GPIO16) in ESP8266. Just an example. You can change according to your actual connection.

:) I know but arduino IDE does not compile with the "D" remove the "D" and put digital pin or gpio number as in other examples

khoih-prog commented 4 years ago

static const uint8_t D0 = 16; is defined in

esp8266/variants/nodemcu/pins_arduino.h
esp8266/variants/wifinfo/pins_arduino.h
esp8266/variants/d1_mini/pins_arduino.h
...

and you can use in sketch. I have no problem compiling with D0, with core ESP8266 core 2.6.3 Try to select NodeMCU, WeMosD1 R1, etc. to see if it's OK. If not, it's possible that you didn't install the ESP8266 core correctly or use the very old core.

FRANAIRBUS commented 4 years ago

Forgive me you are right only give error in generic esp8266 In NodeMCU, WeMosD1 R1 is ok

Sin título-6

tcpipchip commented 4 years ago

Hi @FRANAIRBUS

Contact my friend, mitov@mitov.com, BOIAN

I hope that he can give you some HELP! Recently he ported to VISUINO the MODBUS RTU

khoih-prog commented 4 years ago

Hi @FRANAIRBUS

@tcpipchip is my friend I asked for help and advice in that ModBus-RTU matter.

Don't hesitate to contact his friend.