I hinted at it before – Python has been somewhat forced upon me. It’s grown on me a little – probably more due to familiarity. To be honest, all these languages are really much of muchness to me. What you can do in one, you can do in the other.
I looked into Windows IOT (w/ C#) and Android Things (w/ Java) as platforms for my Gardening for Dummies thing, I have kind of ended up going with Python running on a local (flask) webserver on an RPi4.
The main reason I have ditched the Microsoft and Android-based ‘proprietary’ options is that they do not support the RPi4 (or RPi3B+ for that matter). In words, in Raspberry Pi terms, they are discontinued. This is just plain old irritating, and:
- The vanilla RPi3B I have has no wifi (I broke it – new RPi3Bs are hard to come by now.
- The RPi4 is a pretty big step up performance-wise.
The main downside with the approach I’ve gone for is that
What follows is a list of bits-and-bobs I have come (up) against en route to getting this setup with RPi4 + Buster + python3.7&pycharm + remote dev.
Enable spi & ssh on RPi
spi means you (via PiPlates lib in the first instance) can access RPi4 i/o pins. ssh is for accessing remotely (for next step). Easy to do with:
Remote RP4 dev from PyCharm
At work, I have been using Visual Studio as IDE for Python. It’s okay, PyCharm leaves it for dust in some respects (code completion, refactoring and just being ‘smart’ generally). The whole git experience seems a little better on VS?
What does not seem that straightforward in Visual Studio is remote development with Python on RPi. (Or if it is easy, I lost patience because it did not come up on Google)
Pycharm is pretty easy to set up: just follow the guide here. They start going on about pings and wot-not in the tutorial.
Hiccup #1: Outdated instructions for static IP
In tutorial, they send you to a link for setting up static IP address on your RPi – links to an old page which is Buster’s predecessor (Stretch?). Easy enough to find more up-to-date account with Google.
Hiccup #2: Syncing to RPi remote project on restart
When you are all set up, creating and saving (.py) modules in your project, they should automatically wire them through to the RPi.
I found I have issues when I came back to project having restarted the RPi – the temp project did not have all the project files anymore. Easy to fix with by selected all files in project and Tools >> Upload to <your remote pi>
The ‘tmp’ dir in Linux (for Buster on the RPi4 is just that – it gets wiped (I think) when you reboot.
I changed the path mappings so it uses a permanent directory:
- Goto settings > deployment
- Click the Mappings tab option.
- In deployment path click the little folder icon on the right to (remote) browse to your (permanent) directory location. I had made a directory called in my root path (the default1g4d_dash) on RPi.1/home/pi
- Click OK
- Click on the ‘root’ of your project in PyCharm project-browser-thing, so it is highlighted
- Menu: Tools > Deployment > upload to <email@example.com..x>
This should flick all your files to that new deployment path.