BlueWave Studio forum
Temp sensor doesn't read on first boot - Printable Version

+- BlueWave Studio forum (https://bluewavestudio.io/community)
+-- Forum: OpenAuto Pro (https://bluewavestudio.io/community/forum-86.html)
+--- Forum: Temperature sensor (https://bluewavestudio.io/community/forum-90.html)
+--- Thread: Temp sensor doesn't read on first boot (/thread-3035.html)



Temp sensor doesn't read on first boot - keybrdcowboy - 11-11-2021

I wired up a DS18B20 to the Raspberry Pi to use for OpenAuto. In Raspbian, everything works fine. It always and consistently shows the right temp if I cat the w1_slave. I have set OpenAuto to use that slave device, but when OpenAuto boots, it has the wrong temperature. If I shutdown OpenAuto and return to the Raspbian desktop, then relaunch OpenAuto from there, OpenAuto will then show the correct temp.... anyone know why this would be happening?

Looking in the opanauto.log, there's an error that reads:

"[0x6abea140] [error]  [OpenAuto] [TemperatureSensorManager] unable to open: /sys/bus/w1/devices/28-0316a2798a5a/w1_slave"

However I can copy and paste that same path and I can cat the w1_slave just fine. And again, if I quit OpenAuto and then re-launch it will display the temp fine.

Any ideas? Thanks.


RE: Temp sensor doesn't read on first boot - KreAch3R - 11-11-2021

It looks like to me that the sensor driver isn't ready yet when OAP tries to read the value and it gets the error. Then it doesn't try to read it again until a next restart. Have your running a script on boot that cats the value immediately after reboot? I guess it will also display nothing or get the error (because the sensor won't be ready yet).

How have you set it up? According to this? https://bluewavestudio.io/community/showthread.php?tid=836


RE: Temp sensor doesn't read on first boot - keybrdcowboy - 11-11-2021

So it's not setup quite like that.

I originally had everything connected with a breadboard and using the 4K resistor and that was working fine. However, I changed it up a bit in order to make it fit better for the actual install. Instead of using the resistor, I'm using a Python script to set GPIO 4 to a "pull high" state so that I can get away with NOT using the resistor. Then just connecting the sensor to 5v, GPIO4, and then ground. It's weird to me that it's working in Raspbian but not OpenAuto. I thought maybe the Python script to set the GPIO pin wasn't executing before OpenAuto, but I am executing the Python script in the autostart BEFORE OpenAuto gets started. Unless there's something in the background happening with OpenAuto before the actual GUI ever launches?


RE: Temp sensor doesn't read on first boot - BlueWave - 11-11-2021

Apps in autostart are run at the same time, not one by one. That definitely looks like race condition. Try to create a script when you launch your python code first and then OpenAuto Pro (in separated command).


RE: Temp sensor doesn't read on first boot - keybrdcowboy - 11-12-2021

Would running the script in /etc/rc.local be better? I googled and the internet said that rc.local is ran BEFORE the GUI, but I was still having the same issue. Maybe if I do a python3 /path/to/script && openauto in the autostart?


RE: Temp sensor doesn't read on first boot - KreAch3R - 11-12-2021

(11-12-2021, 05:49 AM)keybrdcowboy Wrote: Would running the script in /etc/rc.local be better? I googled and the internet said that rc.local is ran BEFORE the GUI, but I was still having the same issue. Maybe if I do a python3 /path/to/script && openauto in the autostart?

I think that's what Bluewave is suggesting, disable default OAP autostart and make your own script launching both the sensor and OAP after the sensor.


RE: Temp sensor doesn't read on first boot - keybrdcowboy - 11-13-2021

So I think that's working... I created a new bash script, first line runs the GPIO PULL HI thing and then right after that it launches OpenAuto. Then in the autostart I have it running that one bash script... I've only tried it once so far but it did work that time.... Thanks.


RE: Temp sensor doesn't read on first boot - BlueWave - 11-13-2021

You can also consider to add a sleep between two commands.