Raspberry Pi 2 Board Pin Charts

This is actually the reason we started this blog. After searching for hours just to figure out the pin configuration, we decided a blog would be the best way to organize our findings with people.

We hope that the following information will increase world efficiency by thousands of hours!

http://pi.gadgetoid.com/pinout  <- great resource, Bookmark it!

Raspberry Pi 2 B+ 40-Pin GPIO Configuration

Pins are read in rows starting with the inner pin closest to the corner of the board.

1. 3.3 Volts 2. 5 Volts
3. GPIO2 (SDA1 I2C) BCM 2 4. 5 Volts
5. GPIO3 (SCL1 I2C) BCM 3 6. Ground
7. GPIO4 (GPIO_GCLK, GPCLK0) BCM 4 8. GPIO14 (UART0_TXD0) BCM 14
9. Ground 10. GPIO15 (UART0_RXD0) BCM 15
11. GPIO17 (GPIO_GEN0) BCM 17 12. GPIO18 (GPIO_GEN1, PCM_CLK) BCM 18
13. GPIO27 (GPIO_GEN2) BCM 27 (PCM_D) 14. Ground
15. GPIO22 (GPIO_GEN3) BCM 22 16. GPIO23 (GPIO_GEN4) BCM 23
17. 3.3 Volts 18. GPIO24 (GPIO_GEN5) BCM 8
19. GPIO10 (SPI_MOSI) BCM 22 20. Ground
21. GPIO9 (SPI_MISO) BCM 9 22. GPIO25 (GPIO_GEN6) BCM 25
23. GPIO11 (SPI_SCLK) BCM 11 24. GPIO8 (SPI_CE0_ N) BCM 8
25. Ground 26. GPIO7 (SPI_CE1_N) BCM 7
27. ID_SD (I2C ID EEPROM) BCM 0 28. ID_SC (I2C ID EEPROM) BCM 1
29. GPIO5 BMC 5 30. Ground
31. GPIO6 BCM 6 32. GPIO12 BCM 12
33. GPIO13 BCM 13 34. Ground
35. GPIO19 BCM 19 36. GPIO16 BCM 16
37. GPIO26 BCM 26 38. GPIO20 BCM 20
39. Ground 40. GPIO21 BCM 21

pins3 pins2 pins1

Hope this saved you a ton of time and frustration!

Posted in Uncategorized | Leave a comment

Hooking Up a Thermometer to Raspberry Pi (DS18B20)

This post will be about hooking up a waterproof DS18B20 thermometer to a Raspberry Pi.

What you will need:

1 DS18B20 waterproof thermometer: ~ $2 on eBay

1 4.7 KOhm resistor: Should buy a set of resistors before working on electronics

Breadboard jumper wires: could come with the set of resistors

6 Female to Female Jumper Wires: Bought a 10 pack at a local hobby shop for $2

Electrical Tape: Also bought at hobby shop for $4

Most of this was taken from a great tutorial here: http://www.raspberrypi-spy.co.uk/2013/03/raspberry-pi-1-wire-digital-thermometer-sensor/

That tutorial was for the original Raspberry Pi board and we will introduce the changes we made for taking it off the breadboard. Our pins were also configures for the Pi 2 board.

DS18B20-Temperature-Sensor_bb-230x300

The schematic of attaching the thermometer using the breadboard from the tutorial

Here is a schematic of how you can take the thermometer off of a board(excuse my lack of artistic talent):

therm_schem

If it is not clear, the box-line-box stands for the female jumper cable, breadboard jumper wires were used to connect the jumper cables, and electrical tape was used to wrap up each connection.

thermo_kit_finished

Here is a picture of the finished product and we used color coordinated jumper cables

The tutorial says Pin 1 was connected to P1-06 (Ground), Pin 2 was connected to P1-07 (GPIO4) and Pin 3 was connected to P1-01 (3.3V). We added the ground (black wire) to Pin 20, Pin 2 (yellow wire) to Pin 18 (GPIO 24) and Pin 3 (red wire) to Pin 17 (3.3V) for the Rasperry Pi 2 board.

The tutorial says to add the following dtoverlay=w1-gpio,gpiopin=4 to the bottom of the file that comes up when running the command, in the command line, sudo nano /boot/config.txt ; instead, because we changed the pins around for the Raspberry Pi 2 board, we changed the line to dtoverlay=w1-gpio,gpiopin=24 to suit our the new pin. You can suit this for whatever GPIO pin you choose, just make sure you have the ground and power pins connected to the right pins.

Check out our upcoming post on Raspberry Pi 2 pins! This just reminded me to write it 🙂

After adding that line, as the tutorial says, use sudo reboot in the command line to restart your board.

