0

I want to make one of my projects begin upon startup and found a few tutorials for that, but I want to make it so it only auto-activates when no monitor is detected. I have a pi4, and have heard it doesn't boot up if no monitor is plugged in.

I tried the method with rc.local(Method 1 in the linked site), which didn't work with the program i want to run(perhaps because the program requires bluetooth to an external device?). I did try this method with a simple led flashing code, and it totally worked. Even when i added an LED to the code to indicate when to connect the devices, the LED never lit up. I checked everything over again, but it all looked fine. If you know how to fix this, please let me know.

Script file path I'm trying to run is /home/pi/suit.py

Rather important note- I only have coding experience in Python using thonny, so anything short of step-by-step instructions and you've lost me before you started. Sorry for my inexperience.

Current code from /etc/rc.local (not including comments)

-IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My Ip address is %s\n" "$_IP"
fi

sudo python /home/pi/suit.py & exit 0

  • I’ve no pi handy at the moment to test this but I would always call the program and get it to check if a monitor is connected. This link https://askubuntu.com/questions/639495/how-can-i-list-connected-monitors-with-xrandr has a python program that lists monitors that are connected that may help. Remember though, any auto run program will run in the background so you need to think how it will display any messages - maybe a little display on the GPIO pins would be best... –  Jul 18 '20 at 22:40
  • "I have a pi4, and have heard it doesn't boot up if no monitor is plugged in." That's not true in general... I have several that boot happily, and they have never had a monitor connected. Who said that? – Seamus Jul 19 '20 at 00:33
  • "I have a pi4, and have heard it doesn't boot up if no monitor is plugged in." Then you heard WRONG. See https://raspberrypi.stackexchange.com/questions/113868/monitor-only-recognises-the-signal-when-started-first/113873#113873 Most of my Pi run headless. – Milliways Jul 19 '20 at 00:34
  • @Seamus generally the internet, and i tested it. sometimes, if theres no monitor plugged in, it wont boot up even if you plug one in after the power supply. sorry, this isnt very clear, if u plug in power, then monitor, pi doesnt boot up. thats basically what that means. –  Jul 19 '20 at 00:34
  • @Ceramicmrno0b: Perhaps you've misunderstood something - I'm quite certain they boot without a monitor. Can you test this on your Pi? In other words, disconnect the monitor, boot, then try to SSH into the RPi from your PC/Mac/Linux machine. – Seamus Jul 19 '20 at 00:39
  • @Seamus- i have no other computer besides my pi and a school chromebook. i cant ssh into it even if i knew how. –  Jul 19 '20 at 00:40
  • "I want to make one of my projects begin upon startup [..] but I want to make it so it only auto-activates when no monitor is detected." - How and where do you detect the monitor? – Ingo Jul 25 '20 at 16:57
  • @Ingo, already fixed it, problem solved. –  Jul 25 '20 at 17:24
  • @Ceramicmrno0b can you please make a short answer and accept it after two days? Only accepting an answer will finish the question. Otherwise it will pop up again and again for years with no end. – Ingo Jul 25 '20 at 17:30

1 Answers1

0

followed vnc utorial and got it fixed thx for all the help.