I'm confused. I've developed a system (using Micropython) to write an output stream to a pin using the RMT function. It works perfectly when the ESP32 is plugged into my computer, but doesn't when it's plugged into a battery. I've confirmed the battery is fully charged and is delivering five volts to the usb plug (it has two 18650 cells). I have also confirmed that the code is executing with the battery by putting some led flashing code around the RMT write_pulses() command, and the led does flash so the command is definitely being executed. I'm using a logic analyser (cheap Chinses knockoff, but it works) connected to the output pin, and Saleae Logic Analyser 2 to display the output on my pc.
This is the code I'm running (without the led flashing stuff):
Code: Select all
"""
Works perfectly.
"""
from esp32 import RMT
from machine import Pin
rmt = RMT(0, pin=Pin(23), resolution_hz=1_000_000, num_symbols=512, idle_level=False)
duration = (1000, 300, 2000, 300) * 4
duration = duration + (7800, 300)
print('enter loop')
while True:
try:
rmt.write_pulses(duration, True)
except Exception as e:
print('Fell over', e)
rmt.deinit()
break
except KeyboardInterrupt:
print('keyboard interrupt')
rmt.deinit()
print('rmt deinitialised')
break
rmt.deinit()
print('program ended')
All advice gratefully received.