Does Mesh.off() lower power consumption on Xenon

xenon
Tags: #<Tag:0x00007fe21cf06a58>

#1

The reference docs have literally nothing on Mesh.off(), so I’m wondering if this is how I can lower power consumption without putting the device to sleep. Thanks for any feedback.


#2

You are correct that the Xenon datasheet has TBD for all these.


I can’t point you at exact threads/topics but there have been discussions and measurements of power consumption in sleep and with radio off. If low power is your objective then sleep with a low on duty cycle is necessary.


#3

Thanks. I saw those specs on the datasheet—in the API reference docs here there is no mentioning of this being used for power saving, which is why I was asked.

I have run into a new issue though when turning off the radio. It seems that having Mesh.off() and then later calling Mesh.connect() to publish data is not actually connecting to my gateway. The Xenon starts flickering green on Mesh.connect() then goes right back to Mesh.off().

Here’s an abbreviated form of my code on the Xenon:

#include "Particle.h"
SYSTEM_MODE(SEMI_AUTOMATIC);
volatile unsigned long pulses;
long counter;

void setup() {
  prevMillis = millis();
  pulses = 0;
  counter = 0;
  pinMode(A3, INPUT);
  attachInterrupt(A3, irq, RISING);
  Mesh.off(); // Start with Mesh Radio off
}

void loop() {
currentMillis = millis();
if (currentMillis - prevMillis >= 3000) { // 3 sec sample interval
  prevMillis = currentMillis;
  counter++;
  // pulse calculations go here...

  if (counter >= 600) { // 10 min publish interval
    // more pulse calculations go here...
    noInterrupts(); // disable interrupts for connect/publish
    Mesh.on();      // seems to work
    selectExternalMeshAntenna();
    Mesh.connect();
    waitUntil(Mesh.ready);  // doesn't seem to have any effect
    delay(3000);            // doesn't seem to have any effect
    Particle.publish("anemometer-test", data, PRIVATE); // not publishing

    interrupts();
    Mesh.off(); //turn off radio
  }
}

void irq() {
  pulses++;
}
void selectExternalMeshAntenna() {
  digitalWrite(ANTSW1, 0);
  digitalWrite(ANTSW2, 1);
}

I’ve tried variation of this using AUTOMATIC and SEMI_AUTOMATIC system modes with/without delays to no avail. The device isn’t connecting to the gateway, or if it is, not long enough to publish the data. Am I doing something wrong?

Edit: I realize I could use SYSTEM_THREAD and not enable/disable interrupts, but that is beside the point.


#4

It is actually breathing green now, not flickering (not sure if it was actually flickering last night). so I’ve added the following:

  Particle.connect();
  waitUntil(Particle.connected);

in place of:

  waitUntil(Mesh.ready);  // doesn't seem to have any effect
  delay(3000);            // doesn't seem to have any effect

It appears to be connecting and publishing now :+1: