The only way for me to select a Com Port in the IDE (Ver 2.3.6) is to put the Nano 33 BLE Rev2 into bootloader mode by double clicking the reset button. I am then able to select a Com Port in the IDE and initiate a download of my sketch. The problem is that then Arduino Bootloader gets uploaded to the Nano, and then disables the Com Port before the actual sketch can be downloaded. The Com port selection in the IDE becomes un-selectable until I put the Nano 33 BLE back into bootloader mode and the process repeats. I have read that this is probably a code issue, and have somewhat confirmed that by using the "Bare Minimum" sketch, which I was able to successfully download. The Com port was then available and I then tried to download my sketch as well as an example sketch "DFRobot_DF2301Q" (uart.ino). Even though the Nano 33 BLE was not in bootloader mode, the bootloader was uploaded again and again the Com port gets disabled and I am back at square 1. It seems to be the calls to the Serial port that are the issue. I hate to ask for someone to troubleshoot code, but all I am really doing is Serial.begin() and Serial.println(), which I've done in a few dozen sketches without issue. Thanks in advance.
Windows 11 OS.
Code below:
#include <DFRobot_DF2301Q.h>
#include <ArduinoBLE.h>
#include <Servo.h>
#define Led 8
/**
* @brief DFRobot_URM13_RTU constructor
* @param serial - serial ports for communication, supporting hard and soft serial ports
* @param rx - UART The pin for receiving data
* @param tx - UART The pin for transmitting data
*/
// Use hardware serial: Serial1
DFRobot_DF2301Q_UART asr(&Serial); /*hardSerial =*/
uint8_t actionid = 0;
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(Led, OUTPUT);
digitalWrite(Led, LOW);
//Initialize the DF2301Q Sensor
while(!(asr.begin())){
Serial.println("Communication with DF2301Q Failed, Please Check Connection");
delay(3000);
}
Serial.println("Voice Module Initialized");
/**
* @brief Reset the module
*/
//asr.resetModule();
/*
* @param setValue - Set value, refer to the set type above for the range
*/
asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_MUTE, 0);
asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_VOLUME, 6);
asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_WAKE_TIME, 30);
asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_ENTERWAKEUP, 0);
/**
* @brief Play the corresponding reply audio according to the command word ID
* @param CMDID - Command word ID
*/
asr.playByCMDID(23);
}
void loop() {
// put your main code here, to run repeatedly:
/*
* @brief Get the ID corresponding to the command word
* @return Return the obtained command word ID, returning 0 means no valid ID is obtained
*/
uint8_t CMDID = asr.getCMDID();
if(!(CMDID==0)){
Serial.print("Command is: ");
Serial.println(CMDID);
}
else{
Serial.println("Command ID not valid");
}
delay(2000);
}
I was expecting to be able to select Arduino Nano 33 BLE Rev2, but this is what showed up after using the board manager to install the Mbed OS Nano Boards.
I would think that you would want to use Serial1 which is on the pins labeled Rx and Tx call an asr.begin( ) at the correct baud rate unless the library takes care of that.
That is a fair observation, but it isn't the issue as that is what I originally had in the code. I took it out while troubleshooting. I put it back and the problem is still there. Added Serial1.begin9600); as well. The issue is I can't get a Com port unless in bootloader mode, and when in bootloader mode it downloads the bootloader which then disconnects the Com port. When I upload the Bare Minimum example code, the bootloader downloads, and then the Com port switches to another Com port. Then the Com port is available to download my sketch without entering bootloader mode, but the bootloader still gets downloaded and wipes out the Com Port so that my sketch can't be downloaded. If the sketch is being downloaded, I can't tell, because I don't have a serial port in which to monitor and can't add one as it is "grayed" out. By the way, the same thing happens when I use the DFRobot_2301Q uart.ino code from the examples. I assume that code is fine since it is in the example sketches.
I'm not quite clear about your issues, but the port switching and bootload mode (indicated by the oscillating led) entered either automatically with the 1200bps trigger or manually with the double press of the reset button is complex.
As I say in that thread, my Nano33 BLE has a mind of its own. Sometimes the upload port is managed successfully by the system and other times I need to put the board in programming mode and manually select the port. I don't know if it is a windows issue, or a board issue.
The only way for me to select a Com Port in the IDE (Ver 2.3.6) is to put the Nano 33 BLE Rev2 into bootloader mode by double clicking the reset button.
What OS is running the ide and is downloading the code. Linux, Windows, Mac? There have been issues reported where some version of Linux do not manage the 1200 bps trigger correctly.
I don't have your DFRobot device, but I could get your code load with the automatic 1200bps trigger from the ide, and it certainly did scramble the Nano and the ports shown and available. After load, The usb com port was not shown, but I could find a bootload port with the oscillating light. After several trys, I could get blink loaded again.
I think there is indeed some issue with the DFRobot code and the Nano33BLE. The library ReadMe in github does not indicate that the code was tested and is valid for that device.
Thanks. Super helpful. I did discover the issue. It is using UART, and in particular using DFRobot Voice Recognition over UART. Somehow that kills the serial port. I switched to i2c and everything works as expected. Still something the folks at Arduino need to look at. Yes, I went with the Nano 33 BLE for the bluetooth. Same code, but I hadn't incorporated it yet. I am sure that will be an adventure on it's own.