Need help with Inky Phat crontab update

I want to update the weather on my Inky Phat every 10 minutes.The directions to the Inky Phat say to enter, python weather.py, command after it is set up (which it does and works fine) and it says to add crontab -e
and then I add,
*/10 * * * * python /home/pi/Pimoroni/inkyphat/examples/weather.py
to that file that comes after that, but I must be doing something wrong as it never updates. Is there a code I can add to weather.py so it will update on its own? Or can someone tell me what I’m doing wrong.

1 Like

The file weather.py needs to load some images from the resources directory in /home/pi/Pimoroni/inkyphat/examples, so you need to write a little startup script for it that you call with Crontab:

Create your weather launcher:

cd ~
nano weather.sh
#!/bin/bash
cd /home/pi/Pimoroni/inkyphat/examples/
python weather.py

Ctrl+X, Y, Enter

Make it executable:

chmod +x weather.sh

Then your Crontab script should be changed to /home/pi/weather.sh

The cd part is crucial- it ensures that the working directory is changed so that weather.py can find the contents of /home/pi/Pimoroni/inkyphat/examples/resources

I’m having the same issue/ question. Unfortunately, the workaround above doesn’t do the trick for me. What might I be doing wrong? And thanks!

What code are you running, and which directory is it stored in?

Hey, thanks for the reply! The crontab-code, you mean?

I pretty much opted for the above code in combination for a 10 mins refreshment rate as derived from the Inky Phat “Getting started” page. Also, I added a line to start up the weather app at every boot which so far is also failing. Here’s what I’ve entered into crontab -e:

@reboot python /home/pi/weather.sh

*/10 * * * * python /home/pi/weather.sh

Note that “weather.sh” is a bash script, not a Python script. You shouldn’t need to call it with Python:

@reboot /home/pi/weather.sh
1 Like

Indeed, thank you for clearing that up. I removed the “python” and now it starts up like a charm… still no updates, though. Did I include any errors in the refreshment command line?

*/10 * * * * python /home/pi/weather.sh

Yup- same issue, you need to drop python since it’s not a Python script.

1 Like

thank you so much for your patience with my novice-ness! this really does the trick now.

1 Like

Thanks for that solution, I am no expert in Python and have been tearing what little hair I have out over the last couple of days trying to solve this.
I include some detail of what i’m trying to achieve.
Collect data from a BFE280 on a RasPi 3, send this over the LAN to PiZero W and the lovely little InkyPhat Black for display indoors. This is just a proof of concept and will move to my main home made Raspberry Pi weather station when it is proved to be reliable. I will probably adapt it to also display the temperature in my wood fired bread oven which has an embedded K type sensor and an Adafruit interface to another Pi (I have 6 assorted Pies running various jobs around the place)

Pete

As an afterthought, I had similar issues. Even after following all of Gadgetoid’s advice, I discovered one further step needed (possibly I mistyped something?)

Within the Crontab script, I had to add ‘bash’ before the path to the weather.sh script, so that it now reads:

*/5 * * * * bash /home/pi/weather.sh

…after which it works perfectly.