meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.3k stars 799 forks source link

Help needed, heartbeat led not blinking #4341

Closed ponzano closed 1 month ago

ponzano commented 1 month ago

Hello! I’m developing a new board for Meshtastic based on Nrf52840 and ebyte e22900m22s (sx1262). I got the first prototypes built and successfully compiled and flashed the adafruit bootloader. I’m now trying to add support in the Meshtastic firmware adding the variant files (platformio.ini, variant.h, variant.cpp) and it’s being executed correctly. I’m able to connect to the board using both Bluetooth and usb and send messages to the mesh. There’s a small issue I can’t figure out, the status led that is supposed to flash once every second, like on other boards, is kept turned on and doesn’t blink. I'm almost certain it's not a hardware issue as it behaves and blinks (and fades) correctly when in DFU mode or during flashing. I tried changing the #define LED_STATE_ON but both 0 and 1 give the same result. If I disable heartbeat led from the app it also doesn’t change the behavior. I defined only 1 led in variant.h, and if in variant.cpp I write pinmode(..) and digitalwrite(pin, LOW) or ledoff(pinled_1) it seems to turn off the led briefly at startup. Is there some other file I should edit ? https://github.com/user-attachments/assets/f89455f3-ad60-4563-8ae4-8eb2cca6dc23

ponzano commented 1 month ago

After an afternoon of fiddling, I could get the led blinking BUT only if I tweak the adc_multiplier so that the battery voltage is always read above 4.2v. If it goes at or below 4.2, the debug reports ‘loss of power in powered’ and the led stops blinking (and is kept on) even if usb is not plugged in. Does anyone know why this happens?

rjDipcord commented 1 month ago

With the LED staying off when the board thinks the battery voltage is low and only flashing when it thinks it is high, it sounds to me like there is some sort of power-saving feature at play here. I would also suffice to say the LED output is inverted, and the logic intends to keep the LED in the off state when the battery is low.

ponzano commented 1 month ago

For future reference, I got it working correctly but adding in variant.h:

ifndef _VARIANTRAK4630

define _VARIANTRAK4630

define RAK4630

I'm now looking at what this does in the firmware to adapt it to my variant.