When you’re back in on the command line, type cd /sys/bus/w1/devices then ls Hopefully, you get something like this:thermo_found_ser

WRITE DOWN THAT 28-00000… CODE. The number is unique to each thermometer, we even attached it to ours using tape: 20150628_144404

The tutorial then gives a great python script, which we will copy and paste here to archive, just in case: (we will also look into writing a post about getting python on your board  you can also just google it like us. 🙂

#!/usr/bin/python
defgettemp(id):
  try:
    mytemp =''
    filename ='w1_slave'
    f =open('/sys/bus/w1/devices/'+id+'/'+filename, 'r')
    line =f.readline() # read 1st line
    crc =line.rsplit(' ',1)
    crc =crc[1].replace('\n', '')
    ifcrc=='YES':
      line =f.readline() # read 2nd line
      mytemp =line.rsplit('t=',1)
    else:
      mytemp =99999
    f.close()
    returnint(mytemp[1])
  except:
    return99999
if__name__ =='__main__':
  # Script has been called directly
  id='28-00000482b243'
  print"Temp : "+'{:.3f}'.format(gettemp(id)/float(1000))

We copied this code into a new text document and saved it as thermometer_read.py  You need to change the line id = ’28-00000482b243′ to the id you have for your thermometer! cd to the directory you saved the code file in, then type python file_name.py and… Congratulations! You hooked up a thermometer to your Raspberry Pi!

themo_read

The first reading is if you do not change the id = line correctly

Posted in Uncategorized | Leave a comment

Our First Project

When we went to look for inspiration as beginners, we found that a lot of the projects that people worked on were either too simplistic, too hard, or rather pointless. Do we really need a clap-switch lamp? Really?

So, we stopped looking for something and dove right in to what we want do with a microcontroller: aquaponics. Aquaponics is, as simply as possible, the symbiosis of agriculture (growing plants) and aquaculture (growing aquatic life). The waste products from your fish or whatever are broken down by bacteria, the nutrients are utilized by the plants, and the cleaned water is sent back to the fish. It is extremely more efficient than land-based agriculture or aquaculture alone. (Talking more about aquaponics is outside the scope of this blog post as there are a lot of great resources and a ton of information.) It is the perfect starting project for us, we think, considering our interests, future goals, and ability to progress from the simple (temperature monitoring) to the complex (internet or cellular updates and control).

A lot of people out there may be wondering why we chose one microcontroller over the other.  The best answer is simple: $$$. We worked out what we thought we needed and found that using a Raspberry Pi would be cheaper than an Arduino. We don’t need to tell you that this is something that is important for every project. Try to budget out what you need first, it not only helps you financially, it is great for organizing your build and you might even come across cool things and deals you never even expected.

Another answer includes the fact that the Raspberry Pi board has easy (and cheaper) connective capabilities to other devices compared to the Arduino. This is key, first of all, because we don’t want to run an ethernet cable across the entire house or outfit the Arduino with another $50 WiFi shield, and who knows how much headache. Second of all, I’m sure someone more familiar with Arduino boards can correct me if I’m wrong, but the Raspberry Pi 2 has 4 USB ports, an ethernet, and an HDMI port built-in. You are not going to find that out of the box with Arduino at the same price point.

Furthermore, and the point of no return for Arduino, the Raspberry Pi 2 board just came out like a week before we started working on this project. The whole brand-newiness of that was a great sell. New and $35? It was just too good to pass up.

Finally, when searching around for projects, we found a lot of great Aquaponics systems using Arduino, but many of them are your typical detector and valve controller. We really wanted the ability to easily move onto the internet of things. (Yes, Arduino can do this, but not as cheaply and easily, from our research, but this is debatable.) We also found a couple great projects using the Raspberry Pi, namely aquaPionics and Brewpi that we thought would be great resources to help us develop our work.

That being said, our short-term goal is to get our Raspberry Pi to sense the water temperature and pH in real time. We have the ability to get temperature and pH sensing now (our pH meter is acting wonky), but to have this output in real time in a meaningful way to us is the next step. (We are behind on blog posts from actually working on the project.)

In the long run, we hope to have our system post the data in real-time online and notify via email of any horrible changes. First, we are probably going to do it on a 2×12 LCD screen at regular intervals.

That’s all for now, will start getting into the actual project in following posts and hope to hear from you any suggestions!

. .

Posted in Uncategorized | Leave a comment

How to Choose a Project

These are a few, and what we consider the most important, things you should consider when picking a project:

1. Is it within your skill range?

This is probably the most important consideration. Be honest.  These microcontrollers can do so many amazing things it is easy to find yourself with a dream that you just can’t produce yet. Nothing is worse than being frustrated and giving up, especially when it is easily prevented by choosing a project within your skill range. If you are finding yourself discouraged or overwhelmed by your project it is not because you are too stupid; it is simply because you are working on something outside your present abilities. That’s OK, everybody does it. Maybe you can break down your project into smaller pieces, or find something a little easier to start with, there’s nothing wrong with that. As long as you keep getting better at it than you were before then you’re doing it perfectly. (And the little-known truth is you can never really get worse so you’ve been doing it perfectly.) This can never be said enough: we all make mistakes, we all learn, we all grow. Nobody was born being a professional at anything, despite what the television or Youtube may want you to think. There are hundreds, if not thousands of hours, that go into some of these things, they are only showing the product.

2. Can you keep adding onto the project or use knowledge from it in future projects you have been dreaming of?

This is an important consideration following from the last one. OK, so your dreams of building a personal R2D2 to get you drinks from the fridge, hack you out of an imperial jail cell, and cook you breakfast have only produced a sticky keyboard, paranoia, and a fried circuit board. Still, you can and should start small. You could start by building a robot that actually moves first, then add remote control, then add automatic control. Then you can build a circuit that can detect heat. Then build another machine that can hold different objects. Put them all together and what have you got? Great minds think alike.

3. Do you really care about doing it? (What is the point?)

This doesn’t mean don’t build pointless stuff since you might be learning how to do something for the future. Also, FUN IS A POINT. We’re just saying to consider if you will care about it, pointless or not, because novelty fades fast and you might lose interest in the long run without a clear goal in mind. That being said, you kids only have a few precious years to get your parents to buy you things for your pointless projects: go nuts!

Okay, enough automatic weapons for one post. Please feel free to comment what you think is important to consider when working, some personal experiences, or just plain discussion.

. .

Posted in Uncategorized | Leave a comment

Saving and Backing Up Raspberry Pi SD Cards (with Windows 8 at the bottom!)

Raspberry Pi SD cards are notorious for being corrupted and having to be reformatted, taking everything you’ve worked on with them. It is common sense and good practice to always backup your card whenever you make progress on a project. In case anything happens, you can just reload the image onto the SD card and it will be as if there never was a problem.

Thankfully, backing up an SD card is a very simple task, and can be done in only a few minutes. Not only that, the same procrss can be used to create backups of USB drives and, more uncommonly, hard drives.

Let’s start with the bread and butter for Raspberry Pi users: Win32DiskImager.  Any tutorial you Google is going to use this program. (Trust me, I’ve looked.)

The program is super-simple and intuitive. Download the .zip from the Sourceforge link above, extract it, run the application, and you’ll see this:

WinDiskRead

Creating a backup: Change the device dropdown to the drive with the MicroSD card you want to copy, and specify where you want to save the “Image File”; hit that little pictogram file to browse and find a name and location for it. Hit “Read”. This will take your card and produce an image file in the specified location of everything on it.

Please note:  Before we go on, I did have an issue once where the program could not locate the image file it had just made. When I looked in the folder with Windows Explorer there was a generic FILE with the name I had given it of the correct size. Close Win32 Disk Imager and put .img at the end of the FILE name. This will convert the unspecified file into an image file. Rerun the program and it will recognize this and it will work.

Putting the Backup onto an MicroSD card: Now that you have the image file “read” from the card, putting it back onto a card, for whatever reason, is just as simple but in reverse. Locate the image of the card you would like to use with the little file pictogram again. Then, choose the drive with the card you want to put the backed up files on with the device pulldown. This time click “Write”, it will prompt you to let you know that this will delete everything on the drive. If you are sure you have the right drive, click OK and it will go and put the backup copy back onto the device.

Another note: This will be a complete replica of everything that had been backed up before. When you use the card now, it will be exactly like the time you backed it up. Another important point is that when you are using 2 separate sized SD cards, you can backup a smaller size onto a larger one, but not vice-versa. For example, we put an 8 GB image onto a 16 GB card. The thing is, that new OS in the 16 GB card still thinks it is in an 8 GB drive, as it is a complete copy. That image is the extent of its universe, so to speak, and the free space on the 16 GB card is simply unknown to it. Keep this in mind, and try to invest in microSD cards of the same size. (Unlike we did.)  Theoretically, there might be a way to have a sort of dual-boot device, but we haven’t tried or done any research on that yet.

Windows 8 Users

I was unable to use Win 32 Disk Imager on my Windows 8 device, many of you have faced the same problem.

Win32Fail

You can download Roadkil’s DiskImage and it works on Windows 8! There are 2 tabs at the top instead of the Read and Write buttons you have Write Image and Store Image. Store Image will create the backup, Write Image will put it on the card.

Important note: Write Image did not work for us at first, “Error #5 occurred while writing to disk at sector 2048”, but the fix is easy. According to the developer Roadkil, “Its due to a locking problem on the logical partitions on the physical disk”, he promised an update with a fix in the future (we used 1.6) but there is a simpler fix, in the meantime. Just reformat the SD card again to wipe the partitions, then write the image to it.

RoadkilReadImageSuccess

Posted in Uncategorized | Leave a comment

Setting Up WiFi (Raspbian GUI)

If you have a Raspberry Pi compatible WiFi Dongle, and the Raspbian GUI installed, setting up internet connection is extremely simple.

1. Go to Menu > Preferences > WiFi Configuration

20150506_160807

2. Raspbian should automatically detect the USB dongle as Adapter wlan0

20150506_160829

3. Click Scan to search for WiFi routers

20150506_160847

4. Double-click the router you wish to connect to20150506_160859

5. Enter your password in the PSK box and click Add at the bottom

20150506_161006

6. Click Connect

20150506_161030

That should be it!

20150506_161038

Happy Surfing!

20150506_161143

Posted in Uncategorized | Leave a comment

Setting Up Your SD card and OS with NOOBS

So, you have all the hardware you need to get going with a Raspberry Pi, and now, unless you’ve purchased a preloaded SD card, you’ll need to install the software OS. This whole process takes about 10 minutes, after you have downloaded NOOBS, of course. This is also where having an adapter, either USB or SD, to get your Micro SD card into the computer is absolutely necessary.

For most new users, the best choice is to simply download NOOBS and, specifically, install the Raspbian OS. NOOBS comes preloaded with many Raspberry Pi compatible OS, Rasbian being the most versatile and popular.  We will go over the different OSs in another post.

First, you’ll have to format your new SD card to be compatible. The following instructions are easily found online, and are simply a commented copy of the NOOBS readme file.

NOOBS INSTALLATION INSTRUCTIONS

1. Insert an SD card that is 4GB or greater in size into your computer.

20150506_144022

2. Format the SD card using the platform-specific instructions below:

SD Formatter

a. Windows

i. Download the SD Association’s Formatting Tool from https://www.sdcard.org/downloads/formatter_4/eula_windows/

ii. Install and run the Formatting Tool on your machine

iii. Set “FORMAT SIZE ADJUSTMENT” option to “ON” in the “Options” menu

iv. Check that the SD card you inserted matches the one selected by the Tool

v. Click the “Format” button

b. Mac

i. Download the SD Association’s Formatting Tool from https://www.sdcard.org/downloads/formatter_4/eula_mac/

ii. Install and run the Formatting Tool on your machine

iii. Select “Overwrite Format”

iv. Check that the SD card you inserted matches the one selected by the Tool

v. Click the “Format” button

c. Linux

i. We recommend using gparted (or the command line version parted)

ii. Format the entire disk as FAT

iii. Extract the files contained in this NOOBS zip file.

NOOBS copy

iv. Copy the extracted files onto the SD card that you just formatted so that this file is at the root directory of the SD card. Please note that in some cases it may extract the files into a folder, if this is the case then please copy across the files from inside the folder rather than the folder itself.

v. Insert the SD card into your Pi and connect the power supply.

** Please note, when you format your SD card you will be wiping all of the information on it.**

Your Pi will now boot into NOOBS and should display a list of operating systems that you can choose to install.

**For most applications, and for beginners,the Raspbian OS will probably do the trick. Not only that, but it comes loaded with a GUI to make a new user feel comfortable. Very important: After you install Rasbian and the board reboots, it will prompt you in a command line for a username/password. The defaults are Username: pi // Password: raspberry unless you change the password in the configuration. Also, when you type startx in the Raspbian command line and press enter, you will be taken to the graphical user interface (GUI), which is familiar as a Mac or Windows home screen where you can use a keyboard and mouse to access applications.**

What you should see when you boot the Raspberry Pi with the NOOBS file in it for the first time. Have at least a USB keyboard connected.

20150506_155258

Your best bet is probably Raspbian.20150506_155309

 

20150506_16032420150506_160342

Selecting option 2 allows you to change the password (Recommended) 20150506_160559

Option 3 allows you to change whether you want to boot to the command line or directly to the GUI. Type in startx on the command line to get to the GUI.20150506_16061620150506_160628

Once you finish up the config, your Raspberry Pi will reboot and, once you open the GUI, this is what you will see.20150506_160734

ALWAYS BE SURE TO DO A PROPER SHUTDOWN EVERY TIME OR ELSE YOUR SD CARD WILL BE CORRUPTED AND YOU WILL LOSE EVERYTHING!!!

A20150506_161708

Posted in Getting Started | Tagged , , , , , , , , | Leave a comment