and the summer passed by…

14Aug10

This summer is passing pretty fast, and I’ve learned LOTS of different stuff some more interesting then others but all good in the end.

I’ve had a bit of absence from the blog not because I have nothing to post but because I lack the time to do it. I’ve moved places and am now living with E. We also added a new element to the family (no am not a dad, yet!), we bought a Dog. She’s named Penny, born 15th of May and of Border-Collie breed. Following is a photo of Penny giving you all a big smile:

Next up, I received an award from University of Bedfordshire and train2game company, we had a lovely ceremony and it felt really good to go up on that stand and receive my award (3000£):

For those of you wondering, yes I’ve spent those 3000£ already, I got myself 2 certifications: CEH and CHFI.

Following all this my friend Fabio came and visit me up here in Luton since he is trying to get into the University. Looking at 2 weeks of boredom I ordered an Arduino and what were supposed to be 2 weeks of boredom became 2 weeks of fun hardware and software hacking. I’ve never had electronics in my life so I bought myself an Arduino starter kit from cool-components.co.uk (Amazing company, order took 24 hours to get dispatched), I then went to Maplin and bought a soldering iron and some other bits and bobs that made a good starter kit for electronics. After putting all different components in different containers and learning about them we decided to start doing some stuff. So what did we come up with? This:

Arduino gmail hardware notification

This hack, combines python script with the arduino 3 leds show the level of email a inbox contains (green being from 0 – 4, yellow 5-7 and red 8-10> ), we also added 2 speakers to it one of them louder then the other and when we are at level yellow one of them starts ringing and at extreme/critical level both bells ring and they are L O U D!

Photos and Schematics:

Now to use this you will need 2 scripts:

___________________________________________________________________________________________________________

1st- Python script that will get your gmail inbox size and send it through the serial port to the arduino:

import serial, sys, feedparser, time
#put your account information here
USERNAME=”putyouremailhere@gmail.com”
PASSWORD=”123456password”
PROTO=”https://”
SERVER=”mail.google.com”
PATH=”/gmail/feed/atom”
SERIALPORT = “/dev/tty.usbserial-A700e0U243″ # This must match your serial port if you are on linux mac a ls /dev |grep tty.usb should show your usb
# Set up serial port
try:
ser = serial.Serial(SERIALPORT, 9600)
ser.setDTR(False) # Drop DTR
print ‘SERIAL CONNECTION SUCESSFULL’
except serial.SerialException:
sys.exit()
newmails = int(feedparser.parse(PROTO + USERNAME + “:” + PASSWORD + “@” + SERVER + PATH)["feed"]["fullcount"])
print ‘CONNECTED’
# Output data to serial port
print ‘New mails ‘, newmails
if (newmails > 0 ) & (newmails < 5):
time.sleep(1.0) #Wait for DTR reset
ser.write(‘G’)
print ‘SENT G’
elif (newmails >= 5 ) & (newmails < 10):
time.sleep(1.0)
ser.write(‘Y’)
print ‘SENT Y’
elif newmails >= 10:
time.sleep(1.0)
ser.write(‘X’)
print ‘SENT X’
else:
time.sleep(1.0)
ser.write(‘C’)
print ‘SENT C’
# Close serial port
ser.close()

___________________________________________________________________________________________________________

2nd the Arduino sketch:

int greenPin = 12; // Output connected to digital pin 12

int redPin = 11;

int yellowPin = 10;

int greenmail = LOW; // Is there new mail?

int redmail = LOW;

int yellowmail = LOW;

int highbellPin = 9;

int highbellmail = LOW;

int lowbellPin = 8;

int lowbellmail = LOW;

int val; // Value read from the serial port

void setup()

{

pinMode(greenPin, OUTPUT);

pinMode(yellowPin, OUTPUT);

pinMode(redPin, OUTPUT);

pinMode(highbellPin, OUTPUT);

pinMode(lowbellPin,OUTPUT);

Serial.begin(9600);

Serial.flush();

}

void loop()

{

// Read from serial port

if (Serial.available())

{

val = Serial.read();

Serial.println(val);

if (val == ‘G’){

greenmail = HIGH;

}

else

if (val == ‘C’){

greenmail = LOW;

redmail = LOW;

yellowmail = LOW;

highbellmail = LOW;

lowbellmail = LOW;

}

else

if (val == ‘X’) {

redmail = HIGH;

yellowmail = HIGH;

greenmail = HIGH;

highbellmail = HIGH;

lowbellmail = HIGH;

}

else

if (val == ‘Y’) {

yellowmail = HIGH;

greenmail = HIGH;

lowbellmail = HIGH;

}

}

// Set the status of the output pin

digitalWrite(greenPin, greenmail);

digitalWrite(highbellPin, highbellmail);

digitalWrite(redPin, redmail);

digitalWrite(yellowPin, yellowmail);

digitalWrite(lowbellPin,lowbellmail);

}

___________________________________________________________________________________________________________

So after finishing this project we decided it was LCD time, so I got this really cheap screen from Maplin and we started messing around with it. I found this website to be extremely useful in this part, though anyone that wants to do this project should be able to follow our schematics pretty easily.

Project 2:

So the second project is similar in certains parts to the first one, but essentially what happens is: python script reads gmail rss feed gets number of emails and author of email and writes this information to the LCD screen. The Schematics:

And the Code:

___________________________________________________________________________________________________________

1st Python script

import serial, sys, feedparser, time, textwrap

#Account details

USERNAME=”insertyouremail@gmail.com”

PASSWORD=”1234567password”

PROTO=”https://”

SERVER=”mail.google.com”

PATH=”/gmail/feed/atom”

SERIALPORT = “/dev/tty.usbserial-A700e0U251″ # Change to your serial port!

# Set up serial port

try:

ser = serial.Serial(SERIALPORT, 9600)

ser.setDTR(True) # Drop DTR

print ‘SERIAL CONNECTION SUCESSFULL’

except serial.SerialException:

sys.exit()

while(True):

newmails = int(feedparser.parse(PROTO + USERNAME + “:” + PASSWORD + “@” + SERVER + PATH)["feed"]["fullcount"])

if (newmails > 0 ):

for i in range(0, newmails):

author = str(feedparser.parse(PROTO + USERNAME + “:” + PASSWORD + “@” + SERVER + PATH).entries[i].author)

print “Authors: ” + author

print ‘CONNECTED’

# Output data to serial port

print ‘New mails ‘, newmails

authserial = textwrap.wrap(author,6)

ser.write(str(newmails) + “”)

ser.write(authserial[0])

time.sleep(1.0)

print “SENT:” + str(newmails) + authserial[0]

else:

time.sleep(1.0)

ser.write(’0-box’)

print ‘BOXEMPTY’

time.sleep(1.0)# Drop DTR

# Close serial port

ser.close()

___________________________________________________________________________________________________________

2nd – Arduino sketch

#include <LiquidCrystal.h>

LiquidCrystal lcd(7,8,9,10,11,12); // this is obiusly my connection since i use a ethernet shield i can’t use 10..13

// LiquidCrystal lcd(12, 11, 5, 4, 3, 2); normal connections

int warningPin = 13;

int warningMail = LOW;

void setup(){

lcd.begin(16, 2);

Serial.begin(9600);

Serial.flush();

pinMode(warningPin, OUTPUT);

}

void loop(){

if (Serial.available())

{

lcd.clear();

lcd.setCursor(0, 0);

lcd.print(“Emails:>”);

lcd.setCursor(0,1);

while (Serial.available() > 0) {

// display each character to the LCD

lcd.write(Serial.read());

}

warningMail = HIGH;

digitalWrite(warningPin,warningMail);

}

}

___________________________________________________________________________________________________________
Well both these projects were fun to work on and Im still learning a lot, got a few books to read and thats pretty much what I do in my spare time since I’ve been using most of my time to write my MSc thesis which is ,thankfully, nearly done!!! (I dont even know why I say thankfully after am done with this one, I start my Doctorate straight way but its a whole different topic and I’ve got something reallllllllllly interesting planned!). I would also like to thank Prof. Carsten Maple for all the support he has given me on an academic and friend level he is a great supervisor and am happy to be under his wing.
PS:Oh by the way did I mention ill be talking at Ibwas’10? http://www.owasp.org/index.php/IBWAS10  (SPEAKERS tab)
PPS: Ill also be attending hack.lu simply, because I want to meet the 303 crew.
Thank you all for reading
B.


2 Responses to “and the summer passed by…”

  1. Shame. You could have got me to hack.lu with that money :(

  2. > For those of you wondering, yes I’ve
    > spent those 3000£ already, I got myself 2 certifications: CEH and CHFI.
    Right investment! I was also thinking about CEH but got OSCP =)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.