Hi, Im new here.
My problem is to set up ATMega328 running 8MHz with DHT11 sensor, sending data over nRF24L01+.
The 1st problem was that the DHT library I was using first had issiues working with a 8MHz chip.
That was solved by using another DTH library, confirmed to work @8mhz.
But now, with the new library i've got problems with RF24, or RF24Network lib.
Did anybody had similar problem, or know a non conflicting DHT and RF24 lib running on a 8MHz chip?
Everything was ok on Arduino Nano v3 @16MHz, using older DHT lib.
Separetly DHT11 is working good with the new lib on 8MHz, and the RF24 is also ok.
But together it just won't work.
I don't know the nRF24L01 library, but is it using interrupts ?
The DHT11 or the OneWire DS18B20 have specific timing. That timing can be messed up with an interrupt.
I don't know anymore what I did with the DHT11 (it's on my other computer), but for the DS18B20 I did this:
I choose code for the DS18B20 that doesn't disable interrupts, so everything else can run just fine.
In the loop() function, when there is nothing to do, I collect data from the sensor. So the Arduino is almost reading that sensor all the time. Only when everything was valid without error, the variable for temperature is updated. Sometimes there are 10 false readings in a row. But I don't mind, as long as once in a while the temperature is updated.
Im using DS18B20 also in this project (OneWire.h, DallasTemperature.h)
It runs fine with the RF24 lib on a 8mhz atmega.
RF24 probably doesnt use interrupts, cant tell exactly, im not as good at it
Its just some sort of conflict between new DHT lib and RF24.
So did anybody tried a setup of an 8Mhz chip with DHT11 and nRF24, and got it working?
I'd like to use 8mhz (or even slower in future, ie. 1mhz) due to power cosumption.
You have to tell us more, which libraries are you using ? Some libraries use interrupts, other disable interrupts.
It doesn't have to be interrupts, do you for example have a pullup resistor for the DHT11 ? About 10k ? and the wires are not very long ?
It will be battery operated (3x1.2v Ni-MH, or 2x1.5V AA bat, not sure now), but in future, now im prototyping on a breadboard, with power supply.
Cables are short, pullup resistors are in place.
Arduino IDE 1.0.5-r2.
DHT lib v0.1.13 from Arduino Playground - DHTLib
RF24 & RF24Network libs from maniacbug.
The working DHT library was DHT11 by Rob Tillaart (cant find url now), but it got issues working with 8mhz chip.
There are a few things going on, I can't tell how this all works together.
The DHT11 needs some time before it is ready, I don't know if that is all included in the library.
When you end the loop() with narcoleptic, the setup() executed once and the loop() is executed once. So you can place all your code also in setup().
Perhaps you can do a test.
First of all, use DHT11 on a different pin. You use SPI, and pin 10 is part of the SPI hardware.
Start in setup() with delay of 1 second, read the DHT11, and after that do all the initialization of the DS.begin(), SPI.begin(), radio.begin() and network.begin. Print the DHT11 values to the serial monitor and see if that works.
It was pin 10 that caused the trouble ? I'm glad you have it working.
It makes sense, since the DTH11 pin is set as input sometimes, and pin 10 is the SS pin of the SPI interface on a ATmega328p. It must be set only to output when using the SPI. It can be used for other things, but only as long as it is always output.
I think you had luck that it worked before. You somehow magically managed to avoid the pin/SPI conflict.
Now everything runs fine, including Vcc measuring, and powering on/off DS18B20 and DHT11
If i find 1MHz bootloader for Mega328P i'll try to slow it down further.
Now there is another big challange for me, designing the PCB
Thanks a lot for your help!
Yes I was thinking about attinny84/85. But some nodes will have more sensors, so i need few spare pins.
DS18B20 is no problem as it works over 1wire bus, but more DHT are problematic.
I.e. in the basement, where visible wires are not a problem, there will be just 1 node (placed where the best signal is) and about 5 DHT sensors.
Also, my code is to large at the moment (13-14kb) for any attiny. Probably I could slim down libs from unused functions, but my knowlage is too short for that now