Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect Nano 33 IoT to Arduino Science Journal App #3

Open
ax-sc opened this issue Oct 3, 2020 · 0 comments
Open

Unable to connect Nano 33 IoT to Arduino Science Journal App #3

ax-sc opened this issue Oct 3, 2020 · 0 comments
Labels
type: imperfection Perceived defect in any part of project

Comments

@ax-sc
Copy link

ax-sc commented Oct 3, 2020

The official reference (https://www.arduino.cc/reference/en/libraries/arduino_sciencejournal/) states that this library is compatible with the Arduino Nano 33 IoT - Board. As there is no example code provided, I tried to derivate it from the given firmware for the Arduino Nano 33 BLE Sense and came up with this "minimal" code, which I was able to compile and upload to a Nano IoT.

#include <ArduinoBLE.h>

const int VERSION = 0x00000001;

#define UUID(val) ("cfccb0fd-" val "-4da3-afaf-a4305a6b64b3")

#define DEBUG 1

BLEService service (UUID("0000"));
BLEUnsignedIntCharacteristic versionCharacteristic (UUID("0001"), BLERead);
BLEFloatCharacteristic testCharacteristic (UUID("0002"), BLENotify);

String name;
unsigned long lastNotify = 0;

void printSerialMsg(const char * msg) {
  #ifdef DEBUG
  if (Serial) {
    Serial.println(msg);
  }
  #endif
}

void updateSubscribedCharacteristics() {
    if (testCharacteristic.subscribed()) {
    float test = 3.141;
    testCharacteristic.writeValue(test);
  }
}

void setup() {
  #ifdef DEBUG
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Started");
  #endif

  delay(5000);

  if (!BLE.begin()) {
    printSerialMsg("Failed to initialized BLE!");
  }

  String address = BLE.address();
  #ifdef DEBUG
  if (Serial) {
    Serial.print("address = ");
    Serial.println(address);
  }
  #endif
  address.toUpperCase();

  name = "Nano IoT - ";
  name += address[address.length() - 5];
  name += address[address.length() - 4];
  name += address[address.length() - 2];
  name += address[address.length() - 1];

  #ifdef DEBUG
  if (Serial) {
    Serial.print("name = ");
    Serial.println(name);
  }
  #endif

  BLE.setLocalName(name.c_str());
  BLE.setDeviceName(name.c_str());
  BLE.setAdvertisedService(service);

  service.addCharacteristic(versionCharacteristic);
  service.addCharacteristic(testCharacteristic);

  versionCharacteristic.setValue(VERSION);

  BLE.addService(service);
  BLE.advertise();

  digitalWrite(LED_BUILTIN, HIGH);
}

void loop() {
  while (BLE.connected()) {
    unsigned long now = millis();
    if (abs((long) now - (long) lastNotify) >= 100) {
      updateSubscribedCharacteristics();
      lastNotify = now;
    }
  }
}

After compiling and uploading this, I was able to see the advertised services in a BLE scanner (used LightBlue) and could see the Nano IoT as a connected device in my settings.

IMG_2136
IMG_2137

As a consequence, i would have expected the Nano IoT and the testCharacteristic to be listed as sensor in the App, but neither the device nor the characteristic is shown. I have been using the latest version of this library and of the ArduinoBLE library as well. The device used is an iPhone 5s and the latest version of the Arduino Science Journal App is installed.

I was not able to find any documentation on how a service has to be structured such that the App accepts it as a sensor. As you are providing this library for connecting Arduino devices to the App, i´m placing this issue here but if you think it would be more appropiate in the App-repository, feel free to transfer it.

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Mar 2, 2023
@per1234 per1234 changed the title unable to connect device to Arduino Science Journal App Unable to connect Nano 33 IoT to Arduino Science Journal App Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants