Multiple software_serial

ciao
Sto cercando di usare più di una serial port per comunicare con un modulo HC12 e HC05 Bluetooth.
Ho letto che è possibile ma non riesco:

#include <SoftwareSerial.h>

//-------------------------------HC12 radio 433Mhz
byte HC12RxdPin = 2;  // "RXD" Pin on HC12
byte HC12TxdPin = 3;  // "TXD" Pin on HC12
byte HC12SetPin = 7;  // "SET" Pin on HC12
SoftwareSerial Radio_HC12(HC12TxdPin, HC12RxdPin); // RX nano to HC-12 TX Pin, TX nano to HC-12 RX Pin

//-------------------------------HC05 radio BT
byte HC05RxPin = 9; // "RXD" Pin on HC05
byte HC05TxPin = 10; // "TXD" Pin on HC05
//const byte HC12SetPin = 6; // "SET" Pin on HC05
SoftwareSerial BT(HC05RxPin, HC05TxPin);
...

void setup()
{
  Serial.begin(9600);                       // Open serial port to computer
  
  //------------------------HC12
  Radio_HC12.begin(9600);// Open serial port to HC12
  pinMode(HC12SetPin, OUTPUT);
  digitalWrite(HC12SetPin, HIGH);
  delay(500);
  Serial.println("HC12 ready:");

//  ----------------------HC05 BT
//  BT.begin(9600); // Open serial port to HC05
...

ma mi serve anche l'ultima riga per mandare dati via Bbluetooth alla app sul telefono

ho trovato questo codice e il mio mi sembra formalmente uguale nella parte iniziale e nel setup

#include <SoftwareSerial.h>
SoftwareSerial serialOne(2, 3); // Software Serial ONE
SoftwareSerial serialTwo(8, 9); // Software Serial TWO
 
void setup() {
  Serial.begin(9600);
  while (!Serial) { // wait till Serial
  }
 
  serialOne.begin(9600);
  serialTwo.begin(9600);
}
 
void loop() {
  serialOne.listen(); // listening on Serial One
 
  Serial.println("Data from port one:");
  while (serialOne.available() > 0) {
    char inByte = serialOne.read();
    Serial.write(inByte);
  }
 
  Serial.println();
 
  serialTwo.listen(); // listening on Serial Two
 
  Serial.println("Data from port two:");
  while (serialTwo.available() > 0) {
    char inByte = serialTwo.read();
    Serial.write(inByte);
  }
 
  Serial.println();
}

grazie

Nel codice d'esempio che hai trovato ci sono le due begin (una per ciascuna seriale sofltware) nel tuo codice manca l'inizializzazione della seconda perché commentata.
Inoltre se usi la SOftwareSerial puoi restare in ascolto di una sola porta alla volta, infatti nel codice d'esempio c'è la chiamata al metodo listen della prima seriale software. Nel codice d'esempio usano un trucco, fanno finta di usare due seriali software in realtà inizializzano la seconda e poi non la usano, si mettono in ascolto sulla seriale due (setialTwo) e quello che viene letto viene scritto nella seriale hardware e quindi presumibilmente nel terminale dell'IDE.
Puoi provare a guardare anche l'AltSoftSerial che è più affidabile ma impone l'uso di pin fissi ma potrebbe aiutarti nell'uso di due seriali software

grazie
Qui sotto il programma che dovrebbe mandare i dati via BT
Forse a causa di collegamenti sbagliati, ma adesso non ho + comunicazione con la board su cui ho installato il nano e di conseguenza anche con i sensori
Ho provato un altra board e sembra funzionare, ma adesso sono stanco completo i collegamenti domani
Prima del danno i listening il programma stampava su serial monitor ma non come doveva
Il serial monitor continuava a scorrere invece di bloccarsi come da programma

#include <SPI.h>  // SD SPI 
#include <Wire.h> // RTC DS1307
#include <SoftwareSerial.h>

//-------------------------------HC12 radio
byte HC12RxdPin = 2;  // "RXD" Pin on HC12
byte HC12TxdPin = 3;  // "TXD" Pin on HC12
byte HC12SetPin = 7;  // "SET" Pin on HC12
SoftwareSerial Radio_HC12(HC12TxdPin, HC12RxdPin); // RX nano to HC-12 TX Pin, TX nano to HC-12 RX Pin

//-------------------------------HC05 radio BT
byte HC05RxPin = 9; // "RXD" Pin on HC05
byte HC05TxPin = 8; // "TXD" Pin on HC05
//byte HC12SetPin = 6; // "SET" Pin on HC05
SoftwareSerial BT(HC05RxPin, HC05TxPin);

//-------------------caratteri di comunicazione
char SLAVE_START;//carattere di start codice stazione SLAVE
char MASTER_START;//carattere di start stazione MASTER
char END;// carattere di end trasmissione
char rx;
byte const maxdim = 40;
char stringa[maxdim];

//-------------------orologio RTC DS1307
#include <TimeLib.h>
#include <DS1307RTC.h>

//---------------------scheda SD
#include <SD.h>
byte chipSDSelect;
File datafile;

char logfile; // logfile.txt per nome file di log

byte sensorNumTot;
char id_sensor[8];//vettore codice stazione aggiungere le stazioni se serve

char sending_SLAVE[4]; //vettore SLAVE(i)
char send_this[26]; //vettore per dati a BT

byte i, j, k, index, flag;//contatori

//----------------sezione delay con millis()
unsigned long previousMillis; // will store last time LED was updated
long interval; //intervallo di campionamento

void setup()
{
  Serial.begin(9600);                       // Open serial port to computer
  Wire.begin();

  delay(500);

  //--------------------------led allarms
  pinMode(5, OUTPUT);// led no card no file
  pinMode(6, OUTPUT);// led no RTC
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);

  //------------------------HC12
  Radio_HC12.begin(9600);// Open serial port to HC12
  pinMode(HC12SetPin, OUTPUT);
  digitalWrite(HC12SetPin, HIGH);
  delay(500);
  Serial.println("HC12 ready:");

  //  ----------------------HC05 BT
  //BT.begin(9600); // Open serial port to HC05

  //------------------------Scheda SD
  chipSDSelect = 4;
  pinMode(chipSDSelect, OUTPUT);
  Serial.println("Initializing SD card...");
  delay(500);
  if (!SD.begin(chipSDSelect))// see if the card is present and can be initialized:
  {
    Serial.println("Card failed, or not present");// don't do anything more
    digitalWrite(5, HIGH);
    while (1);
  }
  else
  {
    Serial.println("SD card initialized...");
  }

  logfile = "datalog.txt"; //nome file di log

  SLAVE_START = '<';  //carattere inizio trasmissione stazione SLAVE primo carattere spedito a RX
  MASTER_START = '#'; //carattere di start stazione MASTER primo carattere in arrivo da RX
  END = '>';          // carattere di end trasmissione

  //--------------------indicare numero di sensori
  sensorNumTot = 3; //max 5 sensors

  id_sensor[0] = SLAVE_START; //carattere inizio trasmissione stazione SLAVE
  id_sensor[1] = 'a'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[2] = 'b'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[3] = 'c'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[4] = 'd'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[5] = 'e'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[6] = END; //carattere fine trasmissione
  id_sensor[7] = '\0'; //carattere null

  Serial.println(id_sensor); //print a summary of sensor code

  // riceve e tratta i dati dalla radio

  char stringa[maxdim] = {0}; //il buffer di appoggio della trasmissione
  //Serial.println("stringa");  //scrive stringa sulla seriale per controllo
  //Serial.println(stringa);  //scrive stringa sulla seriale per controllo

  interval = 3000;    //= 15 sec millis intervallo delle interrogazioni delle stazioni

  previousMillis = 0;

  i = 0;
  k = 0;
  rx = 0;
  index = 0;
  flag = 1;

  delay(2000);
}

