Hi,
I've a problem initializing the radio module on a sensor. I created a sensor sketch using humidity sensor sketch. I've removed everything DHT related to leave only a fixed value sent every time the loop method runs (just testing the mysensors part, I don't have a DHT right now).
I'm using MySensors 1.5 and nothing more than a bare Arduino Uno and a nRF24L01+ wired according the "connect the radio" guide. When I run the program, I see a "radio init fail" message. I tried several nRF24 modules (all the same model, bought at the same time) and on an Arduino Mega, I triple checked my wires and wiring (also used a multimeter). The nRF24 module I'm using right now has no problem initializing on another Arduino running an ethernet gateway.
I downloaded the RF24 library from https://github.com/maniacbug/RF24 and the radio module seems to work with the library. Here's what I get in the serial console for the scanner sketch :
RF24/examples/scanner/
00000000000000001111111111111111222222222222222233333333333333334444444444444444555555555555555566666666666666667777777777777777
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
00000002222200000000000000000000100000000000000000000000000206253300000000000000000000000000000000000000000000000000000000000000
00000002222200000000000000000000200000000000000000000000000201123300000000000000000000000000000000000000000000000000000000000000
00000002222300110000000000000001200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000001120100111000000000000002100000000000000000000000000100001110000000000000000000000000000000000000000000000000000000000000
00000002222222211110000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Using the GettingStarted sketch, I get the details for the radio module and it's a + model :
RF24/examples/GettingStarted/
ROLE: Pong back
*** PRESS 'T' to begin transmitting to the other node
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0d2 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0d2
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH
I also tried the 1.4.2 MySensors library, but I get a "check wires" error.
Any idea what might be the cause of this problem ?
Thx
Just in case, here's the sketch :
#include <SPI.h>
#include <MySensor.h>
//#include <DHT.h>
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define HUMIDITY_SENSOR_DIGITAL_PIN 3
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
MySensor gw;
//DHT dht;
float lastTemp;
float lastHum;
boolean metric = true;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
void setup()
{
gw.begin();
//dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
// Send the Sketch Version Information to the Gateway
gw.sendSketchInfo("Humidity", "1.0");
// Register all sensors to gw (they will be created as child devices)
gw.present(CHILD_ID_HUM, S_HUM);
gw.present(CHILD_ID_TEMP, S_TEMP);
metric = gw.getConfig().isMetric;
}
void loop()
{
/*delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
if (isnan(temperature)) {
Serial.println("Failed reading temperature from DHT");
} else if (temperature != lastTemp) {
lastTemp = temperature;
if (!metric) {
temperature = dht.toFahrenheit(temperature);
}
gw.send(msgTemp.set(temperature, 1));
Serial.print("T: ");
Serial.println(temperature);
}
float humidity = dht.getHumidity();
if (isnan(humidity)) {
Serial.println("Failed reading humidity from DHT");
} else if (humidity != lastHum) {
lastHum = humidity;
gw.send(msgHum.set(humidity, 1));
Serial.print("H: ");
Serial.println(humidity);
}
*/
gw.send(msgTemp.set(23.1, 1));
gw.send(msgHum.set(57.5, 1));
gw.sleep(SLEEP_TIME); //sleep a bit
}