Go Down

Topic: I want to add my Data Logger with NRF24L01 (Read 283 times) previous topic - next topic

Suvendu_dash

Hi ! I have a Sketch that is working properly ( Its recording data from a Hall sensor to an SD card on my data logger with out using nRF24l01).

Its working great , but i would like to implement my NRF24L01 to send the values that show up on the serial monitor (from the sensor ) to another NRF24L01 ( so i can see it on the Serial monitor )  and save the data in the SD card through data logger in the receiver side...

The Hardware that I am using is : Arduino Mega with data logger , Sensor , and the things I like to implement is : 2 NRF24L01 and another Arduino ( I have mega , uno , nano ).

I have facing problem when i used the ICSP header for data logger's MOSI, MISO,SCK pin because the Arduino megas's MOSI,MISO and SCK pins are used by nRF24L01.

I attach the draft code  for that..i don't know whether it's working correct or not but compiled perfectly. I attach the Transmitter and receiver output also.

Transmitter side code

Code: [Select]

#include <SPI.h>             
#include <nRF24L01.h>         
#include <RF24.h>             


#define HallVolt1 A0           //declear the analog pin A0
#define HallVolt2 A1           //declear the analog pin A1
#define HallVolt3 A2           //declear the analog pin A2


float hall1[3];


RF24 radio(2,3);             

const byte rxAddr[6] = "00001";

void setup() {

Serial.begin(9600);         
radio.begin();
radio.setRetries (15, 15);     
                               
                                                             
radio.openWritingPipe (rxAddr);
radio.setPayloadSize (32);     
 
radio.stopListening ();       
}

void loop() {

hall1[0] = analogRead (HallVolt1);
hall1[1] = analogRead (HallVolt2);
hall1[2] = analogRead (HallVolt3);


hall1[0]=hall1[0]*5/1023;
hall1[1]=hall1[1]*5/1023;
hall1[2]=hall1[2]*5/1023;


Serial.print("Transmite Hall-1 Effect = ");
Serial.print(hall1[0]);
Serial.print("Volt");
Serial.print("\t");

Serial.print("Transmite Hall-2 Effect = ");
Serial.print(hall1[1]);
Serial.print("Volt");
Serial.print("\t");

Serial.print("Transmite Hall-3 Effect = ");
Serial.print(hall1[2]);
Serial.print("Volt");
Serial.print("\t");


radio.write(&hall1[0], sizeof(hall1));   

delay(1000);

}



Receiver side code

Code: [Select]


#include <SPI.h>                   
#include <nRF24L01.h>               
#include <RF24.h>                   
#include <SD.h>

File myFile;
float hall1[3];

RF24 radio(2,3);                     

const byte rxAddr[6] = "00001";     

void setup() {

   
  while (!Serial);                 
  Serial.begin (9600);             
  radio.begin();
  radio.setPayloadSize(32);         
 
  radio.openReadingPipe(0, rxAddr);
 
  radio.startListening();         
  Serial.println("Initialising SD card...");

  if(!SD.begin(53))
  {
    Serial.println("Initialization failed");
    return;
  }
  Serial.println("Initialization Success");
}


void loop() {
     
      if (radio.available()){
      radio.read(&hall1[0], sizeof(hall1)); 
     
      myFile=SD.open("test.txt", FILE_WRITE);

      if(myFile) 
      {
      myFile.print(" Received Hall-1 Effect. = ");
      myFile.print(hall1[0]);
      myFile.print("Volt");
      myFile.print("\t");
     
      Serial.print(" Received Hall-1 Effect. = ");
      Serial.print(hall1[0]);
      Serial.print("Volt");
      Serial.print("\t");
     
     
      myFile.print(" Received Hall-2 Effect. = ");
      myFile.print(hall1[1]);
      myFile.print("Volt");
      myFile.print("\t");
     
      Serial.print(" Received Hall-2 Effect. = ");
      Serial.print(hall1[1]);
      Serial.print("Volt");
      Serial.print("\t");
     
      myFile.print(" Received Hall-3 Effect. = ");
      myFile.print(hall1[2]);
      myFile.print("Volt");
      myFile.print("\t");
     
      Serial.print(" Received Hall-3 Effect. = ");
      Serial.print(hall1[2]);
      Serial.print("Volt");
      Serial.print("\t");
      Serial.println();
     
     }
     
      delay (1000);
     
     }

}

ieee488

I attach the draft code  for that..i don't know whether it's working correct or not but compiled perfectly.
It your job to figure out if it's working or not.
Are you unable to do anything on your own? ? ?

Suvendu_dash

I think u miss interpreted my post....i am not asked to any  one to write a code for me... i just request for guidance...if u don't have any constructive suggestion plz don't divert this post to any other topic.

U maybe know everything... but I'm a simple human who is trying learn something.

Robin2

Have a look at this Simple nRF24L01+ Tutorial

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features. In other words without any SD Card or datalogger stuff

I have noticed in other Threads that some SD Cards don't behave nicely when expected to share the SPI system.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

ieee488

I think u miss interpreted my post....i am not asked to any  one to write a code for me... i just request for guidance...if u don't have any constructive suggestion plz don't divert this post to any other topic.

U maybe know everything... but I'm a simple human who is trying learn something.

I wrote that you seem incapable of figuring anything out for yourself.

You have a habit of doing that on these forums.
People can see what you have done in the past.
We are not as stupid as you seem to think.


Go Up