Archive | February, 2013

Raspberry Pi and Wifi

16 Feb

The doorbell rang and I ran to open it.  I peeked through the window and saw a small box.  It said Adafruit on it so I knew my items had arrived!  My mom ordered for me a wifi dongle and an analog to digital converter.  While waiting for the converter, I realized that it’s too complicated for my skill level right now so I decided to work with the wifi first.  Since I got my Raspberry Pi, I’ve had to choose between connecting it to the internet or connecting it to the TV because they’re too far apart for the cables to reach.

So, I plugged in the wifi and turned on the Pi.  I realized that the version of Linux that’s on one of my memory cards doesn’t have the wifi config program on the desktop and I searched everywhere for it and couldn’t find it.  So, I googled how to set it up.  The first instructions had me go into a file and add my wireless username and password and the use ifconfig to see if it was connected.  It wasn’t.  So, I put in another memory card that has a different version of Linux on it.  It has the wifi config on it.  I followed the steps on the Adafruit website EXACTLY and . . . it didn’t work.  Everything worked until the very last step and when I clicked the “connect” button, it just said “scanning” for about an hour.

Next, I called my dad in to try things.  The only setting that we really had any control over was the type of wifi security.  So, we went through each one and none of them worked.  In reading, we found out that the type of security our wireless was using wasn’t the best anyhow.  So, we changed it from WEP to WPA2.  I don’t know what that means, but we read that it’s better.

It worked!  I was connected and I could get on the internet on my RPi while connected to the big TV in the livingroom.  I was disappointed to find out that I can’t watch youtube videos, that’s one of my favorite websites for crafts, music, bloopers, and how to fix stuff.  I read that openelec can connect to youtube and I have that on a different memory card.  So, I put that one in and after quite some time trying different things, I came across a website that had simple instructions that actually worked even though I read about a lot of people who couldn’t get it to work.  Here’s the website that I found useful, http://mymediaexperience.com/openelec-with-wifi-on-raspberry-pi/  I still don’t know how to do anything with wireless on openelec.  Now that it’s online, I see “add-ons” but none of them will install when I click the install button.

The best thing about my new setup is that I can now be online while connected to the TV with an HD cable.  I don’t get the buzzing sound anymore like when I was connected with the red/white/yellow cable.

Then came that horrible call of my mom saying, “Bedtime, turn the TV off!”  So, I had to go to bed.  I’ll play with it some more later and let you know how it turns out.  But for now, I’ve connected Wheezy and openelec through my wireless connector.

This is hard work.  I was hoping to be building 3-D printers run by my RPi by now.  I guess I set my goals too high.  But if anybody has a 3-D printer that they’re not using anymore, I’d be happy to figure out how to make it work 😉

Here’s a video with instructions on setting up wifi.  This didn’t work for me, but maybe it’ll work for you.

 

 

Advertisements

Push-Button Sounds

4 Feb

Today’s blog is going to be a little bit different, instead of me doing my blog after doing something fun, I will be making a device that will play sounds when a button is pushed, and blogging at the same time. It’ll be like Freddy on iCarly!  I found this idea on a website, http://learn.adafruit.com/downloads/pdf/playing-sounds-and-using-buttons-with-raspberry-pi.pdf.  I thought this would be fun so forget the superbowl and go raspberry pi. I am starting by setting up the bread board, but I see that there are resistors. I have resistors but I don’t know how to read them so I have to learn. I just found this website http://www.michaels-electronics-lessons.com/resistor-color-code.html that makes it easy to understand. According to the instructions I will need three 10k resistors, and I found that the color code is brown, black, orange but I will check it with my multi-meter just to be sure.

 

My dad explained to me how a bread board works and we just attached the three switches and resistors, it was pretty easy. Now we have to plug it in to my raspberry pi but which way does it go? Thank goodness that adafruit’s website has a picture that really helps. We also have to connect the raspberry pi to the internet and then do the programming from the laptop with “Putty.” I will be right back I have to go plug it in and go connect it. J  Something just happened while I was trying to open putty a message popped up and it said that it timed out.  Turns out that we could never figure out how to make the router give RPi an IP address and keep it that way.  So, we had to log in to the router to find out the new IP address and of course, my dad couldn’t remember the password, so we had to call Verizon (again!) to log in.  We still cannot plug it into the internet and a TV at the same time, so we had no way to see the IP address on the PI if we couldn’t connect the laptop to it.  That was just the beginning of our problems.

 

Our next problem was how to get the mp3 files onto the RPi.  The Windows computer wouldn’t let us copy and paste onto the memory card because it had been formatted.  We don’t know how to get on the internet from the command line and we can’t get on the internet in GUI Linux because our router is too far from the TV (we have a wireless usb device in the mail).  So, we finally put the mp3s on a flash drive.  Sounded easy, right?  It wasn’t.  We had to learn how to “mount” the flash drive.  That took an hour or two.  We used the instructions here, http://elinux.org/RPi_Adding_USB_Drives but they didn’t work.  It said to type “sudo mount -o uid=pi, gid=pi /dev/sda1 /mnt/KFD” where KFD is the directory I made to mount my flash drive.  It finally worked when we typed
“sudo mount /dev/sda1 /mnt/KFD” and left everything else out.

Then, we had to learn how to copy the mp3 files to the same directory as where we’d save the program.  That took some time too.  We didn’t know how to link to the KFD directory when were were in the sda1 director or link to the sda1 directory when were were in the KFD directory.  Finally, we made a directory where I’m going to save my program and called it “sounds”.  I went into the mnt/KFD/Sounds directory and typed “cp laughter-1.mp3 ~/sounds” and it worked!  It’s so confusing going back and forth through all of the directories.

 

Next, we typed the program into vi and saved it.  Then we used chmod to make it executable following the instructions.  We’ve never done that before, we usually just type “python sounds.py”.  The program didn’t work.  It kept playing the sound over and over and over even without pressing a button.  Pressing the button didn’t do anything.  It kept sending this message,

 

Playing MPEG stream from laughter-1.mp3 …

MPEG 1.0 layer III, 256 kbit/s, 48000 Hz stereo

ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front

^CTraceback (most recent call last):

  File “./sounds.py”, line 15, in <module>

[0:04] Decoding of laughter-1.mp3 finished.

[0:06] Decoding of laughter-1.mp3 finished.

[0:01] Decoding of laughter-1.mp3 finished.

[0:05] Decoding of laughter-1.mp3 finished.

[0:02] Decoding of laughter-1.mp3 finished.

[0:03] Decoding of laughter-1.mp3 finished.

sleep(1);

 

My ribbon cable is different than adafruit’s, so maybe we didn’t connect the wires right.  We’re both way too tired to work on it anymore today.  The picture in adafruit’s instructions showed pins 23, 24, and 25 all on the same side.  On mine, all of the odds are on one side and the evens are on the other side.  I think that might be the problem.  Any ideas?

Here’s a picture of my circuit:

Image