Sensors stop giving readings after an hour or so, wont reinitialize

Cross posting here from github, as i didn’t get a response and this is giving me fits, TYIA for any suggestions or advice, and thanks for putting together and continuing to support this amazing project!
… original post at sensors stop giving readings after an hour or two and wont reinitialize without a power cycle · Issue #1350 · kizniche/Mycodo · GitHub

sensors stop giving readings after a couple hours(every time) and wont reinitialize without a power cycle. system is a pi5 running bookworm. Sensors are a bme280 and an scd30 on i2c. everything works fine on power up, after an hour or so readings stop with errors 101 and 110. system restart from within mycodo fails to reinitialize them. power cycle restores functionality


  • Mycodo Version: 8.15.12
  • Raspberry Pi Version: 5b
  • Raspbian OS Version: bookworm

logs are in original post, cant post them here as im a new user(too many links)

1 Like

Again, similar symptoms to what I have been having trouble with since upgrading to 8.15.8. More people keep reporting similar symptoms.

1 Like

Yeah I’m having trouble with my SHT-31 aswell, Im not sure if its Mycodo or the I2C cable getting too much noise or getting stuck or something along the line, if I spam I2cDetect on the Pi console occasionally I get the adress for the sensor to show, but more often than not its blank.

When Im unable to get any response with spamming doing a hard reboot on the Pi can bring it back, but only when I first disable the I2C device in Mycodo.

I am on Mycodo 8.15.12

edit: first thing I’m going to try tomorow is see if I can route the cables for the sensor better so that interference is less likely. maybe shield the cables with some aluminum tape.

I can’t speak for older mycodo versions so I can’t really say if this is some sort of regression on the I2C handling.

edit2: after reading a different thread on this forum, I’ve also put in an order for an LTC4311 I2C extender/active terminator.

I haven’t been online in about a week, but I’m also experiencing random addresses being dropped from my i2c bus. It has happened before and after the update unfortunately

Yep that exactly what I’m experiencing.

This was actually a big reason why I have been transitioning away from Mycodo, and sensors as a whole.

@Lucid3y3 You detailed to me the complications of having a hydroponic system running with so many moving parts and electronic capabilities. Something that heavily engineered should be reserved for research or large commercial ops.

I am experiencing slightly different symptoms… My sensors are not completely dropping off the i2c scan. I can still see all my sensor addresses on the bus, but Mycodo is not recording specific measurements from one sensor, as in that sensor is taking multiple measurements… temp, humidity, vpd… but Mycodo is only reporting the temp as not being acquired. And it’s not the sensor Input module itself that is reporting the error in Mycodo, it’s a bang-bang Function that is reporting that it can’t acquire a measurement. If I manage to deactivate/reactivate the Function that is calculating that measurement before the database becomes locked, I don’t need to do a hard power reset to regain functionality.

Your symptoms sound more like a hardware issue, bad wiring connection, conflicting addresses of multiple devices, faulty sensors, or even a damaged i2c bus on the Pi itself? You need to be as sure as possible you have eliminated any hardware-layer issues before looking at the software for problems. Please post some more details about your specific setup and maybe I can offer some help.
How long are your i2c cables?
Are you using any i2c expanders or range extenders?
What sensors are you using, and which sensor/s are you having the most trouble with?
Are you changing the i2c baud-rate?

Nonsense, Almost all hydroponics system types are highly scale-able, and none of it needs to be rocket-science. There’s no reason we can’t employ some of the same techniques being used in large-scale industrial agriculture to small home-built systems. Design your system so that it is only as complicated as it needs to be to make it perform what you need it to do. Keep in mind that Kyle’s video is a demonstration of what is possible with current available hardware… you don’t need to copy his design exactly to build a system that will grow plants just fine.

In fact, the most basic hydroponics system (DWC) only needs an air pump. For a flood & drain or NFT system, you only need a lighting timer, and a watering pump timer, that’s it. And that can be done with a single dual-outlet wall timer for $12.
That’s how I grew indoor herbs, veggies, and cannabis for years before I found Mycodo and decided to try adding some humidity and air flow control to my system.
The main reason I started using Mycodo was to collect and visualize data and learn where I could make changes and improvements in my system and techniques to help increase growth and harvest yields for my cannabis plants. Cannabis sells for around $150 per ounce in a dispensary… it only costs me about $10 per ounce to grow it in my hydroponics system… so taking some time to gather data and improve my techniques is well worth the effort.
But now that I have all that data, I don’t really need Mycodo, although I’ve become attached to it as a home automation solution since it’s much easier to use than Home Assistant and far more functional than a lot of the other open-source automation options. I have been thinking about keeping Mycodo for the home automation and separating the Hydroponics onto it’s own dedicated and more simplified system, maybe just using a wall-timer and a couple of ESP32s each programmed to handle a specific task in the system… Lights, Pump, Fans, and Humidifier. I absolutely do not need any of the automation for testing my pH or all those peristaltic pumps for mixing nutrients… those are features that really belong on a more large-scale system and are not really practical or cost effective on a small home system. But like I said, Kyle’s video is demonstrating what is possible rather than what is practical… there’s usually a huge chasm (or mountains of money) between what is practical and what is possible. :wink:

Keeping all of that in mind, if you still decide to go the route of using Mycodo… you need to make sure you have dealt with all of the hardware layer issues before you start looking at the software for problems. I2c can be a little difficult to setup at first, especially if your cables are longer than 6 feet and there is a lot of EMI being generated in the immediate vicinity of your sensors. Sensors themselves can also cause problems, especially if they are really cheap knock-offs, or if you have multiple sensors and they all have pull-up resistors.
If you think you have dealt with the above issues and are still having i2c problems, you can try adjusting the i2c bus baud-rate next. The default baud rate on the Pi is 100kHz, but can be set as high as 400kHz. Some i2c devices operate better at different baud-rates, so if you are having i2c problems reading some sensors, try slowly increasing the baud-rate in 50kHz increments until you get good reliable readings from all your sensors… yes, this can take time to test and dial in, but once it’s working you shouldn’t need to change it again (unless you add more sensors or change to different sensors).
To adjust the i2c baud rate open your /boot/config.txt file with a CLI editor such as nano (sudo nano /boot/config.txt)

Scroll through the file and look for the following line…

dtparam=i2c_arm=on <---- this line enables the i2c bus

Add the following to the end of that line, don’t forget the comma, and no spaces before or after the comma…


So now that line should look like this…


Save the file and exit the editor.
Now you can adjust the baud-rate by changing that value as needed.
A reboot is required anytime you change the baud-rate value.