kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
2.98k stars 496 forks source link

Joy-IT Explorer 700 OLED SPI #793

Closed Mark0Mi closed 4 years ago

Mark0Mi commented 4 years ago

Hi I have a PI with the Explorer 700 HAT from Joy-IT The display is the OLED 128x64 SD1306 but unfortunately it seems not to use I2C -> instead it uses SPI (and it is fixed wired on the Explorer700)

Product: https://joy-it.net/en/products/RB-Explorer700 Code examples: https://joy-it.net/files/files/Produkte/RB-Explorer700/Explorer-700%20Beispielcodes.zip in the folder OLED there is the code SSD1306.py to address the display and three sample codes for displaying text.

Can you add support for addressing OLED displays over SPI instead of I2C? or guide me how to do this? thanks!

kizniche commented 4 years ago

How specifically is it accessed by the Pi (i.e. hardware SPI, software SPI, software device, pins)?

Mark0Mi commented 4 years ago

SSD1306.py.txt dispchar.py.txt I have attached the two files to get the display to work as far as I understood it it uses the spidev with hardware SPI (from dispchar.py)

Raspberry Pi pin configuration:

RST = 19

Note the following are only used with SPI:

DC = 16 bus = 0 device = 0 disp = SSD1306.SSD1306(RST, DC, SPI.SpiDev(bus,device))

the SSD1306 class is defined in the second file SSD1306.py

kizniche commented 4 years ago

I just pushed a commit (untested) that adds the ability to select the LCD interface and adds the SPI interface for SSD1306 LCDs. If you're feeling brave and want to upgrade to master, you can test the new code, otherwise you'll have to wait until the next release.

Mark0Mi commented 4 years ago

I did the test - unfortunately it does not work. deamon log:

2020-07-20 16:20:37,192 - ERROR - mycodo.controllers.controller_lcd_b51387b7 - initialize_variables() Exception: invalid literal for int() with base 16: 'None'
Traceback (most recent call last):
  File "/var/mycodo-root/mycodo/controllers/base_controller.py", line 72, in run
    self.initialize_variables()
  File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 298, in initialize_variables
    self.lcd_out = LCD_Pioled(lcd_dev)
  File "/var/mycodo-root/mycodo/devices/lcd_pioled.py", line 23, in __init__
    self.i2c_address = int(str(lcd_dev.location), 16)
ValueError: invalid literal for int() with base 16: 'None'
2020-07-20 16:20:37,196 - INFO - mycodo.controllers.controller_lcd_b51387b7 - Activated in 625.3 ms
2020-07-20 16:20:37,197 - INFO - mycodo.daemon - All activated LCD controllers started

after I click deactivate

Error: Could not deactivate LCD controller with ID b51387b7-ee89-4062-9433-675a9b65d5bf, it's not active.
after I click activate it seems it gets activated but in deamon log the following shows up:
2020-07-20 16:30:12,346 - ERROR - mycodo.controllers.controller_lcd_b51387b7 - initialize_variables() Exception: invalid literal for int() with base 16: 'None'
Traceback (most recent call last):
  File "/var/mycodo-root/mycodo/controllers/base_controller.py", line 72, in run
    self.initialize_variables()
  File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 298, in initialize_variables
    self.lcd_out = LCD_Pioled(lcd_dev)
  File "/var/mycodo-root/mycodo/devices/lcd_pioled.py", line 23, in __init__
    self.i2c_address = int(str(lcd_dev.location), 16)
ValueError: invalid literal for int() with base 16: 'None'
2020-07-20 16:30:12,347 - INFO - mycodo.controllers.controller_lcd_b51387b7 - Activated in 541.8 ms

is there any other log you might need? BR marko

kizniche commented 4 years ago

No, the daemon log is where all the exceptions should be going. I just pushed a fix. You can upgrade to master and test again.

Mark0Mi commented 4 years ago

display works fine ;-) thank you very much!

