I have raspberry-pi 2 and i made a python program. My python program can detect BLE and send scan results using MQTT. The program will run automatically when restarted [Using cron-table]. Then I did mass cloning using the OS developed on Raspberry-pi2. After cloning, I tried on raspberry-pi 3 but BLE can't be scanned.
I've tried to troubleshoot by:
- Turn off crontab and run python program with terminal [BLE scan success]
- Run crontab again after doing hciconfig up and hciconfig down. [Not successful]
- Added shell script before python program in crontab [Unsuccessful]
- Run the command "sudo hcitool lescan" [scan success]
An indication of the problem that occurs is that when the cron-table is turned on, the BLE scan cannot run.
List of Figures:
- When running the program in terminal ["sudo python3 scanning.py"]
- When running the command "sudo hcitool lescan" in the terminal
- Command on crontable
Hardware:
- Raspberry Pi 2 Model B V1.2
- Raspberry Pi 3 Model B+
Operating System:
- OS 10 [2021-03-04-raspios-buster-armhf-full.img]
Can anyone help? What caused this to happen?
hciconfig
has been deprecated . What is the status reported when you dosudo service bluetooth status
? Are there any errors reported injournalctl -k
? There are some benefits to using systemd for startup scripts like making sure the required parts of the system are up before running your script. In crontab, you can put a long sleep before your script is started?