Raspberry Pi Webbot

During the second week of summer, I created a web bot crawler for Raspberry Pi because I wanted to learn more and become an expert with programming Raspberry pi.You may ask, what is a web bot crawler? A web bot crawler is a  program that searches for  websites to create an index of data so they can bookmark for easy searching. Google and Bing use webbots to bookmark websites and download the appropriate information to index for people to search. I came across some errors when I was writing the program from the book for the web bot crawler. The first error that I came across was importing images.  The code was not parsing the URL for the websites correctly. To fix this I had to fix the code so it can parse the URL correctly.

Here is the Python program for the web bot crawler:

import mechanize

import time

from bs4 import BeautifulSoup

import re

import urllib

import string

import os

def downloadProcess (html, base, filetype, linkList):

        #”This does the actual file downloading.”

        print(base)

        print(filetype)

        soup = BeautifulSoup(html)

        for link in soup.find_all(‘a’):

          try:

                linkText = str(link.get(‘href’))

                print(linkText)

                if filetype in linkText:

                        slashist = [ i for i, ind in enumerate(linkText) if ind == ‘/’]

                        print(linkText[slashist[0]+1])

                        print(linkText[slashist[1]])

#This was the line where the program was giving errors

                        directoryName = linkText[(slashist[0]+1):slashList[1]+1]

                        print(directoryName)

                        if not os.path.exists(directoryName):

                                os.makedirs(directoryName)

                        print(‘opening image’)

                        image = urllib.URLopener()

                        print(‘opened image’)

                        linkGet = base + linkText

                        filesave = string.lstrip(linkText,”/”)

                        print(linkGet)

                        image.retrieve (linkGet, filesave)

                elif “htm” in linkText:

                        linkList.append(link)

          except Exception, ex:

                  print(ex)

#start = “http://” + raw_input (“Where would you like to star searching?\n”)

start =  raw_input (“Where would you like to star searching?\n”)

filetype = raw_input (“What file type are you looking for?\n”)

#start = “http://www.irrelevantcheetah.com/browserimages.html

#filetype = “jpg”

numSlash = start.count(‘/’)

slashList = [i for i, ind in enumerate(start) if ind == ‘/’]

if (len(slashList) >= 3):

        third = slashList[2]

        base = start[:third]

else:

        base = start

br = mechanize.Browser()

print(start)

r=br.open(start)

html=r.read()

linkList = []

print “Parsing ” + start

downloadProcess(html, base, filetype, linkList)

for leftover in linkList:

        time.sleep(0.1)

        linkText = str(leftover.get(‘href’))

        print “Parsing” + base + linkText

        br = mechanize.Browser()

        r = br.open(base + linkText)

        html = r.read()

        linkList = []

        downloadProcess(html, base, filetype, linkList)

References:

http://www.amazon.com/Learn-Raspberry-Pi-Programming-Python/dp/1430264241/ref=sr_1_1?s=books&ie=UTF8&qid=1435595569&sr=1-1&keywords=learn+raspberry+pi+programming+with+python

Surveillance Camera

The first Project I did with the raspberry pi was the surveillance camera. The Surveillance camera was a pretty easy projects for me. All you needed was a Raspberry Pi, a dummy IR surveillance camera, and the Raspberry Pi camera module. The dummy IR Surveillance camera was too small for the raspberry pi to fit so, what I did was, I dismantled the whole camera and put it back together without the top inside layer. To fit the raspberry pi, you have to cut a piece of cardboard and slide it through the inside of the camera. This would help the Raspberry Pi stay stationary. The big problem was the Raspberry pi camera module. It was a big problem because every time you try to enable the Camera module, it would never turn on ad not get identified by the Raspberry pi. To fix this, I ordered a different camera module. This one was recognized by the Raspberry Pi.

 

Raspberry Pi camera module:

IR Dummy Camera:

Arduino Temperature Reader program

Here is the finished product:

The bold sentences are comments about that section of the program.

 

* Tutorial 1: Reading Temperature

 

// The output pin of the LM35 temperature sensor

int lm35Pin = A0;

 

void setup()

{

   // set up serial at 9600 baud  

Serial.begin(9600);

}

void loop()

{

int analogValue;

float temperature;

 

   // read our temperature sensor

analogValue = analogRead(lm35Pin);

 

   // convert the 10bit analog value to Celcius

temperature = float(analogValue) / 1023;

temperature = temperature * 500;

 

   //Converting celsius to Farenheit

  

float F = (1.8)*temperature+32;

 

// print the temperature over serial

Serial.print(“Temp in Celsius: “);

Serial.print(temperature);

Serial.println(“C”);

 

Serial.print(“Temp in Farnheit: “);

Serial.print(F);

Serial.println(“F”);

// wait 1 second before reading the temperature again

delay(1000);

EV3 Color Sensor

 

This is the Lego EV3 color sensor. It is similar to the Lego NXT color sensor, but they have combined a light sensor in it. The Ev3 is more square and thin so it can fit in tight spaces. In the NXT color sensor you did not have a cross hole option while in the Ev3 kit you have it on the bottom. The cross hole option allows you to capture motion. You can even build around frames with the Ev3 color sensor. This is going to enhance the building experience. This is a change they made to all the EV3 sensors. They have also improved the actual function of the sensor. Instead of detecting 6 colors like the NXT, you detect 8 in the Ev3. That helps you in programing the sensor. There are now multiple modes that you can use. They are the reflected light and ambient light mode. Reflected light mode lets the robot detect the change in reflect of the color. Ambient light lets the color sensor absorb and detect what color it is facing. You still have the two circular connectors on the bottom on the sensor. I think that Lego made Ev3 better with the sensors as you do not have to do a lot to program them.

 

Here is a color sensor tutorial for you:

Summary of Tutorial:

In this video the robot keeps going forward until the color sensor detects a color. When it does this, the robot is supposed to move back. I would recommend to do this multiple times to check if the color sensor is working.

 

References

https://education.lego.com/en-us/

 

Arduino Temperature Reader



 Arduino is a family of single-board micro-controllers, intended to make it easier to build interactive objects or environments. I used it to make a temperature reader. This project is to make the Arduino read the temperature.The Arduino example only reads the temperature in Celsius.So, I customized the program to measure Fahrenheit and Celsius. I ran into some issues while making the program. One of the most difficult issues was making it read the correct temperature. The problem was that when the computer divided 9 and 5, it rounded the fraction to 1. So it would not read the exact number.

Correct form: Float F = (1.8)*temperature+32;

Wrong form: Float F = (9/5)*temperature+32;

(1.8 came is the decimal of 9/5)

Another issue I had was organizing all the program. I would sometimes define the temperature differently and that would mess up how the programmed function because the computer did not know what definition it should use.

You can find the program in Programs.

 

 

 

Surgery Robot

I chose this article because when you have a brain surgery, there is a risk that a human doctor can make a mistake by maybe cutting a nerve that he/she was not supposed to. Unlike the human, a robot can deliver the surgery without leaving a huge scar on the patient’s head, finish the surgery quickly, and is less error prone.

 

 

Source:http://www.sciencedaily.com/releases/2014/10/141015152556.htm

I think that this robot will be very helpful in hospitals because it will help human doctors finish their jobs quickly and not leave a whole mess in the patient’s head. The robot will leave less of a scar. It is your choice to agree if you want robots to replace human doctors or not. In the article, I learnt that there are many different ways to conduct head surgeries. Some of them are beyond a human doctor’s abilities. The particular robot that has been designed for head surgeries will deliver it by going through the cheek and leaving a very small dot.

References:

http://www.sciencedaily.com/releases/2014/10/141015152556.htm