Bladiebla
Bladiebla

Reputation: 86

GPIO interrupt triggered by different pin

tl;dr:

Listening to a RISING event on GPIO PIN14 (with 10K pulldown resistor); Ghost RISING events when sending/receiving data on different GPIO pin;


I have the following issue:

In my technical room I have a Raspberry Pi 1B, and Raspberry Pi 3; I tested this on both units and I get the same results;

My mains meter has a flashing LED, 1000/kWh; I want to measure this using a photo resistor; The photo resistor is connected to GPIO PIN14; This setup works just fine, as long as I don't use any of the other GPIO pins.

Using the same unit I want to send some data over 433Mhz (GPIO PIN7, but as soon as I transmit data, I get RISING events on PIN14...

Across the internet I found different solutions, none of which seem to be working:

Using the code below, I can see expected behavior of the photo resistor and PIN14; But as soon as I startup the transmissions, the events of sending a message and RISING events on PIN14 synchronize. When I stop sending messages the listener on PIN14 stops working.

Does anyone have any idea how to fix this?

Diagram

PIN14 Listener code:

import datetime
import time

try:
    import RPi.GPIO as GPIO
except RuntimeError:
    print(
        'Error importing RPi.GPIO!  This is probably because you need superuser privileges.')

delta = datetime.timedelta(microseconds=100000)
global last_electric_ping
last_electric_ping = datetime.datetime.now()

GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.IN)


def electric_ping(channel):
    if GPIO.input(14):
        global last_electric_ping
        now = datetime.datetime.now()
        if delta + last_electric_ping <= now:
            print(delta + last_electric_ping, end=" ")
            print('ELECTRIC')
        last_electric_ping = now

GPIO.add_event_detect(14, GPIO.RISING, callback=electric_ping)

while True:
    continue

GPIO.cleanup()

Transmission code:

import time
from pi_switch import RCSwitchSender

sender = RCSwitchSender()
sender.enableTransmit(15) # use WiringPi pin 0

num = 1
while True:
        time.sleep(1)
        print("Woei!")
        sender.sendDecimal(num, 24)
        num += 1

Upvotes: 2

Views: 814

Answers (1)

Bladiebla
Bladiebla

Reputation: 86

Roll the drums:

Apparently I ran into a numbering issue; The BCM pin numbering says physical pin 8 is GPIO14, which is nice;

Now three guesses which number wiringPi gives to physical pin number 8... yes, number 15! Which is the one I'm trying send data to in the second script;

Now excuse while I go slap myself with a brick in the corner over there...

Upvotes: 3

Related Questions