logo elektroda
logo elektroda
X
logo elektroda

ESP8266 - Changing the SSID and password of a Wi-Fi network without software intervention

mgrems 1173 13
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19153706
    mgrems
    Level 11  
    Please advise on the method of communication to be used.

    I have a measurement device assembled and running, which from the measurement sensor on the ESP8266 (client) sends data via UDP to an Application (server), which displays on a graph and "processes" the sent data.
    Because I frequently change the location of the device, and thus the network, each time I have to change the SSID and password of the network in the sensor software wi-fi.

    I wanted to switch to radio transmission on the NRF24L01, but then I need an additional microcontroller board. The ESP8266 takes care of the communication and the microcontroller on one board. I care about the small size of the sensor as a whole (still the battery), which has to fit in the measurement chamber.

    An additional requirement is the transmission speed of the data, min. 100 samples per second. So solutions such as cloud-based BLINK, VIRTUINO etc. are out of the question.

    I was thinking of a solution such as uploading the network configuration parameters at the time of sensor start-up, as used in light bulbs, IoT sockets, but I have no idea under what keyword to look for this. I don't think it's about OTA, because the sensor has to log into the network beforehand anyway, so that it's visible for software updates.

    Hence my request for suggestions and direction on the needed issues.

    Best regards in the New Year - Maciej
  • ADVERTISEMENT
  • #2 19153847
    TvWidget
    Level 38  
    Please specify what "application" means in this case. Is it running on a device on the local WiFi network or on some remote server ?

    If you want to configure the sensor then you will need to have some kind of PC, tablet or smartphone with a screen and keyboard near it. The alternative is to add some buttons and a display to the ESP. Which of these solutions would be better ?
  • #3 19154026
    khoam
    Level 42  
    Take an interest in the ESP-NOW protocol. Then the sensor sending/receiving data over WiFi does not need to log on to the edge router. ESP-NOW will also give you faster data transmission than with traditional WiFi.
    Link .
  • ADVERTISEMENT
  • #4 19154158
    mgrems
    Level 11  
    TvWidget: .
    Everything works on a local network, the sensor has an ESP8266, and the data is received via a PC app (written in Lazarus). I set this up at home, but then move to several locations ie different networks. The PC will connect and the sensor has the configuration of my home network set up. I can add a button and after a long press I could configure it, but I just don't know how. Where do I look for this and under which password?

    khoam: .
    Idea ok, but:
    Can the receiver be a PC application, or is this protocol only for ESP-to-ESP communication? The other thing that discourages me is the knowledge of MAC addresses.

    What I mean by something like this is that I have a bunch of sensors that send a data packet in the form of: [magnitude name; measured value] (i.e. e.g. [voltage; 12.34]). Each sensor, when triggered, sends data into the 'ether' at a set frequency (e.g. every second). I switch on the PC application and it detects that there are, for example, three sensors currently switched on and displays their values digitally with the unit (as they have presented themselves what they are measuring). I select one of them and want to record this data on a graph. I can still, from within the app, send a number to a sensor (or all of them) that determines how often it/they should send data. The highest rate I am interested in is what 10ms . I write the application in Lazarus (Indy10 communication components are probably not suitable for this).

    I know that a lot of my requirements are, but maybe someone, something?
  • #5 19154267
    khoam
    Level 42  
    mgrems wrote:
    Can the receiver be a PC application, or is this protocol only for ESP-to-ESP communication?
    .
    This is a protocol for ESPs only. One or more ESPs in the ESP-NOW network can also act as an AP (in which case the PC application logs into it and retrieves data) or STA (in which case this ESP is also logged into the WiFi network). Alternatively, this 'main' ESP (ideally it should be an ESP32) can send data to the PC e.g. over USB.

    mgrems wrote:
    The highest speed I am interested in is every 10ms.
    .
    The default data rate for ESP-NOW is 1 Mbps. A single data packet can contain max. 250 bytes.
  • #6 19154301
    TvWidget
    Level 38  
    One solution is to create your own WiFi network via ESP. You enter the login data in the PC. The whole thing then works independently of the local network.
  • #7 19154503
    mgrems
    Level 11  
    TvWidget wrote:
    One solution is to create your own WiFi network via ESP. You enter the login data in the PC. The whole thing then works independently of the local network.
    .

    Can I ask for any more hints?
  • ADVERTISEMENT
  • #8 19155167
    TvWidget
    Level 38  
    mgrems wrote:
    I configure this at home, but then I move to several locations i.e. different networks.
    .
    It is not clear from what you have written whether you are only moving the sensor or also the computer.
    The ESP can either connect to an existing WiFi network or create its own. That is, it can work as an access point. With this solution, you can move the complete sensor and computer to any location without having to change the configuration.
  • #9 19155423
    khoam
    Level 42  
    The ESP8266, operating in AP mode will support a maximum of 8 clients - when using the Arduino Core.
    Link .
  • #10 19155799
    mgrems
    Level 11  
    khoam wrote:
    ESP8266, operating in AP mode will support up to 8 clients - when using Arduino Core.
    Link
    .

    This is what I have already done. The ESP connected to the PC via USB is in AccessPoint mode and can connect to up to 8 sensors (that's enough for me). I set the internal network address (or leave the default 192.168.4.1), select the communication channel (1 of 13) listen on UDP. The sensors connect to the network generated by the AP and transmit on UDP on this channel. To make the sensors recognisable in the data packet, I allocate a part for sensor info.
    The AP receives the data and sends it via USB to an application on the PC. This records the readings from all the sensors currently available and I select one of them for analysis etc.

    TvWidget: .
    I have the app on different computers (at home and at work), on different networks, and only carry the sensors. The configuration described above, with the AP and its wifi network, suits me best.

    Despite Sunday, I will be rolling this out today. Thanks for the tips so far. I have one more doubt, but not all at once. As I solve the assumptions so far, let me ask you again.
  • #11 19155908
    TvWidget
    Level 38  
    I was referring to the mode when the sensor is the AP and the computer is the client.
  • ADVERTISEMENT
  • #12 19166384
    mgrems
    Level 11  
    Hello after the break.
    I've wrapped up UDP both ways, just as I wanted. Now I have a problem. The AP sends commands 1 to 9 to the sensor, and the sensor is supposed to respond by assigning a value to the dt variable. Why this is not working is beyond me!

    ESP8266 - Changing the SSID and password of a Wi-Fi network without software intervention .

    Communication works, commands arrive, it works up to line 33 of the code. What is displayed on COM4 is the result of running 33 and 47 lines of code. The value 1000 is displayed because dt was declared at the beginning as: short int dt = 1000; Although commands are recognised no value is assigned to dt :-( .

    help
  • #13 19166403
    khoam
    Level 42  
    Each case should be followed by specific counts, not characters (char) - atoi() returns an int value.
  • #14 19166418
    mgrems
    Level 11  
    The obvious. The worst thing is to check your mistakes. Thanks to

Topic summary

The discussion revolves around configuring an ESP8266-based measurement device to change its SSID and password without software intervention, as the user frequently relocates the device to different networks. Suggestions include using the ESP-NOW protocol for faster data transmission without needing to connect to a router, and configuring the ESP8266 to operate in Access Point (AP) mode, allowing it to create its own Wi-Fi network. This setup enables the user to connect a PC application directly to the ESP8266, facilitating data collection from multiple sensors without reconfiguring the network settings. The user has successfully implemented UDP communication and is now troubleshooting command-response issues between the AP and the sensor.
Summary generated by the language model.
ADVERTISEMENT