Uno+ethernet shield = radio init fail [solved]


  • Hardware Contributor

    Using IDE 1.6.5, MySensors 1.5, building on Windows 7 (64 bit). Started w/ an Uno and built the serial gateway (with a capacitor on the radio power lines). That worked fine (debug messages report success in the IDE serial window). Then I added an Arduino W5100 ethernet shield (plugging it into the uno). I changed the wires to match the WizNet instructions, uncommented SOFTSPI, and I get this message in the serial window:

    0;0;3;0;9;radio init fail

    I double checked all the wires (and I'm using the same patch cords I used for the serial gateway). I also added an external power supply to the uno barrel connection to see if that would help. But I'm still getting radio init failed. If I plug in a network cable, I can ping the arduino successfully so it seems like the ethernet shield is working.

    Any ideas what I should try next? Given that the radio and wires work fine in serial mode, I'm thinking my wiring is wrong but I've tripled checked it and don't see anything. Any help would be greatly appreciated...

    Here's the links to the hardware I bought:
    http://www.aliexpress.com/item/Free-shipping-UNO-R3-MEGA328P-for-Arduino-Compatible-with-USB-cable-and-9V-battery-clip-snap/1960648380.html
    http://www.aliexpress.com/item/UNO-Shield-Ethernet-Shield-W5100-R3-UNO-Mega-2560-1280-328-UNR-R3-only-W5100-Development/674888225.html



  • I have the same problem!! I think is a problem with the new library!! With the 1.4.2 works good!!


  • Admin

    Did you uncomment SOFTSPI in MyConfig.h which is the correct place now?



  • I have the same setup and tried yesterday to get things working with a constant "0;0;3;0;9;radio init fail" error.

    This morning I switched to 1.4.2 and I can confirm that with no other changes I now get "0;0;3;0;14;Gateway startup complete."

    Just to clarify, in 1.5 I did define SOFTSPI in MyConfig.h and in 1.4.2 I did it in RF24_config.h.

    Regards Martin


  • Admin

    Strange. Nothing obvious pops up in my head which could affect this. Only a small modification to the RF24_config.h was done (to fetch the settings from MyConfig.h).

    Guess you've checked that RADIO_CE_PIN and RADIO_SPI_SS_PIN in sketch is correct?

    Could need some help to resolve this issue from people using the same hardware.


  • Admin

    Oh.. someone already created an issue on github!

    This is probably the issue you're seeing.

    MySensors/Arduino#146


  • Admin

    Could someone try the updated ethernet-sketch?



  • Good work!

    I have to admit, this is my first dive into this project so my knowledge is VERY limited. But my gateway says: "0;0;3;0;9;gateway started, id=0, parent=0, distance=0" so I guess its happy now!

    Thank you!


  • Hardware Contributor

    Excellent! Updated code works for me as well. Thanks for the quick response everyone (and I've learned to go check github for issues as well).

    Is there any reason the SOFTSPI flag can't be moved into the sketch as well? I'm assuming as long as it's defined before the include that gets to RF24, it will be OK. That way all the mods for different configs are in the sketch and it would eliminate having to remember to edit/compile/undo before building sensors. Any opinions?


  • Admin

    @TD22057

    Because defines declared in the sketch isn't visible in the cpp files. The Arduino build system isn't exactly the best on the planet.



  • Hi all, I am about to try this as well as I have the same setup with the etehrnet shiled, but I don't really understand the wiring instructions. As the Ethernet shield is fixed on the board what does it mean by connecting MISO/SO to pin 12 and MOSI/SI to pin 11 etc?

    Apologies if this is a silly question


  • Hardware Contributor

    @diggs The instructions are for a general ethernet board - those are the pins it's using. If you use the ethernet shield, the connections are made in the shield, you just need to connect the radio up. If you're not using a shield, you have to make those connections yourself.



  • @TD22057 Thanks for the reply. That would mean then the IRQ is not used with this setup then,



  • Hello,

    I get same message in the serial : 0;0;3;0;9;radio init fail

    // Enable SOFTSPI for NRF24L01 when using the W5100 Ethernet module
    #define SOFTSPI
    #ifdef SOFTSPI
    	// Define the soft SPI pins used for NRF radio
    	const uint8_t SOFT_SPI_MISO_PIN = 50;
        const uint8_t SOFT_SPI_MOSI_PIN = 51;
        const uint8_t SOFT_SPI_SCK_PIN = 52;
    #endif
    
    • EthernetGateway.ino
    #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
    #define INCLUSION_MODE_PIN  3 // Digital pin used for inclusion mode button
    
    #define RADIO_CE_PIN        5  // radio chip enable
    #define RADIO_SPI_SS_PIN    6  // radio SPI serial select
    
    #define RADIO_ERROR_LED_PIN 7  // Error led pin
    #define RADIO_RX_LED_PIN    8  // Receive led pin
    #define RADIO_TX_LED_PIN    9  // the PCB, on board LED
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);  
    

    CE & CSN pin are différents configuration in MyConfig.h & EthernetGateway.ino. Can I change this?

    Other idea please?



  • I'm getting the same error with the serial gateway.using Arduino Nano, My Sensor 1.5 Arduino ide 1.6.5. I tried two different radio modules and an external 3.3 v supply no combination worked.



  • this is probably an obvious question, but I'd rather insult your intelligence than silently let you make the same mistake I made for a while :-). On your hard drive, and I'm not sure how the second copy gets made (I didn't copy the library twice, or if I did, I was drunk when I did it :-)) , there are two copies of the libraries (and thus the config.h file). there is one in c:\program files(x86)\Arduino\libraries and one in your "My Documents"\Arduino\libraries (or wherever your "my docs" is).... it's the one in your "my docs" that counts. Make sure you are editing the right 'myconfig.h' file when you enable SOFT_SPI.


  • Hardware Contributor

    This might be another obvious question, but I'll ask anyway: I see a lot of people saying they're using 1.5 but that version had the bug in it that I originally saw. Did you update directly from the git repository to get the fix? I'm not sure whether or not it's fixed if you download the 1.5 master.zip file.



  • The libraries don't exist under My Documents in my case. I've traced the error back to the code that is causing it, but I don't know what to do about it. In the rf24.h file there is a section that attempts to determine if the rf24 is P variant. It is returning false on the method call rf24.isPvariant. The results of the Serial.println statements I put in the MyTransportNRF24.cpp code are below:

    Before rf24.begin in MyTransportNRF24
    after rf24.begin in MyTransportNRF24
    !rf24.isPVariant() in MyTransportNRF24

    0;0;3;0;9;radio init fail

    Here are the lines in the v1.5 rf24.h that I think are causing the problem.

    Lines 347-351
    RF24::RF24(uint8_t _cepin, uint8_t _cspin):
    ce_pin(_cepin), csn_pin(_cspin), p_variant(false),
    payload_size(32), dynamic_payloads_enabled(false), addr_width(5)//,pipe0_reading_address(0)
    {
    }

    Lines 480-488
    // Determine if this is a p or non-p RF24 module and then
    // reset our data rate back to default value. This works
    // because a non-P variant won't allow the data rate to
    // be set to 250Kbps.
    if( setDataRate( RF24_250KBPS ) )
    {
    p_variant = true ;
    }

    I'll try and copy over the v1.4 version of these files and see if they work.



  • Well, I've completely started from scratch. Latest Arduino IDE, v1.4.2 of MySensors library. Had to copy several *.h files from version 1.5 to C:\Users\mike\Documents\Arduino\libraries\MySensors to get past all the include statements in the compiler. Now the compiler is throwing a lot of error messages (you can peruse them below). This system looked pretty good on their web site, maybe it was too good to be true. I'm trying to get the Gateway.ino sketch to compile. I downloaded it from github. I'll just sit this out and see what the Cognoscenti come up with.

    In file included from C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp:12:0:
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.h:39:28: error: 'DEFAULT_CE_PIN' was not declared in this scope
    MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, int8_t _inclusion_pin=-1, int8_t _rx=-1, int8_t _tx=-1, int8_t _er=-1);
    ^
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.h:39:59: error: 'DEFAULT_CS_PIN' was not declared in this scope
    MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, int8_t _inclusion_pin=-1, int8_t _rx=-1, int8_t _tx=-1, int8_t _er=-1);
    ^
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp: In constructor 'MyGateway::MyGateway(uint8_t, uint8_t, uint8_t, int8_t, int8_t, int8_t, int8_t)':
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp:30:163: error: no matching function for call to 'MySensor::MySensor(uint8_t&, uint8_t&)'
    MyGateway::MyGateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, int8_t _inclusion_pin, int8_t _rx, int8_t _tx, int8_t _er) : MySensor(_cepin, _cspin) {
    ^
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp:30:163: note: candidates are:
    In file included from C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.h:15:0,
    from C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp:12:
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MySensor.h:153:2: note: MySensor::MySensor(MyTransport&, MyHw&)
    MySensor(MyTransport &radio =new MyTransportNRF24(), MyHw &hw=new MyHwDriver()
    ^
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MySensor.h:153:2: note: no known conversion for argument 1 from 'uint8_t {aka unsigned char}' to 'MyTransport&'
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MySensor.h:144:7: note: MySensor::MySensor(const MySensor&)
    class MySensor
    ^
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MySensor.h:144:7: note: candidate expects 1 argument, 2 provided
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp: In member function 'void MyGateway::begin(rf24_pa_dbm_e, uint8_t, rf24_datarate_e, void (
    )(char
    ))':
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp:44:20: error: 'setupRepeaterMode' was not declared in this scope
    setupRepeaterMode();
    ^
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp:87:39: error: 'setupRadio' was not declared in this scope
    setupRadio(paLevel, channel, dataRate);
    ^
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp:88:36: error: 'BASE_RADIO_ID' was not declared in this scope
    RF24::openReadingPipe(WRITE_PIPE, BASE_RADIO_ID);
    ^
    C:\Users\mike\Documents\Arduino\libraries\MySensors\MyGateway.cpp:90:23: error: cannot call member function 'void RF24::startListening()' without object
    RF24::startListening();
    ^
    Error compiling.


  • Hardware Contributor

    @Michael-Hritz I don't think you're going to be able to copy headers from 1.5 into 1.x and ever get that to work - that's why they are different versions.

    Did you sync via github instead of downloading the 1.5 zip? Then edit the IDE sketchbook location preferences to point at the downloaded files and compile. I just tried that with the ethernet sketch and it built with only a couple of warnings.



  • I'll try it tomorrow. I'm burned out for the day. My wife has some gin gimlets waiting for me. Thanks for the suggestion.



  • I got around my earlier problem of “radio init fail” by setting the RF24_DATARATE to RF24_1MBPS (in MYSensor v1.5) as per instructions:
    http://forum.mysensors.org/topic/728/radio-setup-give-check-wires/30

    sonicblaze
    posted 8 months ago reply quote
    0

    @olaeke You might be able to get everything working over 1MBPS instead of the 250KBPS that's defaulted, as doctor64 suggested. I haven't tried it, but I found everywhere that'd have to be changed to make it work in theory.
    Edit <Ardunio libraries folder>/MySensors/Myconfig.h, and change the "RF24_DATARATE" to "RF24_1MBPS".
    Edit <Ardunio libraries folder>/MySensors/MySensor.cpp, and comment out lines 102-105 (the if isPVariant check)
    Recompile and upload new code to both your gateway and your sensor, and that should put them both in a mode compatible with the NRF24L01 sensor (to my best understanding/knowledge).

    But now, I’m getting a “ver mismatch” message. Is this because I’m only running the gateway and I’m not pairing it with a sensor node?
    It appears that I’m seeing mGetVersion returning 0 when PROTOCOL_VERSION is 2 .
    The taBle below shows where the version is set and gotten.

    Item Where used Lines
    mSetVersion MySensor.cpp 349,464
    mSetVersion MyMessage.h 179
    mGetVersion MySensor.cpp 590
    mGetVersion MyMessage.h 180


  • Hardware Contributor

    @hek said:

    @TD22057
    Because defines declared in the sketch isn't visible in the cpp files. The Arduino build system isn't exactly the best on the planet.

    FYI: I found a trick here: http://gammon.com.au/forum/?id=12625 that allows for more normal C/C++ development while still using the Arduino IDE for builds. Basically you create an empty .ino file with any external library include files in it. The IDE will happily rewrite that file and pick up those libraries. Then you can put the regular code (loop(), setup(), etc) in another .c or .cpp file and it will work properly. So you can put #defines or definitions ahead of include files and they work since the IDE only rewrites the .ino file. I've started using this for a sketch I was writing because I needed an enum in the prototype of local functions which the IDE kept screwing up. Works great and still allows the IDE to be used for building/uploading.

    As far as MySensors goes, this would allow you to define the SOFT_SPI macro locally in the sketch and then include the files that use it which makes it a lot easier to maintain your code. Especially when I come back to this in a year and have to remember how I built everything.


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 1
  • 6

15
Online

11.4k
Users

11.1k
Topics

112.7k
Posts