I'm trying to build a simple internet clock with an esp32s2 and a 7-segment display. I am pulling the current time from an API (openweathermap), and using adafruit_datetime to make a string from the unix timestamp in the parsed json, which I then format down to a hh:mm format. It seems to work ONLY when I am running it from a shell on my computer, and not when it runs as code.py, bare. In the latter, the display seems to show a default time of 12:00, and not whatever time is pulled from the request. Any ideas?
print("starting loop")
print("Fetching json from", TIME_DATA_SOURCE)
json_data = requests.get(TIME_DATA_SOURCE)
formatted_data = json_data.json()
current_time_unix = (formatted_data.get("dt"))
current_time = datetime.fromtimestamp(current_time_unix)
timestring = str(current_time)
parsed_time = parse_time(timestring)
simple_time = hh_mm(parsed_time)
print(simple_time)
display.fill(0)
display.print(simple_time)
time.sleep(10)’’’