1

I currently use Arduino IDE to program Raspberry Pico, using this as reference. Arduino-pico Github

My intention, is to use RadioHead library which is not available in MicroPython, to send and receive RF messages through cheap China RF modules.

I used the example code of the RH_ASK library as below, but I cannot see any results printed. Does anyone has tried this? Am I using something wrong? I have connected RF modules on UART0 pins.

#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif

//RH_ASK driver;
RH_ASK driver(2000, 13, 12); 
// RH_ASK driver(2000, 3, 4, 0); // ATTiny, RX on D3 (pin 2 on attiny85) TX on D4 (pin 3 
on attiny85), 
// RH_ASK driver(2000, PD14, PD13, 0); STM32F4 Discovery: see tx and rx on Orange and 
Red LEDS

void setup()
{
#ifdef RH_HAVE_SERIAL
    Serial.begin(9600);   // Debugging only
#endif
    if (!driver.init())
#ifdef RH_HAVE_SERIAL
     Serial.println("init failed");
#else
    ;
#endif
}

void loop()
{   
    uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
    uint8_t buflen = sizeof(buf);



    if (driver.recv(buf, &buflen)) // Non-blocking
    {
      driver.recv(buf, &buflen);
        int i;

        // Message with a good checksum received, dump it.
        driver.printBuffer("Got:", buf, buflen);
    }
}

Thank you in advance

6
  • How did you build the radiohead library? How do you know it built correctly. How did you link your program?
    – joan
    Jun 4, 2022 at 20:11
  • @:Antifa: Earlier I played the cheap China 433Mhz HC12, and found that using serial is easier than using SPI. I used MicroPython. The tutorial I used, and working code: (1) Understanding ... 433MHz Transceiver Module allaboutcircuits.com/projects/… (2) Making a Rpi Pico Based Smart Vehicle Part 2 - tlfong01 2021nov03 forum.pi-top.com/t/making-a-rpi-pico-based-smart-vehicle-part-2/… Section 3. HC12 433MHz RF transceivers, 3.1 uart loop back functions, 3.2 HC12 transmit/receive echo functions.
    – tlfong01
    Jun 5, 2022 at 2:46
  • @joan, I pressed the upload code on Arduino IDE. On, how I know it built correctly, i am not sure. tell me a way and I will check.
    – Antifa
    Jun 5, 2022 at 7:33
  • 1
    @tlfong01, you mean that Radio Head uses SPI? So, I have to change the pin to reflect to SPI ones on Pico?
    – Antifa
    Jun 5, 2022 at 11:07
  • @Antifa: Ah, there is some misunderstanding. I originally wrote a too long comment and cut it short, causing the confusion. I was saying something like: "HC12 talks UART serial, so it is much more newbie friendly than the once popular but old school now SPI 433MHz RFM12B which I once played in my Arduino days. My apologies for the confusion. Cheers.
    – tlfong01
    Jun 5, 2022 at 14:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.