We finally have the Adafruit WebIDE in a place where we think it's solid enough for a beta release. First, a disclaimer: this release will likely have bugs, and minor issues.
The Adafruit WebIDE is by far the easiest way to run code on your Raspberry Pi or BeagleBone. Just connect your Pi or BeagleBone to your local network, and log on to the WebIDE in your web browser to edit Python, Ruby, JavaScript, or anything and easily send it over to your Pi. The WebiDE includes a terminal, so you can easily send various commands to your Pi right from the browser. Also, your code will be versioned in a local git repository, and pushed remotely out to any remote git repository so you can access it from anywhere, and any time.
Installation
Easy installation:
Log into your Raspberry Pi. If you're on a Mac, you can open Terminal.app to log into the Raspberry Pi over SSH. Linux users can open the default terminal application. If you're using Windows, you'll want to download a good terminal application. My favorite is PuTTY.Once you have the terminal application open, assuming you're using Occidentalis, type in the following:
$ ssh [email protected] [email protected] password:
curl https://raw.githubusercontent.com/adafruit/Adafruit-WebIDE/master/scripts/install.sh | sudo sh
The editor will be installed into /usr/share/adafruit/webide using the user webide. The script will install node, npm, redis-server, git, and i2c-tools. If you'd like to review the script, it's located in our repository.
**** Starting the server...(please wait) **** **** The Adafruit WebIDE is installed and running! **** **** Commands: sudo systemctl {start,stop,restart} adafruit-webide **** **** Navigate to http://raspberrypi.local:8080 to use the WebIDE
Due to our very small development team, and limited resources, the only browsers that are supported are Google Chrome, and Mozilla Firefox at this time. We hope to support more in the future!
Manual Installation:
You can manually install the editor by following along in the following installer script and choosing the components you'd like to install:
https://raw.githubusercontent.com/adafruit/Adafruit-WebIDE/master/scripts/install.sh
curl https://raw.githubusercontent.com/adafruit/Adafruit-WebIDE/master/scripts/uninstall.sh | sh
You can also manually uninstall by removing the following components:
- Delete the folder the editor exists in.
- Uninstall nodejs npm redis-server git avahi-daemon i2c-tools.
Getting Started
Setting up your Rapsberry Pi WebIDE will only take a few minutes. Let’s get started.
First up, you will connect to the WebIDE (running on the Pi) using a different computer (not the Pi). The client computer must be on the same network.
Open up a web-browser on a computer that shares the same networks as the Pi and browse to either http://raspberrypi.local:8080 if you are running Raspian/Debian Stretch, or to http://xx.xx.xx.xx where the x's are replaced with your Pi's IP address.
Using the WebIDE
When you first load up the WebIDE for the first time, you should see something similar to what you see above (click on the image to view it in its full size).
- Here is where you can view your editor settings.
- Here is a list of all of your repositories. The Adafruit Raspberry Pi Python Code repository (https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git) is automatically cloned into your Bitbucket account. We have also created a my-pi-projects repository. If it has the little folder icon, that means there are files contained within. If it has an arrow icon, that means it is a file that can be viewed in the WebIDE.
- Click here to clone a repository from Github or Bitbucket. Follow the instructions in the popup.
- No matter where you are in the WebIDE, there will always be a terminal button. Click this to talk directly to your Raspberry Pi, or do things like install libraries without leaving the WebIDE. Handy!
- When you first log in (or refresh your WebIDE in your browser), you will be greeted with a nice message. Read this for any news on the WebIDE.
- As with any piece of code, you can simply click the Run button to execute the code on your Raspberry Pi. The terminal will automatically open when you click Run.
- The Adafruit code is read only, but you can easily copy this code to your my-pi-projects repository. Just click this link and it will automatically copy the folder, and all of its contents over.
- If you want to create a new file, press this button, and name your file (make sure to add a proper file type, like .py to the end of your name, otherwise the editor won't know what to do with it). Then click save to add your new file to the current folder.
- You can also upload a premade file. Once again, make sure it is named properly before importing. You can also import images to the folder (and view those images right in the IDE).
- Make sure to click save after making any changes to code. This will then update the files in your Bitbucket account.
- Just right click on any of the files that you want to change and the following box will pop up. Click delete to permanently delete that file. If you click rename, you will be asked what name you want the file to change to. Make the change, then click save.
- If it is green, and says 'Connected', that means the WebIDE is communicating with your Raspberry Pi. If it is disconnected, the WebIDE will keep trying to make contact with your Pi for awhile, then it will finally give up. It will then ask you to reconnect your Pi, and refresh the browser.
- You can log out of your Bitbucket account at any time by clicking Log out.
In order to see if there are updates available, refresh your browser every day.
Once the WebIDE is installed, you can shutdown (shutdown -h now) or restart (shutdown -r now) your Pi anytime. The next time you want to use it, just start your Pi, and reload raspberrypi.local to log back into the WebIDE.
Using the Debugger
When would you use the debugger? One scenario would be if you're just not getting the right values returned out of your functions. Or your variables aren't being set to the values you'd expect. You could then debug it, set a breakpoint to where you think it's broken, and see exactly what the values are at that given moment in your program. Also, you could use the GPIO pins to light various LED's. As you step through your program, you'll see them turn on and off as you'd expect.
To use the debugger, open a python file, and click the "Debug" link in the toolbar:
Once the debugger is ready, you'll see the following:
The first think you'll notice is the toolbar (#1) has new buttons available:
- Save/Restart allows you to save your file, and restart the debugger for that file in one click. You can initiate that by hitting control-s, or command-s (on OS X).
- The Exit link will exit the debugger.
- The Run link will continue execution of your program either to the end, or to the next breakpoint you have enabled. If there is a breakpoint enabled (clicking in the gutter (#6)), it will stop there, and wait for your instruction.
- Step Over will step through your program line-by-line until it hits the end. This option will skip any function calls. So, if you have a function called foo(), it will just run the entire function, and move to the next line.
- Step In will step through your program as well, but it will jump into many of the functions, instead of skipping over them.
At the bottom two panels, you'll see the Debug Output (#3), and the Debug Variables (#4). The Debug Output displays anything from stdout or stderr that your program would output (such as print statements). The Debug Variables displays the live variables as they're being assigned.
The red line in the editor (#5) moves as you step through your program. It is the line that will execute next, and will stay centered in the editor window as you step through your program.
At the far left of the editor (#6), there is a blank space to the left of the line numbers. This is called the gutter. If you click in the gutter when the debugger is in a "Ready" state, you can add breakpoints. A breakpoint is useful for many situations, such as if you have a longer script, and there is a certain troubling section that is buggy. Instead of slowly stepping through your program you would set the breakpoint (a red square will appear in the gutter), and then click "Run". The script will execute to the breakpoint, and the red line will stop, and wait for you to continue stepping through it.
The last feature you'll want to be aware of is the debug status messages (#7). These will show you what the debugger is doing. For example, when it initially loads, or when you click "Save/Restart", it will be in an "Initializing..." state. When it's ready for your input, it will be "Ready". Some parts of your script will cause it to appear locked up, but it's really waiting for the server to return a response from your script (a long sleep() statement could cause this, for example).
At this point in the debug cycle, you could edit your file, and Save/Restart. You could continue stepping through the program, or you could Exit the debugger.
Using the Visualizer
Generally, the visualizer is a good tool to use if you have simpler scripts that you'd like to understand. Some of the questions it will help you with are: "How does recursion work?", "How does a function call work?", "How do various methods, such as append, work when working with lists?".
Starting the visualizer
In order to start the visualizer, open a python script that you're able to run. In the menu, there will be a link with the title "Visualize". Click the "Visualize" link.
The next screen you'll see is the following:
The code (#2) is listed to the left. As you step through your program, you'll see two arrows in the left gutter that will show you what line has just executed (green), and what will be executing once you click "Forward" (red).
The right column displays the stack (#3) as your program executes. You'll see your variables getting assigned, objects being created, etc.
The bottom pane is your program output (#4). Anytime you have a print statement, or any other type of output, you'll see it displayed in this section.
Here is a screen shot of how it looks while stepping through a program:
Credit to the visualizer is given to Philip Guo at pythontutor.com. We forked, tweaked, converted, and modified his open source creation to work as a streamlined feature within the WebIDE.
FAQ
The default is port 8080. You can change the port by editing the systemd service at the following location:
/etc/systemd/system/adafruit-webide.service
This can happen any number of ways, such as with an SD card that is bad, or if you shut your system down while a commit or push is in progress, or any number of other ways.
You can find out what the real issue is by viewing the log file.
Open the terminal in the webide and execute the following: cd /usr/share/adafruit/webide/logs
Then execute the following command to view the last few commands from the log file: cat output.log
You can also view the errors.log file: cat errors.log
If you see an error such as:
error: object file .git/objects/2c/e98048b95181870dbba33675f3d2bc1d995c47 is empty
fatal: loose object 2ce9804 (stored in .git/objects/2c/e98048b95181870dbba33675f3d2bc1d995c47) is corrupt
You can try fixing that by following this fix from Stack Overflow.
This guide was first published on Oct 05, 2012. It was last updated on Nov 01, 2023.