Skip to content

Instantly share code, notes, and snippets.

@bivald
Created November 25, 2012 16:53
Show Gist options
  • Save bivald/4144298 to your computer and use it in GitHub Desktop.
Save bivald/4144298 to your computer and use it in GitHub Desktop.
XRF Getting out of sleep mode - brute force
#!/usr/bin/python
# This is a crude brute-force tool to remove the cycling on a XRF module (http://shop.ciseco.co.uk/xrf-wireless-rf-radio-uart-rs232-serial-data-module-xbee-shape-arduino-pic-etc/)
# What it does is that every 20 ms it sends out a : WAKE + REMOVE INTLV + Reboot command
# This should be running when you power up your XRF (or when the XRF sends the battery reading, but on startup is easier)
#
# Start the script, start the XRF and it should reset straight away. Afterwards it will boot with the regular STARTED commands, without cycle.
# Everything else is the same (i.e device name etc.)
#
# 1. You need a XRF connected to your computer,
# Either a USB XRF receiver/sender(http://shop.ciseco.co.uk/urf-radio-module-and-serial-inteface-via-usb/)
# Or a XRF radio connected to your Arduino with a slice of pi
#
# 2. You need python-serial installed, to install it:
# sudo pip install pyserial
# or:
# sudo apt-get install py-serial
# or:
# sudo easy_install pyserial
#
# 3. You need to know the /dev/ adress to your XRF, these are usually:
#
# /dev/tty.usbmodem000001 - If you'r on MAC and you have a USB XRF
# /dev/ttyAMA0 - Slice of pi, raspberry
# /dev/ttyACM0 - USB XRF on raspberry
#
import serial
import time
DEVICE = '/dev/ttyAMA0'
BAUD = 9600
while True:
ser = serial.Serial(DEVICE,9600,timeout=0.01)
ser.write('aAAWAKE-----')
ser.write('aAAINTVL000x')
ser.write('aAA REBOOT--')
time.sleep(0.02)
ser.flush()
ser.close()
@martynwheeler
Copy link

martynwheeler commented Jun 16, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment