Notifications
Clear all

433MHz Receiver

11 Posts
5 Users
0 Likes
1,169 Views
revver11
(@revver11)
Member
Joined: 5 years ago
Posts: 16
Topic starter  

I have built the arduino 433MHz receiver Bill demonstrated a little while ago but I have a different module (8pins) but it seems to work.

What I would like to do is modify the code in some way so that knowledge of the buffer size is not needed. I have some devices which use 433MHz to communicate and I would like to eavesdrop on them to figure out how they work etc.

Any suggestions?


   
Quote
noweare
(@noweare)
Member
Joined: 4 years ago
Posts: 117
 

If you need variable size storage you will need to use dynamic memory allocation i.e. malloc, calloc functions from the standard library. I have heard the uno because of its small ram size (appox 2k bytes) does not do well using those functions. You may have to step up to an esp32 or stm32 which have a lot more ram.


   
ReplyQuote
revver11
(@revver11)
Member
Joined: 5 years ago
Posts: 16
Topic starter  

Thank you @noweare

More homework. I don't know malloc and calloc so I'll read up on them.

I'll try the uno first and hope I can trim it enough to fit. Once I know the buffer sizes of my devices, I can forget malloc and hard-code them and then take it from there with my experiments.

I was intending to get a mega and an esp32 soon, so maybe my hand is being forced. Thanks again.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@revver11

Posted by: @revver11

More homework. I don't know malloc and calloc so I'll read up on them.

Look up the C++ 'new' and 'delete' operators too, for dynamic memory management.

Cheers!


   
ReplyQuote
revver11
(@revver11)
Member
Joined: 5 years ago
Posts: 16
Topic starter  

Aw! Even more homework. 🤔 

Thanks 👍 


   
ReplyQuote
revver11
(@revver11)
Member
Joined: 5 years ago
Posts: 16
Topic starter  

I am looking in https://www.arduino.cc/reference/en/ but cannot find any of the keywords there.

Is there a better site to use?


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@revver11

 

This might be a good place to start your search for C++ commands not specified in the Arduino Language Reference.

https://www.tutorialspoint.com/cplusplus/index.htm


   
ReplyQuote
noweare
(@noweare)
Member
Joined: 4 years ago
Posts: 117
 

Malloc, calloc etc... are from the C standard library, you will not find them in the arduino reference section. If you want to practice with how to use them I would recommend using an IDE like CodeBlocks or Eclipse set up for C/C++, not the arduino IDE. It will save you time, plus those environments normally have a debugger so you can step through your code. Once you understand then try it in the arduino IDE.


   
ReplyQuote
revver11
(@revver11)
Member
Joined: 5 years ago
Posts: 16
Topic starter  

@pugwash @noweare

Good advice both. Thank you.

So far I haven't been able to get the time to take it further. Just when I thought I could move ahead, life had other ideas. Ah well, the weekend approaches.

 


   
ReplyQuote
noweare
(@noweare)
Member
Joined: 4 years ago
Posts: 117
 

@revver11 Yeah, I have about 4 unfinished projects I need to button up. Hard for me to

focus on one thing.


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 3 years ago
Posts: 100
 
Posted by: @revver11

What I would like to do is modify the code in some way so that knowledge of the buffer size is not needed.

I agree with the comments other have posted on learning more about memory management in C, C++.

Still, given the issue as you outlined it, what I would do is specify a buffer, just a regular buffer like in the example code, that is "big enough." In the context of the 433 MHz devices you mentioned, I would say 60 or 100 characters is more than enough. The C string ends with a null byte, a zero. 

So the garage door opener, little weather station across the street, who just happens to also be running Bill's sketch for temperature and humidity, the other IoT commands, all of them are probably quite short. Try it.

What's the worst that could happen? It receives a couple messages, then a too-long message overflows the buffer and crashes the Arduino? When my components arrive, I'm going to try this myself. I find my neighborhood is quite crowded with WiFi, always from 12 to 30 other SSIDs competing with me. So I wondered if 433 MHz would work for some applications.

Good luck!

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote