Nano 33 IoT Bluetooth

Hi, I was trying to understand something more about the nano 33, I read some posts related to my question but I couldn't get a clear answer.
The question is, once connected to an app can I send commands to another board via serial? I was able to use the nano 33 to perform actions via bluetooth but I would need to manage a board that has more pins.
For example app sends '1' to nano33 which sends '1' to arduino mega which performs an action.
Would this be possible? if yes could you show me the sample sketches for both boards?

Thanks for your attention.

A serial link between the Nano 33 and the Mega would be the easiest way
Examples ?

Nano code


Mega code

if (Serial1.available())
  char inChar =;
  if (inChar == '1')
      //do something

thanks for the answer, but can I create a serial link like I did with a normal nano? (softwareSerial?) I saw that you can use rx and tx of the nano33 (Serial1) but if I do, the bluetooth no longer works

ok i just saw that it is not necessary to create a software serial (also you cannot)
because you can use different pins as serial hardware, I should try so to not occupy the bluetooth communication right?

Keep the Bluetooth serial connection and the USB serial connection apart just as you would if you were using SoftwareSerial

Strange, I can use BLE and Serial1 at the same time on the Nano 33 IoT. Can you share your code?

Can you confirm you mean Nano 33 IoT? Your post subject says Nano 33 IoT but this is the Nano 33 BLE sub forum.

1 Like

Hi Klaus, let me tell you that I really appreciate your interventions, in the past I have read some posts that have saved me from situations that I really couldn't solve! thank you! some of my friends call me genius .. but I think you are a genius! back to us, it is IoT ... this board has complicated my work a bit, my sketch is a mess, but I managed to do everything, I would use the IoT as main board, which receives commands via bluetooth and them sends to a mega via serial (hardware serial on IoT and SoftwareSerial on mega) and the mega performs many actions. If I tried to do it using Serial1 instead on Hardware Serial, the BLE was no longer detected by my smartphone ... if you tell me so, I will try to rewrite the sketch in that way and maybe I will try to use a DFPlayer on Serial1 to see if the same thing .. I don't need it but I want the truth :rofl::rofl:

BLE_Commands_For_Nano_33.ino (3.7 KB)

Hi Klaus, in this sketch (which if I'm not mistaken I took it from you) I try to test some bluetooth commands, when "value" is read, in this case '1' the BLE LED turns off, so it works. The problem is that if I try to add another command for example:
else if (command = 2) {something}
this does not happen, even if in the serial monitor there is a difference between the reading of the different values ​​.. if I send 1 1 is read, if I send 2 2 is read, yet it seems that there is a conflict between the different actions that should be performed.
can you show me how you would add commands to the sketch i sent by adding a second command? and could you explain to me why it doesn't work this way?

thank you!

== for comparison
The way you have it written, with the single = for assignment, the conditional will always be true and turn the LED on.

//if (command = 1) {
   if (command == 1) {
    digitalWrite( BLE_LED_PIN, LOW );
    Serial.print( " ON " );
1 Like

This is a very common issue and therefore most modern compilers will create a warning. Make sure you enable them in

File -> Preferences -> Compiler Warnings: ALL

When you compile your code you should get something like this:

... .ino:116:15: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   if (command = 1) {
1 Like

Do you know what the beautiful thing is? that I have already worked with a very similar project with classic bluetooth, I had also seen the difference of the double = but I was so taken by the infamous Characteristics that I did not think about the simplest thing. you never stop learning by working with Aduino ... thanks to all guys.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.