Pages: [1]   Go Down
Author Topic: code for receiving serial data from transmitter  (Read 469 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi everyone,im working on flood monitoring system.here my arduino code for receiving data serially..is it this code really work?
im receiving the latitude and longitude data from the transmitter as well as the water level data..is there any changes that i have to make in order to get the code work?sorry, im very new with arduino board...tq for ur help...
Code:
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
 
int rate;
 
void setup(){
 
  Serial.begin(9600);
 
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();
  Mirf.setRADDR((byte *)"serv1");
  Mirf.payload = sizeof(rate);
  Mirf.config();
}
 
void loop(){
 
  while(!Mirf.dataReady()){
  }
  Mirf.getData((byte *) &rate);
 
  Serial.println(rate);
  delay(100);
}
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8596
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've no idea what Mirf.getData() does but

Code:
int rate;
...
Mirf.getData((byte *) &rate);

doesn't seem right. Why are you casting the address of an int to a pointer to a byte?

If Mirf.getData() fills "rate" with more that 2 bytes you will be in trouble.

______
Rob
« Last Edit: December 11, 2012, 03:44:01 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i got the code online...refering to the code...there are no initialization of pin...does it works?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
.there are no initialization of pin...does it works?
You're the one with the hardware - you tell us.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: