ARM mbed Ethernet Starter Kit

By | January 5, 2017

Embedded systems are all about being lightweight, and only including what is really needed. This is sometimes the case for evaluation boards, but other times, evaluation boards come with multiple peripherals. This board is different, it comes with a large array of sensors and peripherals, almost as much as can fit on the board itself, and is designed to get you up and running in two fields; mbed, and IoT. Many thanks to element14 for providing me a board to test, and to play with.

Box Contents

The box contains two boards; Freescale’s FRDM-K64F, and the aptly named mbed Application Shield. There is also a long micro-USB cable, and a quick start guide. The Application shield uses an Arduino R3 shield header style, and fits snugly onto the FRDM-K64F’s exterior connectors.

FRDM-K64F

The FRDM-K64F is Freescale’s Cortex-M4 based Freedom Platform. This board has an RGB LED, an accelerometer and magnetometer, and two user buttons, but it doesn’t stop there. It has a micro-SD slot for data storage, and an Ethernet port for data transmission. With 1 MB of flash memory and 256 KB of RAM, this microcontroller is more than powerful enough to handle data sampling and transmission, and was therefore an excellent choice to include in the mbed Ethernet Starter Kit.

One important thing to take into account, the FRDM-K64F does run a little warmer than some other boards. That doesn’t mean that it requires a radiator or fan, but since the FRDM-K64F is located under the shield, it means that the temperature sensor is sometimes off by a few degrees.

mbed Application Shield

The mbed Application Shield is an Arduino R3 compatible shield, with about as many different sensors and peripherals as it was possible to fit on the board. It contains a temperature sensor, an accelerometer, a speaker, another RGB LED, two potentiometers, a 5-way joystick, a nice back-lit LCD screen, and a header for adding either a Wi-Fi or XBee module. The underside of the board has the connectors, but also a table listing the components, and how to access them (for example, the LM75BD sensor can be accessed at 0x90, and the blue component of the LED is controlled through D8). There is even a URL printed on the bottom, leading you to the mbed site where you can find even more information on the board, as well as example programs.

The LCD screen is a nice 128×32 pixels display, and is easy to read. The two potentiometers are large, and can easily be turned using your fingers, no need for a precision screwdriver. The joystick sits in between the potentiometers, and while I cannot easily push it left and right with my thumb, I can if I switch to my index finger. The RGB LED is nice and bright, and interesting feature, the temperature sensor is also easily accessible, so long as you don’t have an XBee or RN-XV module. You can put your finger on it and see the temperature update very quickly, great for debugging.

The Default Program

This kit comes with a program pre-flashed. While most default programs look something like a blink example, this one is very different. The quick start guide tells you to connect an Ethernet cable to your kit, and then to power it up through the USB connector. When you do this, two things happen. First, the LCD screen displays a message, informing you that it is attempting to connect to a server. Secondly, the host computer detects a removable storage device.

For those of you who are not familiar with the mbed platform, let me explain. ARM’s mbed is a web-based development platform. Instead of having your IDE and compiler suite on your computer, they are on ARM’s servers. You write your program with a web browser, and click compile when you are ready. This compiles the program using ARM’s compilers, and then delivers a download; the binary file.

mbed devices are detected by the host computer as a USB storage device, equivalent to a very small USB pen drive. By placing the binary file inside this folder, the USB driver puts the board into programming mode, flashes it, and resets it. It really is that simple to flash mbed devices.

On the storage folder itself are two files. One of them contains build information, but the second one, IBM.HTM, is where the magic happens. When you click on that file, you are redirected to IBM’s website. During this time, the kit should have connected to Internet, and started uploading data to IBM’s cloud. If everything went well, you will now see a webpage with different sensor data, refreshed periodically. Shake your kit a little, or blow on the temperature sensor to see the output change. Congratulations, your IoT kit is up and running!

This is what IoT is all about. Of course, you can see your kit’s data, but the data from every default kit currently connected is being sent to IBM’s cloud. Your kit is now generating little data, and that data, combined with the data from other kits, can become big data. See how easy it was to send your data? Now imagine what you could do with that data…

Bluemix

Imagine a few thousand kits, all connected together, and imagine that you have access to the data being generated. What could you do with it? A temperature sensor network, something that will give a more accurate estimation than what you can find on the weather forecast? Or maybe an earthquake detection system, using the accelerometers. You might just have the next killer IoT project. Whatever your design, you first need to get that data, and then start sifting through it. If someone leaves a kit in direct sunlight, then one of your sensor readings will be false. If someone drops a kit, then your earthquake detection system will register a single quake. The system needs to know that this particular reading is an error, by comparing data from nearby sensors. This data storage and manipulation requires resources, and that is where Bluemix comes in.

Bluemix is IBM’s IoT solution. Your job is to create sensors, and theirs is to retrieve the data, and allow you to create programs to visualize and act upon that data. Bluemix isn’t free, but a Hobbyist or Start-up plan is free, allowing you to use the platform and see how it can help you develop that killer IoT application. It provides everything you need to get your application up and running; concentrate on your sensor application, and Bluemix will serve as a gateway, allowing you to publish your data to the cloud. IBM will take care of the security of transactions, both on their website to view your data, but also while uploading data.

mbed