void loop()
{
  if (millis() - previousMillis >= interval)
  {
    i++;
    previousMillis = millis();   // save the last time

    //-------------------send to SLAVE(i)

    sending_SLAVE[0] = id_sensor[0]; //carattere start trasmissione
    sending_SLAVE[1] = id_sensor[i]; //codice stazione SLAVE(i)
    sending_SLAVE[2] = id_sensor[6]; //carattere end trasmissione

//    Radio_HC12.listen(); // listening on HC12
    Radio_HC12.print(sending_SLAVE);   //codice stazione SLAVE TU

    Serial.print("sending_SLAVE ");
    Serial.println(sending_SLAVE);

    if (i == sensorNumTot)
    {
      i = 0;
    }
  }

  //-----------------receive from SLAVE(i)

  while (Radio_HC12.available())
  {
    rx = Radio_HC12.read(); //sono sicuro che esista un carattere dal leggere, altrimenti non sarebbe stata chiamata

    if (rx == MASTER_START)//carattere inizio trasmissione da SLAVE(i)
    {
      stringa[0] = rx;//contiene il carattere start dalla SLAVE(i)
      index++;
    }

    if (index > 0) //index > 0 && index < maxdim
    {
      k = index++ - 1;
      stringa[k] = rx;
    }
  }

  //---------------------write SD

  if (rx == END)
  {
    Serial.println(stringa);  //scrive stringa sulla seriale per controllo

    index = 0;

    //---------------------open file

    datafile = SD.open("datalog.txt", FILE_WRITE);    //apre file

    //    Serial.print("sizeof(stringa)");
    //    Serial.println(sizeof(stringa));

    if (datafile)   //if the file is available, write to it:
    {
      //digitalWrite(5, LOW);   // turn the LED on
      //Serial.println("scrivo su file data ora e dati");//scrivo su file data ora e dati
      tmElements_t tm;

      //-----------------------orologio RTC DS1307
      if (RTC.read(tm))
      {
        digitalWrite(6, LOW);   // turn the LED OFF

        if (tm.Hour < 10)       //scrive ora
        {
          datafile.print('0');
        }
        datafile.print(tm.Hour);
        datafile.print(':');    //separatore

        if (tm.Minute < 10)     //scrive minuto
        {
          datafile.print('0');
        }
        datafile.print(tm.Minute);
        datafile.print(':');    //separatore

        if (tm.Second < 10)     //scrive secondo
        {
          datafile.print('0');
        }
        datafile.print(tm.Second);
        datafile.print(' ');    //separatore

        datafile.print(tm.Day);                   //scrive giorno
        datafile.print('/');                      //separatore
        datafile.print(tm.Month);                 //scrive mese
        datafile.print('/');                      //separatore
        datafile.print(tmYearToCalendar(tm.Year));//scrive anno

        datafile.print(',');//separatore

        //---------------scrive stringa dati da stazione TX
        datafile.println(stringa);//scrive stringa dati da stazione TX su file

        //-------------------------chiude file
        datafile.close();//chiude file

        //composizione vettore dati BT

        send_this[0] = stringa[1];
        send_this[1] = ',';
        send_this[2] = stringa[5];
        send_this[3] = stringa[6];
        send_this[4] = stringa[7];
        send_this[5] = stringa[8];
        send_this[6] = stringa[9];
        send_this[7] = stringa[10];
        send_this[8] = stringa[11];
        send_this[9] = ',';
        send_this[10] = stringa[15];
        send_this[11] = stringa[16];
        send_this[12] = stringa[17];
        send_this[13] = stringa[18];
        send_this[14] = stringa[19];
        send_this[15] = stringa[20];
        send_this[16] = stringa[21];
        send_this[17] = ',';
        send_this[18] = stringa[25];
        send_this[19] = stringa[26];
        send_this[20] = stringa[27];
        send_this[21] = stringa[28];
        send_this[22] = stringa[29];
        send_this[23] = stringa[30];
        send_this[24] = stringa[31];

        //stampa di controllo serial monitor
        Serial.println(send_this);

        //spedisce vettore a BT

//        BT.listen(); // listening on BT
        BT.println(send_this);

        //----------------svuoto vettore
        for ( j = 0; j < maxdim; j++)
        {
          stringa[j] = 0;
        }
      }
      else
      {
        digitalWrite(6, HIGH);   // turn the LED on (HIGH is the voltage level)

        if (RTC.chipPresent())
        {
          Serial.println("The DS1307 is stopped.  Please run the SetTime");
          Serial.println("example to initialize the time and begin running.");
          Serial.println();
          digitalWrite(6, HIGH);
          //while (1);
        }
        else
        {
          Serial.println("DS1307 read error!  Please check the circuitry");
          Serial.println();
          digitalWrite(6, HIGH);
          //while (1);
        }
      }
    }
    else
    {
      Serial.println("File not present");// don't do anything more
      digitalWrite(5, HIGH);   // turn the LED on
      //while (1);
    }
  }
}

