Monday, 31 March 2014

Installing Android SDK via eclipse

Once you have installed adt pluggin in eclipse, you can install android sdk by going to Help> Install New Software and add a new update site:
Name: Android SDK installer
Location: http://adt-addons.googlecode.com/svn/trunk/installer/com.android.ide.eclipse.installer.update/

Rest is same as we do for a normal software installation.

Monday, 27 May 2013

Python Code to show the sender and subject of incoming emails 

import imaplib
import email

while 1:
def extract_body(payload):
if isinstance(payload,str):
return payload
else:
return '\n'.join([extract_body(part.get_payload()) for part in payload])
     
try:
conn = imaplib.IMAP4_SSL("imap.gmail.com", 993)
conn.login("username","password")
conn.select()
typ, data = conn.search(None, 'UNSEEN')
except:
continue
try:
for num in data[0].split():
typ, msg_data = conn.fetch(num, '(RFC822)')
for response_part in msg_data:
if isinstance(response_part, tuple):
msg = email.message_from_string(response_part[1])
sender=msg['from']
subject=msg['subject']
br=set("<")
print('\n The sender is  :-')
sender=sender.split()
send=""
for i in sender:
if br.issubset(i):
break
else:
send=send+i
print(send)
print('\nsubject :-'+subject)
payload=msg.get_payload()
#body=extract_body(payload)
#print(body)
typ, response = conn.store(num, '+FLAGS', r'(\Seen)')

finally:
try:
conn.close()
except:
pass
conn.logout()

Friday, 24 May 2013

Burning boot loader with the help of two Arduino Uno Board

Hi,

Sometimes we buy micro controller with no boot loader installed, just like I did.
Actually I didn't buy, rather ordered free samples of atmega328 from Atmel, as a backup micro for my Arduino Uno Board. So If your program is not getting burned on your brand new micro or the program burned is not working or any boot loader error is shown while burning then chances are that either there is no boot loader in your Micro or the boot loader is corrupted.

I faced two problems:

1. There was no Boot loader pre-installed in the micro.
2. The micro I ordered was atmega328 instead of the standard atmega328P.

Let me show you how to solve these problems if you ever face them.

There are many ways to burn a boot loader into a micro controller. The old school way is to make a circuit on a PCB or breadboard, which would need transistors, crystal etc. 

The easier way is to find another arduino Uno board, from your friend or colleague and use it to burn the boot loader.





Above is the fig. of standard arduino Uno Board. Lets call the two arduino boards we have as A1 and A2.
A1 has a micro in which boot loader is already installed. A2 that is your Uno board, has the micro which doesn't have a boot loader. At the rightmost part you can see 6 pins together. These are the ICSP pins that will be used to burn the boot loader.

You would need one-to-one connectors to connect the two boards. The fig. below will show how the connections have to be made.



The connections have to be made between I/O pins of A1 and ICSP pins of A2 as shown in the figure. be careful, don't make mistake in the connections.

For example PIN 17 of A1 should be connected with 1st PIN of the ICSP in A2.


After the connections are made open up the arduino GUI.


Select Tools and config:

Board          --> Arduino Uno
Programmer --> Arduino as ISP

Then click on Burn Boot loader. Voila.. the boot loader is burned.

In case your IC is atmega328 instead of atmega328P, don't worry just find the avrdude.conf file.
it should be in arduino-1.0.3-windows\arduino-1.0.3\hardware\tools\avr\etc directory.

Open the file in an editor. Look  for atmega328P. Under this title look for: 
"signature = 0x1e 0x95 0x0F; "

all you have to do is change 0F into 14, Burn the boot loader and then change back to 0F for normal burning of programs.

Have fun boot loading :)