Traceback (most recent call last):
File "main.py", line 35, in <module>
File "adafruit_ht16k33/segments.py", line 195, in number
File "adafruit_ht16k33/segments.py", line 182, in text
MemoryError: memory allocation failed, allocating 160 bytes
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
The display fails and the program stops running. The program may run 30 minutes, but it also may do this after 10 minutes.
This is my program - any help on what I can do to keep the display going as the program without using the display does for weeks?
Code: Select all
import time
import board
import busio as io
from adafruit_onewire.bus import OneWireBus
from adafruit_ds18x20 import DS18X20
import adafruit_ht16k33.segments
i2c = io.I2C(board.SCL, board.SDA)
display = adafruit_ht16k33.segments.Seg7x4(i2c)
# Initialize one-wire bus on board pin D10.
ow_bus = OneWireBus(board.D10)
# Scan for sensors and grab the first one found.
ds18 = DS18X20(ow_bus, ow_bus.scan()[0])
j = 0
print('Count', 'Raw', 'C', 'F', sep='\t', end='\n')
# Main loop to print the temperature every 5 minutes.
while True:
j = j + 1
temp_c = ds18.temperature
temp_f = (temp_c * 9/5) + 32
dt = round(ds18.temperature, 2)
ct = round(temp_c, 2)
ft = round(temp_f, 2)
print(j, dt, ct, ft, sep='\t', end='\n')
display.number(ct)
display.show()
time.sleep(5)
display.fill(0)
display.show()
display.number(ft)
display.show()
time.sleep(293)
display.fill(0)
display.show()