one minor thing - after booting it shows line1: mycodo 8.5.8 line2: start 128x64 OLED (SD: and then after 30seconds (first refresh I guess) the configured sensor values

if deactivate is pressed same message with stop in line 2: (it should go blank shouldn't it?) if activated again I have to wait 30 seconds for the refresh but that's ok..

many thank for your very quick fix! BR marko

kizniche commented 4 years ago

That is the expected behavior.

Mark0Mi commented 4 years ago

hi after running now on 8.7.1 finally - my display is not working anymore can you check it?

2020-08-21 01:42:00,799 - INFO - mycodo.daemon - Mycodo daemon v8.7.1 starting 2020-08-21 01:42:07,440 - INFO - mycodo.devices.atlas_scientific_uart_dev_ttyUSB0 - Atlas Scientific Board: None, Rev: 0, Firmware: None 2020-08-21 01:42:07,440 - INFO - mycodo.outputs.atlas_ezo_pmp_4f5e51b9 - Initialized in 6326.2 ms 2020-08-21 01:42:07,444 - INFO - mycodo.outputs.wired_1fa43ce2 - Output setup on pin 5 and turned OFF (OFF=LOW) 2020-08-21 01:42:07,445 - INFO - mycodo.outputs.wired_1fa43ce2 - Initialized in 3.5 ms 2020-08-21 01:42:07,446 - INFO - mycodo.outputs.wired_9d5a4f4e - Output setup on pin 6 and turned OFF (OFF=LOW) 2020-08-21 01:42:07,446 - INFO - mycodo.outputs.wired_9d5a4f4e - Initialized in 0.5 ms 2020-08-21 01:42:07,446 - INFO - mycodo.controllers.controller_output - Setting Output 1fa43ce2 startup state to OFF 2020-08-21 01:42:07,447 - INFO - mycodo.controllers.controller_output - Setting Output 9d5a4f4e startup state to OFF 2020-08-21 01:42:07,447 - INFO - mycodo.controllers.controller_output - Activated in 6435.3 ms 2020-08-21 01:42:08,236 - INFO - mycodo.controllers.controller_conditional_460e1353 - Activated in 74.1 ms 2020-08-21 01:42:08,237 - INFO - mycodo.daemon - All activated Conditional controllers started 2020-08-21 01:42:08,434 - INFO - mycodo.controllers.controller_trigger_317ab7f5 - Activated in 59.2 ms 2020-08-21 01:42:08,693 - INFO - mycodo.controllers.controller_trigger_e05919f9 - Activated in 62.2 ms 2020-08-21 01:42:08,958 - INFO - mycodo.controllers.controller_trigger_15e84940 - Activated in 58.6 ms 2020-08-21 01:42:09,272 - INFO - mycodo.controllers.controller_trigger_59b29264 - Activated in 76.8 ms 2020-08-21 01:42:09,276 - INFO - mycodo.daemon - All activated Trigger controllers started 2020-08-21 01:42:09,717 - INFO - mycodo.controllers.controller_input_dd1b392c - Activated in 174.5 ms 2020-08-21 01:42:12,456 - INFO - mycodo.devices.atlas_scientific_ftdi_DT04DC2N - Atlas Scientific Board: ORP, Rev: 2, Firmware: 2.11 2020-08-21 01:42:12,525 - ERROR - mycodo.inputs.atlas_orp_7e37e204 - Calibration measurement not found within the past 120 seconds 2020-08-21 01:42:13,831 - INFO - mycodo.controllers.controller_input_7e37e204 - Activated in 3909.5 ms 2020-08-21 01:42:13,880 - ERROR - mycodo.inputs.atlas_orp_7e37e204 - Calibration measurement not found within the past 120 seconds 2020-08-21 01:42:14,163 - INFO - mycodo.controllers.controller_input_13487ed8 - Activated in 141.8 ms 2020-08-21 01:42:15,924 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.125, 'timestamp_utc': None}} 2020-08-21 01:42:16,854 - INFO - mycodo.devices.atlas_scientific_ftdi_DT04DD8O - Atlas Scientific Board: pH, Rev: 2, Firmware: 2.14 2020-08-21 01:42:16,878 - ERROR - mycodo.inputs.atlas_ph_ea2abd1f - Calibration measurement not found within the past 120 seconds 2020-08-21 01:42:18,181 - INFO - mycodo.controllers.controller_input_ea2abd1f - Activated in 3880.1 ms 2020-08-21 01:42:18,256 - ERROR - mycodo.inputs.atlas_ph_ea2abd1f - Calibration measurement not found within the past 120 seconds 2020-08-21 01:42:18,442 - INFO - mycodo.controllers.controller_conditional_460e1353 - Check this measurement in the Daemon Log. The water temp value is None 2020-08-21 01:42:18,446 - INFO - mycodo.controllers.controller_conditional_460e1353 - Check this measurement in the Daemon Log. The outside temp value is 23.125 2020-08-21 01:42:18,573 - INFO - mycodo.controllers.controller_input_551be49e - Activated in 130.0 ms 2020-08-21 01:42:18,574 - INFO - mycodo.daemon - All activated Input controllers started 2020-08-21 01:42:18,574 - INFO - mycodo.daemon - All activated Math controllers started 2020-08-21 01:42:18,574 - INFO - mycodo.daemon - All activated PID controllers started 2020-08-21 01:42:19,438 - ERROR - mycodo.controllers.controller_lcd_b51387b7 - initialize_variables() Exception: No module named 'Adafruit_BBIO' Traceback (most recent call last): File "/var/mycodo-root/mycodo/controllers/base_controller.py", line 72, in run self.initialize_variables() File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 292, in initialize_variables self.lcd_out = LCD_Pioled(lcd_dev) File "/var/mycodo-root/mycodo/devices/lcd_pioled.py", line 50, in init spi=SPI.SpiDev(lcd_dev.spi_bus, lcd_dev.spi_device)) File "/home/pi/Mycodo/env/src/adafruit-ssd1306/Adafruit_SSD1306/SSD1306.py", line 243, in init gpio, spi, i2c_bus, i2c_address, i2c) File "/home/pi/Mycodo/env/src/adafruit-ssd1306/Adafruit_SSD1306/SSD1306.py", line 85, in init self._gpio = GPIO.get_platform_gpio() File "/var/mycodo-root/env/lib/python3.7/site-packages/Adafruit_GPIO/GPIO.py", line 420, in get_platform_gpio import Adafruit_BBIO.GPIO ModuleNotFoundError: No module named 'Adafruit_BBIO' 2020-08-21 01:42:19,441 - INFO - mycodo.controllers.controller_lcd_b51387b7 - Activated in 745.6 ms 2020-08-21 01:42:19,441 - INFO - mycodo.daemon - All activated LCD controllers started 2020-08-21 01:42:19,441 - INFO - mycodo.daemon - All activated Custom controllers started 2020-08-21 01:42:19,514 - INFO - mycodo.controllers.controller_widget - Activated in 73.0 ms 2020-08-21 01:42:20,516 - INFO - mycodo.daemon - Mycodo daemon started in 19.717 seconds 2020-08-21 01:42:20,704 - INFO - mycodo.daemon - 52.00 MB RAM in use 2020-08-21 01:42:30,957 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.125, 'timestamp_utc': None}} 2020-08-21 01:42:45,918 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.125, 'timestamp_utc': None}} 2020-08-21 01:43:00,878 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.125, 'timestamp_utc': None}} 2020-08-21 01:43:06,798 - ERROR - mycodo.daemon - Could not flash LCD (False): 'NoneType' object has no attribute 'lcd_backlight' Traceback (most recent call last): File "/var/mycodo-root/mycodo/mycodo_daemon.py", line 538, in lcd_flash return self.controller['LCD'][lcd_id].lcd_flash(state) File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 567, in lcd_flash self.lcd_backlight(True) File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 554, in lcd_backlight self.lcd_out.lcd_backlight(state) AttributeError: 'NoneType' object has no attribute 'lcd_backlight' 2020-08-21 01:43:12,831 - ERROR - mycodo.daemon - Could not flash LCD (False): 'NoneType' object has no attribute 'lcd_backlight' Traceback (most recent call last): File "/var/mycodo-root/mycodo/mycodo_daemon.py", line 538, in lcd_flash return self.controller['LCD'][lcd_id].lcd_flash(state) File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 567, in lcd_flash self.lcd_backlight(True) File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 554, in lcd_backlight self.lcd_out.lcd_backlight(state) AttributeError: 'NoneType' object has no attribute 'lcd_backlight' 2020-08-21 01:43:15,993 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.125, 'timestamp_utc': None}} 2020-08-21 01:43:19,079 - ERROR - mycodo.controllers.controller_lcd_b51387b7 - initialize_variables() Exception: No module named 'Adafruit_BBIO' Traceback (most recent call last): File "/var/mycodo-root/mycodo/controllers/base_controller.py", line 72, in run self.initialize_variables() File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 292, in initialize_variables self.lcd_out = LCD_Pioled(lcd_dev) File "/var/mycodo-root/mycodo/devices/lcd_pioled.py", line 50, in init spi=SPI.SpiDev(lcd_dev.spi_bus, lcd_dev.spi_device)) File "/home/pi/Mycodo/env/src/adafruit-ssd1306/Adafruit_SSD1306/SSD1306.py", line 243, in init gpio, spi, i2c_bus, i2c_address, i2c) File "/home/pi/Mycodo/env/src/adafruit-ssd1306/Adafruit_SSD1306/SSD1306.py", line 85, in init self._gpio = GPIO.get_platform_gpio() File "/var/mycodo-root/env/lib/python3.7/site-packages/Adafruit_GPIO/GPIO.py", line 420, in get_platform_gpio import Adafruit_BBIO.GPIO ModuleNotFoundError: No module named 'Adafruit_BBIO' 2020-08-21 01:43:19,079 - INFO - mycodo.controllers.controller_lcd_b51387b7 - Activated in 642.6 ms 2020-08-21 01:43:30,877 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.0625, 'timestamp_utc': None}} 2020-08-21 01:43:45,993 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.125, 'timestamp_utc': None}} 2020-08-21 01:43:47,525 - INFO - mycodo.daemon - Received command to terminate daemon 2020-08-21 01:43:47,796 - INFO - mycodo.daemon - All Custom controllers stopped 2020-08-21 01:43:47,797 - INFO - mycodo.daemon - All LCD controllers stopped 2020-08-21 01:43:47,797 - INFO - mycodo.daemon - All PID controllers stopped 2020-08-21 01:43:47,797 - INFO - mycodo.daemon - All Math controllers stopped 2020-08-21 01:43:47,802 - INFO - mycodo.controllers.controller_input_13487ed8 - Deactivated in 5.5 ms 2020-08-21 01:43:47,821 - INFO - mycodo.controllers.controller_input_ea2abd1f - Deactivated in 24.8 ms 2020-08-21 01:43:47,837 - INFO - mycodo.controllers.controller_conditional_460e1353 - Deactivated in 40.9 ms 2020-08-21 01:43:47,838 - INFO - mycodo.controllers.controller_trigger_e05919f9 - Deactivated in 41.6 ms 2020-08-21 01:43:47,838 - INFO - mycodo.controllers.controller_trigger_59b29264 - Deactivated in 41.8 ms 2020-08-21 01:43:47,839 - INFO - mycodo.controllers.controller_input_dd1b392c - Deactivated in 42.3 ms 2020-08-21 01:43:47,843 - INFO - mycodo.controllers.controller_trigger_317ab7f5 - Deactivated in 46.8 ms 2020-08-21 01:43:47,873 - INFO - mycodo.controllers.controller_trigger_15e84940 - Deactivated in 76.6 ms 2020-08-21 01:43:47,886 - INFO - mycodo.controllers.controller_input_7e37e204 - Deactivated in 89.2 ms 2020-08-21 01:43:47,888 - INFO - mycodo.controllers.controller_input_551be49e - Deactivated in 91.4 ms 2020-08-21 01:43:47,888 - INFO - mycodo.daemon - All Input controllers stopped 2020-08-21 01:43:47,889 - INFO - mycodo.daemon - All Trigger controllers stopped 2020-08-21 01:43:47,889 - INFO - mycodo.daemon - All Conditional controllers stopped 2020-08-21 01:43:47,904 - INFO - mycodo.outputs.atlas_ezo_pmp_4f5e51b9 - Stopped in 0.0 ms 2020-08-21 01:43:47,904 - INFO - mycodo.controllers.controller_output - Setting Output 1fa43ce2 shutdown state to OFF 2020-08-21 01:43:47,904 - INFO - mycodo.outputs.wired_1fa43ce2 - Stopped in 0.4 ms 2020-08-21 01:43:47,904 - INFO - mycodo.controllers.controller_output - Setting Output 9d5a4f4e shutdown state to OFF 2020-08-21 01:43:47,905 - INFO - mycodo.outputs.wired_9d5a4f4e - Stopped in 0.2 ms 2020-08-21 01:43:47,905 - INFO - mycodo.controllers.controller_output - Deactivated in 15.9 ms 2020-08-21 01:43:48,123 - INFO - mycodo.controllers.controller_widget - Deactivated in 218.3 ms 2020-08-21 01:43:48,124 - INFO - mycodo.daemon - Mycodo daemon terminated in 0.599 seconds

