Nano 33 BLE serial port

I am using the Nano33BLE to drive voice synthesiser via the onboard serial port. The port does not seem to work. The same code works OK on an UNO so I'm a little confused. Reading various postings on this subject suggests that I'm not alone. Can anybody shed any light on my problem? Please.

Hi @nikharrison. We’ll need more information in order to be able to help you.

Please post your full sketch.

If possible, you should always post code directly in the forum thread as text using code tags:

  • Do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code. This will make it easier for you to spot bugs and make it easier for us to read.
  • In the Arduino IDE or Arduino Web Editor, click on the window that contains your sketch code.
  • Press “Ctrl + A”. This will select all the text.
  • Press “Ctrl + C”. This will copy the selected text to the clipboard.
  • In a forum reply here, click the “Reply” button.
  • click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum’s code tags markup to your reply.
  • Press “Ctrl + V”. This will paste the sketch between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
  • Repeat the above process if your sketch has multiple tabs.

This will make it easy for anyone to look at it, which will increase the likelihood of you getting help.

If the sketch is longer than the 9000 characters maximum allowed by the forum, then it’s OK to add it as an attachment. After clicking the “Reply” button, you will see an “Attachments and other settings” link that will allow you to make the attachment.

When your code requires a library that’s not included with the Arduino IDE please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.


We also need to know exactly how the voice synthesizer is connected to the Nano 33 BLE.

/*
  Modified 17/04/20

  ***********************************************************

  This was done to test the Voice Synth only.



  ***********************************************************

*/


unsigned long start;
unsigned long timeout = 60000;
int done;



void setup() {

  Serial.begin(9600);         // Using Ch0 and Ch1

  char buf[64];

  speak("[x0][t6][v7][s6][m52][g2][h2][n1] Hello Harry.");  // set up tone/character etc of voice
  waitForSpeech();


  //  =====================
  //  Prototypes here


  void VoiceOut();
  void speak(char* msg);
  void waitForSpeech();

}


//  =====================
//  Main loop here


void loop() {


  VoiceOut();


}




//  =====================
//  Functions here



void speak(char* msg) {
  Serial.write(0xFD);
  Serial.write((byte)0x0);
  Serial.write(2 + strlen(msg));
  Serial.write(0x01);
  Serial.write((byte)0x0);
  Serial.write(msg);
}

//  ==================


void waitForSpeech() {
  start = millis();
  done = false;
  while ( ! done && (millis() - start) < timeout ) {
    while ( Serial.available() ) {
      if (Serial.read() == 0x4F ) {
        done = true;
        break;
      }
    }
  }
}

//  ==================

void VoiceOut() {

  speak("Hello World");
  waitForSpeech();
}




//  ==================

This is the reduced code that works OK on my UNO but not the Nano33BLE. I’m using an Apple laptop.
I have loaded a .pdf of the connections I’m using. Hope this all helps. Cheers.

Sound Controller.pdf (31.7 KB)

Unlike on the Uno, the pins on your Nano 33 BLE marked "RX0" and "TX1" are the Serial1 interface, not Serial. So you just need to change all the occurrences of Serial in your code to Serial1.

This is a nice improvement on the Nano 33 boards. On the Uno, pins 0 and 1 are also used for communication with your computer. This means that if you connect something to those pins on the Uno, it can make it so you can no longer upload to the Uno without removing that connection. It also means that any debug output you try to print to Serial Monitor can interfere with the communication with the device connected to those pins. On the Nano 33 BLE, the two are separate interfaces, so you can use the RX and TX pins as you like without causing any interference with communication with the computer.

Thank you for the quick reply. I’m now sorted. It also explains why I had to disconnect the synth board before I could download to the Uno. Thanks again.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per