OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) RF switching – code additions for OSPi interval program?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #22782

    TonyA
    Member

    I’ve been been delving into adding RF switching to the OSPi system for switching 433MHz 240VAC devices in parallel with the existing station functionality. I don’t seem to be able to locate example code changes for the OSPi Interval program anywhere? As a complete novice on python and the general Linux coding environment, was hoping someone might have some pointers on what code to insert where etc as a starting point?

    So far I’ve managed to:
    * capture the ON/OFF signal patterns of the 433MHz transmitter hardware to replicate via the PI. (http://rayshobby.net/?p=3381)
    * connect a 433MHz transmitter to the RPI – which admittedly is quite straight forward (http://rayshobby.net/cart/433-rf)
    * use python interactive mode to manually set GPIO4 (header pin 16) output high/low – this pin is connected to the 433MHz transmitter input data pin and a change in the RF signal was detected via an RF receiver connected to Audacity.

    The electronics seem right to go and I have the required signal patterns… – so any pointers on code changes for the OSPi Interval program itself would be much appreciated! 🙂

    #26146

    Ray
    Keymaster

    First of all, the Arduino programs should be pretty easy to adapt to RPi by using wiringPi. In particular, the Arduino RC-Switch library works with wiringPi, and it provides a lot of powerful functions. Note that Rich’s sprinklers_pi program is written in wiringPi.

    Now, since Dan’s interval program is written in Python, you will need to convert the code to Python. It’s also fairly straightforward. Below is an example: connect the RF transmitter to +5V, GND, and GPIO pin 17 on RPi, and you need to modify the signal (signature and command) to fit your specific remote socket.


    #!/usr/bin/python

    import RPi.GPIO as GPIO
    import time

    SEND_PIN = 17

    SIGNATURE = 0b0000111101010101

    COMMAND = 0b11110001

    DELAYSHORT = 160
    DELAYLONG = 500

    OVERHEAD = 0 # overhead time (in us) for calling GPIO.output and time.sleep. If 0 doesn't work, try 125

    def ookPulse(on,off):
    GPIO.output(SEND_PIN,True)
    time.sleep((on-OVERHEAD)/1000000.0)
    GPIO.output(SEND_PIN,False)
    time.sleep((off-OVERHEAD)/1000000.0)

    def pt2262Send(signature,command):
    for k in range(0,16):
    for i in range(0,16):
    if((signature>>(15-i)) & 0x1):
    ookPulse(DELAYLONG, DELAYSHORT)
    else:
    ookPulse(DELAYSHORT, DELAYLONG);
    for i in range(0,8):
    if((command>>(7-i)) & 0x1):
    ookPulse(DELAYLONG, DELAYSHORT)
    else:
    ookPulse(DELAYSHORT, DELAYLONG)
    ookPulse(DELAYSHORT, DELAYLONG)
    time.sleep(.005)

    def main():
    GPIO.cleanup()
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(SEND_PIN,GPIO.OUT)
    while True:
    pt2262Send(SIGNATURE,COMMAND)
    time.sleep(5)

    main()
    #26147

    TonyA
    Member

    Thanks Ray, I’ll experiment with that..

    #26148

    jantum
    Member

    Hello,
    This project is really interesting ;o)
    My current setup:
    3 valves controlled by a Gardena Wireless Control System
    Specification could be found here:
    RF Receiver: http://www.gardena.com/de/bewasserung/gartenteich/funkempfanger-r4/
    RF Transmitter: http://www.gardena.com/de/bewasserung/bewasserungssteuerung/funkzentrale/
    The setup communicates through 433 Mhz.
    Therefore I would like to ask, if I could use this setup (the Receiver) to control the valves via the opensprinkler PI?
    With my understanding of the aboved mentioned steps I have to to the following:
    1) Screen the signals send by the transmitter
    2) Add a new RF transmitter to the Opensprinkler PI
    3) Set up a python script to control the valves via the PI GPIO4
    Thanks for your support.
    Kind regards from Berlin (Germany)

    Jan

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) RF switching – code additions for OSPi interval program?