In questi casi il suggerimento che do sempre è quello di creare un piccolo programma che fa l'essenziale ovvero prima si testa la lettura del dato e lo si invia al monitor seriale (Seriale hardware), poi si prova ad inviare dati fissi sull'altra seriale. Quando tutt'e due le cose funzionano allora si fa in modo di leggere i dati da una seriale software e li spedisce sull'altra seriale software. Quando questo mini programma funziona si implementa il resto.

ciao
seguo il suggerimento

#include <SoftwareSerial.h>

//-------------------------------HC12 radio
const byte HC12RxdPin = 2;  // "RXD" Pin on HC12
const byte HC12TxdPin = 3;  // "TXD" Pin on HC12
const byte HC12SetPin = 7;  // "SET" Pin on HC12
SoftwareSerial Radio_HC12(HC12TxdPin, HC12RxdPin); // RX nano to HC-12 TX Pin, TX nano to HC-12 RX Pin


//---------------------------------HC05 Bluetooth
SoftwareSerial BT(4, 5);


//-------------------caratteri di comunicazione
char SLAVE_START;//carattere di start codice stazione SLAVE
char MASTER_START;//carattere di start stazione MASTER
char END;// carattere di end trasmissione
char rx; //buffer ricezione

byte const maxdim = 44; //massima dimensuione del vettore dati dallo SLAVE(i)
char stringa[maxdim]; //stringa dati SLAVE(i)

byte const maxdim_BT = 26; //massima dimensuione del vettore dati dallo SLAVE(i)
char send_this[maxdim_BT]; //stringa dati SLAVE(i)

byte sensorNumTot;
char id_sensor[8];//vettore codice stazione aggiungere le stazioni se serve

char sending_SLAVE[4];

byte i, j, k, index;//contatori

//----------------sezione delay con millis()
unsigned long previousMillis;// will store last time LED was updated
long interval;

void setup()
{
  Serial.begin(9600);// Open serial port to computer

  BT.begin(9600);

  delay(500);

  //------------------------HC12
  Radio_HC12.begin(9600);// Open serial port to HC12
  pinMode(HC12SetPin, OUTPUT);
  digitalWrite(HC12SetPin, HIGH);
  delay(500);
  Serial.println("HC12 ready:");

  SLAVE_START = '<';  //carattere inizio trasmissione stazione SLAVE
  MASTER_START = '#'; //carattere di start stazione MASTER
  END = '>';          // carattere di end trasmissione

  sensorNumTot = 2; //max 5 sesors

  id_sensor[0] = SLAVE_START; //carattere inizio trasmissione stazione SLAVE
  id_sensor[1] = 'a'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[2] = 'b'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[3] = 'c'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[4] = 'd'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[5] = 'e'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[6] = END; //caratte fine trasmissione
  id_sensor[7] = '\0'; //carattere null

  Serial.println(id_sensor); //print a summary of SLAVE(i)

  interval = 2000;    //= 3 sec intervallo delle interrogazioni delle stazioni

  previousMillis = 0;

  i = 0;
  index = 0;

  delay(1000);
}

void loop()
{
  if (millis() - previousMillis >= interval)
  {
    i++;

    previousMillis = millis(); // save the last time

    //-------------------send to SLAVE(i)

    sending_SLAVE[0] = id_sensor[0]; //carattere start trasmissione
    sending_SLAVE[1] = id_sensor[i]; //codice stazione SLAVE(i)
    sending_SLAVE[2] = id_sensor[6]; //carattere end trasmissione

    Radio_HC12.print(sending_SLAVE);   //codice stazione SLAVE TU

    Serial.println(sending_SLAVE);

    if (i == sensorNumTot)
    {
      i = 0;
    }
  }

  //--------------------receive from SLAVE(i)

  while (Radio_HC12.available())
  {
    rx = Radio_HC12.read(); //sono sicuro che esista un carattere dal leggere, altrimenti non sarebbe stata chiamata

    if (rx == MASTER_START)//carattere inizio trasmissione da SLAVE(i)
    {
      //Serial.println("inizio RX from SLAVE(i)");

      stringa[0] = rx;//contiene il carattere start dalla SLAVE(i)
      index = 1;
    }

    if (index > 0) // && rx != END)
    {
      k = index++ - 1;
      stringa[k] = rx; //ricezione e compongo il vettore

      //Serial.print(rx);
      //Serial.print('\t');
      //Serial.println(stringa);
      //delay(500);
    }
  }

  if (rx == END) //ho rivcevuto il carattere END trasmissione inizio a scrivere su SD
  {
    Serial.println(stringa);    //scrive stringa sulla seriale per controllo

    send_this[0] = stringa[1];
    send_this[1] = ',';
    send_this[2] = stringa[5];
    send_this[3] = stringa[6];
    send_this[4] = stringa[7];
    send_this[5] = stringa[8];
    send_this[6] = stringa[9];
    send_this[7] = stringa[10];
    send_this[8] = stringa[11];
    send_this[9] = ',';
    send_this[10] = stringa[15];
    send_this[11] = stringa[16];
    send_this[12] = stringa[17];
    send_this[13] = stringa[18];
    send_this[14] = stringa[19];
    send_this[15] = stringa[20];
    send_this[16] = stringa[21];
    send_this[17] = ',';
    send_this[18] = stringa[25];
    send_this[19] = stringa[26];
    send_this[20] = stringa[27];
    send_this[21] = stringa[28];
    send_this[22] = stringa[29];
    send_this[23] = stringa[30];
    send_this[24] = stringa[31];

    BT.listen();
    BT.println(send_this);

    //------------------------------------svuoto stringa

    for ( j = 0; j < maxdim; j++)
    {
      stringa[j] = 0;
    }
  }
}

ciao
con questa riga

    BT.listen();

ho questo output

HC12 ready:
<abcde>
<a>
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
<b>
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>
a,  18.42,  68.04,  18.50
#a,C,  18.42,C,  68.04,%,  18.50,K,>

ciao
con questa riga commentata, sono riuscito a ricevere sulla app via BT
Non comprendo perchè ho una riga vuota dopo i primi output tra #a e a, #b e b

   // BT.listen();

ho questo output

HC12 ready:
<abcde>
<a>
#a,C,  18.53,C,  67.65,%,  18.50,K,>
a,  18.53,  67.65,  18.50
<b>
<a>
#a,C,  18.52,C,  67.65,%,  18.50,K,>

a,  18.52,  67.65,  18.50
<b>
<a>
#a,C,  18.52,C,  67.65,%,  18.75,K,>

a,  18.52,  67.65,  18.75
<b>
<a>
#a,C,  18.53,C,  67.65,%,  18.50,K,>

a,  18.53,  67.65,  18.50
<b>
<a>
#a,C,  18.52,C,  67.63,%,  18.50,K,>

a,  18.52,  67.63,  18.50
<b>

ciao
ho replicato nel programma principale ma se lascio

BT.begin(9600);// Open serial port to HC05

ho questo output

HC12 ready:
Initializing SD card...
SD card initialized...
<abcde>
sending_SLAVE <a>
sending_SLAVE <b>
sending_SLAVE <c>
sending_SLAVE <a>
sending_SLAVE <b>
sending_SLAVE <c>

se lo commento ho un output corretto, ma ovviamente niente trasmissione al telefono

HC12 ready:
Initializing SD card...
SD card initialized...
<abcde>
sending_SLAVE <a>
#a,C,  19.20,C,  65.41,%,  19.00,K,>
a,  19.20,  65.41,  19.00
sending_SLAVE <b>
#b,C,  18.29,C,  68.39,%,>
b,  18.29,  68.39,>
sending_SLAVE <c>
sending_SLAVE <a>
#a,C,  19.20,C,  65.40,%,  19.00,K,>
a,  19.20,  65.40,  19.00
sending_SLAVE <b>
#b,C,  18.29,C,  68.38,%,>
b,  18.29,  68.38,>
sending_SLAVE <c>

ciao
qui sotto il programma principale

/*
  sketch prova ricezione dari e trasmizzione via BT
  utilizzo di 2 serial
*/

#include <SoftwareSerial.h>

//-------------------------------HC12 radio
const byte HC12RxdPin = 2;  // "RXD" Pin on HC12
const byte HC12TxdPin = 3;  // "TXD" Pin on HC12
const byte HC12SetPin = 7;  // "SET" Pin on HC12
SoftwareSerial Radio_HC12(HC12TxdPin, HC12RxdPin); // RX nano to HC-12 TX Pin, TX nano to HC-12 RX Pin


//---------------------------------HC05 Bluetooth
SoftwareSerial BT(8, 9);// BT tx al pin 8 arduino(rx) BT rx al pin 9 arduino (tx)

//-------------------caratteri di comunicazione
char SLAVE_START; //carattere di start codice stazione SLAVE
char MASTER_START; //carattere di start stazione MASTER
char END; // carattere di end trasmissione
char rx; //buffer ricezione

int const maxdim = 44; //massima dimensione del vettore dati dallo SLAVE(i)
char stringa[maxdim]; //stringa dati SLAVE(i)

int const maxdim_BT = 26; //massima dimensuione del vettore dati dallo SLAVE(i)
char send_this[maxdim_BT]; //stringa dati SLAVE(i)

byte sensorNumTot;
char id_slave[8];//vettore codice stazione aggiungere le stazioni se serve

char sending_SLAVE[4]; //vettore reasmissione codice stazione SLAVE(i)

byte i, j, k, index;//contatori

//----------------sezione delay con millis()
unsigned long previousMillis;// will store last time LED was updated
long interval;

void setup()
{
  Serial.begin(9600);// Open serial port to computer
  Serial.println();

  BT.begin(9600);// Open serial port to HC05

  delay(500);

  //------------------------HC12
  Radio_HC12.begin(9600);// Open serial port to HC12
  pinMode(HC12SetPin, OUTPUT);
  digitalWrite(HC12SetPin, HIGH);
  delay(500);
  Serial.println("HC12 ready:");

  SLAVE_START = '<';  //carattere inizio trasmissione stazione SLAVE
  MASTER_START = '#'; //carattere di inizio trasmissione stazione MASTER
  END = '>';          // carattere di fine trasmissione

  sensorNumTot = 2; //max 5 sesors

  id_slave[0] = SLAVE_START; //carattere inizio trasmissione stazione SLAVE
  id_slave[1] = 'a'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[2] = 'b'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[3] = 'c'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[4] = 'd'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[5] = 'e'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[6] = END; //caratte fine trasmissione
  id_slave[7] = '\0'; //carattere null

  Serial.println(id_slave); //print a summary of SLAVE(i)

  interval = 2000;    //= 3 sec intervallo delle interrogazioni delle stazioni

  previousMillis = 0;

  i = 0;
  index = 0;

  delay(1000);
}

void loop()
{
  if (millis() - previousMillis >= interval)
  {
    i++;

    previousMillis = millis(); // save the last time

    //-------------------send to SLAVE(i)

    sending_SLAVE[0] = id_slave[0]; //carattere start trasmissione
    sending_SLAVE[1] = id_slave[i]; //codice stazione SLAVE(i)
    sending_SLAVE[2] = id_slave[6]; //carattere end trasmissione

    Radio_HC12.print(sending_SLAVE); //codice stazione SLAVE(i)

    Serial.println(sending_SLAVE);

    if (i == sensorNumTot)
    {
      i = 0;
    }
  }

  //--------------------receive from SLAVE(i)

  while (Radio_HC12.available())
  {
    rx = Radio_HC12.read(); //sono sicuro che esista un carattere dal leggere, altrimenti non sarebbe stata chiamata

    if (rx == MASTER_START)//carattere inizio trasmissione da SLAVE(i)
    {
      //Serial.println("inizio RX from SLAVE(i)");

      stringa[0] = rx;//contiene il carattere start dalla SLAVE(i)
      index = 1;
    }

    if (index > 0) // && rx != END)
    {
      k = index++ - 1;
      stringa[k] = rx; //ricezione e compongo il vettore

      //Serial.println(rx);
      //Serial.print('\t');
      //Serial.println(stringa);
      //delay(500);
    }
  }

  if (rx == END) //ho rivcevuto il carattere END trasmissione inizio a scrivere su SD
  {
    send_this[0] = stringa[1];
    send_this[1] = ',';
    send_this[2] = stringa[5];
    send_this[3] = stringa[6];
    send_this[4] = stringa[7];
    send_this[5] = stringa[8];
    send_this[6] = stringa[9];
    send_this[7] = stringa[10];
    send_this[8] = stringa[11];
    send_this[9] = ',';
    send_this[10] = stringa[15];
    send_this[11] = stringa[16];
    send_this[12] = stringa[17];
    send_this[13] = stringa[18];
    send_this[14] = stringa[19];
    send_this[15] = stringa[20];
    send_this[16] = stringa[21];
    send_this[17] = ',';
    send_this[18] = stringa[25];
    send_this[19] = stringa[26];
    send_this[20] = stringa[27];
    send_this[21] = stringa[28];
    send_this[22] = stringa[29];
    send_this[23] = stringa[30];
    send_this[24] = stringa[31];

    //Serial.println(stringa);    //scrive stringa sulla seriale per controllo
    //    Serial.println(sizeof(stringa));
    //Serial.println(send_this);    //scrive stringa sulla seriale per controllo
    //    Serial.println(sizeof(send_this));

    //    //------------------------------------svuoto stringa
    //
    //        for ( j = 0; j < maxdim; j++)
    //        {
    //          stringa[j] = '0';
    //        }

    BT.println(send_this);
  }
}

