PiPlanter | Graphing With PHP

Again, short post. This php code:

will produce this graph:

I learned this using this resource:

http://phpmaster.com/charting-with-pchart/

PiPlanter | Interfacing an ADC, Python, and MySQL [Documentation]

As this post is more of an update, I won’t be adding any explanations, just giving the python code.

This will read 3 values from the adc and put them into the database “adc_database”. It will put them in the table “adc_input_data_4” in the columns “Channel_1″,”Channel_2” and “Channel_3” respectively.

There you go, bigger post coming later tonight.

Basic Wetness Sensor

So I’ve had the idea for a while to try and automate the growing of plants so I need to be able to tell if something’s wet or not. Here’s a video:

Basically the hookup process is that of a regular analog sensor with this in it’s place. There’s a 10k pullup resistor as the voltage divider.

Here’s the source for the Arduino.

That’s pretty complex but I was trying to make the light changes more drastic so it would show up in the video better.

Here are some pictures of the build process:

Thanks for reading!

PiScanner | Project Execution [Demonstration/Distribution]

I should preface this by saying that it is no where near as polished as it could be. But it works, and the objects taken by the camera are recognizable. Eventually, if I have the funding, I will upgrade the Camera.

There are many elements to this project. There really isn’t a great place to start with this project, so well start with the fritzing schematic and a list of materials needed.

You will need:

2 Attiny85’s
16 wires
a breadboard
a 100k ohm resistor
a 330 ohm resistor
a raspberry pi
PIR motion detector
the cables for interfacing with the raspberry pi
an isp programmer for the attiny’s

So let’s look at this schematic:

When motion is detected, the signal pin on the motion detector gets pulled low. at this point the 3.3v attiny pulls pin 1 high, sending a signal into the rpi (it’s 3.3v so it’s safe for the broadcomm) and illuminating an LED so the user can see that motion is being detected.

The raspberry pi then sends a signal to the 5v attiny indicating that motion has indeed been detected. Once this occurs, the 5v attiny pulls the 5v pin going to the webcam high. I had to integrate this step of turning the webcam on via the attiny because there is a hardware misconfiguration that causes the software i’m using to take the picture hang. Turning the camera off and on each time a picture needs to be taken gets rid of this problem, because the camera always takes the first picture after being turned on.

At this point a picture is taken and moved to a flash drive. They could be moved wherever, but a flashdrive works the best for now, as I will be deploying this system in a place where there isn’t internet (in my garage)

Now time for source codes!

Software wise you will need:

The Arduino IDE

Python (I’m using Geany on the raspberry pi)

fswebcam which you can obtain by running

On your raspberry pi.

This is the source for the 3.3v attiny85

This is the source for the 5v attiny85

This is the python source, you will need to install this to make it work though.

This is the Fritzing document.

Here’s a sample image from the camera. It is looking at the breadboard.

PiScanner – GPIO output | Documentation [Research]

I will need to illuminate the “subjects” that I will be capturing. In order to do this, I will eventually need to set some pin high. Weather it be that it sets of a camera flash or turns on some lights for a second, it will need to happen down the line.

 

Like all of my “research” I mostly googled around / plugged in code until something worked. I came back with these links:

http://www.youtube.com/watch?v=q_NvDTZIaS4

https://docs.google.com/file/d/0B2-00drKdqF0V09YSHgxcTEtelk/edit

http://hackaday.com/2012/06/17/using-the-gpio-pins-on-a-raspberry-pi/

 

Basically you need to install the Raspberry Pi GPIO, Import and use the RPi GPIO

1. Download the library:

$ wget http://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.2.0.tar.gz#md5=0fc4bfa6aabc856b0b75252a40ac75cc

2. unzip the file:

$ sudo tar -zxvf RPi.GPIO-0.2.0.tar.gz

you can remove the .tar.gz at that point

3. get into the directory you just created:

$ cd  RPi.GPIO-0.2.0

4. The devs included a great install script with this package, run it to install with:

$ sudo python setup.py install

