Home

Awesome

MicroPython YS-RF34T 433MHz ASK/OOK UART Transceiver

MicroPython examples using YS-RF34T 433MHz ASK/OOK UART transceivers.

demo

This module consists of an unlabelled MCU that provides a UART interface to two daughter ASK/OOK modules.

A 433MHz receiver (YS-RF470) and a 433MHz transmitter (H34C).

This module can be used to emulate or program a ASK/OOK based fixed code remotes.

Does not support rolling code.

Examples

from machine import Pin, UART
uart = UART(1, tx=14, rx=15, baudrate=9600)

# sniff for a remote
def sniff():
    while True:
        if uart.any():
            print(uart.readline())

# eg. received b'\xfd\x84\x19\x04D\xdf'

# replay a remote
def replay():
    # almost the same buf as received
    # byte 1 is how long to tx for
    uart.write(bytearray(b'\xfd\x03\x84\x19\x04D\xdf'))

# transmit
def tx(addr, key, time=3, width=64):
	buf = bytearray(b'\xfd\x00\x00\x00\x00\x00\xdf')
	buf[1] = time & 0xff
	buf[2] = (addr >> 8) & 0xff
	buf[3] = addr & 0xff
	buf[4] = width & 0xff
	uart.write(buf)

# (0x84 << 8) | 0x19 = 33817
tx(33817, 4)

# receive
def rx():
    while True:
        if uart.any():
            buf = uart.readline()
            if len(buf) == 6 and buf[0] == 0xfd and buf[5] == 0xdf:
                addr = (buf[1] << 8) | buf[2]
                key = buf[3]
                print('Found! Address: {}, Key: {}'.format(addr,key))

rx()
# Found! Address: 33817, Key: 1
# Found! Address: 33817, Key: 2
# Found! Address: 33817, Key: 4
# Found! Address: 33817, Key: 8

The MCU understands 2262, 2260, 1527 encoded transmissions.

If you're not receiving anything, check your RX and TX are not switched otherwise the remote might be using an unsupported protocol.

Pinout

PinNameDescription
1GNDGround
2RXDUART receive
3TXDUART transmit
4VCCSupply voltage 3V3 - 5V

Connections

TinyPICO ESP32

from machine import Pin, UART
uart = UART(1, tx=14, rx=15, baudrate=9600)
YS-RF34TTinyPICO (ESP32)
GNDGND
RXD14 TXD
TXD15 RXD
VCC3V3

Transmit Protocol

Write 7 bytes and the MCU will build and send out the desired packet using the onboard ASK/OOK RF module.

Packet = (Header, Time, Address 2, Address 1, Key, Width, Footer), eg.

bytenamedescription
0headerconstant value of 0xFD
1timetransmit time - signal repeats until timeout
2addr2high address bits
3addr1low address bits
4keywhich button was pressed
5widthwidth of signal in ms
6footerconstant value of 0xDF
headertimeaddr2addr1keywidthfootereg
0xFD0x030x840x190x040x400xDFb'\xfd\x03\x84\x19\x04\x40\xdf'
0xFD0x060x220x330x440x500xDFb'\xfd\x06\x22\x33\x44\x50\xdf'

Receive Protocol

When the MCU receives a signal from the receiving ASK/OOK RF module, it will output 6 bytes over UART.

The packet is almost identical to the TX packet, only is missing the Time value.

bytenamedescription
0headerconstant value of 0xFD
1addr2high address bits
2addr1low address bits
3keywhich button was pressed
4widthwidth of signal in ms
5footerconstant value of 0xDF
headeraddr2addr1keywidthfootereg
0xFD0x840x190x040x440xDFb'\xfd\x84\x19\x04\x44\xdf'

RTL-SDR capture with URH and replay with YS-RF34T

See RTL-SDR-URH.md.

Parts

Links

License

Licensed under the MIT License.

Copyright (c) 2019 Mike Causer