0

The basic plan is to have a Attiny85 pass information from a 433Mhz RF module to another chip/Arduino via I2C using VirtualWire and Wire libraries. I have been able to make this system work on their own using Arudino Nano's to debug, but the Attiny85 (A85) seems unable to grab the data from the RF 433 Mhz.

So have spent a few days doing some more research, and basically putting each component separate, to make sure what is being sent is correct.

  1. 433 Mhz transmitter is working by sending a 9 digit number, using VirtualWire.h.
  2. Nano with a 433 Mhz receiver is receiving 9 digit number, VirtualWire.h.
  3. Attiny85 is sending either a no data, or the 9 digit number, to another Nano using Wire.h.
  4. The Nano is getting only No Data, so the I2C is working between A85 and Nano.

Attiny85, on Pin 1 (pin 6 on chip) is not getting any data from the 433 Mhz, which works on (2). I connect the GND of the 433 RX to the chip.

Here is the Receiver code:

#include <VirtualWire.h>
#include <Wire.h>
void setup() {
  pinMode(A3, OUTPUT);
  Wire.begin(); // join i2c bus (address optional for master)
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(4000);   // Bits per sec 
  vw_set_rx_pin(1);
  vw_rx_start();       // Start the receiver PLL running
}
void loop() {
  uint8_t buf[15];
  uint8_t buflen = 15;  
  if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      digitalWrite(A3, LOW);
      Wire.beginTransmission(8); // transmit to device #8
      for (int i = 0; i < buflen; i++) {
        Wire.write(buf[i]);
      }
      Wire.endTransmission();    // stop transmitting
    } else { 
      digitalWrite(A3, HIGH);
      Wire.beginTransmission(8); // transmit to device #8
      Wire.write("no DATA");
      Wire.endTransmission();    // stop transmitting
     }
}

Here is the Transmitter code:

#include <VirtualWire.h>
int xPin = A7;
int yPin = A6;
int buttonPin = 2;

int xPosition = 0;
int yPosition = 0;
int buttonState = 0;
const char *controller;
void setup() {
  Serial.begin(9600);
  pinMode(12,OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(yPin, INPUT); 
  pinMode(xPin, INPUT);
  pinMode(buttonPin, INPUT_PULLUP); 
  vw_set_ptt_inverted(true); //
  vw_set_tx_pin(12);
  vw_setup(4000);// speed of data transfer Kbps
}

void loop(){
   xPosition = analogRead(xPin);
   yPosition = analogRead(yPin);
   buttonState = digitalRead(buttonPin);
if(xPosition > 0 || yPosition > 0) {
  String Data = (xPosition + yPosition);
  controller = Data;
  vw_send((uint8_t *)controller, strlen(controller));
  vw_wait_tx(); // Wait until the whole message is gone

} else {
  digitalWrite(13, 0);
  digitalWrite(4, 1);
  controller = "#s0_0";
  vw_send((uint8_t *)controller, strlen(controller));
  vw_wait_tx(); // Wait until the whole message is gone
}

Serial.println(controller);

}

So basically the A85 is not getting past if (vw_get_message(buf, &buflen)) { on pin 1. But does when using the Nano on pin D2, from the same transmitter, but not at the same-time of-course.

Am I using the wrong Pin on the A85? Chip pin 5 and 7 are used for the I2C so it only leaves analog pins so not sure they would work either. I also tried 8 Mhz and 1 Mhz when loading the A85.

I have tried different Cores as suggested from Google, different versions of VirtualWire and clocked the Attiny 1Mhz, 8Mhz and 16Mhz. None of have worked.

enter image description here

Not sure what else I am missing?

  • 2
    Don't cross post. You already asked this on SO. – gre_gor Mar 7 '18 at 21:48
  • As I had to join this community I did not think of it as cross posting! Still SO, but this one I only just found while doing more research on the problem. Different Community different people was my thinking. – BadAddy Mar 7 '18 at 21:57
  • Cross posting is not permitted. Further, there's no point to involving an extra processor and I2C here. Just have the ultimate target do the decoding. – Chris Stratton Mar 8 '18 at 0:34
  • @ChrisStratton Hi, thank you for taking the time in commenting. I think I have explained why I posted it again, although with more detail. As for the end product, the Nano is just for debugging, rather than using LED's as I wanted to make sure the numbers being transmitted are correct. The end product will eventually be a Attiny84a. The issue is Servo.h and VirtualWire.h do not mix (Both use Timer1), hence the work around, and to make the circuit smaller. – BadAddy Mar 9 '18 at 8:29
2

Have you tried using the Radiohead library? I know you said you tried different versions of Virtual Wire. The RH_ASK class works on a 328p and a nano for sure and they claim a simple Rx program can run on a ATTiny85. They have documentation under RH_ASK regarding the changes you need make to the library. Another possible fix is to edit the Virtual Wire library files, they might have variables like "Max_payload" (Radiohead does) whose size can be decreased. I haven't actually read the Virtual wire library, but I am sure Radiohead should fix your problems.

If this doesn't work, do you have an oscilloscope? Maybe we can try debugging it like that.

Edit: Maybe try commenting out the vw_set_ptt_inverted line first. I don't think you are using the DR3100. Might not make a difference because you haven't actually set a pin for ptt. Next thing you can try is just connecting the data pin of the Tx to the Rx. You should be able to check if the module is actually connected to the ATTiny with this.

-2

ATtiny85 internal oscillator has to be calibrated to work with VirtualWire or you have to use a resonator.

This link provides useful information on how to calibrate the internal oscillator of an ATtiny MCU.

I used a 16Mhz crystal connected to pin 2 and 3, then you have to change type to external and burn bootloader to change fuses.

I don't think that you can use Wire libraries with attiny85. Did you not got any error messages!

  • Would you mind providing more details to your answer? E.g. why do you think it will work after oscillator calibration, how to calibrate the internal oscillator of an ATtiny... – jfpoilpret Mar 8 '18 at 6:13
  • A link to info how to callibrait ernstc.dk/arduino/tinytuner.html I have got VirutalWire and attiny to work to use a crystal or to callibrate the internal oscillator – Carlmikael Mar 8 '18 at 20:51
  • @Carlmikael I can ask what you did crystal wise. I am not really comfortable doing that link stuff. But I can add a crystal. Do you have any link on a tutorial on how to do it. I have 12Mhz Crystals to hand ? – BadAddy Mar 10 '18 at 21:29
  • @BadAddy clock accuracy is unlikely to have anything to do with your problem, but having a completely different clock than assumed might. – Chris Stratton Mar 11 '18 at 2:59
  • @ChrisStratton I have seen many posts about this issue and I have tried many libraries, Tinycores but none of them actually work. I have seen posts where people have suggested it works, but not actually given any detail. Perhaps I just cannot achieve this and maybe try a ATtiny84. – BadAddy Mar 11 '18 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.