Device isn't sending notes when powered via battery

Hello! Hopefully this is my last question :slight_smile:

I have a SparkFun Blues Wireless MicroMod Starter Kit. I am trying to power it with a 6V lead acid battery. I think I am broadly succeeding, but am quite noob at all this, and have encountered a snag.

I connect the 6V battery to a voltage regulator using 18AWG wire and then run that to the VBAT/GND pins of my board. I’m feeding the board about 5V. The regulator can do 2A normal / 3A max. This seems to power the board well. All the LEDs turn on and are brightly lit, multimeter readings look fine, etc.

The code I run on my MCU does the following:

  • First, sets the notecard into sync mode: none as part of setup.
  • Then, for the last step of setup, it changes the sync mode to continuous with inbound/outbound/duration of 60 and begins looping waiting for connection.
  • Once it has a session open, it pulls inbound data and polls until that has succeeded.
  • It then completes a little more initialization with the inbound data, such as setting its time. It then writes a note to log some of the stats on the device and syncs outbound.
  • After outbound sync completes, it sets mode back to off.

All this works great when I power my device via USBC.

When I power my device via battery, I see the modem turn on. The green LED on it flashes. I see a connection made with Blues Notehub… and then nothing. I never get any outbound data. The modem seems to stay in continuous mode as I see the green LED blinking until I kill power.

If I connect my USB (to try and get access to serial monitor) then the MCU resets and suddenly works again.

I’m going to try and add some persistent logging to my device to triage the issue better, or try to find a way to do serial monitoring without providing power, but I wanted to check and see if there were any obvious reasons why this would be occurring?

Thanks

Hi @Meo,

First, and while it’s probably not related, you might be able to simplify your steps. If your Notecard doesn’t need to be in continuous mode, you could set it to minimum or periodic mode and leave it at that. If you want to sync any outbound data as soon as the Note is created, simply add a "sync":true argument to your note.add request. I always think it’s best to let the Notecard handle connectivity on its own and not try to force it to behave a certain way (unless of course you do need continuous mode for web transactions or maybe you need to receive inbound Notes immediately - in which case you could also add the "sync":true arg to your hub.set request). But I digress!

Second, I highly recommend using an FTDI debug cable to properly debug a Notecard without powering it. We have a full guide here.

Thanks,
Rob

Thanks for the response, Rob.

Yeah, I originally had been running on minimal. I was syncing data from my server to Notehub as Environment Variables and then pulling those onto the device.

I was unhappy with having duplicated the source of truth for my information. I wanted my server’s database to be the source of truth for information. My initial approach was pushing me to use transactional wrappers on my server in an attempt to not write to Notehub if writing to my database failed. I realized things would be less error prone if I could consolidate around my database. So, I inverted my approach and started having the device pull from my server rather than pushing my data to Notehub.

So, I am now using web transactions to issue a GET request to my server which pushed me into using continuous mode. Still, this is a device running remotely off a battery, so I’m careful to not leave the device running in continuous all the time.

Thanks for the FTDI link. I’ll look into that. I was thinking about cutting a USB-C data/power cable and cutting the power line, but that’s probably not as sane of a solution as what you’re proposing :slight_smile:

Anyway, just to confirm, if my device is able to connect to Notehub and send session/health check then it should be able to use web requests, too, right? Does the web request demand a good amount more power from the device?

I AM THE STUPIDEST PERSON TO HAVE EVER EXISTED. EVER.

I just figured it out after so many hours of debugging. There was a legitimate power issue earlier on and so I had tunnel vision thinking about modem power usage.

My setup code starts with:

void setup()
{
  // Short delay on setup to allow Serial Monitor logging to initialize.
  // Without this, might miss `println` calls.
  delay(2500);

  Serial.begin(115200);
  while (!Serial)
    ; // wait for serial port to connect

  Serial.println("Beginning setup");

so obviously it works whenever I connect a USB because it breaks out of the while loop instantly… and then it hangs whenever I try powering it via battery.

Everything works now. No issues. Now just need a cure for the overwhelming shame hahahaha.

2 Likes

Glad you found the issue! I’ve done the same thing before so you’re in good company :slight_smile: