Issue between Attiny85 RF 433Mhz Transmitter to Arduino Uno RF 433 Mhz Receiver

Hi Everyone,

I spent a lot of time on this issue and frankly speaking I am stuck.
On my projet I would like to set up a temperature sensor based on Attiny85 / DTH22 configured as a Tx RF 433Mhz transmitter. On the other side I have a Arduino Uno with a Rx RF 433Mhz receiver configuration.
I have tried Virtualwire and Manchester library with the same result.

The Arduino do no detect the signal received from the Attiny85 even if the signal is received , I have checked with an oscilloscope.

Configuration works ( data is sent and recognized at the receiver side ) between 2 Attiny85 configured both for Transmitter and Receiver side.

I try to understand why the configuration Attiny85 (Tx) and Arduino (Rx) not work . I found many example on web side that describe both virtual wire or Manchester implementation.

I understand that the Attiny has timer0 and timer1 that could explain the issue . Do I have to made some
tuning ? I muse that Attiny with Arduino is a common configuration.

I'am using Arduino UNO (not genuine ) IDE 1.8.5 .

kinds regards,
Manu

Is the attiny clocked at the speed you think it is? Check with a blink sketch; if it blinks at the wrong speed, that is the problem.

The fact that it works between two attiny's makes me think you aren't setting the clock speed or have set it to a different speed than you have selected now (and have done the same thing on both of them).

++++++Attiny85 Code ++++++++++++++

#include <VirtualWire.h>
#include "DHT.h"

#define DHTPIN 3

#define DHTTYPE DHT22

const int led_pin = 4;
const int transmit_pin = 2;

struct package
{
float temperature ;
float humidity ;
};

typedef struct package Package;
Package data;

DHT dht(DHTPIN, DHTTYPE);

void setup()
{
// Initialise the IO and ISR
vw_set_tx_pin(transmit_pin);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(500); // Bits per sec
pinMode(led_pin, OUTPUT);
}

void loop()
{
digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
readSensor();
vw_send((uint8_t *)&data, sizeof(data));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(led_pin, LOW);
delay(100);
}

void readSensor()
{
dht.begin();
delay(100);
data.humidity = dht.readHumidity();
data.temperature = dht.readTemperature();
}

++++++Arduino Receiver code ++++++++++++++
#include <VirtualWire.h>

const int receive_pin = 12;
const int led = 13;
char temperatureChar[10];
char humidityChar[10];

struct package
{
float temperature = 0.0;
float humidity = 0.0;
};

typedef struct package Package;
Package data;

void setup()
{

/* Initialisation du port série */
Serial.begin(115200);
Serial.println("setup done");
//delay(1000);
// Initialise the IO and ISR
vw_setup(500); // Bits per sec
vw_set_rx_pin(receive_pin);
vw_rx_start(); // Start the receiver PLL running
Serial.println("setup done");
pinMode(led,OUTPUT);

}

void loop()
{
uint8_t buf[sizeof(data)];
uint8_t buflen = sizeof(data);

if (vw_have_message()) // Is there a packet for us?
{
Serial.println("message recu");
vw_get_message(buf, &buflen);
// delay(1000);

memcpy(&data,&buf,buflen);

Serial.print("\nPackage:");
Serial.print(data.temperature);
String temperatureString = String(data.temperature,1);
temperatureString.toCharArray(temperatureChar,10);

String humidityString = String(data.humidity,1);
humidityString.toCharArray(humidityChar,10);

digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(100);
Serial.print("\n");
Serial.println(data.humidity);
}
}

Maybe I found the issue, to use virtualWire library with Attiny85 I installed an old version ( McCauley) of VirtualLibrary , perhaps not compatible with Arduino .

// Copyright (C) 2008 Mike McCauley
// $Id: VirtualWire.h,v 1.14 2014/03/26 01:09:36 mikem Exp mikem

Anyone can confirm this ?

We can rule out the possibility that the library you are using does not support the attiny85, and we can definitely rule out the possibility that it doesn't support Arduino. You have proven that it does by successfully using it to communicate between two attiny85's, right?

So either your code doesn't work on the Uno, or there's some difference between the attiny85 and uno.

