Tryinng to run trackball python file on boot up

I have a Breakout Garden Mini SPI i2c. Plugged into that is the trackball breakout on the left side. Color LCD breakout in the center and RV3028 RTC breakout on the right.
Everything works to a point. I can run the mouse.py file for the trackball from idle3 no problem. And from terminal with python3 /home/pi/test-mouse.py
My problem is if I try to launch it on bootup via crontab it doesn’t work?
@reboot python3 /home/pi/test-mouse.py &
And if then try to lunch it via idle3 I get the following error message.

Traceback (most recent call last):
  File "/home/pi/test-mouse.py", line 15, in <module>
    trackball = TrackBall(interrupt_pin=4)
  File "/usr/local/lib/python3.7/dist-packages/trackball-0.0.1-py3.7.egg/trackball/__init__.py", line 51, in __init__
    raise RuntimeError("Invalid chip ID: 0x{:04X}, expected 0x{:04X}".format(chip_id, CHIP_ID))
RuntimeError: Invalid chip ID: 0x0000, expected 0xBA11

If I remark out the crontab entry and reboot. It’s back to working from idle again.
Anybody in the know, know what’s going on? Something to do with the interrupt GPIO 4?

Does it give the same error message if the program’s called from /etc/rc.local ?

I’ll give it a try and let you know, have to go look up how to do that. ;)

Oh, just type:

sudo nano /etc/rc.local

and put:

python3 /home/pi/test-mouse.py &

below the line that says

fi

and above the line that says

exit 0

then reboot.

Tried that, didn’t work. I don’t get any error message when trying crontab or rc.local. I only get that error if I “try” to run it via crontab, and then run it manually via idle3.
I may have messed up my rc.local? I took out some of those lines under the “by default this file does nothing”. It still doesn’t work on boot up but runs fine from idle3.
I followed this and left the exit 0 at the end.
https://www.raspberrypi.org/documentation/linux/usage/rc-local.md

I would leave everything as is, only add lines to the file. That said it may not work anyway.

When I’m trying out the track-ball I’ve give it a try - and see if I can get it working.

Best of luck!

I can recreate the original, I’ll just copy it from my other Pi. Then just add my one line and have another try.
I’ve used crontab numerous times in the past to run my python code on boot up with no issues. I’m not sure what’s going wrong this time though.

Ok, I recreated the original file, then just added my line. Same deal as trying via crontab.
Doesn’t run on bootup and now errors out when I try to run it via idle3.
Undo my rc.local edit and reboot, and it runs from idle.
I wonder if it has something to do with my RV3028, which also uses the interrupt pin? I have no idea if its wired to a different GPIO via the Breakout garden, there is no pinout for the mini.

EDIT: It’s not the RV3028. I removed it and it didn’t make any difference.

I figured out one way to get it working in Raspbian. Do the following from a terminal window

git clone https://github.com/pimoroni/trackball-python
cd trackball-python
cd examples
sudo ./install-service.sh

Have a look at the README.md file for info.
This does the evdev-mouse setup for you and it loads on bootup all on its own.

EDIT: I didn’t like how the ball click worked / didn’t work so I disabled the service
The manual trackball software install is as follows.
From a terminal window run the following

git clone https://github.com/pimoroni/trackball-python
cd trackball-python
sudo ./install.sh

then to install the trackball service

cd examples
sudo ./install-service.sh

to disable service

cd trackball-python
cd examples
sudo systemctl stop pimoroni-trackball.service
sudo systemctl disable pimoroni-trackball.service

to enable again

sudo systemctl enable pimoroni-trackball.service
sudo systemctl start pimoroni-trackball.service

EDIT: I would still like to get the basic mouse.py file to run on boot. Click does what I want with that one and I can easily edit the scroll directions. My trackball will be turned on its side 90 degrees for mounting. I’ve made that edit to mouse.py and it worked just fine.