L298N DC Motor Controller on Pi 5

Hi,
I have Mycodo 8.16.0 running well on both Raspberry Pi4 and Pi 5, both are setup with the same inputs and outputs (using pinctrl for Pi 5 outputs), however the only output option for a Peristaltic Pump: L298N DC Motor Controller , is the following “[GPIO] Peristaltic Pump: L298N DC Motor Controller (Pi <= 4) (RPi.GPIO)” . I realize that’s for Pi<=4 but there is no option for Pi5 for the L298N controller board so I tried it and does not work on Pi 5 , it just stays in "unconfigured " state.
My Question is , are there plans to get a Pi5 version of L298N DC Motor Controller into Mycodo?

1 Like

Hi. I just added a new L298N Pump Output for the Pi 5. I haven’t tested it, so if you are inclined, you can upgrade to master to test, and please let me know if it works.

Hi Kyle Thanks so much for looking at this so quickly .
I have tried it… I did not install over my install because I was bit worried about losing a few settings I am working on, so I extracted the new file (pump_l298n_pi5.py) and loaded it as a custom output , then these are the issues I had ( some I solved , but maybe incorrectly)

  1. Unique name not unique …so I changed ‘output_name_unique’: ‘DC_MOTOR_L298N_PI5’, - This sorted out the issue

  2. “ERROR - mycodo - Could not turn output on: name ‘cmd_output’ is not defined”
    …. I added “from mycodo.utils.system_pi import cmd_output” (copied from the on_off_pinctrl.py) Which solved that issue

  3. Then I get this error … which I have not solved ……ERROR - mycodo - Could not turn output on: name ‘self’ is not defined
    Here is the log info…
    Traceback (most recent call last):
    File “/opt/Mycodo/mycodo/mycodo_daemon.py”, line 773, in output_on
    return self.controller[‘Output’].output_on_off(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/opt/Mycodo/mycodo/controllers/controller_output.py”, line 299, in output_on_off
    return self.output[output_id].output_on_off(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/opt/Mycodo/mycodo/outputs/base_output.py”, line 378, in output_on_off
    ret_value = self.output_switch(
    ^^^^^^^^^^^^^^^^^^^
    File “/opt/Mycodo/mycodo/outputs/custom_outputs/dc_motor_l298n_pi5.py”, line 218, in output_switch
    self.run(output_channel)
    File “/opt/Mycodo/mycodo/outputs/custom_outputs/dc_motor_l298n_pi5.py”, line 248, in run
    self.switch_pin(self.options_channels[‘pin_1’][channel], True)
    File “/opt/Mycodo/mycodo/outputs/custom_outputs/dc_motor_l298n_pi5.py”, line 285, in switch_pin
    self.logger.debug(
    ^^^^
    NameError: name ‘self’ is not defined

I also noticed your commit also changed on_off_pinctrl.py, so I updated that and I get same error as point 3 above.

Is it an issue that I am just replacing those files (or loading as a custom module) and not doing a complete upgrade/ overwrite of the /opt/Mycodo files ?

1 Like

Thanks for testing. This commit should fix those issues.

Thanks for the update , it now complains about the key ‘pin’ of the dictionary on line 284 " f"GPIO {self.options_channels[‘pin’][0]} set ON with ‘{cmd}’: “”

If I take “{self.options_channels[‘pin’][0]}” out of the debug logger line then it seems ok,… it starts no problem and with debug out as follows:

2025-02-03 18:03:40,016 - DEBUG - mycodo.outputs.dc_motor_l298n_2_4950bb9a - output_on_off(on, 0, sec, 0.0, 0.0, True)
2025-02-03 18:03:40,025 - DEBUG - mycodo.outputs.dc_motor_l298n_2_4950bb9a - GPIO set ON with ‘pinctrl set 19 dh’: Status: 0, Return: b"Can’t set pin value, not an output\n", Error: b’’
2025-02-03 18:03:40,034 - DEBUG - mycodo.outputs.dc_motor_l298n_2_4950bb9a - GPIO set ON with ‘pinctrl set 26 dl’: Status: 0, Return: b"Can’t set pin value, not an output\n", Error: b’’
2025-02-03 18:03:40,035 - DEBUG - mycodo.outputs.dc_motor_l298n_2_4950bb9a - Output 4950bb9a-52f9-476f-b3aa-ea0c5a3d759d CH0 (PH Pumps) ON at 2025-02-03 18:03:40.016316. Output returned: None

1 Like

These should be the last fixes needed.

Hi , yes all working well now.
Thanks for your efforts and quick responses.

1 Like