B4R Tutorial ESP Configurator based on B4RSerializator

SS-2017-07-09_16.48.51.png


This tool replaces the browser based solution (https://www.b4x.com/android/forum/threads/esp8266-wifi-remote-configuration.68596/). It is simpler and much more powerful.

B4RSerializator, which converts objects to bytes and vice versa, is used for the communication with the B4J app and to save the settings in the EEPROM. B4RSerializator is also compatible with B4A and B4i so you can also create a mobile app.

In this specific example the data includes MQTT related settings. It should be simple to change it to store other fields. Just make sure to set the field types correctly.

If the ESP is not connected to the local network then you should connect the PC to the ESP access point and set the ip address to 192.168.4.1, which is the default ip.
If it is connected to the network and you know its ip address then you can use it instead. The ESP local ip is printed in the logs.

Now click on Get to get the stored parameters or click on Set to send the parameters to the board.
In this example it is configured to connect to the network and then connect to a MQTT broker.

Note that the Get and Set features start a new connection and close it when done. This is a simpler and safer approach compared to maintaining a continuous connection.

If you are using Java 9+ then replace jControlsFX with jControlsFX9.
 

Attachments

  • B4R_ESPConfigurator.zip
    2 KB · Views: 2,739
  • B4J_ESPConfigurator.zip
    46.1 KB · Views: 2,471
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
This is absolutely brilliant @Erel, I'll test it later when I'm back home from my bike ride. I'm about 28 miles away from my home and having a quick 10 minutes rest before heading back :)

I'm thinking about attempting to modify your code so that I can also set subjects through the B4J app separated by commas, "sub1, sub2, sub3" etc. I'm not sure if it possible but nevertheless I'll attempt it.

Thank you again @Erel, great work as usual...
 

rbghongade

Active Member
Licensed User
Longtime User
Fantastic! Erel. Just checked the code and it works flawlessly on Wemos D1 R2. Erel is a genius!
This feature overcomes the greatest difficulty of connecting the sensor node at customer premises.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm thinking about attempting to modify your code so that I can also set subjects through the B4J app separated by commas, "sub1, sub2, sub3" etc. I'm not sure if it possible but nevertheless I'll attempt it.
It is possible, but it is better to update the Record type and add more fields. This way you will not need to parse the stored data.
 

ma7tin

Member
Licensed User
Hi guys, what might be a reason for - Failed to connect .. message in ESP Configurator
My module is in my local network when I ping it .. but cannot GET any information when I try to use B4J ESP Configurator.
Module is connected to external 3.3V power supply not to PC USB, doesnot work either cases.
Any ideas ?
 

ma7tin

Member
Licensed User
I did basic IP and password setup on NodeMCU ESP8266 12-E board using B4R ESP Configurator.
Log was AP-1 and IP:192.168.4.1 so I've use android phone to setup IP to my local network using ../set/SSID/password.
Than I try to use B4J ESP Configurator to read/write info from board but not succedd with connection as I finished with - Failed to connect - message.
 

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
[QUOTE = "ma7tin, post: 545943, member: 94014"] Hice la configuración básica de IP y contraseña en la placa NodeMCU ESP8266 12-E usando B4R ESP Configurator.
El registro fue AP-1 e IP: 192.168.4.1, así que he usado el teléfono Android para configurar el IP en mi red local usando ../set/SSID/password.
Luego, trato de usar el Configurador ESP4 de B4J para leer / escribir información de la placa, pero no tuve éxito con la conexión, ya que terminé con - No se pudo conectar - Mensaje. [/ QUOTE]
Lo que tienes que hacer es conectar tu computadora al punto de acceso de la red WIFI ("esp") y listo.

Saludos...
 

KiloBravo

Active Member
Licensed User
I know this is an old thread, but ...
I downloaded the attached files from the first post and spent about 15 minutes getting the B4J version to run.
I was getting a ton of Java Errors in the log.
Simple solution, go to the Libraries Manager, uncheck jControlsFX, then check the JControlsFX9 library.
After that both sides worked great. I am using Java 11, with B4J v8.90.

Hopefully this saves someone a few minutes of time !
 

Cableguy

Expert
Licensed User
Longtime User
I know this is an old thread, but ...
I downloaded the attached files from the first post and spent about 15 minutes getting the B4J version to run.
I was getting a ton of Java Errors in the log.
Simple solution, go to the Libraries Manager, uncheck jControlsFX, then check the JControlsFX9 library.
After that both sides worked great. I am using Java 11, with B4J v8.90.

Hopefully this saves someone a few minutes of time !
You saved me a HUGE headake!
 

viriato

Member
Licensed User
Longtime User
Hi,
Do you have the same example for b4A ? in place of the b4J example

Thanks
 
Top