Hi all,
I am experimenting with an irrigation project which has arduino mini pros to send data to a Yun to receive it and then post it as feed via the internet.
I am working on the communication-to-yun part and decided for the RF option with some cheap 433mhz receiver/transmitter pair.
The hardware is arm mcu wl te122 (https://www.amazon.co.uk/d/7hr/XCSOURCE-433Mhz-Transmitter-Module-Receiver-Arduino-TE122/B00V4ISS38/ref=pd_lpo_vtph_23_bs_t_2?_encoding=UTF8&psc=1&refRID=W3TS99VKX14RA9B7SJDY) from xsource.
I went for the radiohead library as it seems the standard and also because i want to use it for more long distance communication with some lora transceivers later on.
My first experiment uses a mini pro to send the data and the uno to receive it.
I used standard default wiring, pin 12 on the mini pro is connected to the DATA pin of the transmitter and pin 11 of the UNO is connected to DATA pin of the receiver.
All works fine using the code below.
However when I connect the receiver to a Yun instead of the UNO then I don't seem to receive any message.
I have tried using different pins, switching receivers between the UNO and YUN and checked the wiring.
I also tried to re-initialize the driver in the main loop - basically everything else I could think of - all to no avail.
I am kind of puzzled that there are almost no examples on the internet - however the yun seems supported by the radiohead library and I could find no special instruction for the yun.
I have seen some discussions on the facts that the pin layout is different, but nothing I have seen should impact my setup as far as i can tell.
Anyone successfully got a similar receiver working on the YUN?
Or do you spot anything obvious in my setup?
Thanks in advance,
Mauro
Receiver
#include <Bridge.h>
#include <RH_ASK.h>
#include <SPI.h> // Not actually used, but needed to compile
#include <Console.h>
RH_ASK driver;
void setup() {
Bridge.begin();
Console.begin();
// Wait for Console port to connect
while (!Console);
Console.println("Receiver started");
// try to initialize rf receiver
if(!driver.init())
Console.println("RF module init failed");
Console.println("RF init succeded");
}
void loop() {
Console.println("Listening again ...");
uint8_t buf[26];
uint8_t buflen = sizeof(buf);
if(driver.recv(buf, &buflen)) // Non-blocking
{
//Message with a good checksum received, dump it
driver.printBuffer("Got: ", buf, buflen);
Console.print("Message: ");
Console.print((char*) buf);
}
delay(5000);
}
transmitter
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver;
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}
void loop()
{
const char *msg = "Fritz says: Happy journey!";
Serial.print("sending message: "); Serial.println(msg);
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(1000);
}