I got it I had overwritten the number of channels..I have changed the code. I'm not sure to what extent its correct. What i want it to do is read the values and transmit it to the receiver. And display on the serial monitor..
// The modified code (transmitter)......//
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const int SensorPin = A0;//Analog Input pin that senses vout
int SensorValue = 0;//sensorpn default value
float Vin = 5;//input vloltage
float Vout = 0;//Vout default value
float Rref = 18000;//reference resistors value in ohms
float R = 0;//tested resistor's default value
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
#define NUM_CHANNELS 1
typedef struct
{
//long int td;
int data [ NUM_CHANNELS ];
}
SRF24_Data;
SRF24_Data RData;
SRF424_Data*pSRData = &RData;
void setup()
{
Serial.begin(9600);
radio.begin();
radio.setRetries(15, 15);
radio.openWritingPipe(rxAddr);
radio.stopListening();
}
void loop()
{
SensorValue = analogRead(SensorPin);//read vout on analog Input pin A0(arduino can sense from 0-1023, 1023 is 5v)
Vout = (Vin* SensorValue)/1023; //convert Vout to volts
R = Rref* (1/((Vin/Vout)-1));//formula to calculate tested resistors value//
Serial.print("\nR: ");
Serial.print(R);
const char text[] = "R ";
//const char text[1] = "HEYMANN";
radio.write(&text, sizeof(text));
//long int t = millis();
radio.write(pSRData, sizeof(SRF24_Data));
delay(1000);
}
//I'm getting the following error//
[[
Arduino: 1.8.6 (Windows 10), TD: 1.43, Board: "Arduino/Genuino Uno"
sketch_sep28tr:24:1: error: 'SRF424_Data' does not name a type
SRF424_Data*pSRData = &RData;
^
C:\Users\Hemanth Kumar\Desktop\Project\examples\sketch_sep28tr\sketch_sep28tr.ino: In function 'void loop()':
sketch_sep28tr:51:15: error: 'pSRData' was not declared in this scope
radio.write(pSRData, sizeof(SRF24_Data));
^
Multiple libraries were found for "nRF24L01.h"
Used: C:\Users\Hemanth Kumar\Documents\Arduino\libraries\RF24-master
Not used: C:\Users\Hemanth Kumar\Documents\Arduino\libraries\RF24
Not used: C:\Users\Hemanth Kumar\Documents\Arduino\libraries\RF24
Not used: C:\Users\Hemanth Kumar\Documents\Arduino\libraries\RF24
Not used: C:\Users\Hemanth Kumar\Documents\Arduino\libraries\RF24
exit status 1
'SRF424_Data' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
]]
Hemanth03:
I got it I had overwritten the number of channels..I have changed the code. I'm not sure to what extent its correct. What i want it to do is read the values and transmit it to the receiver. And display on the serial monitor..
What program is that paired with? It is pointless considering one wireless program on its own.
What happens when you run the program?
Have you been successful in getting any communication between the nRF24s?
srnet:
Is that a real circuit, your are really using two AA Duracells to power a Teensy ?
I'm planning to use teensy for both(tx, rx), but as of now i'm using uno for transmitter part and teensy for receiver part. I'll not be using exact same cells instead a 5v power supply that is to power up my analog front end(AFE), which consists of voltage divider and opamp(ADA4522-2).
Hemanth03:
I'm planning to use teensy for both(tx, rx), but as of now i'm using uno for transmitter part and teensy for receiver part. I'll not be using exact same cells instead a 5v power supply that is to power up my analog front end(AFE), which consists of voltage divider and opamp(ADA4522-2).
So its not a real depiction of how you have everything connected up ?
srnet:
So its not a real depiction of how you have everything connected up ?
It is same except for the power supply and the microcontroller. I'll change the microcontroller once I get it that wont be a problem. I wasn't getting the exact power supply component in fritzing while perparing the circuit hence that battery cells.
I wasn't getting the exact power supply component in fritzing
That is one of the reasons we hate fritzing here. There are ways of drawing your own symbols but this is beyond the skill of the people who this hateful package is aimed at.
Hemanth03:
It is same except for the power supply and the microcontroller.
How the parts are actually connected up is important, so if you dont use a schematic drawing program, just draw the actual real circuit on paper and take a picture.
And if your not posting the real circuit, at least tell people.
Not in relation to the circuit diagram I have mentioned in the earlier.
Now I'm just trying to measure an unknown resistor with a simple voltage divider and communicating between two nRF24L01. I'm receiving some junk value...
//Transmitter CODE//
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
const int SensorPin = A0;//Analog Input pin that senses vout
int SensorValue = 0;//sensorpn default value
float Vin = 5;//input vloltage
float Vout = 0;//Vout default value
float Rref = 1800;//reference resistors value in ohms
float R = 0;//tested resistor's default value
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
#define NUM_CHANNELS 1
typedef struct
{
long int td;
int data [ NUM_CHANNELS ];
}
SRF24_Data;
SRF24_Data RData;
SRF24_Data *pSRData = &RData;
void setup()
{
Serial.begin(9600);
radio.begin();
radio.setRetries(15, 15);
radio.openWritingPipe(rxAddr);
radio.stopListening();
}
void loop()
{
SensorValue = analogRead(SensorPin);//read vout on analog Input pin A0(arduino can sense from 0-1023, 1023 is 5v)
Vout = (Vin* SensorValue)/1023; //convert Vout to volts
R = Rref* (1/((Vin/Vout)-1));//formula to calculate tested resistors value//
Serial.print("\nR: ");
Serial.print(R);
const char text[] = "0";
//const char text[] = "HEMANTH";
radio.write(&text, sizeof(text));
//long int t = millis();
radio.write(pSRData, sizeof(SRF24_Data));
delay(1000);
}
[CODE]
//Receive code//
[CODE]
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
void setup()
{
while (!Serial);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, rxAddr);
radio.startListening();
}
void loop()
{
if (radio.available())
{
char text[] = {0};
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
[CODE]