ON/OFF Switch


#1

1. What OS? (Wheezy or Jessie)


Jessie full (26/02/16 build)

2. What class/size SD card? (ex. class 10 16gb)


8Gb

3. What Model Pi? (A+, A, B+, B, Pi2)

Pi2

4. Please describe the bug / issue. Attaching any relevant screenshots would be very helpful! Thanks in advance.

I have a simple switch (old PC power switch) plugged into 15 (GPIO22) and 17 (3.3 volt), with the GPIO set to IN. Once I press the button it keeps toggling between HI and LOW every few seconds.

LOW…

…then HIGH…

…then LOW…

…and so on…

Not sure if I need a resistor or capacitor, or a programming issue - but from memory I had done this previously just with WebIOPi.


#2

Hmmm. We may need to get your account credentials so we can see this issue in action.

@eptak any ideas as to what is happening here?

-B


#3

Doh! Hey Benny,

I already have your credentials. :blush:


#4

LOL, Yes you do.

I tested it on another Pi with the same results. The switch is floating from HIGH to LOW on the ControlPi on pins 15 and 17.

See how you go.

Cheers


#5

can you try with the local debug, eg webiopi (it’s installed with cayenne)
open your browser to http://piaddress:8000/app/gpio-header


#6

Same thing Eric. You still see it going from HIGH to LOW to HIGH etc…






#7

Hi Guys,

Any ideas on this? Do you want logs or access?

Cheers

Ben


#8

Logs would be great! Fine if you post them here.


#9

The webiopi logs don’t show anything. Is there another log that the GPIO activity is logged? I have looked through the webiopi config and its just all pretty standard stuff. I did switch another GPIO connected to a relay, but it didn’t amend the log at all!

2016-03-22 20:31:48 - WebIOPi - INFO - Starting WebIOPi/0.7.16/Python3.4
2016-03-22 20:31:48 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2016-03-22 20:31:48 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2016-03-22 20:31:48 - WebIOPi - INFO - Temperature - DS18B20(slave=28-000003e9b620) mapped to REST API /devices/000003e9b620
2016-03-22 20:31:48 - WebIOPi - INFO - DigitalActuator - RelaySwitch mapped to REST API /devices/J1nDKuvDLv7xqHEs
2016-03-22 20:31:48 - WebIOPi - INFO - DigitalActuator - ValveSwitch mapped to REST API /devices/wIuurxHFHwxvnEML
2016-03-22 20:31:48 - WebIOPi - INFO - DigitalActuator - RelaySwitch mapped to REST API /devices/xMIJzssoKnqwII0x
2016-03-22 20:31:48 - WebIOPi - INFO - Access protected using /etc/webiopi/passwd
2016-03-22 20:31:48 - WebIOPi - INFO - HTTP Server binded on http://192.168.100.239:8000/
2016-03-22 20:32:07 - WebIOPi - INFO - Stopping…
2016-03-22 20:32:07 - WebIOPi - INFO - HTTP Server stopped
2016-03-22 20:32:34 - WebIOPi - INFO - Starting WebIOPi/0.7.16/Python3.4
2016-03-22 20:32:34 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2016-03-22 20:32:34 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2016-03-22 20:32:34 - WebIOPi - INFO - Temperature - DS18B20(slave=28-000003e9b620) mapped to REST API /devices/000003e9b620
2016-03-22 20:32:35 - WebIOPi - INFO - DigitalActuator - RelaySwitch mapped to REST API /devices/J1nDKuvDLv7xqHEs
2016-03-22 20:32:35 - WebIOPi - INFO - DigitalActuator - ValveSwitch mapped to REST API /devices/wIuurxHFHwxvnEML
2016-03-22 20:32:35 - WebIOPi - INFO - DigitalActuator - RelaySwitch mapped to REST API /devices/xMIJzssoKnqwII0x
2016-03-22 20:32:35 - WebIOPi - INFO - Access protected using /etc/webiopi/passwd
2016-03-22 20:32:35 - WebIOPi - INFO - HTTP Server binded on http://192.168.100.239:8000/


#10

@eptak


#11

For me it’s a normal behavior to have input channels that have changing values is they are not tied to something (sensor, ground, power).


#12

Is this what are you talking about

“If you have no pull-up or pull-down resistors attached to an input port, its status is not clearly defined. It is “floating”. It is susceptible to random electromagnetic radiation or static from you, from any devices near or far and from the environment. Any wires attached to the GPIO ports act as antennae for this radiation (it’s mostly radio waves).”


#13

Ill give that a go and see if it makes a difference.

Cheers


#14

Hey Benny!

Were you able to make any progress here?


#15

Yep, looks like it.


#16

I’ll give that a go tonight. Have been away for the Easter break drinking beer and eating food (not in front of a computer!).


#17

so- tell me- can Cayenne tell the remote device to use the internal pull-up resistors, or shall I use an external SIP resistor pack as pullups?

My current issue:
the internal GPIO INPUT pull-up.
I gotta know-
it’s kind of important to me.
I can design either way, but I gotta know now.
can Cayenne tell the remote Pi unit to use GPIO pull-up?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Cat5 Orange
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Cat5 Blue
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Cat5 Green
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Cat5 Brown