Does it work with an Uno on both sides? That would be the next thing I'd try (a nano or 5v pro mini is equivilent to an Uno - can use one of those on one side for this test).

Have you done the sanity check I suggested above of uploading a blink-like sketch to the attiny85 and verifying that it's running at the speed you think it is? If your attiny's were running at one speed, but you thought they were running at a different speed and had that speed selected, communication would work from uno to uno, and from tiny85 to tiny85, but not tiny85 <-> uno. It is very common for people to have forgotten to set the fuses to select clock speed (by doing "burn bootloader" with the desired clock settings selected) and not realize it when uploading via ISP.

Also - take version numbers and dates in open source files (particularly anything that came from github) with a grain--- no, a spoonful --- of salt. Everyone forks everyone elses libraries on github and modifies the code without updating readme's, comments, or other documentation.

I had successfully configured Transmitter based on Attiny85 and Arduino Uno receiver by using Manchester Library . I took several days to find the right implementation mostly on web forum like this seul one .
I had had to setup the internal clock set to 1 Mgz for the Attiny.

Now I would like to use VirtualWire library that allow sending structure data but It seems that a lot of tuning and pitfall could be encountered.

To summarize Attiny85 with RF433 is used as transmitter and a remote Arduino Uno for me will be used.
I understand that some Pin out and timer can be met on this specific implementation .
I did not found a lot of example with google search so before moving forward I would like to have your recommendations.

To summarize my web research :

  • this implementation seems to be supported by virtualWire library
  • virtualWire library can be in conflict with timer and with pinout used on Attiny85

I am a newbie and I try to learn by-myself so please apologize me in advance.

Please share your point of view, I would appreciate for sure . kind regards. Manu

rgds,
Manu

I am still working to run attiny85 with a DTH22 connected.
When I configure the Attiny clock to 8Mhz , I have ????? characters appear on the console, so I m not able to see if the DTH22 value are correct.

I am using the following DTH lib : Arduino/libraries/DHTlib at master · RobTillaart/Arduino · GitHub.
Some Web research show this Lib should work .

How can I fix the console issue met today ?

remark : with 1Mhz settings , at 9600 baud console works perfectly.
Here is the code I used :

include "SoftwareSerial.h"
#include <dht.h>

const int Rx = 3; // this is physical pin 2
const int Tx = 4; // this is physical pin 3
const int ledPin = 2 ;

SoftwareSerial mySerial(Rx, Tx);

dht DHT;
#define DHT22_PIN 0

struct
{
uint32_t total;
uint32_t ok;
uint32_t crc_error;
uint32_t time_out;
uint32_t connect;
uint32_t ack_l;
uint32_t ack_h;
uint32_t unknown;
} stat = { 0,0,0,0,0,0,0,0};

/* void setup()
{
pinMode(ledPin,OUTPUT);
pinMode(Rx, INPUT);
pinMode(Tx, OUTPUT);
mySerial.begin(9600); // send serial data at 9600 bits/sec
}
*/

void setup() // + DHT
{
pinMode(ledPin,OUTPUT);
pinMode(Rx, INPUT);
pinMode(Tx, OUTPUT);
mySerial.begin(9600);
}

void loop()
{

// READ DATA
mySerial.println("DHT22, \t");
uint32_t start = micros();
int chk = DHT.read22(DHT22_PIN);
uint32_t stop = micros();
//delay(2000);
switch (chk)
{
case DHTLIB_OK:
stat.ok++;
mySerial.println("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
stat.crc_error++;
mySerial.println("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
stat.time_out++;
mySerial.print("Time out error,\t");
break;
case DHTLIB_ERROR_CONNECT:
stat.connect++;
mySerial.print("Connect error,\t");
break;
case DHTLIB_ERROR_ACK_L:
stat.ack_l++;
mySerial.print("Ack Low error,\t");
break;
case DHTLIB_ERROR_ACK_H:
stat.ack_h++;
mySerial.print("Ack High error,\t");
break;
default:
stat.unknown++;
//mySerial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
mySerial.print(DHT.humidity, 1);
mySerial.print(",\t");
mySerial.print(DHT.temperature, 1);
mySerial.print(",\t");
mySerial.print(stop - start);
mySerial.println();
digitalWrite(ledPin, HIGH);
delay(150);
digitalWrite(ledPin, LOW);
// mySerial.println("Done !"); // On signal la fin de l'envoi
delay(150); // Et on attend 1s pour pas flooder

}

Set attiny for 8mhz, do burn bootloader to set it to run at 8mhz. Then upload sketch.

You never set tiny to run at 8mhz, so it was running at 1 (the default), but you were compiling for 8, so timing was off by factor of 8

thanks for your great help, it works now. I was thinking the fuses was set through the GUI.
Now all works like a charm :).

Attiny85 (8Mhz internal) + DHT22 + DTHlib (Arduino/libraries/DHTlib at master · RobTillaart/Arduino · GitHub) work perfectly.
Next stage for me RF433 with virtualWire Lib between Attiny and Arduino Uno.

Thanks again for you GREAT Help DrAzzy.

Now I am tring to send the temperature and humidity value through RF 443Mhz signal.
B
ut when I add vw_setup(2000) command in the setup configuration I have some issue :

  • DTH value are no more read
  • led no more blink .

I muse I have an issue with the timer0 and 1 used by both library.

Perhaps I have to modify the timer use on virtualLibrary (I read something about that), can anyone confirm this point .

thanks in advance, rgds, Manu

Likely not related to the timer specifically - DHT doesn't use timers at all, and VW may use timer1, but definitely not timer0. So there is no conflict.

The fact that the LED stops blinking says one of two things - either you're using a core that uses timer1 for millis and delay (use my core; the decision that that one core designer a few years back made, to use timer1 for millis on tiny85 was really really dumb, don't get me started), or somewhere you're crashing the whole thing (usually this happens because you write off the end of an array, though there are other ways to do it)

Hi DrAzzy,

You wrote use my core could you please elaborate ? do I need to use a special version of attiny core which version ? appreciate your help again. thanks .

To summarize, I muse that attiny85 + DTH22 + Virtualwire could work with Arduino uno configured as receiver. I found lot of thread on the web . I found a Virtualwire library that run with the attiny85 but delay value do no reflect the frequency of LEB blinking. Is there any VirtualWire really compatible with attiny85. I am not able to modify the .h & .cpp so I am stuck. perhaps I will give up such association .

If delay value does not reflect the time you see, that is why virtualwire is not working. You need to do "burn bootloader" after selecting the speed and clock source from the tools submenus (again, I assume you are using my version of ATTinyCore, not some other version).

See: GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 - it can be installed through board manager or manually.

I thought virtualwire became radiohead library - that version is newer and may work better?

I have installed the mentioned ATTinyCore , Led blinking is fixed but as soon as I set vw_setup(2000) command , It do not work anymore. could you please give le the link to VirtualWire Lib compliant with AttinyCore ? thanks in advance

manu95:
I have installed the mentioned ATTinyCore , Led blinking is fixed but as soon as I set vw_setup(2000) command , It do not work anymore. could you please give le the link to VirtualWire Lib compliant with AttinyCore ? thanks in advance

Sorry, I have not used virtualwire or radiohead; I couldn't give any recommendation.

I found the library code thoroughly incomprehensible (particularly RH, which not only suffers from #ifdef hell, but also kitchen-sink-ism), and I wasn't comfortable using it for that reason. I made my own RF protocol for my 433mhz OOK RF projects (though it hasn't been library-ified and is not in a state suitable for use by others currently).

Hi everyone,
I would like to try this configuration that works (seen on Github project : crycode-de (Peter Müller) · GitHub ) : attiny85 + dht22 + Radiohead.
Unfortunately I have a compilation error :

Error :
In file included from /Users/manu/Documents/Arduino/libraries/RadioHead/RH_E32.cpp:6:0:
/Users/manu.marcon/Documents/Arduino/libraries/RadioHead/RH_E32.h:282:23: error: ‘Serial’ was not declared in this scope
RH_E32(Stream *s=&Serial, uint8_t m0_pin = 4, uint8_t m1_pin = 5, uint8_t aux_pin = 8);

RadioHeab library used :
http://www.airspayce.com/mikem/arduino/RadioHead/

Anyone could help me ?
tx