Skip to content

Conversation

@sodoku
Copy link

@sodoku sodoku commented Nov 20, 2025

I was playing around with 433Mhz and thought this might help someone. Feel free to reject if this is too basic.

@unicab369
Copy link
Contributor

can you add example how to receive the data?

@sodoku
Copy link
Author

sodoku commented Nov 20, 2025

can you add example how to receive the data?

This example works with a simple transmit only board. I haven't used a receiver yet, but I can see if I can also make it work. Would you split this in two examples or put both in one?

@unicab369
Copy link
Contributor

if the code is too big, I would split it into 2 if not one is ok i think.

@cnlohr
Copy link
Owner

cnlohr commented Nov 21, 2025

Is it possible to do both send and receive from one part? If so, that would be best.

And I am glad you kept things simple, but I do think the minimum viable product would be both send and receive.

@cnlohr
Copy link
Owner

cnlohr commented Nov 21, 2025

So definitely not a no, @sodoku but, maybe a "when you get TX/RX going.

Other than that the PR is good.

@sodoku
Copy link
Author

sodoku commented Dec 1, 2025

@cnlohr I managed to solder my receiver antenna and play around a bit with it. Reading how rc-switch does the receive and looking through the ch32fun examples, it looks like I will need to use interrupts for the input data change detection and for being able to measure time difference (micros() in Arduino). Imho that would make this example more complex.
What do you think?

@cnlohr
Copy link
Owner

cnlohr commented Dec 3, 2025

@sodoku on ch32fun, you use SysTick->CNT, and for comparing times you do something like:

uint32_t start_time = SysTick->CNT;
while( 1 )
{
   // Do stuff
   if( TimeElapsed32( SysTick->CNT, start_time ) >= Ticks_from_Ms(150) )
   {
      // 150ms elapsed.
      start_time += Ticks_from_Ms(150);
   }
}

@sodoku
Copy link
Author

sodoku commented Dec 5, 2025

I spent hours on this and learned a lot, but somehow the timing values didn't make sense. I am not sure what I am doing wrong. I boiled my problem down to a very simple example:

int miliseconds = 15000;

uint32_t start_time = SysTick->CNT;

while ( 1 )
{
  // Do stuff
  uint32_t diff = TimeElapsed32( SysTick->CNT, start_time );
  if ( diff >= Ticks_from_Us( miliseconds ) )
  {
    start_time += Ticks_from_Us( miliseconds );
    printf( "%lu \n", diff / DELAY_US_TIME );
  }
}

This works an outputs:

+15000
+15000
+15000
+15000
+15000
+15000
+15000
+15000

However if I change miliseconds to a smaller value of 1500 since I need to count the timings in small values of microseconds (e.g 650), I get:

+1500
+1575
+1722
+1811
+1974
+2188
+2366
+2428
+2456
+2492
+2498
+2523
+2552
+2668
+2819
+3032
+3198
+3351
+3429
+3453
+3478
+3512
+3683
+3723
+3801

What am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants