ARM mbed is a rapid development platform for ARM-based microcontrollers with an online IDE, community and cookbook of ready-to-go hardware and libraries. In this tutorial, we will connect the mbed LPC1768 board to Xively, and log a few values over an ethernet connection to test our connectivity.
Specs Overview: (LPC1768 Microcontroller):
|I/O Pins||2xSPI, 2xI2C, 3xUART, CAN, 6xPWM, 6xADC, GPIO|
|Flash Memory||32KB RAM, 512KB|
|Clock Speed||96 MHz|
|Programming Language||C/C++, Online IDE|
Connecting the mbed
If this is your first time using the mbed platform, you’ll need to create an account at mbed.org. To do this, simply plug the mbed Microcontroller into your computer using the USB cable provided.
On your computer, the mbed board will show up as a new disk containing a file called MBED.HTM. Click this file to go to the account registration page for mbed.org. Follow the signup instructions and you’re in!
Your hardware is now all set! If you haven’t already plugged the mbed NXP LPC1768 into the Application Board, you can do that now.
If you’d like to make sure everything’s working, try this:
Click to import a “Hello World” program into your mbed online IDE.
Click “Compile” on the toolbar. The online IDE will create a file containing your program - wait for it to download.
Drag the compiled
Hello_World_LPC1768.binfile onto the mbed drive on your computer.
Now you have put your compiled “Hello_World” into the mbed. Press the reset button on the NXP LPC1768 board.
You should see a blue blinking light on the board. Congratulations! You’ve made the hello world of physical computing.
Import the Jumpstart Demo
Now it’s time to work with some code of our own. Our project is going to use the Xively mbed library to make connecting to Xively easy.
To get things started, import the Xively Jumpstart Demo program into a new project on your online mbed IDE.Click Here to Import the Xively mbed Jumpstart Demo
This project includes both the code that will run on the mbed, and all of the libraries that make it easy to connect to Xively and use the features of the Application Board.
Once you've imported the Xively Jumpstart Demo, notice all of the libraries that are now in your project's sidebar. These libraries allow us to access Xively and the features of the application board with simple functions in our main.cpp file.
Here are what these new libraries do:
Library Description mbed-libxively The Xively library wraps Xively API calls in a simple interface, and handles the HTTP protocol interaction with the Ethernet library mbed-rtos The mbed Real Time Operating System library defines the OS that runs on the board EthernetInterface The EthernetInterface library includes the networking stack necessary for communication between the LPC1768 and the web C12832_lcd The interface library for the on-board LCD screen MMA7660 The MMA7660 library provides simple access to the on-board 3-axis accelerometer and tilt sensor
Now you will need to open main.cpp and update the values of these two constants: XI_FEED_ID and XI_API_KEY.
Click "Compile" on the toolbar and wait for it to download to your computer.
Connect the application board to the web via an ethernet cable.
Drag the compiled xively-jumpstart-demo_LPC1768.bin file onto the mbed drive and press the reset button on the NXP LPC1768 board.
Go to the device's workbench, and you will see live API calls coming in. When you move the board around, you can see the corresponding channels report the movement - orientation and side_rotation.
Try connecting a Xively feed to any of the inputs or outputs on the Application Board, you have plenty to chose from. Find more demo sketches and inspiration for the mbed Application board on the Application board section of the mbed Cookbook. Have fun!