NewSoftSerial problem

#include <NewSoftSerial.h>
NewSoftSerial nss(12,13); // Put your TX and RX pins here
byte vals[3];
int heartRate, oxyLevel;

void setup( ) 
{
  nss.begin(9600);
  Serial.begin (9600);
}

void loop ()
{
 if(nss.available() >= 3)
  { 
    vals[0] = nss.read(); //represent byte 1
    vals[1] = nss.read(); //represent byte 2
    vals[2] = nss.read(); //represent byte 3
    
    heartRate = 0; // Sets all 8 bits to 0
    oxyLevel = 0; // Sets all 8 bits to 0

    bitWrite(heartRate, 0, bitRead(vals[1], 0)); // Set bit 0
    bitWrite(heartRate, 1, bitRead(vals[1], 1)); // Set bit 1
    bitWrite(heartRate, 2, bitRead(vals[1], 2)); // Set bit 2
    bitWrite(heartRate, 3, bitRead(vals[1], 3)); // Set bit 3
    bitWrite(heartRate, 4, bitRead(vals[1], 4)); // Set bit 4
    bitWrite(heartRate, 5, bitRead(vals[1], 5)); // Set bit 5
    bitWrite(heartRate, 6, bitRead(vals[1], 6)); // Set bit 6
    bitWrite(heartRate, 7, bitRead(vals[0], 0)); // Set bit 7(Vals[0])
    bitWrite(heartRate, 8, bitRead(vals[0], 1)); // Set bit 8(Vals[0])
   
    oxyLevel = vals[2];
    Serial.print(",");
    Serial.print(heartRate);
    Serial.print(",");
    Serial.println(oxyLevel);
  }
    
  delay (1000);
}

Guys, i uploaded this program yesterday on my Arduino Pro Mini using the 5V FTDI Basic Breakout Board then i proceed to transmit the data wirelessly using the Xbee Explorer Regulated. At my receiver end, i connect a Xbee Explorer Dongle to collect the transmitted values.

My serial monitor at the receiver end looks like this:
,68,99
,68,99
,67,98
,68,99

This is what i wanted.
To my dismay, when i tried transmitting again today, my serial monitor at the receiver end shows nothing.:disappointed_relieved:I tried changing the tx and rx pin to 10,11 but to no avail. Guys, can you all help? I got really no idea what is the problem. Nothing is spoilt.

I will appreciate your help. Thanks. :slight_smile:

To my dismay, when i tried transmitting again today, my serial monitor at the receiver end shows nothing.:disappointed_relieved:I tried changing the tx and rx pin to 10,11 but to no avail.

Why? If the code was working with pins 12 and 13, what purpose does it serve to change where the sensor is connected?

The Arduino has LED that flash when there is serial data sent or received. The XBee breakout boards have LEDs that flash when there is data sent or received. Knowing what those LEDs are doing would be useful.

If you were able to read the sensor data once, using NewSoftSerial, and send and receive it using Serial and the XBees, the problem now is NOT with NewSoftSerial.

When i change the programming code of the tx and rx pins to 10 and 11, i changed the digital pins connections to 10 and 11 as well. I realised that data is not transmitted cause the Din pin of the Xbee Explorer Regulated is not blinking. PaulS, you are right - the problem is not with NewSoftSerial. My mistake. So what is the problem? Is it the programming code?

The Serial.print() function sends data out of the Arduino to the XBee to transmit. If the LED on the board that the XBee is attached to is not indicating that it is receiving data to broadcast, it is not a software problem, especially since it worked at one time.

Moving wires around rarely corrupts the software.

Moving wires around rarely corrupts the software.

Never had the fun of threading core memory, huh?

Never had the fun of threading core memory, huh?

Nope. That's a hardware problem. I'm a software developer.

Okay. :) Guys, the weird thing is that i am able to transmit my voltage readings using the Serial.print ( ); command too - Din pin blinking. But it doesn't work for my heartrate and oxylevel. Why? :)

But it doesn’t work for my heartrate and oxylevel.

Because you’re not sending them?
Seriously, how can we tell?
What steps have you taken to debug the situation?
Do you have a simple sketch to send “the quick brown fox”?

I am able to send the string "the quick brown fox" and received it as well. I have tested both Xbee (transmitter and receiver) and it is working fine. I tried uploading the sketch (first post) on my Arduino Duemilanove and attempted to transmit the readings but it is also not sending anything.

http://www.nonin.com/documents/OEM%20III%20Module%20Specifications.pdf (Page 5 & 10)

I guess the problem lies with my pins connections from the nonin module (heartrate & oxylevel) to the Arduino? I am using Serial data format #1. I connect a 150ohm resistor between pin 9 and 15. I connect Digital pin 10 (my TX) of the Arduino to pin 10 of the module Digital pin 11 (my RX) of the Arduino to pin 11 of the module. Pin 16 of module to my Xbee Explorer Regulated 3.3V pin Pin 15 of module to my Xbee Explorer Regulated Gnd pin