This board is designed specifically with mbed in mind, and as such, it makes development much easier. The CMSIS device means that flashing can be done simply by dropping a binary into the MBED device. The mbed platform itself recognizes the kit, not just the and gets you up and running in seconds. There are a number of example programs available, and can serve as a starting point for your application.<br />For those unfamiliar with mbed, it is ARM’s IoT spearhead, allowing development to be done using any web browser. You don’t need to install a development environment, the editor, compiler, linker and any other tool you need are already available, already set up, and ready to be used. Enter your code, hit compile, and the server will send you a compiled binary, all you have to do is to copy this file to the USB flash drive detected by your computer, the CMSIS device does the rest.

Example application

This summer has been a pretty hot one. I work in a home office, and the temperature inside has gone above 30°C, and being British, that is pretty unbearable for me. I have a small USB fan on my desk, it is something a geek would have, but it doesn’t have an on/off button, you either connect it, or you don’t. I use a large desktop case, and the USB ports aren’t easy to get to. I wanted to use the ARM mbed Ethernet Starter Kit to help me out, but I have myself 5 minutes. I have to be able to connect the board, program, and flash my solution in 5 minutes only. The electronics were done beforehand, and are simple. The fan is connected to the USB port of my computer, and the power line is put through a relay. The relay is activated by the power line of the ARM mbed Ethernet Starter Kit, and goes into a digital I/O pin; when the pin goes low, the relay is powered, and the fan starts. If the I/O pin goes high, then the relay deactivates. To help debugging, the on-board LED will also light up.

The aim is simple. Read the temperature, and activate or deactivate an output according to a threshold. The threshold will be generated using one of the potentiometers. Both values will be displayed on the screen.

Start the clock. I created a new project, using a “Ethernet IoT Starter Kit” blank project. First things first, we need to import some libraries. Using the import wizard, I imported the mbed library, since that will be required. The temperature is read using the LM75B, and there is a library with the same name. However, in the shield examples, there is a library called TMP102, and this is the one I chose to use. Why? Well, example code, and I need everything done in 5 minutes. The screen is controlled by a C12382, and once again, there is a library by the same name. There is no need to look at the hardware to see what libraries to use, the example programs already use the libraries, and give an excellent starting point.

The libraries have been imported. Time to start things up. The mbed environment is based on C++, so first of all, everything needs to be imported:

Next, for a basic version, three things need to be set up. We will be reading from two sensors, and outputting to the screen. The digital output and the LED will be done later. To set up the sensors and output, use this:

The values here aren’t random, they are written underneath the board, and also used in the examples on the mbed website. The first line creates a TMP102 object called temperature, specifying the communication pins, and the I2C address. There is no need to write specific I2C calls, everything is already done, and we will see that later.

The threshold will be set using the potentiometer, and analogue device connected on pin A0 (and again, this is written on the shield’s underneath).

To output the data, the LCD screen will be used, and it is done using a C12832 object, written on line 3.

Now, my programming background makes me create functions to retrieve sensor data, but in both of these sensors, that isn’t really needed, as you will see. Here are the two functions I created:

Now, time to add a loop. This loop will read in sensor data, write out that data, wait for a second, and the repeat, forever. The loop will be made like this:

Now, save the file, compile it, wait for a few seconds, and your browser will ask you if you want to save a file. Accept, save this file directly onto the mbed flash drive, and you have now done something that normally takes software licences, installation time and expensive flashing tools to accomplish. That’s all you have to do to get your application up and running. Time to test it.

This application isn’t complete, but it does let us test out a few things. Start up the board, and two lines of text will be displayed. First, the current temperature, and secondly, the threshold. Move the potentiometer Pot1 around, and the change will be seen on the screen. For my version, I set it for temperatures between 0 and 40° Celsius, but you can change it to anything, including some very precise setups. The application works fine until now, and I have two minutes left, so let’s add a few lines. The underside of the shield tells us that the ZigBee TX line is D0, and since this application doesn’t need ZigBee, let’s use that. Time to use that as an output:

Now, inside main, let’s make sure that the output is by default set to a logical high, which, if you remember, turns the fan off. This can be done in a single instruction:

We also need the LED to turn on, which might require a few more lines. This LED is an RGB led, and uses three outputs:

Just like the relay, the LED uses open collectors, so turning the digital output high will turn the LED off. So, let’s turn the LED off by default:

Now, the last thing to do is to create something that turns the output/LED on and off depending on the readings. I have a few seconds left, so this is done quickly:

Time’s up. Compile, and flash. There are my 5 minutes, and it works. If I set the threshold, it turns the LED on and off depending on the temperature. A few minutes more with a breadboard and a few tools, and everything is up and running. That’s it, I feel better already; this is keeping my face cool, and using technology.

Conclusions

While mbed is made to be as easy as possible, it still remains extremely complex. The amount of libraries available is staggering, and like any technology, you need to spend time getting to know it better. Embedded is all about being small, and having only what is really needed, but this kit is the opposite, it is a concentration of technology available to be used. This example was literally a five-minute experiment, but the amount of sensors on board makes it a complete solution to prototype a number of possible applications. It has enough input and output to experiment with a large amount of technologies, from simple serial communications to something that isn’t available on a lot of systems, ZigBee/RN-XV.

The ARM mbed Ethernet Starter Kit is different from most kits in that it has embedded networking, and with its large amount of sensors, it makes it ideal for IoT applications, and with the mbed platform and IBM’s cloud. This kit is highly recommended for several reasons; to get to know the mbed platform, to understand IoT and what can be done, but also to use IBM’s IoT platform.

Thanks to Farnell element14 for providing a board for evaluation.

Leave a Reply

Your email address will not be published. Required fields are marked *