046 – MicroPython TechNotes: RF433 Transceivers



I have a spare components from Gorillacell for RF433 transceivers which produces a functional circuit.
HARDWARE INSTRUCTION:
1. Attach the RF433 transceiver module to ESP32 as follows:
RF433 Rx/Tx G pin to ESP32 ground pin.
RF433 Rx/Tx V pin to ESP32 5V pin.
RF433 Rx/Tx S pin to ESP32 GPIO 23 pin.
2. (Optional) Power the ESP32 shield with an external power supply through the type-C USB cable connector.
3. Connect the ESP32 to the computer through a micro USB cable.
SOFTWARE INSTRUCTION:
1. Copy the source code and run source code to the assigned ESP32, 1 for the transmitter side and another 1 for the receiver side circuit.
2. Feel free to modify the source code and please let me know if you made progress or you have any concern.
VIDEO DEMONSTRATION:
SOURCE CODE:
1. Example # 1, blinking an LED, transmitter:
# More details can be found in TechToTinker.blogspot.com
# George Bantique | tech.to.tinker@gmail.com
from machine import Pin
from time import sleep_ms
transmit = Pin(23, Pin.OUT)
sw = Pin(0, Pin.IN)
while True:
transmit.value(not transmit.value())
sleep_ms(50)
2. Example # 1, blinking an LED, receiver:
# More details can be found in TechToTinker.blogspot.com
# George Bantique | tech.to.tinker@gmail.com
from machine import Pin
from time import sleep_ms
receive = Pin(23, Pin.IN)
led = Pin(2, Pin.OUT)
while True:
led.value(receive.value())
sleep_ms(50)
3. Example # 2, sending message through RF433 modulated serial UART:
# More details can be found in TechToTinker.blogspot.com
# George Bantique | tech.to.tinker@gmail.com
from machine import Pin
from machine import UART
tx = UART(2, baudrate=9600, tx=23, rx=25)
# tx.write('This is a test messagern')
4. Example # 2, receiving message through RF433 modulated serial UART:
# More details can be found in TechToTinker.blogspot.com
# George Bantique | tech.to.tinker@gmail.com
from machine import Pin
from machine import UART
rx = UART(2, baudrate=9600, tx=25, rx=23)
# print(rx.read())
while True:
if rx.any():
print(rx.read())
5. Modified # 1, toggling the state of the receiver on-board LED, transmitter:
# More details can be found in TechToTinker.blogspot.com
# George Bantique | tech.to.tinker@gmail.com
from machine import Pin
from time import sleep_ms
transmit = Pin(23, Pin.OUT)
sw = Pin(0, Pin.IN)
var_sw = 1
while True:
if sw.value()==0: # means, sw is pressed!
var_sw = not var_sw # toggle the state of variable
transmit.value(var_sw) # send it to the radio
sleep_ms(50)