DiY IoT: Energia dev environment
If you haven't read the first installment in this series, I recommend you do it now. I'll wait...
If you are not in the mood—I know, you will do it later, I trust you—you can download the latest version of Energia here. (You will need it if you wish to follow along.) Another thing you need is Java runtime environment, it can be downloaded here.
As you will notice fairly quickly, Energia is a development environment that requires no complicated switches, flags, or options that might become a pitfall especially if you are fairly recent to the trade. Mostly, it streamlines your work, making most actions just a matter of writing your logic and clicking a button to both compile and upload to the platform. As part of this strategy, most of your solutions will consist of creating a single source file, so returning to previous work after period of absence will be as simple as a one-sweep review.
Another huge benefit is the built-in libraries that come with Energia; we will review some of these in later posts. This collection of libraries will make your programming experience more pleasant than you can imagine! In fact, because of these libraries, most complicated tasks (like talking to a peripheral over I2C or UART) can be achieved with two to three lines of code.
There are several best practices you can follow to enhance your experience further:
1. Do not be shy. If you feel that your project is complicated enough to justify it, add a second file (or third, or as many as you feel comfortable with)! Clear representation is as important in Energia as it is in any other IDE.
2. On the same subject, header files are less explicitly presented when first starting with Energia, but they can be used just like in any other IDE. Adding and including .h files will do the job.
3. Energia comes with a large variety of libraries that make your life easy, but they only help if you take your time to get familiar with them. Sometimes you might find yourself implementing a mechanism that already exists.
4. Although it looks different, Energia uses a good old C++ compiler, so (almost) anything that works in normal C++ should work here.
5. Remember the limitations of your hardware platform. Code space is precious, so if you find yourself writing elaborate mechanisms and drifting to over-complicating your project, it might be wise to stop, review, and simplify. It is hard to describe the anguish of finishing a beautiful piece of code only to see your world shatter when a compiler says your program will not fit on the device.
Before we begin, you will need to install the appropriate drivers to allow your LaunchPad to be properly recognised and enumerated. Like most modern development boards, LaunchPad is equipped with an FTDI chip that emulates serial and JTAG protocols over USB; this will be our way to communicate with and program the LaunchPad. (If you are on a Mac, the appropriate driver can be downloaded here.)
After downloading, you will need to unpack the ZIP file, run the resulting PKG file, and restart your Mac.
At this stage, we are safe to connect the LaunchPad to the computer—it should be recognised automatically. If you have any problems or doubts, it is possible to verify proper enumeration in several ways:
1. Check the output of "sudo dmesg" command—it should look something like:
FTDIUSBSerialDriver: 0 451c32a start—ok
2. Check the list of /dev/cu.usbserial-* devices; a new one should appear in the list once you connect the LaunchPad. (In my case, it was conveniently named /dev/cu.usbserial-cc3101B, but it might differ slightly for you.)
Prepare the board for programming
To prepare the board for programming, there is a simple step we need to complete: While holding the LaunchPad such that USB connector is facing upwards, look at the row of jumpers in the middle section. Find the jumper labelled J8; it should be on the far left of the board. Attach a wire to the upper leg labelled TCK. Now locate a jumper labelled J15 in a section labelled SOP on the far right of the board, and attach the other end of the wire to its lower leg, which is labelled 2. In other words J8—>SOP2.
This is how the connection should look:
|Related Articles||Editor's Choice|
|Related Articles||Editor's Choice|