Pages: [1]   Go Down
Author Topic: (Help) Leonardo with SKXBEE for wireless transmission  (Read 337 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm doing project on force sensing resistors and flex sensors with wireless communication using SKXBEE (Cytron)
I'm using Serial1 to send the output to Xbee, but I can't get any data from Leonardo, is the coding wrong? Need some help here~

int outputFSR = 0;       
int outputFlex = 0;
int SensorPins[] = {0,1,2,3,4,5,6,7,8,9};   // set the analog pins (connected to FSRs and Flex Sensor) into an array
int SensorCount = 10 ;                            // number of sensors on the insole
int sensorArray[] = {};                            // set the voltage values into an array

void setup()
{
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  Serial1.begin(9600);
 
  while (!Serial)
  {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
}

void loop()
{
  // read the FSR analog values:
 
  for (int thisPin = 0; thisPin < SensorCount; thisPin++)
  {
   
    if ( SensorPins[thisPin]==0||SensorPins[thisPin]==9)
    {
          //for flex sensor only
     
      int FlexValue = analogRead(SensorPins[thisPin]);
      outputFlex = map(FlexValue, 700, 800, 0, 255);
      sensorArray[thisPin] = outputFlex;
    }
    else
    {
      //for FSR values

      int FSRValue = analogRead(SensorPins[thisPin]);           
     
      // map it to the range of the 8-bit analog output:
      outputFSR = map(FSRValue, 0, 1023, 0, 255); 
      sensorArray[thisPin] = outputFSR;
     
      // store each sensor value into an array
    }
           

  // Send the values to Xbee

  Serial1.print("Sensor ");
  Serial1.print(thisPin);
  Serial1.print(" = ");
  Serial1.println(sensorArray[thisPin]); 
 

  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(450);
  } 
 
 
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 638
Posts: 50331
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
with wireless communication using SKXBEE (Cytron)
And this relates to XBee how?

A link to the device you are using, a diagram of how it is connected to the Arduino, and some information on how the device is configured (and what it is talking to) would be useful.
Logged

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

My project is basically getting data from Force sensing resistors and flex sensors from Analog inputs of Leonardo and send the data via Xbee to computer (Xbee Dongle)

I have tried using Arduino Uno but using Serial instead of Serial1 and it works, I can get data from Terminal of X-CTU software for Xbee,
but for my project I need more analog input as Leonardo offers.

but when I connected to Leonardo to Xbee, I could not get any data from my Xbee dongle (no data in from Terminal of X-CTU).
Do I really need to include Xbee library or include coding like:

while(Serial1.available())
{

}

My connection for Leonardo to Xbee (as attached photo)
Leonardo-Xbee
5V-5V
Gnd-Gnd
Tx-Rx
Rx-Tx

Hope u can help me, thanks~~


* DSC_0130.JPG (708.78 KB, 2592x1944 - viewed 10 times.)
Logged

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

problem solved, getting data from Xbee dongle
by omitting the code
while (!Serial)
  {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

Logged

Pages: [1]   Go Up
Jump to: