Esp32 433mhz communication

meneldor
Posts: 67
Joined: Mon Dec 25, 2017 7:28 am

Re: Esp32 433mhz communication

Postby meneldor » Tue Dec 04, 2018 12:40 pm

Thank you guys, i have NO experience with any transmit/receiver module, but im very interested in it, as i need low power one way connection to my esp32 board. The transmiter could be any other architecture . The RMT module looks as good start, i already made a voltage divider for the receiver data pin.

meneldor
Posts: 67
Joined: Mon Dec 25, 2017 7:28 am

Re: Esp32 433mhz communication

Postby meneldor » Wed Dec 05, 2018 6:49 am

Well, im gonna need some more help guys, as im too bad at radio waves, modulations, etc :) Im gonna send a signed int/float for temperature. Lets say i use the VirtualWire lib on the Arduino nano transmiter for which I've found the following info:
http://www.airspayce.com/mikem/arduino/VirtualWire.pdf
Messages of up to VW_MAX_PAYLOAD (27) bytes can be sent
Each message is transmitted as:
• 36 bit training preamble consisting of 0-1 bit pairs
• 12 bit start symbol 0xb38
• 1 byte of message length byte count (4 to 30), count includes byte count and FCS bytes
• n message bytes, maximum n is VW_MAX_PAYLOAD (27)
• 2 bytes FCS, sent low byte-hi byte

Everything after the start symbol is encoded 4 to 6 bits, Therefore a byte in the message is encoded as 2x6 bit symbols, sent hi nybble, low nybble. Each symbol is sent LSBit first. The Arduino Diecimila clock rate is 16MHz => 62.5ns/cycle.
For an RF bit rate of 2000 bps, need 500microsec bit period.
The ramp requires 8 samples per bit period, so need 62.5microsec per sample => interrupt tick is 62.5microsec.
The maximum packet length consists of (6 + 2 + VW_MAX_MESSAGE_LEN*2) * 6 = 408 bits = 0.204 secs (at 2000 bps).
where VW_MAX_MESSAGE_LEN is VW_MAX_PAYLOAD + 3 (= 30).
What RMT config i should use? I am a bit confused :?

PeterR
Posts: 99
Joined: Mon Jun 04, 2018 2:47 pm

Re: Esp32 433mhz communication

Postby PeterR » Wed Dec 05, 2018 11:26 am

Don't let the radio/modulation voodoo spook you.
The 433MHz modules do all the RF work. You give them a sequence of bits, they give you bits back.
The only gotcha is that the RX module may tend to ramp up the volume when nothing is happening.
This results in the first part of your message being drowned out hence you send 'training bits' (or just send the data a few times).

The code you quote is talking about a bit stream & message packet format rather than RF.
The key points are packet format and bit length.

bit length - how long a bit is! 1/2000bps = 500uS
samples per bit = 8 = 500uS/8 = 62.5 uS between samples of the input signal

I have not used the RMT module in RX mode but is seems that you configure an input clock to give your base 'tick'
The tick is your smallest measure of time and is when the RMT will sample your input.
You are free to use any sample (tick) interval you want provided you sample the Arduino 2000bps adequately.
8 ticks per bit is cool but you could use more or less.

Next you tell the RMT how many tick samples changes to ignore (the filter) before deciding to change the bit - for example the bit is high until you have 4 ticks of low. 3 ticks low then high is still high. This is just a filter to ignore noise.

You may find that you cannot divide your clock properly to match the Arduino (which is software bit banging) and/or the Arduino times are not accurate. Fine if you send Arduino to Arduino but not when you have your code in the loop.
If you can reduce your Ardunio bps and/or reduce the packet length all the better until you are working.

EDIT: Suggest you wire an ESP GPIO to your RMT and then switch GPIO on/off based on esp_timer_get_time() and see what comes out of the RMT.
The manual was not clear about threshold units etc so best that you quickly understand the RMT in isolation.

meneldor
Posts: 67
Joined: Mon Dec 25, 2017 7:28 am

Re: Esp32 433mhz communication

Postby meneldor » Wed Dec 05, 2018 2:51 pm

I decided to switch the Arduino lib to RadioHead's RH_ASK Image as there the docs are cleaner and just started to diving in it :)

PeterR
Posts: 99
Joined: Mon Jun 04, 2018 2:47 pm

Re: Esp32 433mhz communication

Postby PeterR » Wed Dec 05, 2018 3:54 pm

Cool, if at first you do not succeed - download another library!
RadioHead does look the better deal.

meneldor
Posts: 67
Joined: Mon Dec 25, 2017 7:28 am

Re: Esp32 433mhz communication

Postby meneldor » Thu Dec 06, 2018 9:06 am

Well, i am completely lost :) I didnt know that implementing this "simple" communication is so hard(for me). I have no idea how to use RF transceivers between different platforms and libraries. The only examples for the RMT lib are for NEC remotes and NeoPixel. I just cant believe that nobody is connecting ESP32 with wireless cheap peripherals. Of course I can use the same RadioHead lib on both devices, or the VirtualWire lib, but they are dependent of the Arduino core which i dont need.
Does anyone use any RF module on ESP32 using non-Arduino lib ? Any help is highly appreciated !

Thank you!

PeterR
Posts: 99
Joined: Mon Jun 04, 2018 2:47 pm

Re: Esp32 433mhz communication

Postby PeterR » Thu Dec 06, 2018 11:49 am

Hi,
Forget the remote examples, they are much more involved.

I have not used RMT RX & cannot put time in ATM but I can help you break the problem down....

This is not an RF problem...
The 433MHz TX module accept a series of bits.
The 433MHz RX module returns a series of bits.

The modules just add RF pixie dust, forget them FTM.
Instead wire your ardunio GPIO pin directly to an ESP32 pin.
Write an ardunio program which turns a 32 bit into a series of bits on the GPIO.
Slow the ardunio down, really slow so you can see the LED pattern (or wire several LEDs and convert from serial pattern to parallel). Or print the TX and RX value.
Write an ESP program which polls its GPIO and lights an LED accordingly.
Test and play.

Now you can send and receive a value by 'bit bashing'.
Next replace the ESP GPIO poll with RMT code. All the RMT does is replace your GPIO poll with hardware polling - which will be faster and more reliable. Basically you will tell the RMT how many samples makes a bit but you will have to learn that bit.
It may take time before you understand the RMT clock dividers.
Next speed up the arduino and the ESP RMT to (say) 1024 bps.

Next you need a training pattern before your 32 bit value. That will be a series of 10101 etc before you send your 32 bits.
Understand that you will not receive all your training so your 32 bits is at the end.
Have your ardunio send different training pattern sequences and check that ESP still receives the 32 bits.

Now uses the 433MHz module. Should just work.
The library will just do this 'better'.

Another thought is wire GPIO to 433MHz. Have the ESP32 poll its 433MHz and turn LED off/on.
That should give you confidence.

meneldor
Posts: 67
Joined: Mon Dec 25, 2017 7:28 am

Re: Esp32 433mhz communication

Postby meneldor » Thu Dec 06, 2018 12:03 pm

Thank you for your effort Peter! I will try the basics. Now i print all the channels to the console and am seeing alot of traffic, even with the transmitter turned off, but its useless to me.

PeterR
Posts: 99
Joined: Mon Jun 04, 2018 2:47 pm

Re: Esp32 433mhz communication

Postby PeterR » Thu Dec 06, 2018 1:35 pm

You will see noise. So short changes on the input you should ignore.
You need to 'latch' each bit.
Typically 3 periods high, 1 period low means '1' and 1 high, 3 low means '0'.

The complexity then is counting the intervals and deciding what you have.
But you can do this really slow at first and using wires rather than 433MHz.
A logic analyzer would be easiest but really slow with an LED may be good enough.

I would ditch the 433Mhz until you understand the protocol and are happy with basic communication though.
Good luck.

Deouss
Posts: 290
Joined: Tue Mar 20, 2018 11:36 am

Re: Esp32 433mhz communication

Postby Deouss » Mon Dec 10, 2018 4:54 pm

Small update on RF module and RMT.
I managed to translate signal into RMT items however I got very weird results when started RMT TX.
The time of pulses does not match the time I set. I checked clock divider and APB and all looks good.
However this might be issue with number of items which is pretty high - around 700.
The docs say that RMT has limited number of items per memory block or so. It is kind of confusing.
Something is not working right so I will just try to use SPI and see what's the issue.
Also I noticed RMT item high impulses are not immediate square spikes but slight rising edge affecting frequency modulation a bit.
Maybe it is irrelevant for RF devices but I haven't tested it yet.

Who is online

Users browsing this forum: Google [Bot] and 15 guests