2020-08-21 01:44:03,849 - INFO - mycodo.daemon - Mycodo daemon v8.7.1 starting 2020-08-21 01:44:10,468 - INFO - mycodo.devices.atlas_scientific_uart_dev_ttyUSB0 - Atlas Scientific Board: None, Rev: 0, Firmware: None 2020-08-21 01:44:10,468 - INFO - mycodo.outputs.atlas_ezo_pmp_4f5e51b9 - Initialized in 6324.8 ms 2020-08-21 01:44:10,486 - INFO - mycodo.outputs.wired_1fa43ce2 - Output setup on pin 5 and turned OFF (OFF=LOW) 2020-08-21 01:44:10,487 - INFO - mycodo.outputs.wired_1fa43ce2 - Initialized in 17.0 ms 2020-08-21 01:44:10,490 - INFO - mycodo.outputs.wired_9d5a4f4e - Output setup on pin 6 and turned OFF (OFF=LOW) 2020-08-21 01:44:10,490 - INFO - mycodo.outputs.wired_9d5a4f4e - Initialized in 0.9 ms 2020-08-21 01:44:10,490 - INFO - mycodo.controllers.controller_output - Setting Output 1fa43ce2 startup state to OFF 2020-08-21 01:44:10,491 - INFO - mycodo.controllers.controller_output - Setting Output 9d5a4f4e startup state to OFF 2020-08-21 01:44:10,492 - INFO - mycodo.controllers.controller_output - Activated in 6439.3 ms 2020-08-21 01:44:11,311 - INFO - mycodo.controllers.controller_conditional_460e1353 - Activated in 54.4 ms 2020-08-21 01:44:11,312 - INFO - mycodo.daemon - All activated Conditional controllers started 2020-08-21 01:44:11,487 - INFO - mycodo.controllers.controller_trigger_317ab7f5 - Activated in 53.0 ms 2020-08-21 01:44:11,717 - INFO - mycodo.controllers.controller_trigger_e05919f9 - Activated in 52.8 ms 2020-08-21 01:44:11,948 - INFO - mycodo.controllers.controller_trigger_15e84940 - Activated in 52.9 ms 2020-08-21 01:44:12,173 - INFO - mycodo.controllers.controller_trigger_59b29264 - Activated in 52.7 ms 2020-08-21 01:44:12,176 - INFO - mycodo.daemon - All activated Trigger controllers started 2020-08-21 01:44:12,585 - INFO - mycodo.controllers.controller_input_dd1b392c - Activated in 194.4 ms 2020-08-21 01:44:15,311 - INFO - mycodo.devices.atlas_scientific_ftdi_DT04DC2N - Atlas Scientific Board: ORP, Rev: 2, Firmware: 2.11 2020-08-21 01:44:18,510 - INFO - mycodo.controllers.controller_input_7e37e204 - Activated in 5753.1 ms 2020-08-21 01:44:18,859 - INFO - mycodo.controllers.controller_input_13487ed8 - Activated in 143.0 ms 2020-08-21 01:44:20,618 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.0625, 'timestamp_utc': None}} 2020-08-21 01:44:21,498 - INFO - mycodo.controllers.controller_conditional_460e1353 - Check this measurement in the Daemon Log. The water temp value is None 2020-08-21 01:44:21,498 - INFO - mycodo.controllers.controller_conditional_460e1353 - Check this measurement in the Daemon Log. The outside temp value is 23.0625 2020-08-21 01:44:21,557 - INFO - mycodo.devices.atlas_scientific_ftdi_DT04DD8O - Atlas Scientific Board: pH, Rev: 2, Firmware: 2.14 2020-08-21 01:44:37,544 - DEBUG - mycodo.controllers.controller_input_13487ed8 - Adding measurements to InfluxDB with ID 13487ed8-c14e-4c47-8da6-124028f42280: {0: {'measurement': 'temperature', 'unit': 'C', 'value': 23.0625, 'timestamp_utc': None}} 2020-08-21 01:44:37,867 - INFO - mycodo.controllers.controller_input_ea2abd1f - Activated in 5703.6 ms 2020-08-21 01:44:38,249 - INFO - mycodo.controllers.controller_input_551be49e - Activated in 131.0 ms 2020-08-21 01:44:38,249 - INFO - mycodo.daemon - All activated Input controllers started 2020-08-21 01:44:38,250 - INFO - mycodo.daemon - All activated Math controllers started 2020-08-21 01:44:38,250 - INFO - mycodo.daemon - All activated PID controllers started 2020-08-21 01:44:39,172 - ERROR - mycodo.controllers.controller_lcd_b51387b7 - initialize_variables() Exception: No module named 'Adafruit_BBIO' Traceback (most recent call last): File "/var/mycodo-root/mycodo/controllers/base_controller.py", line 72, in run self.initialize_variables() File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 292, in initialize_variables self.lcd_out = LCD_Pioled(lcd_dev) File "/var/mycodo-root/mycodo/devices/lcd_pioled.py", line 50, in init spi=SPI.SpiDev(lcd_dev.spi_bus, lcd_dev.spi_device)) File "/home/pi/Mycodo/env/src/adafruit-ssd1306/Adafruit_SSD1306/SSD1306.py", line 243, in init gpio, spi, i2c_bus, i2c_address, i2c) File "/home/pi/Mycodo/env/src/adafruit-ssd1306/Adafruit_SSD1306/SSD1306.py", line 85, in init self._gpio = GPIO.get_platform_gpio() File "/var/mycodo-root/env/lib/python3.7/site-packages/Adafruit_GPIO/GPIO.py", line 420, in get_platform_gpio import Adafruit_BBIO.GPIO ModuleNotFoundError: No module named 'Adafruit_BBIO' 2020-08-21 01:44:39,179 - INFO - mycodo.controllers.controller_lcd_b51387b7 - Activated in 808.5 ms 2020-08-21 01:44:39,179 - INFO - mycodo.daemon - All activated LCD controllers started 2020-08-21 01:44:39,180 - INFO - mycodo.daemon - All activated Custom controllers started 2020-08-21 01:44:39,252 - INFO - mycodo.controllers.controller_widget - Activated in 72.1 ms 2020-08-21 01:44:40,254 - INFO - mycodo.daemon - Mycodo daemon started in 23.226 seconds 2020-08-21 01:44:40,260 - INFO - mycodo.daemon - 50.38 MB RAM in use

