1
0

asynchronous_gpio_transmit.py 768 B

12345678910111213141516171819202122232425262728
  1. import logging
  2. import time
  3. from RPi import GPIO
  4. import cc1101
  5. logging.basicConfig(level=logging.INFO)
  6. _GDO0_PIN = 18 # GPIO24
  7. GPIO.setmode(GPIO.BOARD)
  8. GPIO.setup(_GDO0_PIN, GPIO.OUT, initial=GPIO.LOW)
  9. with cc1101.CC1101() as transceiver:
  10. transceiver.set_base_frequency_hertz(433.92e6)
  11. transceiver.set_symbol_rate_baud(600)
  12. transceiver.set_output_power((0, 0xC0)) # OOK modulation: (off, on)
  13. print(transceiver)
  14. print("starting transmission")
  15. with transceiver.asynchronous_transmission():
  16. while True:
  17. print(1, end="", flush=True)
  18. GPIO.output(_GDO0_PIN, GPIO.HIGH)
  19. time.sleep(1.0)
  20. print(0, end="", flush=True)
  21. GPIO.output(_GDO0_PIN, GPIO.LOW)
  22. time.sleep(1.0)