Possibly damaged two Nano 33 BLE's trying to connect to app

Hello Ladies and Gentlemen.

I'm working on my first app and I believe I have damaged 2 Nano 33 BLE's once I was finally able to connect to my cell phone.

The first time I was able to get the Nano to connect with the MIT Inventor app, It appeared to connect successfully, but that was the last time. I could not connect again. Then I tried connecting with with LightBlue software, which I have been using successfully all along and could not connect with that either.

I tried a new Nano 33 BLE with LightBlue first and was able to connect. I then tried the new Nano with the MIT software and successfully connected 1 time and now cant connect with either the MIT software or the LightBlue.

I tried doing a double press reset and re loading the sketch but no difference.

Any Ideas?

I'm very reluctant to mess with this any more until I figure this out.

The MIT Inventor project is still a work in progress that looks like these 4 pages:




The Arduino code:

[code]
const int RadPin = A0;      // Radiator Input Thermister
const int CndPin = A1;      // Condenser Input Thermister
const int AuxPin = A2;      // Auxilary Input Not used at this time
const int FanPin = 9;       // Set Fan pin
const long Period = 10000;  // Recheck period

long previousMillis = 0;    // last time the temperature levels were checked, in ms

                    /*
                      Temperatur Monitor

                      This example creates a Bluetooth® Low Energy peripheral with the standard Temperature service and
                      level characteristic. Pins A0, A1 and A2 are used to calculate the temperatures of 3 sensors.
                      The data is calculated by the time set in the constant Period.

                      The circuit:
                      - Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT,
                        Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board.

                      You can use a generic Bluetooth® Low Energy central app, like LightBlue (iOS and Android) or
                      nRF Connect (Android), to interact with the services and characteristics
                      created in this sketch.

                      This example code is in the public domain.
                    */

#include <ArduinoBLE.h>

// Define the Temperature Service
BLEService TempService("53436b3f-5f91-474b-963e-8b09b170c670");        //*** BLEService Class Any Hex Name 128-bit UUID in String format *********************************************************

// Define Temperature Level Characteristics as BLEUnsignedIntCharacteristic, BLEUnsignedCharCharacteristic will not work.

