logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

LILYGO TTGO T-A7670E - running modem from battery, hardware or ESP32 code?

baru0 846 20
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21830961
    baru0
    Level 12  
    Hello, I have a question for professionals regarding the LILYGO® TTGO T-A7670E board. I don't paste links, because you can google it on Ali for £170, and in Poland the highest price is probably £700 ;) .
    My question is: is the modem boot from the battery pack programmed in hardware, or uploaded code from the ESP32?
    Why my question? I bought two boards and one won't fire the modem on battery and the other fires up. The former was plugged in and programmed by Thonny, and in order to upload the code you have to clear the memory; this is the default setting, so I don't know if I deleted some default code when uploading, or if the board is just faulty.
    Please don't laugh at my ignorance (I'll return the favour with my expertise on bees or cookers ;) ), and here I am enjoying tinkering with something, trying to create a gateway that sends temp and weight data.
    I've connected the latter for now, but without uploading, then I have no file preview and no comparison in the shell, only the parameters are displayed.
  • ADVERTISEMENT
  • #2 21831026
    gbksiazczak
    Level 31  
    baru0 wrote:
    The former was plugged in and programmed by Thonny, and to upload the code you have to clear the memory, this is the default setting

    - This second one was also "plugged in and programmed"?
    So the first one doesn't work at all and the second one partially?
  • ADVERTISEMENT
  • #3 21831030
    TvWidget
    Level 38  
    The board is just the hardware. The key role is played by the software. It must match the hardware. It is not clear what exactly you have loaded. The phrase "won't fire the modem on battery" doesn't actually say anything. The use of Thonny may indicate Micropython. That is, the board contains the underlying software (Micropython), which can be called an operating system. The Thonny software cannot erase or modify this system. The main task of this system is to interpret the code contained in the files you have uploaded. Connect the board to your computer and run any terminal program with the parameters 115200 bps 8N1. Indicate what messages appear on the screen.
  • #4 21831093
    baru0
    Level 12  
    --- BRAMKA LTE URUCHOMIONA (CH: 11) ---                                         
    Traceback (most recent call last):                                              
      File "main.py", line 513, in <module>                                         
      File "main.py", line 509, in start                                            
    KeyboardInterupt:                                                               
    MicroPython v1.27.0 on 2025-12-09; Generic ESP32 module with ESP32              
    Type "help()" for more information.                                             
    >>>                                                                             
    >>>                                                                             
    >>> E (92779) task_wdt: Task watchdog got triggered. The following tasks/users :
    E (92779) task_wdt:  - mpy_machine_wdt (CPU 0/1)                                
    E (92779) task_wdt: Tasks currently running:                                    
    E (92779) task_wdt: CPU 0: IDLE0                                                
    E (92779) task_wdt: CPU 1: IDLE1                                                
    E (92779) task_wdt: Print CPU 0 (current core) backtrace                        
                                                                                    
                                                                                    
    Backtrace: 0x40163A7E:0x3FFBFF10 0x40086505:0x3FFBFF40 0x40091CD7:0x3FFBBE20 0x0
                                                                                    
    E (92779) task_wdt: Aborting.                                                   
    E (92779) task_wdt: Print CPU 1 backtrace                                       
                                                                                    
    A fatal error occurred. The crash dump printed below may be used to help        
    determine what caused it. If you are not already running the most recent        
    version of MicroPython, consider upgrading. New versions often fix bugs.        
                                                                                    
    To learn more about how to debug and/or report this crash visit the wiki        
    page at: https://github.com/micropython/micropython/wiki/ESP32-debugging        
                                                                                    
    MPY version : v1.27.0 on 2025-12-09                                             
    IDF version : v5.5.1                                                            
    Machine     : Generic ESP32 module with ESP32                                   
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
    Backtrace: 0x40091cd7:0x3ffbc420 0x40208516:0x3ffbc440 0x4020856c:0x3ffbc460 0x0
                                                                                    
                                   

    Is this what it was all about?
    This board that doesn't boot from the battery is where these codes come from, and this is where the uploader is uploaded.
    It only works on USB.
    I didn't upload anything to the other one because I wanted to make sure I "didn't break anything", which is why this query.
    How can I see that it works? Because the signs of the module working are the two LEDs: internet and LTE.
    The former, which won't boot from the battery (on USB it works), also excites these two LEDs when sending data.
  • ADVERTISEMENT
  • #5 21831120
    TvWidget
    Level 38  
    Explain in more detail what is meant by the phrase "Only works on USB".
  • #6 21831122
    gbksiazczak
    Level 31  
    The error message
    E (92779) task_wdt: Aborting indicates that the Task Watchdog Timer (TWDT) on an ESP32 (or similar ESP-IDF/Arduino based device) has been triggered, causing the system to panic and reboot. This happens when a task (usually the idle task or a long-running user task) fails to "feed" the watchdog within the set timeframe (default is often 5 seconds).
    Common Causes

    Blocking Functions: Using delay() or long while loops without allowing the operating system (FreeRTOS) to switch tasks.
    High CPU Load: A task is running at a high priority and never yielding, preventing lower-priority background tasks (like Wi-Fi handling or idle tasks) from running.
    Long Computations: Performing intensive calculations, SD card operations, or SPIFFS file operations that take longer than 5 seconds.
    Networking Issues: The code is stuck waiting for a Wi-Fi or MQTT connection that fails to materialize.

    How to Fix

    Add Yields/Delays: Introduce vTaskDelay(1 / portTICK_PERIOD_MS) or delay(1) inside your long-running loops to allow the watchdog to be fed.
    Use vTaskDelay instead of delay(): For task-specific delays, vTaskDelay is preferred in FreeRTOS environments.
    Optimize Code: Break long-running tasks into smaller chunks to ensure the CPU remains responsive.
    Increase Timeout: If necessary, increase the watchdog timeout period in menuconfig (CONFIG_ESP_TASK_WDT_TIMEOUT_S).
    Use Non-blocking Code: Utilize interrupts or asynchronous libraries (like AsyncTCP) for tasks involving networking or sensors.

    Identifying the Problematic Task
    The log output usually follows with "Tasks currently running," which highlights which CPU core (0 or 1) and task (e.g., loopTask, IDLE0) failed to yield. If IDLE0 is listed, it means your code is starving the system on Core

    You need to check how this relates to the board and program used
  • ADVERTISEMENT
  • #7 21831173
    TvWidget
    Level 38  
    baru0 wrote:

    Is this what it was all about?

    Yes.
    Show the code snippet from the "main.py" script from line 500 to 513.
    That's where the error occurred.
  • #8 21831234
    baru0
    Level 12  
    Gentlemen, this should not be the result of an error in the main.py . because "on USB it works" , i.e. the board works connected to the computer or power supply. It executes the code. The error in the terminal could be due to the operation of the board, it is written to run on power. This is how the board is set up, it listens continuously in ESP NOW and wakes up the Modem every few cycles.
    My question is whether it is possible to check (or repair) that the same action takes place on the battery.
    If ( the virgin - not yet uploaded ) starts itself on the battery and starts the modem , for example; has pre-loaded code (like the file main.py) to start and which after connecting to the Thonny cleared , or is it clearly a hardware error .
    I can't quite figure it out .
    Lilygo which does not want to wake up the modem , after typing the code " blink the diode" , "on battery performs this action i.e. ESP turns on but the modem can no longer wake up .
    Chat told me fairy tales about low voltage , I checked , this "virgin" starts the modem even at 2.65V , so it's a fairy tale .
    Maybe I am explaining it convolutedly , sorry .

                   wlan.active(True)
                    time.sleep(0.2)
                    wlan.config(channel=int(chan))
                    e.active(True)
                    print(" -> Nasłuch aktywny.")
                except Exception as ex:
                    print(f" -> Błąd restartu WiFi: {ex}. Reset urządzenia.")
                    machine.reset() 
    
            time.sleep(0.1)
            gc.collect()
    
    if __name__ == "__main__":
        start()
  • #9 21831254
    TvWidget
    Level 38  
    The ESP32 chip requires a 3.3V supply and the modem a little more usually 3.6..4V. Measure these voltages when running on battery power. With the modem and WiFi on, there is a relatively high current draw. Perhaps the battery is not charged or is faulty. If there is 2.65V on the Li-Ion battery then it is probably completely discharged. There is probably a protection circuit on the board that disconnects the battery at low voltage. For example, on one board it may work at 2.65V and on another at 2.75V
  • #10 21831280
    baru0
    Level 12  
    The battery pack is 4.05 volts to start with, that's not it.
    I wrote that the virgin one turned on (starts the modem) at 2,65 V, a bigger drop I didn't want to risk.
    baru0 wrote:
    Chat told me fairy tales about low voltage, I checked, this "virgin" starts the modem even at 2.65V which is a fairy tale .

    And the other one, at 4.7V will not start the modem.
  • #11 21831283
    TvWidget
    Level 38  
    I don't quite know how to interpret the information you give. You write that "on USB it works". You give messages reading when the board was connected via USB. These indicate that the board does not work after all.
    Please explain what exactly you mean by "on USB it works".
  • #12 21831304
    baru0
    Level 12  
    >>21831283
    Because it works, i.e. executes the program code, connected to USB or power supply, but it doesn't run the modem from the battery - here is the problem.
    Only the ESP32 starts up on battery (executes command - blink diode), diode connected to ESP pin.
    And the error in the terminal could be because the board has a program preloaded that starts it up when it's connected to power (USB here, to read what it's doing) and at the same time probably cuts off access in the terminal. (The residual message it managed to get between reboots, I think, is 'data sent, I'm turning on listen'.)

    This board is a two-module board, are you familiar with it? Probably so, although I couldn't find any mention of this model on Elektroda.
    Anyone has, had dealings with it? I would be happy to get in touch .
    Attachments:
    • LILYGO TTGO T-A7670E - running modem from battery, hardware or ESP32 code? 3.jpg (2.55 MB) You must be logged in to download this attachment.
    • LILYGO TTGO T-A7670E - running modem from battery, hardware or ESP32 code? 1.jpg (337.82 KB) You must be logged in to download this attachment.
  • #13 21831314
    TvWidget
    Level 38  
    I cannot understand what you are writing.
  • #14 21831338
    gbksiazczak
    Level 31  
    ESP is supposed to communicate with the modem, simple tests with AT commands....

    Programming
    The LILYGO® TTGO T-A7670E is mainly done through the Arduino IDE using the ESP32 core. This requires configuring the TinyGSM library to communicate with the 4G/LTE modem (A7670E) via AT commands, setting the appropriate APN for the SIM card and using the UART pins (default TX:12, RX:11).
    Key programming steps:

    Environment: Installation of Arduino IDE and ESP32 board support (2.0.x or later versions recommended).
    Libraries: Installing TinyGSM (v0.11.5+) and PubSubClient (for MQTT) in Library Manager.
    Code: Using sample codes for TinyGSM with SIMCom A7670 modem support, taking into account the modem power pins (usually PIN 4 or 5 for T-A7670E).
    SIM configuration: It is necessary to enter the correct APN of the mobile network operator and often to disable the PIN of the SIM card.
    Power supply: During data transmission (LTE), power supply from a LiPo battery or an external 5V source is recommended, not just from USB.
  • #15 21831370
    baru0
    Level 12  
    >>21831338
    For me it's simpler in Thonny.
    It all works, it's as you write, thanks, but it says the problem is "not switching on" (not executing the program from the battery).
    TvWidget wrote:
    I can't understand what you write

    It's a shame, I was asking about "what a virgin plate might have in memory and how to see it".
    baru0 wrote:
    If ( the virgin one - not uploaded yet ) boots itself on the battery and starts the modem , for example; does it have the preloaded code

    I have uploaded these posts to ChatGPT. Here is the response ;)
    Quote:
    This is what you are looking for: flash dump (dump). Then you can:

    keep a copy,

    even upload back to a second disc.


    If anyone could help with a piece of code on how to run the modem from the battery, I would appreciate it.
  • #16 21831381
    TvWidget
    Level 38  
    You are giving vague information. If you only used Thonny to upload the software then:
    Connect the "working" board to your computer. Start Thonny. Press "CTRL+C" and wait for 2 seconds. This will stop the code currently being executed. Micropython will prompt with a >>. The Thonny program should display a list of scripts on the device. You can see their contents, modify them, copy them to the PC, etc.
    Describe what exactly you are doing to the board when "it doesn't run the modem from battery " and what when "on USB it works".
  • #17 21831407
    baru0
    Level 12  
    >>21831381
    Are you making posts? To a visitor (maybe a layman), who has uploaded the soft and works, you explain how to do it?
    If you want to help, know how: what you're explaining would just erase that first memory, otherwise you won't get to Thonny.

    baru0 wrote:
    GPT chat - wrote :This is what you are looking for: a flash dump (dump). Then you can:keep a copy,even upload back to the other disc.

    .
    "Stupid chat" understood me and answered half the question and you didn't.
    Sorry, if anyone wants to really help me, please do and I will be grateful.

    Edit: flash ripped beautifully from the new one and uploaded to the older one . The old one on the battery now fires without a problem, so it is working, half the problem solved.
    Now need to write code that will do it like the original , because from the binary it can not be extracted , at least by me ;)

    Moderated By ArturAVS:

    3.1.9. Disseminate content that is ironic, mocking or malicious, which is a sign of disrespect towards other Users or third parties.

  • #18 21831437
    TvWidget
    Level 38  
    Quote:
    If you want to help, know how: what you are interpreting would just erase that first memory, otherwise you wouldn't get to Thonny.

    You are wrong. Thonny will not delete anything by itself. Deleting a file requires an explicit invocation of the appropriate command by the user. You may want to perform some action besides running Thonny that you don't mention.

    You are hiding key information. You are only conveying the conclusions you have drawn based on them. You yourself mentioned "ignorance" at the beginning. These conclusions may therefore be wrong.
    If you used Thonny to upload the software it means that both boards have Micropython pre-installed. The only difference is in the scripts. Usually the scripts are *.PY files which are plain text files. They are easy to compare and see what they do. They can also be modified.
    You have made a copy of the entire memory, which if no security is in place only allows you to clone the device software. You wrote "what a virgin board might have in memory and how to see it ". You now have a bin file in which nothing can be "seen". In practice, the memory image cannot be edited or modified.
    When uploading software to the "non-functioning" board, did you use only Thonny or other tools ?
    Describe what exactly you do with the board when "it does not run the modem from battery " and what when "on USB it works".
  • #19 21831559
    LEDówki
    Level 43  
    A battery is not a battery. Perhaps this is where the problem lies?
  • #20 21831864
    baru0
    Level 12  
    In my opinion you're a bit spammy. I've already been ripped off by a moderator (but I'm entitled to be a bit stressed). If you don't read the questioner's posts carefully, then you don't give a correct and complete answer either, even though you have one.
    In your last post you insinuate.
    TvWidget wrote:
    You conceal key information. You are only passing on the conclusions you have drawn based on it. You yourself mentioned "ignorance" at the beginning. These conclusions may therefore be wrong.
    If you used Thonny to upload the software it means that both boards have Micropython pre-installed.


    Meanwhile, everything was already clear in the first post. These are my questions, the key words are in bold.
    baru0 wrote:
    I bought two boards and one won't fire the modem on battery and the other fires. The former was connected and programmed by Thonny


    baru0 wrote:
    The latter I've plugged in for now, but without uploading , then I have no file preview and no comparison in the shell, only the parameters are displayed.

    I asked about flash memory, how to rip; I got no answer, and the latter, to my knowledge, are confusing very; the chat prompted me with two commands in the terminal and I got it, to the point.
    Here I thank my colleague TvWidget for his help and please don't help me anymore.
    .
    As of today, the situation is that I have the bootstrap code extracted from the binaries and it works; work is progressing, but I may share the knowledge once the project is complete.

    LEDówki wrote:
    The battery is not the battery. Maybe this is where the problem is?


    I'm probably not expressing myself professionally, sorry, it's all about the 3.7 volt battery.
    Problem solved, it was the program's fault; let's develop the topic further, hard to find pointers to Micropython. But the joy is, all the more so for the layman; the subject of weight has been broached several times, but everyone gets stuck.
    If anyone 'stumbles with this board', I'd be happy to get in touch.
    Regards

    Moderated By ArturAVS:

    3.1.9. Dissemination of ironic, hilarious or malicious content that is disrespectful to other Users or third parties.

  • #21 21831984
    LEDówki
    Level 43  
    The question is important, because under the same name different people imagine different things. Once you wrote rechargeable battery, once battery, now rechargeable battery. Better to ask than to guess. The problem could have been with too little power. The USB 2.0 socket is only 0.5A current and that's after the computer recognises the device or thereabouts demands more than 100 mA. With power supplies (parish chargers) it is already different. Some blindly allow 2 A of current others are only 0.5 A and such a device must somehow know how much current it can draw. Usually there was some kind of wonkiness on the power supply side - voltages on the data lines or a short circuit between the data lines. A device that saw such a 'sign' could draw more than 0.5 A of current. In your case, the protection is software, because the designer didn't foresee the possibility of powering from something more powerful than USB 2.0 or maybe 3.0 (0.9 A). It's good that you coped and didn't wait passively for a ready-made one.

FAQ

TL;DR: Set your serial terminal to 115200 bps; “The board is just the hardware. The key role is played by the software.” [Elektroda, TvWidget, post #21831030]

Why it matters: This FAQ helps ESP32/MicroPython users diagnose why a TTGO T-A7670E modem starts on USB but not on battery, and decide if the fix is code, power, or hardware.

Quick Facts

Is modem boot on battery a hardware feature or controlled by ESP32 code?

It’s controlled by software that must match the board. The PCB provides power paths, but the ESP32 firmware decides when and how the modem powers up and initializes. Quote: “The board is just the hardware. The key role is played by the software.” Configure and debug the software first. [Elektroda, TvWidget, post #21831030]

What does “only works on USB” actually mean and how should I test it?

Clarify whether code runs, LEDs behave, and logs appear only when USB is plugged. Then replicate with battery while monitoring serial logs and LED states. If behavior differs, describe it precisely. The forum request was to define “on USB it works” before deeper debugging. [Elektroda, TvWidget, post #21831283]

Why does the modem fail on battery while the ESP32 can still blink an LED?

The ESP32 runs from 3.3 V, but the LTE modem needs around 3.6–4.0 V and significant surge current during network attach. Under battery power, voltage sag or protection cutoff can prevent the modem from starting even if the ESP32 blinks. Measure both rails under load. [Elektroda, TvWidget, post #21831254]

Does uploading code with Thonny erase the board’s base system?

Using Thonny to copy scripts does not erase the underlying MicroPython runtime. MicroPython acts like the OS; your files run on top of it. If behavior changed, review your main.py and boot sequence rather than assuming firmware was wiped. [Elektroda, TvWidget, post #21831030]

How do I capture a clean boot log to diagnose startup issues?

Use a serial terminal and record the full boot. Steps:
  1. Connect USB, open a terminal at 115200 bps, 8N1.
  2. Reset the board and capture all output from power-on.
  3. Share exact messages and timestamps for analysis. End the USB session before battery tests to avoid parasitic power. [Elektroda, TvWidget, post #21831030]

What is the ESP32 Task Watchdog (TWDT) error and how do I fix it?

TWDT triggers a panic if a task doesn’t yield within the window (often ~5 s). Fix by breaking long loops, adding vTaskDelay(1) or delay(1), avoiding blocking calls, or increasing the timeout if justified. Quote: “Task watchdog got triggered… causing the system to panic and reboot.” [Elektroda, gbksiazczak, post #21831122]

How should I verify the power rails on the TTGO T-A7670E?

Measure the ESP32 3.3 V rail and the modem’s higher rail during attach and data bursts. Check for dips and confirm the battery and protection circuitry aren’t cutting out. Different boards can have slightly different cutoff thresholds that change behavior. [Elektroda, TvWidget, post #21831254]

Which LEDs indicate LTE activity and that the modem is alive?

Users observed two indicators: an “internet” LED and an “LTE” LED. When the modem initializes and transmits, both LEDs illuminate or blink; absence on battery while present on USB suggests a battery or power-path issue rather than code alone. [Elektroda, baru0, post #21831093]

What firmware versions are shown in the posted crash log, and does that matter?

The log shows MicroPython v1.27.0 and ESP-IDF v5.5.1 on a Generic ESP32 module. Version context helps others reproduce, identify known issues, and suggest compatible libraries or modem drivers. Include these lines in any bug report. [Elektroda, baru0, post #21831093]

If a “virgin” board starts the modem at 2.65 V, does that prove low voltage isn’t the issue?

No. One sample starting at 2.65 V doesn’t guarantee consistent operation. Protection thresholds and load profiles differ between units. Another board might refuse to start the modem even with a higher open-circuit voltage like 4.7 V if the rail sags under load. [Elektroda, baru0, post #21831280]

How can I separate a software bug from a hardware fault on this board?

First, confirm serial settings and gather boot logs. Next, run a minimal script (LED blink only) on battery and USB. Then enable the modem step-by-step, logging each step. Differences point to power or hardware; identical failures point to software. [Elektroda, TvWidget, post #21831030]

What is ESP‑NOW in this project’s context?

ESP‑NOW here refers to the ESP32’s peer-to-peer listening mode that wakes the modem every few cycles as part of the user’s gateway logic. If modem wake fails only on battery, inspect the wake sequence and power gating around those cycles. [Elektroda, baru0, post #21831234]
ADVERTISEMENT