Get started with Intel Edison and Node.js
In this guide we will build a simple Node.js web server project on a Intel Edison. At its most basic, the process for deploying code to a Intel Edison consists of two major steps:
- Setting up your Intel Edison with balenaOS, the host OS that manages communication with balena and runs the core device operations.
- Pushing your Node.js project to the balena image builder, which pulls in all necessary dependencies and creates the container image for your application.
Once these steps are finished, your Intel Edison will download the container image, kick off your application, and begin sending logs to your balena dashboard!
What you will need
- An Intel Edison
- A base board for the edison that has an USB-OTG port. Any of the following boards will do the trick:
- A micro-usb cable
If you find yourself stuck or confused, help is just a click away:
The troubleshooting section of the forums is where our engineers address any issues you may be having with balena.
You can read more about our approach to support here.
If you don't already have a balena account, make sure to sign up.
Adding an SSH Key
Balena uses git to push code from your computer to a dedicated repository. As part of the account creation process, you will be asked to add a public SSH key. The SSH key secures your connection to our server, letting us know you have the authority to make changes to the repository.
Note: You can click Skip to move past this step for now, but you will not be able to push code to your Intel Edison until you have added a public key to your account. This can be done at any time from the Preferences page on the dashboard.
If you have a public SSH key, simply paste it into the box provided and click Save Key:
You can also import your key from GitHub. If you choose this option, you will be asked to enter your GitHub username:
Don't have an SSH key?
If you are unfamiliar with SSH keys, we recommend you take a look at GitHub's excellent documentation. This will walk you through everything you need to create a key pair. Window's user? Be sure to check out these instructions.
Create an application
An application is a group of devices that share the same architecture and run the same code. When you provision a device, it is added to a specific application, but can be migrated to another application at any time.
To create an application, select the Intel Edison device type, select an application type, enter a name, and click Create new application:
Note: To create an application with multiple containers, you'll want to use the starter or microservices application type. The starter applications are full-featured and free for all users, with a limit of up to ten total devices across all starter applications.
This will take you to the dashboard for your newly created application, where you can manage your whole fleet of Intel Edisons.
Add your first device
To connect with balena, your Intel Edison will need a balenaOS image that is configured for your device type, application, and network. Start by clicking Add device in your application dashboard:
For most applications, you will have the option to select a device type. By default, the device type you chose when you first created the application will be selected. Applications can, however, support any devices that share the same architecture, so you can choose another device type if needed.
After selecting a device type, you will see a list of available balenaOS versions. In general, the most recent version is recommended. You can also select whether you would prefer a Development or Production edition with the respective toggle:
Note: When you're first getting started, a Development image will be most useful, as it permits a number of testing and troubleshooting features. For production use, be sure to switch to a Production image. More details on the differences between Development and Production images can be found here.
A toggle is also used to select whether your network connection will be through Ethernet Only or with the option for WiFi + Ethernet. Selecting Wifi + Ethernet allows you to enter a WiFi SSID and WiFi Passphrase:
Clicking Advanced presents the option to select the rate at which your device checks for updates and the option to download just a configuration file (
config.json) rather than an entire image:
Once you have finished your image configuration, click the Download balenaOS button. When the download completes, you should have a zipped image file with a name like
FirstApp is the name you gave your application on the dashboard.
Provision your device
In order to deploy code on the Edison, you'll first need to flash new firmware () onto the device's internal eMMC.
Note: This will erase the current yocto OS system on your Edison and any data or configurations you have on it. If you have to revert to the old way of doing things, you can restore your Edison to its factory default firmware by following the instructions in our restore original Edison firmware guide.
Install Intel Flash Tool Lite
First you will need the firmware flashing tool provided by Intel. So head over to this link and get it set up on your computer.
Warning: There is a known issue with the flash tool and OSX 10.11 - El Captitan. In this case, we recommend using the flashall scripts and dfu-util.
Flash the balena Firmware onto the Edison
Note: Before you start this step, ensure that your Edison is not plugged into your Computer.
On your computer open the newly installed Flash Tool Lite. Select the blue browse button in the top right hand corner and browse to the folder where you had previously extracted balenaOS. This folder should be called something like
balena-myFleet-0.1.0-0.0.14. In this folder you should be able to find and select a file called
The flash tool will auto-detect the configurations for flashing, so you do not need to adjust any of the drop down menus. Your flash tool panel should look something like this:
Once you are satisfied you have selected the correct
FlashEdison.json file from the correct folder, you can click the
Start to Flash button in the bottom left of the flash tool. The flash tool will now try and detect if the Edison is plugged in.
At this point, plug your Edison into your computer using the micro usb cable.
Note: It is important that your Edison is connected via the OTG-USB port on the base board. If you are unsure of which micro usb port this is, have a look at this image.
Once your Edison is connected to the computer, the flash tool should auto-detect it. A device will appear in the central pane of the flash tool and you should see the progress of your Edison Firmware flashing.
Note: If you get stuck at this point or your device never shows up on the balena dashboard, please let us know over on our forums.
Once your Edison has reached 100% on the progress bar, the flashing process has completed, but the device still needs to reboot. Let your Edison sit for about 2 minutes.
After a successful firmware flash, you may get a warning pop-up. You can safely click
Alternative method of flashing Edison firmware for Mac OSX 10.11 - El Capitan
To use this method, you will need to have MacPorts installed on your system. Once MacPorts is installed, run the following in your terminal:
sudo port install dfu-util usbutils coreutils && sudo port activate dfu-util
Make sure the Intel Edison is unplugged from your system, then unzip the downloaded balenaOS image. Navigate to the unzipped directory and run the following:
sudo chmod +x ./flashall.sh sudo ./flashall.sh
Plug in the Intel Edison, as per the instructions on your terminal. You can check the progress of the flash on your terminal. Once the flashing is complete, your Edison will need to reboot.
Now that we have a device or two connected to a balena application, let's deploy some code and actually start building something.
To clone the project, run the following command in a terminal or your preferred git client:
$ git clone https://github.com/balena-io-projects/simple-server-node.git
Note: This project runs an application in a single container. If you would like to start with a multicontainer project, run
git clone email@example.com:balena-io-projects/multicontainer-getting-started.git.
Once the repo is cloned, change directory into the newly created
simple-server-node directory and add the balena git remote endpoint by running the command
git remote add shown in
the top-right corner of your application page:
$ cd simple-server-node $ git remote add balena <USERNAME>@git.balena-cloud.com:<USERNAME>/<APPNAME>.git
Note: On other git clients there may be an alternative way to add a remote repository.
So now we have set up a reference in our local git repository (the one on our development computer) to the balena application remote repository. So when we push new changes to this remote repository it will get compiled and built on our servers and deployed to every device in the application fleet.
Warning: The balena git repository is not intended as a code hosting solution, and we cannot guarantee the persistence of data in balena git remotes.
Now to deploy this code to all device(s) in the application just run the command:
$ git push balena master
If you want to completely replace the source code of the application with a new source tree, you may need to force the push by running
git push balena master --force, due to how git works.
Note: On your very first push, git may ask you if you would like to add this host to your list of allowed hosts. If the ECDSA key fingerprint matches
SHA256:NfwmqnKId5cx1RWpebbEuuM87bCJbdyhzRnqFES9Nnw, you are pushing to the right place. Type 'yes' to continue.
You'll know your code has been successfully compiled and built when our friendly unicorn mascot appears in your terminal:
This means your code is safely built and stored on our image registry. It should only take about 2 minutes to build your code and subsequent builds will be quicker because of build caching.
Your application will now be downloaded and executed by all the devices you have connected in your application fleet. You may have to wait about 6 minutes for the first push... So time for more tea, but don't worry, all subsequent pushes are much, much faster due to Docker layer sharing. You can see the progress of the device code updates on the device dashboard:
You should now have a node.js web server running on your device and see some logs on your dashboard. If you go to the
Actions page for your device, you can enable a public URL, this URL is accessible from anywhere in the world.
If you follow the URL, you will be served a page saying "Hello, World!". Alternatively you can point your browser to your devices IP address.
- Learn more about the Dockerfile that is used to build your application.
- Build an application that uses multiple containers.
- Get to know the web terminal, which can be used to SSH into your application containers and the host OS.
- Try out local mode, the most efficient way to rapidly develop and test your balena application.
These example projects will give you an idea of more things that can be done with balena:
SORRY! we currently don't have any other Node.js projects for the Intel Edison. How about submitting one to us at firstname.lastname@example.org?
Enjoy Balenafying All the Things!