// Note define Characteristics and  
BLEUnsignedIntCharacteristic RadLevelChar("694d181e-4421-47f3-9653-c4d6bb295a07",  // standard 128-bit characteristic UUID *******************************
    BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes
BLEUnsignedIntCharacteristic CndLevelChar("0407dd37-ae29-4ec7-ab40-a83898d610df",  // standard 128-bit characteristic UUID *******************************
    BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes
BLEUnsignedIntCharacteristic AuxLevelChar("ad43db8f-e3e6-4025-b745-43f2100f27e1",  // standard 128-bit characteristic UUID *******************************
    BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes

void setup() {
  Serial.begin(9600);    // initialize serial communication
  //while (!Serial);

  pinMode(LED_BUILTIN, OUTPUT); // initialize the built-in LED pin to indicate when a central is connected

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting BLE failed!");

    while (1);
  }

  /* Set a local name for the Bluetooth® Low Energy device
     This name will appear in advertising packets
     and can be used by remote devices to identify this Bluetooth® Low Energy device
     The name can be changed but maybe be truncated based on space left in advertisement packet
  */

  BLE.setLocalName("Testing 123"); //******************************************************************************

    BLE.setAdvertisedService(TempService); // add the service UUID
    TempService.addCharacteristic(RadLevelChar); // add the radiator level characteristic
    TempService.addCharacteristic(CndLevelChar); // add the condenser level characteristic
    TempService.addCharacteristic(AuxLevelChar); // add the aux level characteristic
    BLE.addService(TempService);  // Add the Temperature service
    RadLevelChar.writeValue(0);   // set initial value for this characteristic
    CndLevelChar.writeValue(0);   // set initial value for this characteristic
    AuxLevelChar.writeValue(0);   // set initial value for this characteristic

  // Start advertising Bluetooth® Low Energy.  It will start continuously transmitting Bluetooth® Low Energy
  // advertising packets and will be visible to remote Bluetooth® Low Energy central devices
  // until it receives a new connection

  BLE.advertise();  // start advertising

  //Serial.println("Bluetooth® device active, waiting for connections...");
}


  void loop() {
  // wait for a Bluetooth® Low Energy central
  BLEDevice central = BLE.central();

  // if a central is connected to the peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's BT address:
    Serial.println(central.address());
    // turn on the LED to indicate the connection:
    digitalWrite(LED_BUILTIN, HIGH);

    // check the temperature levels every Period (ms)
    // while the central is connected:
    while (central.connected()) {
      long currentMillis = millis();
      // if Period ms have passed, check the temperature levels:
      if (currentMillis - previousMillis >= Period) {
        previousMillis = currentMillis;
        updateTemperatures();
      }
    }
    // when the central disconnects, turn off the LED:
    digitalWrite(LED_BUILTIN, LOW);
    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
  }
  }

  void updateTemperatures() {
  // Read the current voltage level on each analog input pin.
  //   This is used here to simulate the charge level of temperaturs.

  int Rad = analogRead(RadPin);
  int Cnd = analogRead(CndPin);
  int Aux = analogRead(AuxPin);
/*
  int RadLevel = map(Rad, 0, 1023, 0, 100);
  int CndLevel = map(Cnd, 0, 1023, 0, 100);
  int AuxLevel = map(Aux, 0, 1023, 0, 100);
 */  
  
  int RadLevel = Rad;
  int CndLevel = Cnd;
  int AuxLevel = Aux;
  
  
  Serial.print("Rad Level % is now: "); Serial.println(RadLevel);
  Serial.print("Cnd Level % is now: "); Serial.println(CndLevel);
  Serial.print("Aux Level % is now: "); Serial.println(AuxLevel);

  RadLevelChar.writeValue(RadLevel);            // update the Radiator level characteristics
  CndLevelChar.writeValue(CndLevel);            // update the Condenser level characteristics
  AuxLevelChar.writeValue(AuxLevel);            // update the Aux level characteristics
  }
[/code]

Hi. :stuck_out_tongue_winking_eye:
When you get this working, you'll find there's lots of effective ways to display the parameters.

Hello John

It's very unusual for software to harm an Arduino, they are quite tough. Just ensure you have the correct power supply and keep the board cool (desktop fan works great).

Thanks for the reply Chris.

I agree, I have no idea how this could happen. I'm also not sure if there really is any physical damage to the Arduino. Do you know if there is a way to do a factory reset of the board. Something beyond what the double reset boot loader does?

As far as power supply, I am currently testing using the USB port on my computer.

As far as cooling, I see no need for it the whole board only draws 10ma with the BLE connected to LightBlue and operation the automotive radiator cooling fan it was designed for.

Video of it trying to connect with LightBlue

Thank
John

:grin: - that sound in the background - a single engine aircraft?

... I though that was it's 'standby' value - you would be surprised how hot an Arduino can get. I'm not sure that USB power from your PC is enough, I found that not all PC USB ports are the same - that might be contributing to the issue. Certainly test the port or simply use a battery/power adaptor.

Have you seen this?

1 Like

I don't know about the specs, but that is the current I read with an Ameter at the Vin pin. In my case the Arduino powers nothing. It just reads 3 temp sensors and applies a PWM signal to the fan to control fan speed. Note the PWM signal is not fan power it is just a control signal. The fan itself is actually 600W.

So I am trying to get the BLE to display the 3 temp signals to the Android.

I haven't seen that article but it doesn't seem to be the symptoms I'm having. Plus my Arduino still works for everything else.

I have seen other articles that discuss re-flashing the boot loader, but I'm not sure if that is my problem since I have no issues loading sketches.

Seems as though it is the BLE module, given that the Arduino still works for everything else.

Just to be sure - Android Device - BLE is switched on, Fine Location is on.

What is the make and model of your Android Device?

You only need one integer characteristic Uuid really - can't see the data receive Blocks.

Note, you cannot open another Screen once Bluetooth is connected - that will break the connection! Think of each Screen as being a totally separate, individual entity, as that is what they are - each occupying their own memory allocation.

Either move the Temperature Display components etc to the Bluetooth enabled Screen, or change the design to use virtual screens.

When we define virtual screens, we use one 'real' App Inventor Screen (most often Screen1). Screen-sized Vertical Arrangements on it are displayed/hidden as required - they are the Virtual Screens. This is generally a better approach for multi-screen Apps, they share data without having to "pass" it between screens and it also reduces code duplication, making the App more efficient and the code easier to follow if you have to return to it at a later date.
So, instead of separate "houses", virtual screens are "rooms" of the same "house".

Edit: is Serial comms working (Android Terminal) even though BLE isn't?

The Arduino is a Nano 33 BLE.

I don't know how to tell if BLE is switched on. I know regular Blue Tooth is on.

Both LightBlue and MIT AI2 Companion both have access to my location.

Android is a Moto Z4, Android version 10.

I don't expect that code to be anywhere close its actually my first App. So that is something I will need to figure out.

Good to know on the displays. It would be difficult to get the connection list and my data on one screen so that I could actually read it while driving so I will need to research the virtual screens.

The above two issues may explain why the MIT app doesn't work but it doesn't explain why the LightBlue app doesn't work. Something happened to these boards after connecting the first time with the MIT app.

Not sure what the Android Terminal is. The serial comms work on my computer (Serial Monitor). If I un-comment the two lines below I get to the point where it displays on the serial monitor "Bluetooth® device active, waiting for connections...". But then it never connects and no more statements in the main loop execute.

 //while (!Serial);
 //Serial.println("Bluetooth® device active, waiting for connections...");

The serial ports do act kind of messed up though. It seems that after I upload the software I need to change the serial port to use the serial monitor. I don't recall that being the case previously.

That sound in the background is my wife power washing the house. I have also tried this connected to a 30A power supply connected at 13.8V to the Vin pin, The Nano 33 BLE will accept up to 20V. Same results.

That has me thinking. I'm wondering if the break in connection from the screen change was so abrupt that it may have caused damage to the BLE. The connection must have been made successfully otherwise the screen would not have changed. I will be experimenting with virtual screens but for the moment I have no way to test. For now, I will just try to get the screens to swap with a button.

Making a little more headway with this using virtual screens. Initial screen looks like this:

Once Connected:

I ordered 5 HM-10 BLE boards that I can play around with using my Uno. And I also ordered a new Nano 33 BLE for once I get this figured out.

...they renamed it but a lot of example code of course refers to the old name.

I think it may have corrupted the chip's "inner OS" (Nano 33 BLE has a different CPU to the Uno for example) - so the reset discussed on the Arduino Forum that I linked to is worth trying.

That is strange. When testing the BLE connection with your App, comment-out the Serial lines in the Sketch.

Does that consist of two labels per value? One for the title, one for the value itself?

What do your Blocks look like? Having 3 characteristics of the same type (int) smells like trouble.

Snippet: Using only one integer characteristic:

Also, ensure you are using the latest official MIT BLE Extension:
https://www.professorcad.co.uk/appinventortips#TipsBluetooth