Skip to content
Discussion options

You must be logged in to vote

@MrTinkerman

This will log the temperature every 5 minutes

import uasyncio as asyncio
# LOG TEMPERATURE ==========================================


async def log_temperature(loop=True):
    while True:
        print("logging temperature")

        with open("/sd/test01.txt", "a") as file:  # 'a' for append to file
            ds_sensor.convert_temp()  # Read temperature
            await asyncio.sleep_ms(750)
            temp = ds_sensor.read_temp(ds_rom)  # Temperature
            ct = rtc.now()  # Current time [YYYY, M, D, h, m, s, us, ?]
            log_entry = f"{ct[0]}.{ct[1]:02d}.{ct[2]:02d} {ct[3]:02d}:{ct[4]:02d}:{ct[5]:02d}  {temp}"
            file.write(f"{log_entry}\r\n")
   …

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@MrTinkerman
Comment options

@MrTinkerman
Comment options

@bixb922
Comment options

@MrTinkerman
Comment options

@bixb922
Comment options

Answer selected by MrTinkerman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants