Multiple Software Serial connections from the UNO

I have two serial devices that talk to my arduino. One is a hc 06 bluetooth module, and another is an Arduino on a breadboard.
This is what is on the board at the moment:

#include <Servo.h>

#include <SoftwareSerial.h>
#include <NewPing.h>
#define TRIGGER_PIN  2
#define ECHO_PIN     3
#define MAX_DISTANCE 40

SoftwareSerial mySerial(9,8);
SoftwareSerial powerSerial(14,15);

int ledPin = 13;
long previousMillis = 0;        
long interval = 20000;           // interval at which to blink (milliseconds)





float temp;
int tempPin = 0;

int humiPin =1;
float humi;


NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
Servo myservo;

void setup() {
  mySerial.begin( 9600 );    // 9600 is the default baud rate for the mymySerial Bluetooth module
powerSerial.begin(9600);
//Serial.begin(9600);
myservo.attach(7);
}

void loop() {
 
  
 
distanceHandler();
//powerModuleHandler();
checkSerialIncoming();
//temperaturehumidityHandler();

//debug();
/*

doServo(true);
delay(1000);
doServo(false);
delay(1000);
*/

}
















void distanceHandler()
{
  
 
 int uS = sonar.ping();
 delay(700);
  int Distance = uS / US_ROUNDTRIP_CM;
    // Serial.print(Distance);
  if(Distance<=15&&Distance!=0) 
  {
  //Serial.println("NEWMAIL");
 
    mySerial.println("NEWMAIL");
  }
  
  
}

void temperaturehumidityHandler()
{
  
  
   unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
  previousMillis = currentMillis;   
  temp = analogRead(tempPin);
  temp = temp * 0.48828125;
 
  //Serial.print(temp);
  
   mySerial.print("T");
   mySerial.println(fixDigits((int)temp));
  
   
    humi = analogRead(humiPin);
    mySerial.print("H");
    mySerial.println(fixDigits((int)humi*2));

   
   
  // Serial.print("T");
  // Serial.println(fixDigits((int)temp));
  
   
    humi = analogRead(humiPin);
  //  Serial.print("H");
  //  Serial.println(fixDigits((int)humi*2));
   
  }
  
  
  
  
  
  
  
}



void powerModuleHandler(){
  
 
  
  if(powerSerial.available()>0)
  {
    
    
    
    mySerial.print("P");
    mySerial.println(powerSerial  .parseFloat());
    
    
    
    
    
    
  //Serial.println( Serial.parseFloat());
    
    
  } 
  
  
}
void checkSerialIncoming()
{
   if(mySerial.available()>0)
 {//blinkLED(2);
 //Serial.println("ok,got response" );
 char response=mySerial.read(); 
  if(response=='O')
  doServo(true); 
  else if(response=='F')
  doServo(false);
  
  //mySerial.write('resp');
 }
  
  
  
  
  
  
  
  
  
}



void debug(){
   humi = analogRead(humiPin);
  
  Serial.println(humi*2);
  delay(10000);
}

String fixDigits(int number)
{
  char buf[12];
 if(number<10)
  return "0"+number ;
  else return itoa(number,buf,10);
  
}


void doServo(boolean state)
{
  if(state)
  {
   myservo.write(95); 
  }
  else 
  myservo.write(0);
  
}




void blinkLED(int count) {
  for (int i=0; i< count; i++) {
    digitalWrite(ledPin, HIGH);
    delay(500);
    digitalWrite(ledPin, LOW);
    delay(500);
  } 
}

It is all glitching . For some reason, im not able to talk to both properly. when I comment out poweModule.begin(), it works.

What is the problem ?

What is the problem ?

First, are you having problems talking TO them or are you having problems LISTENing to them?

Only one instance of SoftwareSerial can listen at a time.

The serial mySerial is not seeming to receive properly :confused:

The serial mySerial is not seeming to receive properly :confused:

Where do you switch which instance is listening? Which instance should be listening most of the time? What data can you afford to have ignored?

If the answer is none, the answer is a Mega with 4 hardware serial ports. It is NOT multiple SoftwareSerial instances. Multiple SoftwareSerial instances are ONLY for devices that you talk to but do NOT need to listen to. Like having multiple wives.

You MIGHT be able to get yet another software serial to work alongside regular SoftwareSerial - but I have not tried it and it was not designed with that in mind.

...R
Planning an Implementing a Program Several things at a time Serial Input Basics Stepper Motor Basics
Python-Arduino Comms Python GUI demo EzScrn

is it possible to get Serial (pins 0,1) and a software Serial to work together ?

is it possible to get Serial (pins 0,1) and a software Serial to work together ?

Of course.