I am trying to transmit from an ATtiny85 running at 16MHz internal clock to an Arduino Uno with the Manchester Library.
The problem is that the Arduino is not receiving any data.
I have hooked an oscilloscope to the ATAD/DATA pin of the transmitter, and I can see data being transmitted. I have also done the same thing on the DATA pin of the receiver, and it shows data being received. But the Arduino Uno is not detecting anything.
I have tried having an Arduino Uno sending data to itself, which does work, but the data gets dropped very often.
Here is the source code of the transmitter:
#include <Manchester.h>
#define TX_PIN 3 //pin where your transmitter is connected
uint16_t transmit_data = 2761;
void setup() {
pinMode(1,OUTPUT);
man.setupTransmit(TX_PIN, MAN_1200);
}
void loop() {
digitalWrite(1,HIGH);
man.transmit(transmit_data);
delay(200);
digitalWrite(1,LOW);
delay(200);
}
And this is the code on the receiver:
#include "Manchester.h"
#define RX_PIN 4
#define BUFFER_SIZE 22
uint8_t buffer[BUFFER_SIZE];
void setup() {
Serial.begin(9600);
man.setupReceive(RX_PIN, MAN_1200);
man.beginReceiveArray(BUFFER_SIZE, buffer);
}
void loop() {
if (man.receiveComplete()) {
uint8_t receivedSize = 0;
// do something with the data in 'buffer' here before you start receiving to the same buffer again
receivedSize = buffer[0];
for(uint8_t i=1; i<receivedSize; i++)
Serial.write(buffer[i]);
Serial.println();
man.beginReceiveArray(BUFFER_SIZE, buffer);
}
}
This is the code I used to test with only the Arduino Uno:
#include <Manchester.h>
#define RX_PIN 7
#define TX_PIN 8 //pin where your transmitter is connected
uint16_t transmit_data = 2761;
int lastTransmit = 0;
void setup() {
Serial.begin(9600);
man.setupReceive(RX_PIN, MAN_1200);
man.setupTransmit(TX_PIN, MAN_1200);
man.beginReceive();
}
void loop() {
if (millis() - lastTransmit > 200) {
man.transmit(transmit_data);
lastTransmit = millis();
}
if (man.receiveComplete()) {
uint16_t m = man.getMessage();
Serial.println(m);
man.beginReceive();
//start listening for next message right after you retrieve the message
}
}