kizniche commented 4 years ago
ModuleNotFoundError: No module named 'Adafruit_BBIO'

Install with:

~/Mycodo/env/bin/pip install Adafruit_BBIO
Mark0Mi commented 4 years ago

2020-08-21 09:16:35,509 - ERROR - mycodo.controllers.controller_lcd_b51387b7 - initialize_variables() Exception: argument 1 must be str, not int Traceback (most recent call last): File "/var/mycodo-root/mycodo/controllers/base_controller.py", line 72, in run self.initialize_variables() File "/var/mycodo-root/mycodo/controllers/controller_lcd.py", line 292, in initialize_variables self.lcd_out = LCD_Pioled(lcd_dev) File "/var/mycodo-root/mycodo/devices/lcd_pioled.py", line 50, in init spi=SPI.SpiDev(lcd_dev.spi_bus, lcd_dev.spi_device)) File "/home/pi/Mycodo/env/src/adafruit-ssd1306/Adafruit_SSD1306/SSD1306.py", line 243, in init gpio, spi, i2c_bus, i2c_address, i2c) File "/home/pi/Mycodo/env/src/adafruit-ssd1306/Adafruit_SSD1306/SSD1306.py", line 89, in init self._gpio.setup(self._rst, GPIO.OUT) File "/var/mycodo-root/env/lib/python3.7/site-packages/Adafruit_GPIO/GPIO.py", line 278, in setup pull_up_down=self._pud_mapping[pull_up_down]) TypeError: argument 1 must be str, not int 2020-08-21 09:16:35,518 - INFO - mycodo.controllers.controller_lcd_b51387b7 - Activated in 832.0

