mx05v notes

Fri 16:211Q: Transmitting and Receiving messages through RF433 using Raspberry Pico

AntifaI’m currently working in a new DIY project, where I need to send a message through RF from Raspberry Pico, and receive it in an other Raspberry Pico through RF. I have bought some common RF433 receivers and transmitters (see image below) I’m using MicroPython. I have searched Internet to find pos…pi-picomicropythontlfong016715(1) MX-05V is newbie firendly. (2) Arduino video tutorial, libraries, and demo code are easy to find. (3) Pico equivalent is not around, unfortunately. (4) Fortunately the code is not that complicated, so you can try to convert the Arcuino C++ code to Pico MicroPython (the other way around is more difficult, though). If you decided to use MX-05V, you might like to list the simple code and me or others might give a hint on how to convert it to python. PS, I once used use Arduino Decimilla 3V3 SPI RF12B and found it tricky to work with, But 5V MX-05V is much simpler. / to continue, … AntifaThanks for your comment. I will try your proposal to convert Arduino library to RpiPico. Do you have any specific library recommendation? tlfong016715Ah, I need to first look at the datasheet, to make sure if my suggestion makes any sense. 433MHz Wireless Modules MX-05 _ HobbyComponents forum.hobbycomponents.com/viewtopic.php?t=1324I randomly googled and found this library. Now I am checking it out. HCWireless Arduino Library for 433MHz Wireless Tx & Rx modules – HobbyComponents forum.hobbycomponents.com/viewtopic.php?f=58&t=2914The HobbyComponents does not provide any MX-05V datasheet. Other shops seems to link another chip: components101.com/modules/433-mhz-rf-receiver-module.This tutorial looks better: How to use 315Mhz RF Transmitter and Receiver Modules (MX-FS-03V / MX-05V) with Arduino myhowtosandprojects.blogspot.com/2014/01/….And this looks like a good library: VirtualWire Library VirtualWire, by Mike McCauley (PDF), helps you use very inexpensive wireless radio modules – PJRC pjrc.com/teensy/td_libs_VirtualWire.htmlAntifaI will check and I will get back to you tlfong016715OK. BTW, documentation is very good: airspayce.com/mikem/arduino/VirtualWire.pdfJust now I tried to download VirtualWire in my Windows 10, but no luck. I have no Arduino staff in my PC Windows, and no Arduino in hand. It would be nice if you can installed VirtualWire somewhere and pass me a copy of the source code, then I can skim through it and see if it would be easy just to translate the bare bone part and try it in Rpi Pico MicroPython. AntifaFri 16:21I have found this VirtualWire library for Pi. Indeed it is not for Pico. Also this source code has a dependency to RPi.GPIO which is not for Pico also. quadmeup.com/virtualwire-support-for-raspberry-pitlfong016715Oh my goodness. piVitrualWare is many times better than original VirtualWare for Arduino, because is it already in python, therefore saves a lot of C++ to python conversion time. However, there are two small problems: (1) As you said, it is using Rpi built in Rpi Gpio module, which is not the same as the Pico GPIO module. I think it easy to do the almost trival one to one conversion. (2) The PiPGIO thing a bigger problem:(a) it is sort of a daemon thing, meaning that you can only run it in the background, (b) I heard that PiGPIO might not run smoothly on Rpi4B, because of system timing problem. And Pico is no multitasking OS like Rpi OS, so the timing problem might be more tricky to handle. But I think we can do these: (i) study the PiGPIO source code, and see how it interface with the daemon, and the main idea of the MX05V control, (ii) then rewrite the VirtualWire thing starting from afresh, …With PC Windows Thonny Rpi Pico MicroPython. I think it is not a complicated job at all. PiVirtualWire can be downloaded to Rpi or Windows, but I have not played with linux CLI commands for over a year, and don’t have a working Rpi4B in hand (I have 5 working Pico’s in hand! :)) So it would be nice if you can do the following for me:(A) Down load the PiVirtualWare in any platform you like, (A) Pass me the complete python code listing. I guess the complete listing should be shorter than 500 lines. I will study the code and guesstimate how long it would take me to do a quick and dirty conversion, perhaps only the transmit part, to prove the concept.Nothing urgent, please take your time. BTW I already ordered a couple of the real thing, they should arrive in 2 working days: item.taobao.com/…. Cheers.  2 hours later… Antifa339Fri 19:09You mean this?github.com/DzikuVx/…I have found also this, but it lacks some functions.
forums.raspberrypi.com/…tlfong016715Fri 19:31Ha, your two links are very helpful, and the first link is almost what I want, actually better than what I want. I am sorry I don’t express myself clearly and caused the confusion.Let me try again. (1) the piVirtualWaire library is what I want to explore further. But I don’t have any Rpi4B or other linux thing in hand, and I don’t want to setup Rpi4B just to install the piVirtualWire. So I thought you might help to install the piVirtaulWire in your Rpi (I assumed you have Rpi3/4, and you have experience using Rpi OS and linux CLI commands like Make etc),get the python listing and send me a copy. But this is NO longer necessary, because you first link is what almost what I want, or even better. Anyway, I will now look at your first link and see how useful it is.Now your second link about a “shim” useful to those who want to run Rpi python programs (using Rpi built in GPIO or GPIOZero modules) on Pico. This shim would convert the original Rpi porgram to run in Pico and run it there. This clever thing is of course useful in general, but not for our situation, because using the piGPIO, a daemon thing, which I think the above shim cannot handle.This might be a bit complicated, but not too important, because if the first link’s source code is complete and not too long (as I have guessed, less than 500 lines), it might be easy to rewrite part of the code initializing Rpi GPIO pins to Pico GP pins.Anyway, you have already helped a lot in this research part. Perhaps you can now take a break, sit down and let me skim your first link’s piVirtualWire code and see how useful is it. tlfong016715Fri 20:01github.com/DzikuVx/…I am back. I went to your first link on VirtualWire: github.com/DzikuVx/…I found the guy written this piVirtualWire uses joan’s piGPIO which is a GPIO module similar to Rpi’s GPIO or GPIOzero, but in the form of a daemon, running on the background, and have special functions, like timing interrupts, callback functions, PWM etc. I have never used this piGPIO before, because I don’t need those special functions based on a daemon.I have skimmed the VirtualWire library and found it a simple library with two basic functions, (1) sending a message, (2) receiving a message, both using one pin. There are also CRC functions, but not important in our application.Of course I am only guessing. I tend to think that piVirtualWire (or VirtualWire) is just a software utility based on serial communication stuff, ie RxTx, UART etc.So there is a big chance if we use Pico python SDK’s UART functions, we can write something similar of piVirtualWire.As I said earlier, my MX05V toys might arrive the day after tomorrow. I will then do the first basic experiments: (1) Just power up the transmitter module, and input some rubbish data, say a square wave pulse to the output pin, and (2) at the same time, set up the receiver module, and use my scope to display the waveform at input pin.I am assuming that the xmit and recv module start to operate automatically when powered up, it is only we need hardware or software (VirtualWire) to encode and decode the messages send/receive.You might like to google more tutorials or videos to see if my guesses make sense, or wait until my MX05V toys arrive when I will verify my guesses. AntifaFri 20:23thank you very much for the support tlfong016715Ah one more thing. I forgot to mention that components 101 mention a complicated encoder and decoder, which is not used in our cheap cheap moduels. components101.com/ics/…You are welcome. I once played with similar RF modules RFM12B and nRL2401+. I have never played with MX05V before, so it is a good chance to update myself. How nice we can learn together. Cheers. tlfong016715Fri 21:00Just now I watch this tutorial a second time: Arduino RF Tutorial [Using VirtualWire] (MX-05V / MX-FS-03V) 18,712 viewsJan 19, 2014
youtube.com/…, and I found I made a wrong guess: The receiver module will NOT start when powering up, we need to use a VirtualWire function to start it up. So ignore my wrong guess I made earlier.  13 hours later… tlfong016715yst 10:21My RF toys departed China DongGuan yesterday morning, and arrived HongKong TsingYi this morning, and to be collected at the branch in Castle Peak Road, where I am living. So I could start playing this toy this weekend.SF Express Delivery Tracking 顺丰速运有限公司 SF1134814948188
2021-10-22 09:33:20 Delivery order placed 商品已经下单
2021-10-22 11:28:38 Waiting for collection 等待揽收中
2021-10-22 21:55:00 SF collected item顺丰速运 已收取快件
2021-10-22 23:59:00 DungGuan Hung Kwong Hotel to ship to DaiLong 快件在【东莞凤岗鸿光酒店营业点】完成分拣,准备发往 【东莞大朗中转场】
2021-10-23 01:07:00 Arrived Dung Guan Transit 快件到达 【东莞大朗中转场】
2021-10-23 01:43:00 To ship to HongKong TsingYi 快件在【东莞大朗中转场】完成分拣,准备发往 【香港青衣中转场】
2021-10-23 06:17:00 Arrived TsingYi 快件到达 【香港青衣中转场】
2021-10-23 08:00:00 To deliver to ShamShuiPo Castle Peak Road SF Branch 快件在【香港青衣中转场】完成分拣,准备发往 【深水埗青山道順豐站】(see full text)tlfong016715yst 10:45Now I am studying the piVirtualWire.py at the link you last referenced. It is an old program written in 2015 using piPGIO. But it is only approx 350 line long. So I hope to write a preliminary. simple Pico MicroPython version this weekend. The complete listing follows.

MicroPython v1.16 on 2021-06-18; Raspberry Pi Pico with RP2040

Type "help()" for more information.
Traceback (most recent call last):
  File "<stdin>", line 25, in <module>
ImportError: no module named 'pigpio'

piVirtualWire.py - DzikuVx piVirtualWirepiVirtualWire 2015feb24

piVirtualWire/piVirtualWire.py / @pawelspychalski pawelspychalski init Latest commit 42b5703 on Feb 24, 2015

(see full text)  5 hours later… tlfong016715yst 15:24Now I am taking a closer look at the piVirtualWire library/code. There are indeed just a couple of functions, mainly for (1) Setting up transceiver and receiver, (2) sending and receiving text messages, (3) and doing CRC checking.The simplified code is list below. The titles of the main functions are highlighted in red.penzu.com/p/f1e301a4The Tx Class is summarized below:“””
Instantiate a transmitter with the Pi, the transmit gpio,
and the bits per second (bps). The bps defaults to 2000.
The bps is constrained to be within MIN_BPS to MAX_BPS.

self.pi = pi

self.txbit = (1<<txgpio)

if bps < MIN_BPS:
bps = MIN_BPS
elif bps > MAX_BPS:
bps = MAX_BPS

self.mics = int(1000000 / bps)
self.wave_id = None
pi.set_mode(txgpio, pigpio.OUTPUT)The most important statement to pay attention is the last one:pi.set_mode(txgpio, pigpio.OUTPUT)I think the most important statement to pay attention is the last one:pi.set_mode(txgpio, pigpio.OUTPUT)which means to set the GPIO pin for transmit to output modetlfong016715yst 16:23My RF toys arrived 10am this morning. 🙂And I googled the schematics of the Xmit and Recv modules. I found them simple electronic circuits, without any intelligence, just blindly sends/receives high low signals. So I guess the encoding and decoding are done externally. I guess we can use complicated hardware chips. But we can also use big banging Rx/Tx UART like software stuff as in the VirtualWire. I suspect we can also use MCU built in UART things, the on board Rpi4B or Pico UART features.I also found that the VirtualWire also does not do anything to “setup” the modules, because they are stupid hardware just doing one job, transmit or receive. The MCU or Pico just set up one GP pin as output for the transmit module, another GP pin as input for the receive module, can can start business, that is what I am going to gamble now.Now the schematic.

user image

tlfong016715yst 17:34

user image

Now I am going to put up the antennas. 🙂 tlfong016715yst 18:07I read the MX05V and FS1000A and found that the receiver MX05V accepts power 3V to 12V, but the transmitter must use 5V. So I need to use a level converter to upshift the Pico 3V3 GP pin output to 5V logic.

user image

user image

  2 hours later… tlfong016715yst 19:57And I am going to use HCT125 to do the level shifting job.74AHCT125 – Quad Level-Shifter (3V to 5V) – A -US$1.50


Level shifting chips let you connect 3V and 5V devices together safely.

This chip is similar to others in the shop (such as the 74LVC125) except ***this one is particularly good at converting 3V logic up to 5V***.

(1) ***Just power the 74AHCT125 with 5V, it will detect 3V logic properly***.

(2) ***You can also use it to connect 5V logic out to 3V logic in***, that’s ***when you want to power the 74AHCT125 with 3V, it can safely read 5V logic on the input pins***.(see full text)  1 hour later… tlfong016715yst 21:16Now I am reading docs for Pico UART, which I found very different from Rpi UART. I am summarizing the methods I will be using for controllong MX05 and FS1000A.

Quick reference for the RP2

UART (serial bus)
There are two UARTs, UART0 and UART1. UART0 can be mapped to GPIO 0/1, 12/13 and 16/17, and UART1 to GPIO 4/5 and 8/9.