c è forse troppa roba attaccata ad un nano?

Non è un problema di troppa roba attaccata al nano ma il fatto che con la SoftwareSerial NON puoi usarne due in contemporanea o leggi e scrivi su una o leggi e scrivi sull'altra.
Quindi o provi a studiare l'uso della libreria AltSoftwareSerial di cui ho messo il link nel primo messaggio per verificare se è adattabile al tuo hardware e alle tue esigenze o devi ripensare il programma in modo che leggi i dati da un dispositivo li memorizzi, poi passi all'altro e li trasmetti. Ovviamente nel momento della trasmissione i dati del primo dispositivo non puoi leggerli e andranno persi.
Un ulteriore alternativa è quella di passare ad un hardware dotato di almeno due seriale hardware, una che usi per il debug e una che la usi per un dispositivo. L'altro dispositivo lo agganci tramite una seriale software, puoi guardare se questa fa al caso tuo

Ciao
Grazie
Ho capito che non posso usarle contemporaneamente
Ho anche guardato non studiato ancora il link dato
Quello che non capisco e' perche' questo programma funziona, cioe' riceve i dati, li stampa su serial monitor e poi manda i dati via BT alla app su telefono
Quello che ho in piu' nel programma principale sono la parte relativa al tempo e la scrittura su SD
Continuero' a studiare

/*
  sketch prova ricezione dari e trasmizzione via BT
  alla app su telefono
  utilizzo di 2 serial
*/

#include <SoftwareSerial.h>

//-------------------------------HC12 radio
const byte HC12RxdPin = 2;  // "RXD" Pin on HC12
const byte HC12TxdPin = 3;  // "TXD" Pin on HC12
const byte HC12SetPin = 7;  // "SET" Pin on HC12
SoftwareSerial Radio_HC12(HC12TxdPin, HC12RxdPin); // RX nano to HC-12 TX Pin, TX nano to HC-12 RX Pin


//---------------------------------HC05 Bluetooth
SoftwareSerial BT(8, 9);// BT tx on to pin 4 arduino(rx) BT rx on to pin 5 arduino (tx)

//-------------------caratteri di comunicazione
char SLAVE_START;//carattere di start codice stazione SLAVE
char MASTER_START;//carattere di start stazione MASTER
char END;// carattere di end trasmissione
char rx; //buffer ricezione

int const maxdim = 44; //massima dimensione del vettore dati dallo SLAVE(i)
char stringa[maxdim]; //stringa dati SLAVE(i)

int const maxdim_BT = 26; //massima dimensuione del vettore dati dallo SLAVE(i)
char send_this[maxdim_BT]; //stringa dati SLAVE(i)

byte sensorNumTot;
char id_slave[8];//vettore codice stazione aggiungere le stazioni se serve

char sending_SLAVE[4]; //vettore reasmissione codice stazione SLAVE(i)

byte i, j, k, index;//contatori

//----------------sezione delay con millis()
unsigned long previousMillis;// will store last time LED was updated
long interval;

