OK. I have the parts mentioned in the subject, but am really struggling to get them to all work together.
After a day of running in circles, I started back at the beginning.
Using IDE 1.5.6r2
Here's my results / progress so far :
After reading about the 3.3V problems on the Mega, I used an LM317T and pot. to create a seperate 3.3V supply. Common ground to the Arduino supply, and capacitors over the ic.
I stripped everything off the board, and connected only the enc28j60 ethernet module ( cheap $1 unit ) as follows :
Gnd > common system ground.
Vcc > 3.3V
CS > pin 53
SCK > pin 52
SI > pin 51
SO pin 50
Added the UIPEthernet library.
On my local PC, using XAMPP, created a php script to receive data from the Mega, and write to a file.
Code in the script sends data to the PC's php page.
This is now all working very reliably.
Next I stripped the board down again, and tried the NRF24L01 module.
Using the same pins as I had for the ethernet module, and no results whatsoever.
Next changed CS pin to pin 7, and added code :
#include <SPI.h>
#include <RF24.h>
#include "printf.h"
#define RF_CE 9
#define RF_CSN 7
RF24 radio(RF_CE, RF_CSN);
void setup() {
Serial.begin(9600);
printf_begin();
radio.begin();
radio.printDetails();
}
void loop() {
}
The printDetails gave a load of values, but all were zero / blank. Nothing like what I had seen on other web searches.
Before trying to rip the Arduino Uno out of another project, I tried 1 last thing : I connected the MISO, SCK, and MOSI to pins 1, 3, and 4 of the Mega's ICSP headers ( next to the reset button ).
All of a sudden, the above sketch ran and the values were populated with an array of data, much like I have seen on other sites.
Now I can't explain why the rf24 library would not see the ethernet module on pins 50 - 53, but does on the ICSP pins. Could it be the library ? or the board definition / layout file used in the IDE ? I don't know, and since it wasted 2 days of tearing my hair out, I was just glad to have found something that works.
But here's the next problem :
I am wanting the Mega to communicate with another Mega using the RF module, and then upload data to the php on the PC over the ethernet. But I can't get them to all work together.
The ethernet works, but as soon as I add code for the RF, it stops working. Code includes :
#include "RF24.h"
#include "printf.h"
#define RF_CE 9
#define RF_CSN 7
RF24 radio(RF_CE, RF_CSN);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL }; // Radio pipe addresses for the 2 nodes to communicate.
// in setup
printf_begin();
radio.begin();
radio.setRetries(15,15);
radio.setPayloadSize(8);
radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1,pipes[1]);
radio.startListening();
radio.printDetails();
Ideally, I would like to use the ethernet to not only push data to the php page, but also to act as a server to serve a http page to the PC, so the PC user can click on links to activate options on the Mega. I know how to do all this, but I can't get the ethernet and RF to work at the same time.
Is this a case of multiple SPI devices, although can exist on the system at the same time, each being controlled / activated with its CS pin, but therefore can not have the ethernet server running at the same time that the RF is listening ?
I have even tried removing the ethernet Server code, and only using the ethernet Client code, and would re-code so that the Client reads a txt file on the PC every few minutes to get commands issued to it. But after removing the Server code, it still does not work.
I have also tried using radio.stoplistening and .startlistening before and after ethernet client code, but has no effect.
Any suggestions or advice ?