I’ve always been a headless user ever since I first started with the Raspberry Pi. The idea of investing in a separate screen, keyboard and mouse for a gadget ‘I didn’t even know how to use yet’ seemed crazy.
I’m now 2-3 years in to my ‘life of Pi’ and I’m still doing things the same way, well, until this week that is.
A couple of days ago I found a plugin (via my friend Albert Hickey) for my favourite text editor Notepad++, that gives you some basic FTP functionality in a little side window right next to your code.
What does this mean? It means I can have the luxury of proper syntax-highlighted code with the convenience of quick upload to my Pi, without moving out of my editing window.
Let me show you how!
Out With The Old…
FileZilla has been my FTP application of choice since I started using the Pi. It works very well, is simple enough to use and lets me store my various Pis as ‘sites’ so I can connect with just two clicks. Hard to beat right?
In With The New…
After my handy little find this week, FileZilla is as redundant to me as the Compact Disc. No longer do I need to install, update or open a completely separate application to move code to my Pi – it can all be done from within the same window I’m writing the code in.
NppFTP is an easy to use Notepad++ plugin, connecting to your devices and allowing convenient file upload/download via FTP. If you’re not sure what Notepad++ is, it’s a superb text editor that highlights Python beautifully – leagues head of using prehistoric ‘nano’ or other boring black screen editors.
Let’s show you how to install and use NppFTP with Notepad++.
Install the Plugin
Open Notepad++ and click on Plugins > Plugin Manager > Show Plugin Manager:
A window will appear and a list of available plugins will generate. I guess this is like their little repository of approved plugins. Scroll down and tick the box for ‘NppFTP‘ and then click ‘Install‘. It’ll ask you to restart the application afterwards:
Set Up Your Profile(s)
Once installed and restarted, click Plugins > NppFTP > Show NppFTP Window to open the FTP side window:
Once opened, you’ll need to set up a profile – that’s what we used to call a ‘site’ in FileZilla. This is simply saving your Pi’s IP address, username and password for quick access in future (static IP addresses recommended!).
Click on the little cog icon and select ‘Profile settings‘:
This will open a new window – now click ‘Add new‘. Give the profile a meaningful name then click ‘OK‘.
In the window that remains, enter the details as follows:
- Hostname: Your Raspberry Pi’s IP address (I use the Fing Android app to find mine)
- Connection Type: SFTP
- Port: 22 (Always seems to be this for the Pi)
- Username: Your username (default is ‘pi’)
- Password: Your password (default is ‘raspberry’)
Leave everything else as it is, and click ‘Close‘. You can do this as many times as you like if you have multiple Pis. Here’s an image of my setup:
Connect To Your Pi
Now for the fun part. In the NppFTP window, click the leftmost icon which is the ‘(Dis)connect‘ button. Clicking that will drop down any profiles you have set up. Now just click the profile you want to connect to.
Assuming that your Pi is connected to your network, within a few seconds you should see your Pi’s directories appear in the NppFTP window (you may get a security warning first – click yes to that):
You’re now ready to send/receive your code to/from your Raspberry Pi!
So you’ve written a lovely bit of code, and now you want to send it to your Pi for a test run.
Firstly, you must save your script somewhere. The file needs to be saved on your machine first – it can’t just send what you see on screen – it needs a saved file to chuck over to your Pi.
Once it’s saved, use the NppFTP window to navigate to the directory on your Pi that you want to send the file to, and simply click the icon with the arrow pointing upwards – the ‘Upload file‘ button.
Within a few seconds your script will be on your Pi ready to run. Personally, I complete this headless process by using Putty to SSH in and run my Python files:
Updating Code (WARNING!)
What if you already have the file on your Pi, but just want to make a few tweaks?
If we were using FileZilla, we’d push the file over and see an overwrite warning with some options. This is where NppFTP fails a little, offering no warning and overwriting without hesitation.
Version control can help here – I always create new versions of my project scripts when I make changes, giving me something to roll-back to if I mess it up.
Pulling a script from your Pi to your PC works the same way but just using the ‘Download file‘ button instead. Select the file in the NppFTP window and click the download button to show the file in Notepad++ instantly. Neat huh?
NppFTP offers me the basic functionality that I need in a convenient way, making my old FTP software redundant. It’s free, quick, easy to install and a doddle to use. The lack of overwrite warnings is bound to trip me up at some point, but let’s see how that goes.
Seriously give this a try – it’ll make using your Raspberry Pi just that little bit easier, saving the proper headaches for the code itself!
Until next time…