0

I bought an RF sender and a receiver mode. The sender is connected to GPIO 6 and the receiver to GPIO 12. At first I just want to test with the simplest of tarnsmission tests. Here is my sender py code:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
GPIO.setup(6, GPIO.OUT) # output rf
print("Testing RF out, Press CTRL+C to exit")

try:
     print("set GIOP high")
     GPIO.output(6, GPIO.HIGH)
     time.sleep(5)               
except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
   print("Keyboard interrupt")

except:
   print("some error") 

finally:
   print("clean up") 
   GPIO.cleanup() # cleanup all GPIO 

The code is just setting high the GPIO 6 and five seconds later quit. The receiver (which I start before a start sending anything):

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
GPIO.setup(12, GPIO.IN) # input RF

print("Starting to read RF input, CTRL+C to exit")

try:
     while 1:
          if GPIO.input(12):
             print("Something from GPIO 12")  
except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
   print("Keyboard interrupt")

except:
   print("some error") 

finally:
   print("clean up") 
   GPIO.cleanup() # cleanup all GPIO 

Unfortunately I don't get anything from GPIO 12. I am a newbie to RF communication. What do I have to do the get something. The code is very terse and at this point I just want to test I actually get something.

1

I can't see anything wrong with your logic or your code (although I haven't tried running the code).

Double check you are using the correct GPIO. GPIO 6/12 are on pins 31/32 of the 40 pin expansion header.

You could test the code receive logic with my pigs utility (part of the pigpio suite).

sudo pigpiod
pigs w 12 0
pigs w 12 1

Another diagnostic tool to consider is piscope which will let you visualise GPIO level changes.

  • Thank you. When running "pigs w 12 1" my python rfin,py start showing "Something from GPIO 12" as expected. However my rfout.py does not achieve that, Thank you. I'll figure it out. – user1231247 Jun 9 '17 at 14:26
  • I am getting a bit of noise - not much - but every 3-5 secs a few clicks on the reader side. Would a pull up/pull down resistor help? If so what sort (ohm) I should use? – user1231247 Jun 10 '17 at 9:09
  • No, not really. You can power the transmitter from 5V but the receiver needs to be powered from 3.3V (unless you use a voltage divider on the receive pin). Do you have aerials attached to the receiver and transmitter? Perhaps edit your question to add a photo of your kit. – joan Jun 10 '17 at 9:20
  • The reader and transmitetr are rated to work 3v-12v so I've put it to use 3.3V. Aerials (abou 17.5 cm) have been soldered to both. I have a cordless mouse nearby. – user1231247 Jun 10 '17 at 10:32
  • @user1231247 Perhaps the auto level detection is kicking in and rejecting a level signal. Try sending a PWM signal on the transmitter or send some codes using abyz.co.uk/rpi/pigpio/examples.html#Python__433_py or abyz.co.uk/rpi/pigpio/examples.html#pdif2__433D – joan Jun 10 '17 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.