logo elektroda
logo elektroda
X
logo elektroda

Transparent UART Bridge Between Atmega32 Microcontrollers Using ESP-07 Modules

mmaker 1455 8
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17283659
    mmaker
    Level 19  
    Hi. I would like to upgrade my old stereo project in which the control is based on Atmega32 microcontrollers, more precisely I need wireless communication between the Amplifier and the Subwoofer i.e. between one atmega and the other. Both devices are already prepared to exchange data via UART. This involves commands on-off, louder, quieter, filter, phase and others - generally transmission in both directions. I also have 2 ESP-07 modules, to which the whole question refers and for which I have made TTL adapters. Is it possible to set up a transparent transmission via UART (Atmega->ESP->Router->ESP->Atmega, or bypassing the router) so that I don't have to use AT commands, because frankly speaking it complicates the whole situation a bit. I am a layman when it comes to ESP while I program atmegas in C.
  • ADVERTISEMENT
  • #2 17284257
    Anonymous
    Anonymous  
  • ADVERTISEMENT
  • #3 17284934
    mmaker
    Level 19  
    I understand that all of this can be done using the Arduino environment?
  • #4 17285044
    PowracajacyBumerang
    Level 9  
    mmaker wrote:
    may I understand that all this can be done using the arduino environment?
    .
    You can write programs on the ESP in the Arduino IDE.
  • ADVERTISEMENT
  • #5 17290273
    mmaker
    Level 19  
    Hello I consider the topic closed. I managed to do it with the help of the tutorial and the appropriate code from the internet. Topic to be closed ;) .
  • #6 17290880
    krzbor
    Level 27  
    Interesting thread, many people will end up here in the future. Why don't you write more about this topic and include links to these guides and codes. Save others from searching.
  • #7 17291384
    mmaker
    Level 19  
    In a nutshell for my ESP-07 module (but also for all ESPs) it looks like this:
    1. we download the Arduino IDE to our computer from the link selecting the correct architecture for our computer.

    2. We install the software. After installation, we run the Arduino program, click on File -> Preferences and in the field "Additional URLs to the board manager:" paste only the address of this link , confirm OK.

    3. in the main window, select Tools -> Tile: "Arduino/Genuino Uno" menu. -> Board Manager... In the manager window, scroll through the list and look for the item "esp8266 by ESP8266 Community" as shown in the image:
    Transparent UART Bridge Between Atmega32 Microcontrollers Using ESP-07 Modules .
    After selecting the item, click Install.

    4. after installation, go to the "Tools" menu, scroll down the list and select the "Generic ESP8266 Module" board. Click again on the "Tools" menu, which shows us a lot of settings for our module. I just selected the appropriate COM port.

    Now we just need to paste the ready code into the main window of the programme and upload it to our module by short-circuiting GPIO0 to ground while applying voltage to the module. This way we enter the flashing mode. You also need to remember to connect TX and RX lines correctly, so crosswise ;) .
    I, to make my life easier, made a TTL level adapter with voltage converter and buttons to reset and flash the module. I used 2 USB to Serial adapters (one self-made on FT232RL and the other on PL2303) and both work ok.

    The software you need, depending on the configuration you want, can be found at https://circuits4you.com/2018/01/01/esp-to-esp-communication/.

    All you need to do is to copy the code, change the SSID to the one assigned by your router, password, port for UDP communication, IP/Broadcast address and set the baudrate for UART transmission. The disadvantage of this type of solution is that it can sometimes cut one or two characters from the beginning of a string, but it happened very rarely with me. Alternatively, you have to deal with it somehow on the target device.

    Link to the Arduino IDE ESP8266 tutorial on Youtube:
    https://www.youtube.com/watch?v=Ao5XcORsYxA
  • #8 17291970
    krzbor
    Level 27  
    Interesting code for transmission. However, I don't know if it will work properly. At 9600 we have less than a character per 1ms, and the author has introduced a delay(20) into the code. This delay makes it possible to transmit a mere 50 characters per second. In my opinion, this delay is completely unnecessary. The speed will be "stabilised" by the UART anyway. The second problem is the extreme wastefulness of transmission - each UDP packet that contains many bytes necessary for transmission carries only one byte of information. In UDP, by default, there is no check as to whether a packet has arrived, and the code does not address this problem programmatically. If we know what we are exchanging, e.g. short sequences (several hundred bytes), it is much better to collect such a sequence and send it in one packet. We are then certain that the packet will arrive in full or not at all. You may even be tempted to acknowledge receipt of the packet and retransmit it.
  • ADVERTISEMENT
  • #9 17295590
    jony15
    Level 25  
    Or perhaps such hc-12 moduls.

Topic summary

The discussion addresses implementing wireless UART communication between two Atmega32 microcontrollers controlling an amplifier and subwoofer using ESP-07 modules. The goal is to achieve transparent UART bridging without relying on AT commands, simplifying integration for users familiar with Atmega programming but not ESP modules. It is confirmed that custom firmware can be developed on ESP-07 modules using the Arduino IDE, enabling direct UART data forwarding. A step-by-step guide for setting up the Arduino environment for ESP8266 modules, including ESP-07, is provided, covering board manager installation and configuration. Concerns about transmission efficiency and latency are raised, noting that introducing delays (e.g., delay(20)) in code reduces throughput significantly and that UDP packets carrying single bytes are inefficient and unreliable without acknowledgment or retransmission mechanisms. Suggestions include batching data into larger UDP packets and implementing acknowledgment to ensure data integrity. Alternative wireless modules like HC-12 are briefly mentioned as options.
Summary generated by the language model.
ADVERTISEMENT