kizniche commented 4 years ago

Was there an event that caused your display to stop working? No LCD code has changed in mycodo since it was confirmed to work.

Mark0Mi commented 4 years ago

I switched back to the previous version apt-get update and upgrade then the mycodo upgrade to the latest 8.7.1 -> dashboards still not working... I switched then back to beginning of August (backup restore). From there I had the issue with the gateway timeout which I fixed by installing bcrypt==3.1.4 (you might remember I started from beginning with the desktop version of rasp. and there was an issue where the webserver would not start) then I have resetted all the dashboards and did the upgrade - since then I think the display is not working. Not sure what is causing this.. I did a switchback right before the upgrade but the display stays dark.. The command line file still works where I get the display to print something (the files I added in the beginning) Do you have any other idea how to get it back to work?

kizniche commented 4 years ago

Since the Adafruit_Python_SSD1306 is deprecated, I'm inclined to convert the module to using the Adafruit_CircuitPython_SSD1306 library. I declined to use the CircuitPython libraries in the past because of the difficulty with working with multiple I2C buses, a problem I've since overcome with the use of Adafruit_Python_Extended_Bus.

kizniche commented 4 years ago

I switched back to the previous version...

This is hard to follow. When you pasted the most recent error traceback, were you running the latest release?

Mark0Mi commented 4 years ago