void setup()
{
  Serial.begin(9600);// Open serial port to computer
  Serial.println();

  BT.begin(9600);// Open serial port to HC05

  delay(500);

  //------------------------HC12
  Radio_HC12.begin(9600);// Open serial port to HC12
  pinMode(HC12SetPin, OUTPUT);
  digitalWrite(HC12SetPin, HIGH);
  delay(500);
  Serial.println("HC12 ready:");

  SLAVE_START = '<';  //carattere inizio trasmissione stazione SLAVE
  MASTER_START = '#'; //carattere di start stazione MASTER
  END = '>';          // carattere di end trasmissione

  sensorNumTot = 2; //max 5 sesors

  id_slave[0] = SLAVE_START; //carattere inizio trasmissione stazione SLAVE
  id_slave[1] = 'a'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[2] = 'b'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[3] = 'c'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[4] = 'd'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[5] = 'e'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_slave[6] = END; //caratte fine trasmissione
  id_slave[7] = '\0'; //carattere null

  Serial.println(id_slave); //print a summary of SLAVE(i)

  interval = 2000;    //= 3 sec intervallo delle interrogazioni delle stazioni

  previousMillis = 0;

  i = 0;
  index = 0;

  delay(1000);
}

void loop()
{
  if (millis() - previousMillis >= interval)
  {
    i++;

    previousMillis = millis(); // save the last time

    //-------------------send to SLAVE(i)

    sending_SLAVE[0] = id_slave[0]; //carattere start trasmissione
    sending_SLAVE[1] = id_slave[i]; //codice stazione SLAVE(i)
    sending_SLAVE[2] = id_slave[6]; //carattere end trasmissione

    Radio_HC12.print(sending_SLAVE); //codice stazione SLAVE(i)

    Serial.println(sending_SLAVE);

    if (i == sensorNumTot)
    {
      i = 0;
    }
  }

  //--------------------receive from SLAVE(i)

  while (Radio_HC12.available())
  {
    rx = Radio_HC12.read(); //sono sicuro che esista un carattere dal leggere, altrimenti non sarebbe stata chiamata

    if (rx == MASTER_START)//carattere inizio trasmissione da SLAVE(i)
    {
      //Serial.println("inizio RX from SLAVE(i)");

      stringa[0] = rx;//contiene il carattere start dalla SLAVE(i)
      index = 1;
    }

    if (index > 0) 
    {
      k = index++ - 1;
      stringa[k] = rx; //ricezione e compongo il vettore
    }
  }

  if (rx == END) //ho rivcevuto il carattere END trasmissione inizio a scrivere su SD
  {

    Serial.println(stringa);    //scrive stringa sulla seriale per controllo

    send_this[0] = stringa[1];
    send_this[1] = ',';
    send_this[2] = stringa[5];
    send_this[3] = stringa[6];
    send_this[4] = stringa[7];
    send_this[5] = stringa[8];
    send_this[6] = stringa[9];
    send_this[7] = stringa[10];
    send_this[8] = stringa[11];
    send_this[9] = ',';
    send_this[10] = stringa[15];
    send_this[11] = stringa[16];
    send_this[12] = stringa[17];
    send_this[13] = stringa[18];
    send_this[14] = stringa[19];
    send_this[15] = stringa[20];
    send_this[16] = stringa[21];
    send_this[17] = ',';
    send_this[18] = stringa[25];
    send_this[19] = stringa[26];
    send_this[20] = stringa[27];
    send_this[21] = stringa[28];
    send_this[22] = stringa[29];
    send_this[23] = stringa[30];
    send_this[24] = stringa[31];


    BT.println(send_this);
  }
}

Probabile che funzioni perché inizializza la seriale software dell'HC12 dopo quella del BT che usa solo per inviare dati senza mai leggere se il BT ha inviato qualcosa.
Il fatto che scriva sulla seriale hardware è ininfluente in quanto essendo hardware è sempre disponibile (nei limite del buffer)

Ciao
Adesso funziona
Dovevo portare i begin all'inizio di tutto

void setup()
{
  Serial.begin(9600); // Open serial port to computer

  Wire.begin();

  BT.begin(9600);// Open serial port to HC05

  delay(500);
...