Custom PMIC settings for Monitor One

I am not sure if I am doing something wrong nor right with respect to Power Manger settings. I am trying to increase the min. power source voltage so my 12 v (350ma) solar panel will charge the battery and not go into the low voltage state (flashing red on the chrg light). So my questions that I could figure out on my own are.

  1. Does the "SystemPowerConfiguration conf" go into void setup () or void start up ()?
  2. Do you need to call "PMIC power(true);" in void loop ()?
  3. Is there are way to verify the setting with a location call back. (I tried putting PMIC power(true) in the call back and it unit stopped working)?

I am also using Vin on the main board and not one of the expansion boards.

Thank you in advance.

Here is the code below.

#include "Particle.h"
#include "Arduino.h"
#include "edge.h"
#include "SparkFun_ADS1015_Arduino_Library.h"




SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
    { "app.gps.nmea", LOG_LEVEL_INFO },
    { "app.gps.ubx",  LOG_LEVEL_INFO },
    { "", LOG_LEVEL_INFO },
    { "net.ppp.client", LOG_LEVEL_INFO },
char buf[256];
ADS1015 adcSensor;
void myLocationGenerationCallback(JSONWriter &writer, LocationPoint &point, const void *context);

void setup()
	SystemPowerConfiguration conf;

	int res = System.setPowerConfiguration(conf);"setPowerConfiguration=%d", res);


  if (adcSensor.begin() == true)
        Log.error("ADC Successfully Started");
        Particle.publish("Log", "ADC Successfully Started");
   		Log.error("ADC Failed");
  		Particle.publish("Log", "Failed");


void loop()

        //PMIC power(true);
       //"Current PMIC settings:");
        //"VIN Vmin: %u", power.getInputVoltageLimit());
        //"VIN Imax: %u", power.getInputCurrentLimit());
        //"Ichg: %u", power.getChargeCurrentValue());
       //"Iterm: %u", power.getChargeVoltageValue());
//delay (11000);

// Testing the ADC module
	//short adc0, adc1, adc2, adc3;
	//adc0 = adcSensor.getSingleEnded(0);
	//adc1 = adcSensor.getSingleEnded(1);
	//adc2 = adcSensor.getSingleEnded(2);
	//adc3 = adcSensor.getSingleEnded(3);
	//Serial.print("AIN0: "); Serial.print(adc0);
	//Serial.print("AIN1: "); Serial.print(adc1);
	//Serial.print("AIN2: "); Serial.print(adc2);
	//Serial.print("AIN3: "); Serial.print(adc3);
	//delay (2000);

void myLocationGenerationCallback(JSONWriter &writer, LocationPoint &point, const void *context)
int PB1 = adcSensor.getSingleEnded(0);
int PB2 = adcSensor.getSingleEnded(1);
int PB3 = adcSensor.getSingleEnded(2);

String Bearing1;
String Bearing2;
String Bearing3;"Bearings").beginObject();"PB1").value(PB1);"PB2").value(PB2);"PB3").value(PB3);

if (PB1 > 1200 && PB1 <3200)
		Bearing1 = "Running";
		Bearing1 = "Failed";
if (PB2 > 1200 && PB2 <3200)
		Bearing2 = "Running";
		Bearing2 = "Failed";
if (PB3 > 1200 && PB3 <3200)
		Bearing3 = "Running";
		Bearing3 = "Failed";

Particle.publish("Bearing 1=", Bearing1, PRIVATE | WITH_ACK);
Particle.publish("Bearing 2=", Bearing2, PRIVATE | WITH_ACK);
Particle.publish("Bearing 3=", Bearing3, PRIVATE | WITH_ACK);

  1. Setup is good.
  2. See below for an example.
  3. From docs:

void loop() {
PMIC power(true);"Current PMIC settings:");"VIN Vmin: %u", power.getInputVoltageLimit());"VIN Imax: %u", power.getInputCurrentLimit());"Ichg: %u", power.getChargeCurrentValue());"Iterm: %u", power.getChargeVoltageValue());

    int powerSource = System.powerSource();
    int batteryState = System.batteryState();
    float batterySoc = System.batteryCharge();

    constexpr char const* batteryStates[] = {
        "unknown", "not charging", "charging",
        "charged", "discharging", "fault", "disconnected"
    constexpr char const* powerSources[] = {
        "unknown", "vin", "usb host", "usb adapter",
        "usb otg", "battery"
    };"Power source: %s", powerSources[std::max(0, powerSource)]);"Battery state: %s", batteryStates[std::max(0, batteryState)]);"Battery charge: %f", batterySoc);

Thank you. It seems to be working. Is there any risk with inserting PMIC Power(true) into mylocationGenerationCallback? I wanted the battery and charging information to be part of the loc callback when I put the unit to sleep.



You should be able to do that from the location generation callback.

1 Like

I was able to add those to the my location callback. Thanks for all the help.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.