USB stick not always detected on power up
Posted: Tue Aug 16, 2016 9:27 am
Hi,
Background.
Using latest raspbian and have created a Python data logging script that runs on power up using system to etc.
On power up it looks to see if a USB drive is mounted by checking to see if /media/PI has a sub folder. If so, it opens a file on it and writes to it. If not, it writes to a folder on the SD card.
Maybe not the most elegant approach but it seemed to work .
However, I have noticed that sometimes when the USB drive is inserted and the PI powers up it is not detected.
If I use "sudo systemctl stop .." to stop the script and then restart it the drive is always detected.
Could there be some timing issue on power up, do I need to wait for the drive to be mounted (somehow), I did think of just adding a time.sleep(5) in the script.
Cheers
Steve
Background.
Using latest raspbian and have created a Python data logging script that runs on power up using system to etc.
On power up it looks to see if a USB drive is mounted by checking to see if /media/PI has a sub folder. If so, it opens a file on it and writes to it. If not, it writes to a folder on the SD card.
Maybe not the most elegant approach but it seemed to work .
However, I have noticed that sometimes when the USB drive is inserted and the PI powers up it is not detected.
If I use "sudo systemctl stop .." to stop the script and then restart it the drive is always detected.
Could there be some timing issue on power up, do I need to wait for the drive to be mounted (somehow), I did think of just adding a time.sleep(5) in the script.
Cheers
Steve