Now you should see a bunch of text in the command line. I have no idea why, but my first run of this command didn’t “take” but I ran it again and now it works great.

 

To use this, you need to know what pins correspond to pins on the RPi. You can google this yourself.

 

Now we get writing code. I’m using a graphical python editor called geaney which comes pre-loaded with squeeze.

 

To blink pins 11 and 13, use and run this python script.

You can see the plaintext version of that script here.

 

Essentially i’m trying to mimic things I’ve done with an Arduino for some time.

Maybe later today (if I can somehow find a 100ohm resistor) I’ll work on using inputs. I have a PIR motion sensor with me, but I neglected to bring the proper resistor to use it. I do have tack switches and resistors for those, which I could use to mimic the motion detector, but I don’t think that would be as cool.

 

PiScanner | Basics [Research]

So I’ve determined that there will be 2 parts to this project.

 

1. Be able to take a picture with a USB webcam via command line.

I’ve landed on a program called fswebcam. I found it via a few google searches. I installed it by using the command:

 

$ sudo apt-get install fswebcam 

 

I used the:

 

$ man fswebcam

 

command to “derive” how to use the program, but essentially I made a

 

config file

 

that the program can execute. You can run the program with the above configuration by typing:

 

fswebcam -c /home/user/Pictures/picture.conf //the location of the .conf file should be wherever you put it, so the code after the space after the -c will be different for you. 

 

This will produce an image from your webcam in the location you specified in the picture.conf file.

 

Other info can be found here: http://www.r3uk.com/index.php/home/38-software/100-webcam-capture-using-fswebcam

 

I installed all of this on my server and got the below image. This is what the laptop running this website sees!

 

 

2. Write a python (I’ve decided to go with python because I’ve never used python before, it will be good to learn something new. And because there is already a library for controlling the GPIO pins on the RPi baked into the language.) script that can sense weather or not this sensor‘s alarm pin is pulled low. At that point, the script should then execute the above bash command and take a picture. After that, that photo should be moved somewhere to do something, but I don’t know what that will be yet. It will probably be uploaded to a secure location on my server and then I will have it email me if at the end of the night, something shows up.

http://pypi.python.org/pypi/RPi.GPIO

 

PiScanner | Project Execution [Declaration]

Raspberry Pi

Hello Hello Hello!

//If you just want to see the PiScanner Progress, skip the next 2 blocks

So, you may have noticed an absence of recent posts on this website. This is due to a few factors but the main one is a lack of focus. Not a lack of focus in a multi-tasking sense, but in a sort of literal sense. I’ve got foggy fragments of ideas, but no concrete ideas that are feasible. I think that the introduction of the “Project Execution” prefix in the title of this post (and hopefully all of my other project-based posts) will keep me “responsible” in regard to things I try and undertake.

There will be 5 steps for each project.

  1. Declaration
  2. Research
  3. Documentation
  4. Report feasibility [1] (This is where we will learn if the project is possible or not, and if not why.), Share all code [2] Take Lots of pictures [3]
  5. Demonstrate / Distribute
Now to PiScanner
After Receiving my Raspberry Pi :

Raspberry Pi

In the mail recently, I’ve got a whole new area of new more powerful computer science to enter into, and I think the PiScanner is the best way to do this.

 

The PiScanner will be a program that will identify motion using a PIR detector in junction with the GPIO pins, capture an image using a webcam or other camera compatible with the ports on the board, and then upload that image to a server to be viewed via rss.

 

This will be great for my backyard at night, it’s like animal planet out there this time of year and it will teach me a bunch of new things upon completion.

 

Check back for more!

 

Sensing the Brightest Point

Youtube demo here:

 http://www.youtube.com/watch?v=YbwSl5Hp3r8

This is a round about way of using a servo to move an analog sensor to 3 points to triangulate the servo degree where the photocell experiences the most light.

 

The servo sweeps back and forth and then another servo points to where the brightest point was.

 

It is very simple wiring, but the code is a little fancy. It’s all commented up here, but as always deduction is your friend.

 

Raspberry pi soon?