Introduction: PIC KICK TWEET !
This is an Instructable showing you how to integrate Twitter in your embedded application. Watch this Instructable in Action https://www.instructables.com/id/PIC-KICK-TWEET-1/
Working: A desktop application is created with ease for grabbing the latest tweet from your twitter account. The application then forwards the tweet to the serial port to which the embedded device is connected. A firmware is written to capture the tweet sent by the application. The tweet is displayed on the 16x2 CLCD on the embedded device.
Stuffs your need to complete this Instructable with ease:
Processing (or processing.org as known on the web) is a an opensource programming language and environment for people who want to create animations and interactions with a variety of devices and other applications with ease. Initially targeted at artists and designers with no prior programming experience for prototyping, today it is also used by students, researchers, hobbyist and even professionals to rapidly prototype their ideas by making desktop applications without breaking a sweat. The language is itself based on the popular programming language Java but you need not know Java to start Processing. Processing runs on Windows® OS, MAC® OS and Linux.
MPLABX IDE is a graphical, debugging toolset for all of Microchip's product line of microcontrollers and memory devices.It includes a feature-rich editor, source-level debugger, project manager, software simulator, and supports Microchip’s popular hardware tools.Based on the open-source NetBeans platform, MPLAB X runs on Windows® OS, MAC® OS and Linux, supports many third-party tools, and is compatible with many NetBeans plug-ins.
PIC KICK is an embedded system development board by ENTESLA for Microchip’s 40 pin 8-bit microcontroller. It is a low cost kick start board designed to help professionals, students and amateurs to explore the capability of PIC16, PIC18 architecture and practice application development for various interfaces with minimal hardware reconfiguration. It features a USB-Serial converter on-board, leds,buttons,16x2 Character LCD, Analog Input using a potentiometer and USB. It comes pre-programmed with the ds30Bootloader which makes it easy to program via usb-serial port. And yes.. you can power it using your workstation's USB port.
Working: A desktop application is created with ease for grabbing the latest tweet from your twitter account. The application then forwards the tweet to the serial port to which the embedded device is connected. A firmware is written to capture the tweet sent by the application. The tweet is displayed on the 16x2 CLCD on the embedded device.
Stuffs your need to complete this Instructable with ease:
- A Workstation with a USB port.
- Internet connectivity for the Workstation.
- A Twitter account from which the tweets are to becaptured.
- Processing IDE for creating the desktop application.
- MPLABX IDE with C18 compiler for writing the firmware for the microcontroller.
- A PIC KICK development board from www.entesla.com.
- Enthusiasm.
Processing (or processing.org as known on the web) is a an opensource programming language and environment for people who want to create animations and interactions with a variety of devices and other applications with ease. Initially targeted at artists and designers with no prior programming experience for prototyping, today it is also used by students, researchers, hobbyist and even professionals to rapidly prototype their ideas by making desktop applications without breaking a sweat. The language is itself based on the popular programming language Java but you need not know Java to start Processing. Processing runs on Windows® OS, MAC® OS and Linux.
MPLABX IDE is a graphical, debugging toolset for all of Microchip's product line of microcontrollers and memory devices.It includes a feature-rich editor, source-level debugger, project manager, software simulator, and supports Microchip’s popular hardware tools.Based on the open-source NetBeans platform, MPLAB X runs on Windows® OS, MAC® OS and Linux, supports many third-party tools, and is compatible with many NetBeans plug-ins.
PIC KICK is an embedded system development board by ENTESLA for Microchip’s 40 pin 8-bit microcontroller. It is a low cost kick start board designed to help professionals, students and amateurs to explore the capability of PIC16, PIC18 architecture and practice application development for various interfaces with minimal hardware reconfiguration. It features a USB-Serial converter on-board, leds,buttons,16x2 Character LCD, Analog Input using a potentiometer and USB. It comes pre-programmed with the ds30Bootloader which makes it easy to program via usb-serial port. And yes.. you can power it using your workstation's USB port.
Step 1: Setup Your Twitter
- If you already have a twitter account jump to the developers page for twitter at https://dev.twitter.com/ If you do not have a twitter account create one and jump to the developers page.
- Sign In to your twitter account from the developers page.
- Create a new application as shown in the image.
- Describe your application to twitter.
- Goto the Settings tab. Under Application Type select Access type to Read,Write and Access direct Messages. Wait for a couple of minutes and check if the change has been reflected in the Details tab.
- Twitter uses OAUTH authentication protocol for authenticating applications before they access a twitter account. More about OAUTH at https://dev.twitter.com/docs/auth/oauth/faq
- Once the Access type has been changes Create Access tokens for the application under the Details tab.
- It may take a moment to generate the Access tokens. Once created, goto the OAUTH tool tab to find the keys that you need for authenticating the application that you will be making it the next few steps. Copy these keys to your notepad. Do not share these keys with others.
The most critical step is done now. You now need to create you application before you can start accessing the tweets!
Step 2: Firmware for PIC KICK in MPLABX
As mentioned before, we are going to display the tweets on the 16x2 CLCD present on the PIC KICK development board. To accomplish this you need to write a firmware for interfacing the on-board PIC18f4520 microcontroller with CLCD and routines for transmitting and receiving data on the UART. This seems to be a challenging job for beginners. Thankfully ENTESLA provides libraries with demo codes for these peripherals. The user can use these libraries as reference or use them in their applications for rapid prototyping.
If you are eager to set the PIC KICK in action without making any changes in the firmware jump to the next step..otherwise..
The ready-to-use code for the twitter application project for PIC18f4520 can be found as a .zip attachment to this Step. The code works with MPLABX and C18 compiler. You need to download MPLABX with the C18 compiler and install it before you want to make changes to the firmware.
The firmware provided is pretty straight forward and is well commented.
If you are eager to set the PIC KICK in action without making any changes in the firmware jump to the next step..otherwise..
The ready-to-use code for the twitter application project for PIC18f4520 can be found as a .zip attachment to this Step. The code works with MPLABX and C18 compiler. You need to download MPLABX with the C18 compiler and install it before you want to make changes to the firmware.
The firmware provided is pretty straight forward and is well commented.
Attachments
Step 3: Flashing the Microcontroller
The PIC KICK development board comes pre-programmed with the ds30 bootloader. You can flash the microcontroller with the code easily via the USB-UART bridge on-board. You need not buy/build a separate programmer.
- Download the utility used to program the PIC microcontroller.
- Download the .hex file to flash the microcontroller from the attachment to this Step.
- Execute the ds30 Loader GUI found in the downloaded folder.
- Configure the utility with the COM port number assigned to the PIC KICK development board from device manager.
- Configure the Device as PIC18f4520 and Baudrate as 9600.
- Click Program. You may have to press the RESET button on the PIC KICK board to invoke the ds30Bootloader.
Attachments
Step 4: Creating the Twitter App Using Processing.org
- Download the Processing Environment from http://processing.org/download/ . If you do not have the latest Java environment installed on your workstation download it along the Processing Environment.I am currently using Processing 1.5.1.
- Download the sample code for twitter application from the .zip attachment here. Extract it to an accessible location.
- Open the Twiiter_App file from the downloaded folder using the processing.exe application downloaded from www.processing.org
- Enter the respective keys noted in your Twitter account as in Step 1. into the respective string variables between the double quotes in the Twiiter_App code.
void draw()
{
//Retrieve Last Tweet
lastTweet=readMsg(1);
//Compare it with last tweet
if(tempTweet.equals(lastTweet)==false)
{
tempTweet=lastTweet;
//Write to console
println(lastTweet); //for debugging
//Write to Serial port
myPort.write(lastTweet); //Send the string to serial port
//postMsg(msgOut);
}
else
{
}
delay(20000); //Refresh every 20 seconds
}
Attachments
Step 5: Lets TWEET !
Ok.. Before we start to Tweet here are the things you've got to ensure you have done..
References:
http://robotgrrl.com
http://twitter4j.org
http://www.microchip.com
http://twitter.com
http://processing.org
- Flash the PIC KICK with the .hex provided.
- The PIC KICK development board is connected to the USB port of you workstation. Ensure that the device manager shows the PIC KICK as COM1. Change the COM port number to COM1 if shown a different number.
- The String variables of the authentication keys in the Twitter application code is changed to the respective keys of your twitter account.
- The Workstation is connected to the Internet.
References:
http://robotgrrl.com
http://twitter4j.org
http://www.microchip.com
http://twitter.com
http://processing.org