Qdeathstar:
Post your code
Ok, sorry, here are two snippets of what I'm trying to do.
Acctually I want a 2 way communication, so both codes are pretty equal.
First one, receive an input command from Serial and send it via RF.
#include <SPI.h>
#include <RHReliableDatagram.h>
#include <RH_ASK.h>
#define RECEIVER_PIN 2
#define TRANSMITTER_PIN 8
#define ETHERNET_ADDRESS 1
#define EASYVR_ADDRESS 2
RH_ASK RadioHead(2000, RECEIVER_PIN, TRANSMITTER_PIN);
RHReliableDatagram RF(RadioHead, ETHERNET_ADDRESS);
void setup() {
Serial.begin(115200);
Serial.print(F("Initializing"));
pinMode(TRANSMITTER_PIN, OUTPUT);
Serial.println(F("..."));
Serial.println(F("..."));
if (!RF.init()) {
Serial.println("RadioHead initializiation failed.");
}
}
void loop() {
if (RF.available()) {
readRadioHead();
}
if (Serial.available()) {
serialRead();
}
}
void serialRead() {
char input[64];
char command[32];
char value[32];
if (Serial.available()) {
Serial.readBytesUntil('\n', input, sizeof(input));
}
sscanf(input, "%31[^=]=%31s", command, value);
if (strstr(command, "POWER") && atoi(value) == 1) sendRadioHead("POWER=1");
else if (strstr(command, "PLAY") && atoi(value) == 1) sendRadioHead("PLAY=1");
}
boolean sendRadioHead(char send[64]) {
char reply[64];
byte size = sizeof(reply);
if (RF.sendtoWait((byte *)send, strlen(send), EASYVR_ADDRESS)) {
Serial.printf(F("Sending: %s"), send);
if (RF.recvfromAckTimeout((byte *)reply, &size, 2000)) {
Serial.printfn(F(" (Reply: %s.)"), reply);
return true;
}
else {
Serial.println(F(" (No reply)."));
}
}
else {
Serial.println(F("sendtoWait failed."));
}
return false;
}
boolean readRadioHead() {
char receive[64];
char reply[64];
char command[32];
char value[32];
byte size = sizeof(receive);
if (RF.recvfromAck((byte *)receive, &size)) {
sscanf(receive, "%31[^=]=%31s", command, value);
Serial.printf(F("Request: %s=%s"), command, value);
if (RF.sendtoWait((byte *)reply, strlen(reply), ETHERNET_ADDRESS)) {
Serial.printfn(F(" (Reply: %s.)"), reply);
return true;
}
else {
Serial.println(F(" (Reply failed)."));
}
}
return false;
}
Second one, receive the input command from RF and send the IR command.
#include <SPI.h>
#include <Livolo.h>
#include <RHReliableDatagram.h>
#include <RH_ASK.h>
#include <IRremote.h>
#define RECEIVER_PIN 2
#define TRANSMITTER_PIN 8
#define ETHERNET_ADDRESS 1
#define EASYVR_ADDRESS 2
IRsend IR;
RH_ASK RadioHead(2000, RECEIVER_PIN, TRANSMITTER_PIN);
RHReliableDatagram RF(RadioHead, EASYVR_ADDRESS);
void setup() {
Serial.begin(115200);
Serial.print(F("Initializing"));
pinMode(TRANSMITTER_PIN, OUTPUT);
Serial.println(F("..."));
if (!RF.init()) {
Serial.println("RadioHead initializiation failed.");
}
delay(2500);
}
void loop() {
if (RF.available()) {
readRadioHead();
}
}
boolean sendRadioHead(char send[64]) {
char reply[64];
byte size = sizeof(reply);
if (RF.sendtoWait((byte *)send, strlen(send), ETHERNET_ADDRESS)) {
Serial.printf(F("Sending: %s"), send);
if (RF.recvfromAckTimeout((byte *)reply, &size, 2000)) {
Serial.printfn(F(" (Reply: %s.)"), reply);
return true;
}
else {
Serial.println(F(" (No reply)."));
}
}
else {
Serial.println(F("sendtoWait failed."));
}
return false;
}
boolean readRadioHead() {
char receive[64];
char reply[64];
char command[32];
char value[32];
byte size = sizeof(receive);
if (RF.recvfromAck((byte *)receive, &size)) {
sscanf(receive, "%31[^=]=%31s", command, value);
Serial.printf(F("Request: %s=%s"), command, value);
if (strstr(command, "POWER") && atoi(value) == 1) IR.sendSAMSUNG(0xE0E040BF, 32);
else if (strstr(command, "PLAY") && atoi(value) == 1) IR.sendSAMSUNG(0xE0E0E21D, 32);
if (RF.sendtoWait((byte *)reply, strlen(reply), ETHERNET_ADDRESS)) {
Serial.printfn(F(" (Reply: %s.)"), reply);
return true;
}
else {
Serial.println(F(" (Reply failed)."));
}
}
return false;
}
I'm using this RF modules:
Transmitter
Receiver
The transmitting / receiving part works "fine", but the IR part simply doesn't work, as I said the IR Led still blinks, but with less intesivity ("less brighter") and the commands aren't recognized by the TV or the HT anymore.