I am writing a python code to detect balls using RPi, Pi Cam, and OpenCV library. I am a newbie to RPi. How can I use Raspberry Pi standalone which works just like Arduino? Thus, there should be auto login and auto execution of a python code.


How can I use Raspberry Pi standalone which works just like Arduino?

You can't use it exactly like an Arduino, or at least not easily, and it would not be very desirable to do so. The Pi is a considerably more complex piece of hardware.

there should be auto login

Unless you are using it in a very unusual way, an Arduino does not require a login or possess the potential for such, etc., because it does not run an operating system. Instead, it is programmed with firmware.

You can enable auto-login using raspi-config on Pi based operating systems such as Raspbian.

auto execution of a python code

Execution of code at boot does not require anyone logged in. Logically enough, it's the other way around: There must be appropriate software running first in order for anyone to log in.

The first non-kernel code executed on POSIX style operating systems such as Raspbian is init, and everything else descends from this. Note that the current init system is actually systemd, but a lot of documentation refers to the older SysV style init.

In either case, the easiest method to start something at boot is via /etc/rc.local, which is executed by the init system.

| improve this answer | |
  • Great. Thank you. So after the auto execution command added into /etc/rc.local, can I make that code run 'forever' (until battery lasts)? – Mat_python Oct 4 '16 at 0:46
  • Sure, just make sure, as per that linked post, that whatever it is forks into the background. You can do that in the python script but it is probably easier to just use & at the end in rc.local (beware in shell scripts & is also used together with > for a completely different purpose). You can try that out on the command line to get the idea. The reason for this is the rc.local script itself must complete in a few seconds, so you can't do things there that take a long time. But if they exit into the background, they can last there forever. – goldilocks Oct 4 '16 at 1:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.