So I am creating a signal message using rf module 433mhz. I know you guys might have seen similar post.
I have read many posts but cant make things working.
receiver code on arduino nano :
#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif
// driver(speed not to mess with that , receive pin , transmit pin , push to talk )
RH_ASK driver(2000, 2,4,5);
// RH_ASK driver(2000, 4, 5, 0); // ESP8266 or ESP32: do not use pin 11 or 2
// 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
{
// int i;
// Message with a good checksum received, dump it.
// driver.printBuffer("Got:", buf, buflen);
String rcv;
for (int i =0; i < buflen; i++) {
rcv += (char)buf[i];
}
Serial.println(rcv);
} else {
Serial.println("else");
Serial.println((char)buf[0],buflen);
delay(1000);
}
}
transmitter code :
#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif
// driver(speed not to mess with that , receive pin , transmit pin , push to talk )
RH_ASK driver(2000, 5,3,0); // ESP8266 or ESP32: do not use pin 11 or 2
// 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
//pinMode(4, OUTPUT);
}
void loop()
{
const char *msg = "higgh";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(1000);
// digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level)
// delay(1000); // wait for a second
// digitalWrite(4, LOW);
}
Its working if i use another arduino nano as transmitter but not with attiny85.
I am able to make blink successfully run with attiny85 . so adding code to attiny85 is fine i guess.
Also i am using 3 , which is pin 2 for attiny85
I even changed 5v to attiny85 to 3 v ish still didnt work