Brain Coral Tutorial: Hello Galileo

Version 16

    We will go over two different methods of creating a new file on your Galileo. One involves editing and creating files directly on the board through the command line. The other will use your host computer to create and transfer files to your Galileo. There is also a third option that uses SFTP described here: Running ftp server on Galileo


    Using vi editor

    The default editor that comes with Unix is called visual editor, known as vi. We will use this to create and edit a new file directly on the board.


    1. Create a new file using vi

      While in the "projects" directory you created earlier, create a new file called "1-1-hello-galileo.js" by running vi 1-1-hello-galileo.js which will open an inline command editor.

    2. Enter “insertion mode"

      Type "i" to enter "insertion” mode in vi. You will know that you are in this mode when the character on the bottom left side of the screen changes to an input dialog. It resembles a capital letter "I" (with serif).

    3. Instantiate a new “Galileo” object

      The following code creates a reference to the "galileo-io" npm module. We then instantiate a new Galileo object to use in the rest of this file. On the first and second line of your new file, insert the following code:

      var Galileo = require('galileo-io');
      var board = new Galileo();


    4. Add some sample code:


      board.on('ready', function() {   
          console.log('Hello Galileo!'); 


      When the Galileo board is ready, the code inside the function will run.

    5. Save and close the file

      Now it’s time to save the file and close the vi editor. Press the escape key to exit vi's insertion mode. This will go into vi’s “command” mode. You will know you are in this mode by looking on the bottom left of the screen. The input symbol will change into a single dash, which is followed by the file name.

      To write (save) the file and quit out of vi, type :wq while in the command mode. This will take you back to your current directory and out of the vi interface. Now, run the code by executing: node 1-1-hello-galileo


    Node knows that you are executing a JavaScript file, so there is no need to include the “.js” file extension. You should see the 'Hello World!' string logged in your terminal. Pressing the "ctrl" + "c" keys together will close the node server, and take you back to your current directory.


    Using the Secure Copy command

    The second method, and perhaps an easier method of writing files to your Galileo, is to use Secure Copy (SCP). The SCP command is a Unix command that allows you to securely copy files from your host to a remote computer on your network. If you haven’t already, create a directory on your Galileo called "projects". We will transfer project files from your host PC to this folder.

    To use secure copy on a Windows machine, you’ll need to install software to do so.


    scp on Windows

    1. Download and install WinSCP

      To be able to copy files to your Galileo, you can use a free tool like WinSCP. After installing it, you will need to set up the source (a folder on your computer where the source files will be) and the destination (a directory on the Galileo) directories for the files that will be copied.

    2. Create a new file

      Create a file named “1-1-hello-galileo.js” (also done in the vi section) on your host. Then, drag over the files to the "projects" directory on your Galileo. Log into Galileo using SSH or telnet to test the file transfer.

    3. Test your new file

      Within the command line on Galileo, navigate to the "projects" directory and ensure your file transferred properly by running the list command, ls. You should see your file listed. Test it out by executing node 1-1-hello-galileo.

    The full code for 1-1-hello-galileo.js is:


    var Galileo = require('galileo-io');
    var board = new Galileo();
    board.on('ready', function() {
        console.log('Hello Galileo!');


    scp on Mac/Linux

    The scp command is built into the system and will be used via the command line. After creating a project folder and file on your host, and a project folder on the Galileo, you can copy over the file using the SCP command.

    1. Copy a file to the Galileo using the scp command

      In your terminal, navigate to the root folder "projects" and run: scp -C 1-1-hello-galileo.js

      The -C flag compresses the file over the network for a faster transfer. This will copy the “hello-galileo.js” file over to the Galileo’s “projects” folder. Replace the x placeholders with your board’s IP address.

    2. Run the code

      Back in your command line on your Galileo, navigate to the "projects" directory and run: node 1-1-hello-galileo



    If you would like to transfer an entire directory and it’s content, use the -r flag and the directory name while invoking the SCP command. This is something you may want to do the first time you transfer over many files using one terminal command. For example:


    scp -C -r path-of-source-directory


    The -r flag stands for “recursive”, meaning that it will process all of the files in the current and subdirectories. If you are currently in the source directory in your host terminal, you can replace the full path name with a period:


    scp -C -r .

    < Setting up your environmentReading analog input using galileo-io >