I'm now on the latest version (but I know switching back does not get the display back - for whatever reason) to check if the display is damaged I ran the python scripts supplied by the vendor - and then the display works while running these scripts but mycodo does not initialize the display properly

kizniche commented 4 years ago

Can you test the circuitpython library? You will need to remove the current library because it has the exact same name as the new library. Uninstall with ~/Mycodo/env/bin/pip uninstall adafruit-python-ssd1306 (it may be Adafruit_SSD1306, so try both). Then, install the new library: ~/Mycodo/env/bin/pip install adafruit-circuitpython-ssd1306 then edit the pins, below, and execute the following code from the virtualenv with ~/Mycodo/env/bin/python ~/test_lcd.py

import adafruit_ssd1306
import board
import busio
import digitalio

spi = busio.SPI(board.SCK, MOSI=board.MOSI)
dc_pin = digitalio.DigitalInOut(board.D3)
reset_pin = digitalio.DigitalInOut(board.D4)
cs_pin = digitalio.DigitalInOut(board.D5)
disp = adafruit_ssd1306.SSD1306_SPI(128, 32, spi, dc_pin, reset_pin, cs_pin)

disp.fill(0)
disp.show()

image = Image.new('1', (disp.width, disp.height))
draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, disp.width, disp.height), outline=0, fill=0)
draw.text((x, top), "TEST LINE", font=font, fill=255)
disp.image(image)
disp.display()
Mark0Mi commented 4 years ago

