SSD1306 Display Functions no longer work

Hi!
Thanks for sharing your great project and for your time.
After the update the display stops to working
Here’s the log files for SPI and I2C configurations:

Display SPI

Traceback (most recent call last):
File “/home/pi/Mycodo/mycodo/functions/display_ssd1306_oled_128x64_spi.py”, line 378, in initialize_variables
self.device = LCD_Pioled_Circuitpython(lcd_settings_dict=lcd_settings_dict)
File “/var/mycodo-root/mycodo/devices/lcd_pioled_circuitpython.py”, line 39, in init
self.i2c_address = int(lcd_settings_dict[“i2c_address”], 16)
KeyError: ‘i2c_address’

Display I2C

Traceback (most recent call last):
File “/home/pi/Mycodo/mycodo/functions/display_ssd1306_oled_128x64_i2c.py”, line 358, in initialize_variables
self.device = LCD_Pioled_Circuitpython(lcd_settings_dict=lcd_settings_dict)
File “/var/mycodo-root/mycodo/devices/lcd_pioled_circuitpython.py”, line 42, in init
self.spi_bus = lcd_settings_dict[“spi_bus”]
KeyError: ‘spi_bus’

After the update from what version to what version?

When I updated to 8.10.0

I just committed a fix. Upgrade to master and see if the issue persists.

Now i have this:

Traceback (most recent call last):
File “/var/mycodo-root/mycodo/controllers/base_controller.py”, line 86, in run
self.loop()
File “/var/mycodo-root/mycodo/controllers/controller_function.py”, line 70, in loop
self.run_function.loop()
AttributeError: ‘NoneType’ object has no attribute ‘loop’

That type of error only occurs after the controller has already crashed and produced the relevant error. You need to include all log lines up to and including the line stating the Function has been Activated.

Sorry

Traceback (most recent call last):
File “/home/pi/Mycodo/mycodo/functions/display_ssd1306_oled_128x64_i2c.py”, line 358, in initialize_variables
self.device = LCD_Pioled_Circuitpython(lcd_settings_dict=lcd_settings_dict)
File “/var/mycodo-root/mycodo/devices/lcd_pioled_circuitpython.py”, line 50, in init
self.spi_bus = lcd_settings_dict[“spi_bus”]
KeyError: ‘spi_bus’

Those line numbers indicate you’re running old code and did not upgrade to master.

But the line is different.
I don’t know, maybe something goes wrong in “before_install”
This line:

Can you provide the log lines up to and including the Activation line?

Can you try a fresh install of Raspberry Pi OS and Mycodo, then upgrade to master, to see if the issue persists?

I reinstalled Raspberry pi OS and Mycodo, and i updated to master.
But still not works.

This is the log:

Traceback (most recent call last):
File “/var/mycodo-root/env/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py”, line 154, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File “/var/mycodo-root/env/lib/python3.7/site-packages/busio.py”, line 130, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File “/var/mycodo-root/env/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py”, line 49, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File “/var/mycodo-root/env/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py”, line 308, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/var/mycodo-root/env/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py”, line 160, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File “/var/mycodo-root/env/lib/python3.7/site-packages/busio.py”, line 120, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=stop)
File “/var/mycodo-root/env/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py”, line 56, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end - start)
File “/var/mycodo-root/env/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py”, line 179, in read_bytes
return self._device.read(number)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/pi/Mycodo/mycodo/functions/display_ssd1306_oled_128x64_i2c.py”, line 353, in initialize_variables
self.device = LCD_Pioled_Circuitpython(lcd_settings_dict=lcd_settings_dict)
File “/var/mycodo-root/mycodo/devices/lcd_pioled_circuitpython.py”, line 62, in init
addr=int(str(self.i2c_address), 16))
File “/var/mycodo-root/env/lib/python3.7/site-packages/adafruit_ssd1306.py”, line 220, in init
self.i2c_device = i2c_device.I2CDevice(i2c, addr)
File “/var/mycodo-root/env/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py”, line 50, in init
self.__probe_for_device()
File “/var/mycodo-root/env/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py”, line 163, in __probe_for_device
raise ValueError(“No I2C device at address: 0x%x” % self.device_address)
ValueError: No I2C device at address: 0x60

So it looks like it can’t access your device at that address.

I don’t kow where address 0x60 comes from.
i set my device to 0x3C.

Just committed a fix. Upgrade to master and see if it works.

Wonderful! it started working again in I2C Mode.
But still nothing in SPI.

when i started with Mycodo, from version 8.9.2, SPI never works, so i decided to use the display in I2C mode.

this is the log:

SPI Bus = 0

Traceback (most recent call last):
File “/home/pi/Mycodo/mycodo/functions/display_ssd1306_oled_128x64_spi.py”, line 373, in initialize_variables
self.device = LCD_Pioled_Circuitpython(lcd_settings_dict=lcd_settings_dict)
File “/var/mycodo-root/mycodo/devices/lcd_pioled_circuitpython.py”, line 80, in init
cs=self.pin_cs)
File “/var/mycodo-root/env/lib/python3.7/site-packages/adafruit_ssd1306.py”, line 302, in init
dc.switch_to_output(value=0)
AttributeError: ‘int’ object has no attribute ‘switch_to_output’

SPI Bus = 1

Traceback (most recent call last):
File “/home/pi/Mycodo/mycodo/functions/display_ssd1306_oled_128x64_spi.py”, line 373, in initialize_variables
self.device = LCD_Pioled_Circuitpython(lcd_settings_dict=lcd_settings_dict)
File “/var/mycodo-root/mycodo/devices/lcd_pioled_circuitpython.py”, line 77, in init
spi=SPI.SpiDev(self.spi_bus, self.spi_device),
File “/var/mycodo-root/env/lib/python3.7/site-packages/Adafruit_GPIO/SPI.py”, line 42, in init
self._device.open(port, device)
FileNotFoundError: [Errno 2] No such file or directory