which GPIO?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

which GPIO?

#1 Post by manjh » 30 May 2016, 21:06

I am struggling with a simple problem. Am setting up a new NodeMCU that needs to switch two relays, and handle two input switch devices.
After some experimenting I managed to connect the two relay lines to GPIO12 and 14. I can control them by sending http commands thru on/off actions in Domoticz.

But for some reason I can't get the switches to work.
To make things simple I am testing with a simple wire connector to ground (Wiki says switch should be connected between GPIO and ground).

So I have two questions:
1. is there an overview of which GPIO lines can safely be used for input and for output? I searched the Wiki, can't find it.
2. what the f..k is wrong with my switch setup...? When I connect the GPIO with ground, it should change status, right?

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: which GPIO?

#2 Post by manjh » 31 May 2016, 21:21

any takers? Which GPIO lines are safe to be used for input and output?

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: which GPIO?

#3 Post by tozett » 31 May 2016, 22:04


manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: which GPIO?

#4 Post by manjh » 31 May 2016, 22:56

Thanks for that link, I will read thru it carefully.

Meanwhile I am moving forward. Decided to go back to basics and use a patch wire to connect the GPIO pins to ground and see what happens.
Tried GPIO0 (D3): works fine.
GPIO2 (D4): when I connect this to ground the blue led lights up and stays on. NodeMCU freezes.
GPIO13 (D7): works fine
GPIO15 (D8): no response.
Of course I defined a switch task in ESP Ease before testing.

Also tried GPIO9 and 10 (SD2 and 3): no good.

So it looks like I found 2 usable switch inputs, which is sufficient for now.

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: which GPIO?

#5 Post by manjh » 31 May 2016, 22:59

Another thing I discovered: I was trying to connect the signal-out from a PIR sensor to an input pin.
The PIR sensor itself is powered from 5V and ground.
The signal lead shows 1.65V when motion is detected, and drops to 0 when it is quiet.

But when I connect it to a GPIO pin, the voltage does not drop to zero, so no change is detected.
I switched off the pull-up in the task.
Also tried a pull-down to ground via 4K7 resistor, which helped a little but not much.
I've been looking for a pull-down checkbox, but there is no such thing.

Am I missing something? How should I attach this PIR sensor?

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: which GPIO?

#6 Post by tozett » 01 Jun 2016, 07:49


manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: which GPIO?

#7 Post by manjh » 01 Jun 2016, 09:35

Exactly my connection: power to the PIR unit is 5V, output is 1,65V when active, zero when inactive. Even the unit looks identical. :)

Problem is that the GPIO does not drop to zero when the PIR unit goes inactive.
I already tried a pulldown resistor of 4K7 to ground, which helps a few millivolts but not enough. Getting a lower value R may help, but I am reluctant to try.

Is there a pulldown option in ESP Easy? I can see the pullup tickbox, so I assumed that de-selecting that box would mean "pulldown".
My measurements show different.
Difference between selecting pullup and not selecting is measurable, but very small.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: which GPIO?

#8 Post by tozett » 01 Jun 2016, 09:42

i am powering the PIR with 3.3V, and it works...
may you try this to (there is lots of info on this in google..)

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: which GPIO?

#9 Post by JR01 » 01 Jun 2016, 11:16

Or use a logic level converter 3.3v to 5v

https://www.sparkfun.com/products/12009
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: which GPIO?

#10 Post by manjh » 01 Jun 2016, 11:50

I don't understand. The PIR sensor is powered from the USB-in line, so it is 5V (measured it).
Ground is common, so no problem.
The signal line of the sensor is either 0 or 1,65V, so no conversion needed here as well.

My problem is with the level of the GPIO line when the sensor is inactive. It does not drop to zero!

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: which GPIO?

#11 Post by tozett » 01 Jun 2016, 13:28

i did not measure my output, but its running on 3.3volt and working without any other mods ....
do you have another sensor at hand?

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: which GPIO?

#12 Post by manjh » 01 Jun 2016, 19:13

tozett wrote:i did not measure my output, but its running on 3.3volt and working without any other mods ....
do you have another sensor at hand?
Which GPIO did you connect to, and what kind of device did you use in the ESP Easy task?

hamster
Normal user
Posts: 62
Joined: 27 Sep 2015, 21:01
Location: UK

Re: which GPIO?

#13 Post by hamster » 01 Jun 2016, 19:14

I am using a HC-SR501 PIR without any issues
The PIR is powered by 5v
the output is 3.3v connected GPIO 12 on ESP12e
I have the pull up enabled
inversed is disabled

I also tried the smaller HC-SR505 Mini PIR's but found these unreliable

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: which GPIO?

#14 Post by tozett » 01 Jun 2016, 19:37

dsun22.png
dsun22.png (132.53 KiB) Viewed 11852 times

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: which GPIO?

#15 Post by manjh » 02 Jun 2016, 11:26

OK, I attached it exactly you you did, except used GPIO13 (D7).

PIR power to 5V and ground, signal to D7.
Connected a VU meter over ground and data to see what is happening.

As soon as the PIR sensor switches on, the data line is 1.65V.
When it switches off, the data goes down to 0.01V.
This puzzles me, since pullup is switched on! I would expect D7 to go up.

More importantly, when I look at the log, the PIR does not switch at all.
Disconnect the data line: state goes to 0.
Connect it again: state goes back to 1, regardless of the motion sensor being on or off.

Weird...

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: which GPIO?

#16 Post by tozett » 02 Jun 2016, 13:36

Try another Hardware...

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: which GPIO?

#17 Post by manjh » 02 Jun 2016, 18:35

tozett wrote:Try another Hardware...
Sounds like the old service mechanic "switch parts and see what happens" approach.
It simply does not make sense.
The PIR sensor works OK, the signal line goes to 1.65V when motion is detected, and falls back to zero when not.
Problem is the NodeMCU that does not see this...
Anyway, I am giving up. Have a spare standalone PIR unit that I will be using...

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: which GPIO?

#18 Post by tozett » 02 Jun 2016, 19:27

i measured my output. if the pir has detections, it is 3.3v.
the pir is powered with 5V from my wemos-d1 mini.

i googled, this page says, they have also 3.3v on output: https://learn.adafruit.com/pir-passive- ... r/overview

you have only 1.65, means half of my output-voltage on detection.... :roll:

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 124 guests