yes I can - I had to change the code a little please review if this is ok -> TEST LINE is shown on the display after executing this code

import adafruit_ssd1306 import board import busio import digitalio

from PIL import Image from PIL import ImageDraw from PIL import ImageFont

spi = busio.SPI(board.SCK, MOSI=board.MOSI) dc_pin = digitalio.DigitalInOut(board.D16) reset_pin = None cs_pin = digitalio.DigitalInOut(board.CE0) disp = adafruit_ssd1306.SSD1306_SPI(128, 32, spi, dc_pin, reset_pin, cs_pin)

disp.fill(0) disp.show()

image = Image.new('1', (disp.width, disp.height)) draw = ImageDraw.Draw(image) padding = 1 top = padding x = padding font = ImageFont.load_default() draw.rectangle((0, 0, disp.width, disp.height), outline=0, fill=0) draw.text((x, top), "TEST LINE", font=font, fill=255) disp.image(image) disp.show()

disp.display()

kizniche commented 4 years ago

Ah, sorry I missed a few variables. Now I need to figure out how to do a switcheroo with user libraries, considering they're named the same (thanks, Adafruit).

Mark0Mi commented 4 years ago

no worries - one question why did my display stop working in mycodo? do you have any glue about that?

kizniche commented 4 years ago

No, like I said, none of the LCD code changed in Mycodo. So, either you have a filesystem issue of some kind (e.g. corrup files), or a library updated and broke something. The fact you didn't have Adafruit_BBIO is indicative of a filesystem issue because it is required for the LCD to operate, and you say your LCD was operating previously.

Mark0Mi commented 4 years ago

just a short update I did a complete re-install and now it is working again..