How to use Nano 33 BLE without desktop?

I am using Arduino Nano 33 BLE.
I connected the board to my laptop and uploaded a sketch for ble.
Using nRF Connect app, the arduino board can be scanned and connected.

But the problem is the next. After I disconnected the board from my laptop and used other power such as phone charger, my arduino board can't be scanned by nRF Connect although the led turned on, so power is supplied well.

I want to make a portable product with BLE, so this is the problem unless there is a really small computer.
What should I do to solve this problem?

For reference, here's my ble code.

#include <ArduinoBLE.h>

int x, y, z;

BLEService customService("180C");


BLEIntCharacteristic ble_x("6eea5885-ed94-4731-b81a-00eb60d93b50", BLERead | BLENotify);
BLEIntCharacteristic ble_y("03d0cffe-bd7f-4d17-ba39-86e57adb5ddd", BLERead | BLENotify);
BLEIntCharacteristic ble_z("c8411116-479e-4bc7-a216-1e3c22d32809", BLERead | BLENotify);

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);
  while(!Serial){;}
  if (!BLE.begin()){
    Serial.println("BLE failed to Initiate");
    delay(500);
    while (1) {;}
 
  }


  BLE.setLocalName("Arduino Environment Joystick");
  BLE.setAdvertisedService(customService);

  customService.addCharacteristic(ble_x);
  customService.addCharacteristic(ble_y);
  customService.addCharacteristic(ble_z);

  BLE.addService(customService);

  BLE.advertise();
  Serial.println("Bluetooth devic is now active, waiting for connections...");

}



void loop() {
  // put your main code here, to run repeatedly:

  BLEDevice central = BLE.central();
  if (central)
  {
    Serial.print("Connected to central : ");
    Serial.println(central.address());
    while(central.connected())
    {
      delay(200);

      x=analogRead(A0);
      y=analogRead(A1);
      z=digitalRead(5);

      ble_x.writeValue(x);
      ble_y.writeValue(y);
      ble_z.writeValue(z);


      Serial.println("Reading Sensors");
      Serial.println("x : "+ String(x));
      Serial.println("y : "+String(y));
      Serial.println("z : "+String(z));
      delay(500);
    }
  }

  Serial.print("Disconnected from central: "+central.address());

}

If it works while connected to your laptop, there can hardly be anything wrong with the code. If it then fails when you change the power supply, I guess you can safely conclude there is something wrong with the new one. It may be simply inadequate.

Do you mean 'inadequate' voltage or inappropriate connection way?

I think the voltage is enough because the led of the board turns on.

To supply power by a phone charger, I just connected a USB cable of the charger to the USB connector of the board. Will be this connection way problematic?

Actually, in order to run the BLE correctly with my laptop, I need to select a proper port. With wrong port or unselected port in Arduino IDE, BLE also doesn't work with my laptop. But after selecting proper port, and while connecting, it's ok to select another port in Arduino IDE, still BLE works and the board is scannable.

It's possible that waiting for the connection to the USB host is keeping your sketch from running. Try changing to:

  Serial.begin(9600);
  while(!Serial && mllis() < 5000) {;}

That will abandon the wait after five seconds.

1 Like

Can you post a schematic showing all connections and power supplies. Do not waste your time with a frizzy, they are useless. Post links to technical information on the hardware devices.

This works, thanks!

Also thanks for everyone who advised.

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