Cannot connect device to hub using Sensor Tutorial

Hi,

I tried using the Sensor Tutorial for the following configuration:
Notecarrier-AF/Adafruit-Huzzah32/CPP-Arduino-Wiring

I am having a problem getting the device to connect to the project in Notehub.

The Quickstart project example worked okay.

I then created a new project with new productUID.

I created the example sketch using Arduino IDE 1.8.13.
I am using an MS8607 temp/humidity/pressure sensor.

I see the hub.set request during setup and the note.add requests while in the loop, but I never see the device connect on the hub. I am seeing the 100 note capacity error - but I assume that’s because I can’t connect.

Can you help me debug this.

Thanks,
Ralph

Here is the output on the Serial Console:

09:34:39.617 → rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
09:34:39.617 → configsip: 0, SPIWP:0xee
09:34:39.617 → clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
09:34:39.617 → mode:DIO, clock div:1
09:34:39.617 → load:0x3fff0030,len:1100
09:34:39.617 → ho 0 tail 12 room 4
09:34:39.617 → load:0x40078000,len:12308
09:34:39.617 → load:0x40080400,len:3076
09:34:39.617 → entry 0x400805ec
09:34:42.268 → MS8607 Connected…
09:34:42.548 → {“req”:“hub.set”,“product”:“com.hotmail.ralphjy:ms8607”,“mode”:“continuous”,“body”:{“agent”:“note-arduino”,“compiler”:“gcc 8.4.0”,“req_interface”:“i2c”,“cpu_name”:“esp32”}}
09:34:42.748 → {}
09:34:42.828 → Temperature = 22.27 *C
09:34:42.828 → Humidity = 39.16 %
09:34:42.828 → {“req”:“note.add”,“file”:“sensors.qo”,“sync”:true,“body”:{“temp”:22.27000045776367,“humidity”:39.16220092773438}}
09:34:42.988 → {“err”:“error adding note: can’t exceed 100 notes per file (currently 100; see note.template)”}
09:34:58.023 → Temperature = 22.26 *C
09:34:58.023 → Humidity = 39.04 %
09:34:58.023 → {“req”:“note.add”,“file”:“sensors.qo”,“sync”:true,“body”:{“temp”:22.26000022888184,“humidity”:39.04013061523438}}
09:34:58.183 → {“err”:“error adding note: can’t exceed 100 notes per file (currently 100; see note.template)”}

And the sketch

#include <Notecard.h>

#include <Wire.h>
#include <Adafruit_MS8607.h>
#include <Adafruit_Sensor.h>

#define serialDebug Serial
#define productUID "com.hotmail.ralphjy:ms8607"

Notecard notecard;
Adafruit_MS8607 ms8607;

void setup() {
  // put your setup code here, to run once:
  delay(2500);
  serialDebug.begin(115200);

  Wire.begin();
  notecard.begin();
  notecard.setDebugOutputStream(serialDebug);

// Try to initialize!
  if (!ms8607.begin()) {
    serialDebug.println("Failed to find MS8607 chip");
    while (1) { delay(10); }
  }
  serialDebug.println("MS8607 Connected...");

  J *req = notecard.newRequest("hub.set");
  JAddStringToObject(req, "product", productUID);
  JAddStringToObject(req, "mode", "continuous");
  notecard.sendRequest(req);

}

void loop() {
  // put your main code here, to run repeatedly:
  float tempC, tempF, humid, press;
  sensors_event_t temp, pressure, humidity;
  ms8607.getEvent(&pressure, &temp, &humidity);

  tempC = temp.temperature;
  tempF = tempC * 9 / 5 + 32;
  humid = humidity.relative_humidity;
  press = pressure.pressure;

  serialDebug.print("Temperature = ");
  serialDebug.print(tempC);
  serialDebug.println(" *C");
  serialDebug.print("Humidity = ");
  serialDebug.print(humid);
  serialDebug.println(" %");

  J *req = notecard.newRequest("note.add");
  if (req != NULL) {
      JAddStringToObject(req, "file", "sensors.qo");
      JAddBoolToObject(req, "sync", true);
      J *body = JCreateObject();
      if (body != NULL) {
          JAddNumberToObject(body, "temp", tempC);
          JAddNumberToObject(body, "humidity", humid);
          JAddItemToObject(req, "body", body);
      }
      notecard.sendRequest(req);
  }
  
  delay(15000);

}

Hi @ralphjy and welcome to the Blues Wireless community!

You’re seeing that error because you’ve maxed out the storage capacity of Notefiles on your Notecard. I would issue this request to reset your Notecard and then try running your Arduino sketch again:

{"req":"card.restore","delete":true}

If the sketch runs without error and you’re still not seeing data in Notehub, make sure your antenna is installed correctly on MAIN too, just to make sure the cellular signal is not a culprit.

Thanks,
Rob

Thanks.

How do you normally send requests to the Notecard when debugging? Do you connect using the carrier USB?

I think that my connections are okay and I couldn’t connect even before I had the error so I suspect that I’ll still be broken, but I’ll try resetting.

I guess I could send a sync and check status after that? I thought the Quickstart example also used the cellular connection, so wouldn’t that mean the antenna is okay?

Hi,

Not sure what did it but maybe it was resetting the Notecard and restarting the program.

Things are working now…

I did notice another message on the resync

> {"req":"hub.sync.status"}
{
 "status": "resetting all trackers because of session ID mismatch",
 "requested": 11
}

But not sure if that did anything to fix it.

Guess I should have tried hooking up directly to the Notecard earlier. I wasn’t sure if there were any power contention issues or whether connecting simultaneously from different sources would be an issue.

I’ll need to get used to this environment.

If I had wanted to send multiple sequential requests from the Feather - e.g. hub.sync and multiple hub.sync.status requests - what is the syntax for doing that?

I was getting redeclaration errors when I tried that.

Thanks,
Ralph

Hi @ralphjy,

I’m guessing the card.restore command is what resolved the issue. To clarify your earlier questions, yes the quickstart does use a cellular connection so if it was working before then the antenna shouldn’t be a problem!

If I had wanted to send multiple sequential requests from the Feather - e.g. hub.sync and multiple hub.sync.status requests - what is the syntax for doing that?

Notice this line in your sketch:

JAddBoolToObject(req, "sync", true);

This is optional, but tells the Notecard to initiate a sync with Notehub every time a Note is added (the alternative is to wait on a periodic basis as noted at the end of the sensor tutorial). I point that out because you don’t have to manually make a hub.sync request when using sync:true (otherwise you’d be telling the Notecard to sync twice, depending on when/where you use hub.sync).

I’d recommend looking at our GitHub repo of Arduino examples as well, especially if you want to see the response from a request like hub.sync.status.

Rob

J *req = notecard.newRequest(“note.add”);
How to capture error code to issue above command {“req”:“card.restore”,“delete”:true}
I don’t see any return type to capture the error code for this function J *req = notecard.newRequest(“note.add”);

@Srihari - please create new topics for new questions, thanks!

You should never use the card.restore or card.restart APIs as part of your product’s functionality. This can potentially lead to excessive wear on the flash memory.