from machine import UART, Pin
uart1 = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))
uart1.write('hello')  # write 5 bytes
uart1.read(5)         # read up to 5 bytes


class UART – duplex serial communication bus

(see full text)I will now goto Windows Thonny Pico MicroPython to write a little UART demo program, a UART serial loop back program, I will be using GP0 for Tx, GP1 for Rx9600Bd8N1I will try to write 3 characters ‘abc’ and read back the bytes object.I am new this pico uart. I guess it might take me two working days to debug this pico uart serial loopback program. tlfong016715yst 21:45

user image

tlfong016715yst 22:10Writing the pico serial loopback program is much easier than I expected. It only took me 10 minutes. The program listing with sample output is shown below:# mx05v04.py MX05V, FS1000S 433MHz Demo Program v0.4 tlfong01 2021oct23hkt2202
# Pico GP Pin Assignment
# GP0 = UART0 TxD = MX05 433MHz Revciver Module Data Pin
# GP1 = UART0 RxD = FS1000D 433MHz Transmit Module Data Pin
# Setup
# To loop back, short TxD pin to RxD pin

from machine import UART, Pin
import utime

uart0 = UART(0, baudrate = 9600, tx=Pin(0), rx=Pin(1))

def testUartLoopBackV01():
print(‘Begin testUartLoopBackV01(), …’)
testMsg = ‘Hello World’
print(‘ writeTestMsg =’, testMsg)(see full text)Now my test plan for the RF 433MHz MX05V Receiver and FS1000S Transmitter is summarized below:1. Only one pico is used for this preliminary testing.2. Pico GP0 is connected to FS1000S data pin.3. Pico GP1 is connected to MX05V data pin.4. Run the above demo program.5. If bytes read from Receiver is the same as bytes written to Transmitter, then everything is OK.6. I forgot the level shifter for the Transmitter FS1000S. I need to find the HCT125 chip to make the level shifter.7. Day is done: youtube.com/…. Will carry on tomorrow: youtube.com/….  11 hours later… tlfong0167159:13Now I am setting up the transmitter and receiver module, But I don’t know the use of the pot in the transmitter module. Is it for changing/tuning the frequency of the transmission to match with the receiver. I don’t know if the couple of receivers I have in hand have different frequencies. If yes, then is it possible for one Pico to control multiple transmitters to talk to multiple receivers at different frequency channels?Please let know if you happen to know any Arduino tutorials on how to use the pot. tlfong019:42I found this Arduino forum discussion on MX05 very good:forum.arduino.cc/t/…  8 hours later… tlfong01671517:34Now I have placed the MX05 and FS1000 on to the bread board, with the 3V to 5V level shifter, ready to do the point to point wiring.

user image

user image

Now I am thinking of naming my project “PicoVirtualWire”. For now I have Pico GP0 and GP1 shorted by a jumper/jumper wire, and that the serial loopbackverifies that UART TxD message sent out is received by RxD.If both MX05V and FS1000S are working OK, when I remove that TxD to RxD jumper, and run the same serial loopback program without any changes to the program, the output should be the same. In other words, the real hardware jumper/jumper wire is replaced by the RF 433MHz send/recv operation, thus the name “PicoVirtualWire”.

MicroPython v1.16 on 2021-06-18; Raspberry Pi Pico with RP2040
Type "help()" for more information.
Begin testUartLoopBackV01(), ...
  writeTestMsg = Hello World
  bytes read = b'Hello World'
End   testUartLoopBackV01().

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.