Sensor of temperature stops to report data when board is power supplied.

My sketch is reading the sensor HTS221 of temperature/humidity and populating characteristics of the ble to be read externally.
Works properly when the nano 33 ble sense is connected with the Arduino IDE. I can see the values of temperature and humidity trough the serial monitor and trough the BLE Scanner 4.0 (IOS App)
To allow the sketch to run powered by a power supply (5V), I had to comment the line "while (!Serial);" disabling the dependences of a serial connection. Connected to a power supply, the sensor HTS221 of the nano 33 ble sense reports the temperature and humidity as 0 (zero). Another sensor (ds18b20) connected reporting external temperature continues reporting the temperature correctly.
When back connected to IDE everything works perfectly again.

Any idea how to solve this issue?

I had the same issue a while ago and left myself a note in my example project.

// Without Serial when using USB power bank HTS sensor seems to need some time for setup
delay( 10 );

The while(!Serial) will create enough delay because it waits for you to start the Serial Monitor. That is why it works while connected to a PC.

I believe I answered this question not so long ago and the issue was solved.

Thank you Klaus!

Working now.

Answered in the post: Using HTS221 with BLE seems to require LSM9DS1? - Nano 33 BLE Sense - Arduino Forum

Cheers!

Not sure about your exact issue, however ensure you read both temperature and humidity, as a current bug causes the HTS221.h library to hang on HTS.readTemperature(), without calling HTS.readHumidity()