Check out this video:

and the tutorial: https://lemariva.com/blog/2020/06/micropython-m5camera-timelapse-over-mqtt