Monday, March 24, 2014

Reading L3G4200D Gyro sensor via I2C using Stellaris launchPad – PART 1

I got a stellaris LM4F120 launchPad hanging around for sometime. I haven’t done much with that other than trying FreeRTOS on it. Recently I got a cheap L3G4200D from ebay. I read the raw values(XYZ axis angular rate) from it via I2C using the stellaris.

I haven’t yet figured out how to convert it to real angles. In second part I will create a 3D WPF app to display a 3D axis view.

Sensor module i got from ebay have L3G4200D,ADXL345,HMC5883L,BMP085 sensors and its cheap.

Sensor modules I2C SCL & SDA pins are connected to  GPIO pins 6 & 7 ie, PA6 (I2C1SCL), PA7(I2C1SDA) of stellaris 
Value is send to the PC using UART0 which is  connected to the stellaris virtual port which will appear on PC.

Checkout the code in github

Here is the screenshot of raw values received in PC


User manual

Stellaris LM4F120 LaunchPad Evaluation Board Software

Getting Started with the Stellaris EK-LM4F120XL LaunchPad Workshop (Videos & Articles)

Creating a new project 

Blinking LED

Some other tutorials 

Stellaris Launchpad for Beginners

Some code I referred

Online Stores to purchase Texas Instruments products

Tuesday, October 9, 2012

AmazonGlacierGUI - A GUI Client for Amazon Glacier

I have created a tool for Amazon glacier ,

Its a WPF MVVM application in C#

Amazon glacier pricing information is confusing , a pricing calacultor is available at

Tuesday, November 22, 2011

Google reader notes JSON To Delicious Export Tool

I was heavily using google reader notes for the past 2-3 years , as they stopped note in reader service I moved to delicious, I am happy with it, but i have tons of bookmark in google reader notes, I want them exported to delicious, luckily google reader settings page has an option to export notes to JSON format,

I created a tool to export this JSON to delicious.

Goto for the tool & source code

Tuesday, May 4, 2010

A generic excel file Importer / Reader - Converting Excel rows into Strongly typed entity

Its my blog post after a long time ,
Its simply a class it can be used to map Excel columns to an entity fields by adding an attribute to the property

Eg: An excel file with two columns Name and Phone Number
Our Entity is

public class ExcelItem
public string Name {get;set;}
public string Phone {get;set;}
To get List <ExcelItem> containg the excel rows, simply
Importer<ExcelItem> _Importer = new Importer<ExcelItem>();
List<ExcelItem> data=_Importer.ParseExcel("FILE PATH", "sheet1");


using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.OleDb;
namespace ExcelImporter
//3-may-2010 Priyan R
public class Importer where T : new()
public List ParseExcel(string filePath,string sheetName)
string tempFile, connectionString, query;
OleDbConnection con = null;
OleDbDataReader reader = null;
OleDbCommand command = null;
connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
filePath + @";Extended Properties=""Excel 8.0;HDR=YES;""";
query = "SELECT * FROM [" + sheetName + "$]";
var ret = new List();
con = new OleDbConnection(connectionString);
command = new OleDbCommand(query, con);
reader = command.ExecuteReader();
while (reader.Read())
var entry = new T();
foreach (var property in entry.GetType().GetProperties())
var attributes = property.GetCustomAttributes(false);
var attribute = property.GetCustomAttributes(false)
.Where(p => p.GetType() == typeof(ExcelColumnIndex)).FirstOrDefault(); ;
if (attribute != null)
property.SetValue(entry, reader[((ExcelColumnIndex)attribute).Index].ToString(), null);

if (con != null && con.State == System.Data.ConnectionState.Open)
return ret;
public class ExcelColumnIndex : Attribute
public int Index { get; set; }

Download sample application

Friday, November 27, 2009

ASP.NET Validation Controls - Conditionally validating

Using the server side Page.Validate() and Client Side Page_ClientValidate() , we can validate a group of controls conditionally. For eg. i just need to validate some fields only when a checkbox is checked. Both Page.Validate() and Page_ClientValidate() allows to pass a validation group , So we group a set of controls with a validation group and calls this validation functions in both client & server side only on the required validation condition

Server Side

protected void btnSubmit_Click(object sender, EventArgs e)
if (!IsValid) return;
lblMsg.Text = "Passed validation";


function CheckValidation() {
var cbValidate = document.getElementById('<%=cbValidate.ClientID %>');
var flag = true;
if (cbValidate.checked) {
if (!Page_ClientValidate("vgSubmit"))
flag = false;
else {
return flag;


Download Code

Wednesday, September 23, 2009

URL Rewriting with ASP.NET 3.5 using System.Web.Routing.UrlRoutingModule

In 2.0 we used Context.RewritePath() or other URL rewrite modules. With 3.5 its easy to do. I did it for my blog for better SEO.

      • Add reference to system.Web.Routing
        Add System.Web.Routing.UrlRoutingModule http module to web.config
        Implement an IRouteHandler
        Registering routes in global.asax

I am going to rewrite blogs/Posts/{BlogPostID}/{*BlogPostTitle}

I implemented a generic IRouteHandler , it will copy url parameters( eg: BlogPostID,BlogPostTitle ) to http context item collection, so i can URL rewrite any page , without modifying IRouteHandler implementation.

using System;
using System.Web;
using System.Web.Routing;
using System.Web.Compilation;
using System.Web.UI;
public class SiteRouteHandler : IRouteHandler
//30 june 2009 Priyan R

public IHttpHandler GetHttpHandler(RequestContext requestContext)
Page page;
page = BuildManager.CreateInstanceFromVirtualPath(PageVirtualPath, typeof(Page)) as Page;
foreach (var item in requestContext.RouteData.Values)
HttpContext.Current.Items["qparam." + item.Key] = item.Value;
return page;
public string PageVirtualPath { get; set; }

In global.asax added


new Route("Blogs/Posts/{BlogPostID}/{*BlogPostTitle}",
new SiteRouteHandler() { PageVirtualPath = "~/Blogs/Details.aspx" })

So in Details.aspx I can read the parameters


Check the code.

Download Code

Wednesday, August 12, 2009

A simple Rss Feed Parser using LINQ To XML

Download Code

A simple class that can be used to parse rss feed, Check the code attached it will display my twitter updates by parsing the rss feed using the class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;
namespace RssFeed

//12-aug-2009 Priyan R
public class RssParser
public RssParser()
Items = new List<RssItem>();
public RssParser(string url):this()
URL = url;
#region Methods
public void Parse()
XDocument doc = XDocument.Load(URL, LoadOptions.None);
Items = (from t in doc.Descendants("item")
select new RssItem()
Title = t.Element("title").Value,
Description = t.Element("description").Value,
Link = t.Element("link").Value


#region properties
public string URL { get; set; }
public List<RssItem> Items { get; set; }
#region RSS Item Class
public class RssItem
public string Title{ get; set; }
public string Description { get; set; }
public string Link { get; set; }