PID Controll with Shell Skript Output does not work

Hi im kinda new in the mushroom community and are trying to set up an automatic humidity and temperature controll for my cultivation. The measurment works fine:

But after i set up the outputs via shell skript and connecting them with the sensor via a PID function i cant get the system work properly. The outputs are always set to off and there is no regulation. I dont get any P, I or D values. Right now i manually switch the power of the humidyfire off and on same with the heater.

I use a Tasmota NOUS A4T with two power connectors therefore Power 1 and 2 in the link. I can turn them seperatly off and on via mycodo. Here the outputs:

The PID settings are configurated like this:

In the log files i always get the following error:

File “/opt/Mycodo/mycodo/controllers/controller_pid.py”, line 448, in get_last_measurement_pid
self.last_time = last_measurement[0] / 1000
~~~~~~~~~~~~~~~~^~
TypeError: unsupported operand type(s) for /: ‘NoneType’ and ‘int’
2024-12-03 13:04:45,347 - DEBUG - mycodo.controllers.controller_pid_438b529c - Latest (CH1, Unit: percent): 90.25253681239033 @ 1970-01-21 02:27:07.437866
2024-12-03 13:04:45,577 - DEBUG - mycodo.controllers.controller_pid_438b529c - PID: Input: 90.25253681239033, Output: P: 0.0, I: 0.0, D: 0.0, Out: 0.0
2024-12-03 13:05:07,315 - ERROR - mycodo.controllers.controller_pid_e8d984c6 - Exception while reading measurement from the influxdb database
Traceback (most recent call last):
File “/opt/Mycodo/mycodo/controllers/controller_pid.py”, line 448, in get_last_measurement_pid
self.last_time = last_measurement[0] / 1000
~~~~~~~~~~~~~~~~^~
TypeError: unsupported operand type(s) for /: ‘NoneType’ and ‘int’
2024-12-03 13:05:45,338 - ERROR - mycodo.controllers.controller_pid_438b529c - Exception while reading measurement from the influxdb database
Traceback (most recent call last):
File “/opt/Mycodo/mycodo/controllers/controller_pid.py”, line 448, in get_last_measurement_pid
self.last_time = last_measurement[0] / 1000
~~~~~~~~~~~~~~~~^~

The PID graphs look like this:

Did i configurate something wrong?

Sounds like you’re making things much more complicated than they need to be.
Why are you setting up your outputs via a shell script?
Are you using outputs that aren’t supported by Mycodo?
Looks like some of the screen shots you intended to post are missing?
If you’re new to Mycodo, you will be much better off using Bang-Bang controllers to control temperature and humidity than trying to use PID controllers.

1 Like

Thanks for the help :slight_smile: I couldn’t put in more pictures because my account is too new, so I was limited to adding only one screenshot.
The power supply I’m using was not in the selection of output devices, but Tosmata was preinstalled. So I connected the power supply with mykodo via a shell script. It works fine, but I couldn’t get the PID running.
The Bang-Bang Function, on the other hand, works just fine. So thank you very much again! I was kind of overthinking the system, I guess.

1 Like

If your Output is connected to a device running Tasmota you can try using the MQTT options in Mycodo for controlling that device as well. You would need to setup an MQTT Broker like Mosquitto on the same Pi running Mycodo…

And then setup your Outputs…

I have many devices running Tasmota and use MQTT to communicate with and control all of them with Mycodo.

I tried MQTT but couldn´t trigger the two outputs of my Tasmota device separately so I sticked with the Shell Skript. But to be fair I didn´t put that mutch time in figuring out how MQTT works. Is MQTT the long term better solution?

I would say that MQTT is the more standard solution, it is used extensively in industrial systems integration and automation. This is just one reason Tasmota is designed specifically to use MQTT and HTTP as it’s primary modes of communication with external systems. If you want to take full advantage of all the available remote-control features of your Tasmota Device, I’d recommend using MQTT. There is a little learning involved since it’s designed to handle some complex scenarios, but for the most part it’s pretty straight forward and easy to setup once you’ve learned the basics… and simpler than having to write custom scripts.

Here’s the Tasmota documentation for MQTT…

For the Tasmota NOUS A4T… the MQTT Topic for the power outlets should be something like…
“cmnd/tasmota/POWER1”
“cmnd/tasmota/POWER2”
and the payload would be “ON” or “OFF”.

If you already have an MQTT server like Mosquitto set up on your Raspberry Pi, I also recommend installing a diagnostic app like MQTT Explorer on your laptop or desktop so you can visually monitor the actual MQTT Topics that your devices are sending to the MQTT server… this makes things easier to understand as well as making setting up Tasmota and Mycodo easier.

1 Like

Thank you very much for the help and sharing the information! I will try to set things up as you recommended to get a better feeling for the system.

1 Like

I notice you enabled setpoint tracking using the same measurement as the measurement value, which doesn’t make sense. Why was this done?

You also have a measurement max age of 60 seconds set… Is your input measuring every 60 seconds or sooner? You will see “cannot obtain measurement” errors if you’re trying to sample faster than your input is acquiring measurements.

I dindn´t do it on purpose. It was kind of a play and find out how the system will react if I change a specific value. I think i have to learn more about the PID functionality in order to set i up correct.