Sensing Movement Lesson 12

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
fremenusul
 
Posts: 6
Joined: Sat Oct 12, 2013 6:29 pm

Sensing Movement Lesson 12

Post by fremenusul »

I have all the materials and equipment for http://learn.adafruit.com/adafruits-ras ... t/overview

I have followed the walk through exactly but I am getting a "Door alarm" message even though my reed switch is closed. The PIR seems to work so I disconnected it (and commented out the code).

I am very new to Pi, electronics and this whole experience.

fremenusul
 
Posts: 6
Joined: Sat Oct 12, 2013 6:29 pm

Re: Sensing Movement Lesson 12

Post by fremenusul »

Has anyone been able to actually make this lesson work?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sensing Movement Lesson 12

Post by adafruit_support_mike »

We test all our tutorials to make sure they work before publishing them. Most people don't post to the help forum when a project works.

Post a photo of your hardware and connections and we'll see what we can find.

fremenusul
 
Posts: 6
Joined: Sat Oct 12, 2013 6:29 pm

Re: Sensing Movement Lesson 12

Post by fremenusul »

Image

Image

In GRND and pin 23.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sensing Movement Lesson 12

Post by adafruit_support_mike »

Try disconneting the reed switch and running the script again. Let's make sure it returns the correct value when there's no connection.

fremenusul
 
Posts: 6
Joined: Sat Oct 12, 2013 6:29 pm

Re: Sensing Movement Lesson 12

Post by fremenusul »

When disconnected it is giving me "Door Alarm" which doesn't seem right to me.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sensing Movement Lesson 12

Post by adafruit_support_mike »

That's what's it's supposed to do. This line:

Code: Select all

io.setup(door_pin, io.IN, pull_up_down=io.PUD_UP)  # activate input with PullUp
connects an internal resistor to the GPIO pin. When there's nothing connected to door_pin, its voltage will be HIGH. That will pass the test in this line:

Code: Select all

    if io.input(door_pin):
and cause the code to print "DOOR ALARM!"

Take a look at the last line on this page of the tutorial: http://learn.adafruit.com/adafruits-ras ... t/software
Remember that the door switch warning will be activated when the magnet is removed from the sensor rather than the other way around.

fremenusul
 
Posts: 6
Joined: Sat Oct 12, 2013 6:29 pm

Re: Sensing Movement Lesson 12

Post by fremenusul »

Ok, so if nothing is connected the pin is HIGH.

The issue I have is no matter if the reed switch is next to the magnet or not, I get Door alarm. It never switches back to LOW.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sensing Movement Lesson 12

Post by adafruit_support_mike »

That means we need to test the switch. Disconnect it from the breadboard and test the resistance through it with the magnet far away, then with the magnet right up against the switch enclosure. You should see zero resistance when the magnet is far way, and infinite resistance when the magnet is close.

fremenusul
 
Posts: 6
Joined: Sat Oct 12, 2013 6:29 pm

Re: Sensing Movement Lesson 12

Post by fremenusul »

Its acutally the opposite.

I get .6 ohm when connected and infinite when they are not connected.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Sensing Movement Lesson 12

Post by adafruit_support_mike »

Could you post a photo of that please? From your description, it sounds like you have a normally-open reed switch being closed by the magnet, not a normally-closed reed switch being opened by the magnet.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”