Back to Smartcitizen.me

Power-off Qwiic on SCK2.1 power-off

Hi,

I’ve successfully connected the SAM-M8Q through AUX and have been collecting data.

However, when I turn off the SCK2.1 the GPS board continues to be powered (PWR light is on and the PPS light indicates it’s capturing/processing satellites signals).

It’s possible to turn off the SAM-M8Q but requires connecting a pin to the SAM-M8Q INT pin. This isn’t optimal as I requires some additional wiring. Anyways, does the SCK2.1 have any ‘free’ pins to use?

Alternatively, is it possible to disable Qwiic power?

There’s some additional information on the SAM-M8Q Sparkfun page.

I’m currently considering going into low-power mode instead if I can’t do this - we’ll see how little power draw there is.

Cheers,
C-

I added code to sam/src/SckAux.cpp in the sensor’s stop() method to put the GPS/GNSS to sleep. It isn’t doing anything.

I’m wondering if the goToSleep in sam/src/SckBase.cpp is calling the AUX sensor stop methods at all?

I’ll try to implement this and get back to you.

Hi Cyrille,

Previously we were cutting power to auxiliary sensors when entering sleep mode, but some sensors (mostly electrochemical gas sensors) don’t like this kind of turn off/on, so we decided to remove it.

For a quick solution, you could cut the power of the auxiliary bus completely when sleeping and turn it on again on wake:

  1. On the goToSleep() function (around line 1278 will work) cut the power by adding the line::
    digitalWrite(pinPOWER_AUX_WIRE, HIGH);
  2. At the end of the SleepLoop() function, reconnect by adding the line:
    digitalWrite(pinPOWER_AUX_WIRE, LOW);

I haven’t tested this, but I think it should work as long as the sensors that are connected to the auxiliary bus don’t get affected negatively by the sudden power cut.

Other posibility is calling the stop() and start() methods for the auxiliary sensors on the same places we mentioned before, and implement the low power mode for your GPS.

To implement this properly, I think we need to create a new config setting to enable and disable the cutting of auxiliary power on sleep, or the option to call the stop() and start() method of the sensors. So the user can configure it depending on the type of sensors connected.
I will put this on the To-do list!

Hope this help!
Cheers
Victor

1 Like

Hi victor

Not sure if it’s relevant but when a Calypso Anemometer is attached (via a Uart port on a pm board) manufacturer instructions are not to cut the power because it upsets internal calibrations. So gas sensors are not the only ones with an issue there.
With my system I have made it so the start and stop commands received via I2c only set/unset a “started” flag; whilst readings continue to be taken every 30 second s via the loop function in the ‘.ino’ file. But of course this device only draws micro amps when active anyway.

Ahhh penny just dropped. This might be why the PM Board has its own 5 v power feed to usb socket from power distribution board. I will need to add a similar power lead to the 2nd pm board for the same reason I guess.

Cheers
Bryn
@oscgonfer

Hi,

It’s been busy but I finally had a bit of time and gave it a try - it was quick and easy to implement.
Perfect @victor . Doing just as you specified works like a charm:

1 Like

Hi Bryn,

Yes each sensor has its own requirements, at some point it will be nice to have a power cut setting per sensor. Still when you have connected several sensors with different settings at the same time this solution won’t work.

Cheers
Victor

Yes; I agree with that. Some sensors (such as dust and 4G radio can use a lot of power when active and so you are incentivized to implement a power cut option. But others (smart, low power) sensors don’t like to have the power removed without warning. I do not think it’s a good idea to implement power cut on the whole I2C bus; but rather implement it on each MCU board.

We currently have 2 separate MCU’s independently powered and can add more (as I have). But if power cut option per sensor is implemented; digital pins are consumed at a rate of one per sensor. eg . The power control option is employed on the dust sensors on PM board but it chews through digital pins.
To implement power control for every grove port means a new board design is required.

Then you say maybe we need to change the MCU to (a different version of SAMD21 or SAMD51 perhaps ) so to have more digital pins and more UART Ports and the whole thing balloons out of control. There are implications on building the firmware etc etc.

So while it the above appears to work at first - responding to on/off responsively, after a few minutes of operating the GNSS loses power and intermittently returns.

I’ll explore the low-power option.

It would be interesting to learn the pathway by which you implemented the SAM-M8Q; Having recently gone through the SAM code I find that it implements a unified API for 3 types of GPS in order to get just one set of GPS readings; Each one of those GPS Devices is connected a different way, one of them uses UART, another I2C.
did you just add a fourth one; or did you implement your own ? Or, is it somehow similar to one of the existing boards.

Hi Bryn,

I connected it using I2C.
You can see my code for this here: https://github.com/serialc/smartcitizen-kit-21/blob/eef9e1df6114476965e25da407df7656465a1b44/sam/src/SckAux.cpp#L2076

I didn’t do much but rename some methods so they’re generic rather specifying the one GNSS model model. I didn’t quite understand how the I2C query returns a unique identifier for the device.

Cheers,
Cyrille

Hi @victor ,

So I’ve been trying to access the methods in the Sck_GPS class (the start() and stop()) but I’m unclear as how to do this from within the SckBase::goToSleep() or SckBase::sleepLoop().

I can see that I have to use the auxBoards instance of AuxBoards, but I’m unable to call auxBoards.start() and auxBoards.stop() from sleepLoop() and goToSleep(), respectively.
I think the problem is that I’m missing the parameters to pass but can’t figure out how to retrieve the SensorType here.

Any suggestions how to do this?

Kind regards,
Cyrille

Hi @cyrille.mdc,

I think the best place to call the GPS sleep code is inside the goToSleep() function, you can do it in line 1284 after the code that stops the PM sensor.

   ...
	// Stop PM sensor
	if (urban.sck_pm.started) urban.sck_pm.stop();

	// Sleep GPS (ADDED FOR THIS EXAMPLE)
	if (sensors[SENSOR_GPS_FIX_QUALITY].enabled) auxBoards.stop(SENSOR_GPS_FIX_QUALITY);

	if (sckOFF) { ...

In this example first we check if the SENSOR_GPS_FIX_QUALITY is enabled (we can use any of the GPS SensorType defined in Sensors.h) and then called the auxboards.stop() function that will call the stop function for GPS, you can check that in line 194 of SckAux.cpp file.

To wake up the GPS at the end of the goToSleep() function add the same code but calling auxboards.start(). Be aware that you need to pass this (SckBase object pointer) to the start method.

...	// Recover Noise sensor timer
	REG_GCLK_GENCTRL = GCLK_GENCTRL_ID(4);  // Select GCLK4
	while (GCLK->STATUS.bit.SYNCBUSY);

	// Wake up GPS (ADDED FOR THIS EXAMPLE)
	if (sensors[SENSOR_GPS_FIX_QUALITY].enabled) auxBoards.start(this, SENSOR_GPS_FIX_QUALITY);
}

On the other side if you need to call specific code for sleep/wake on the GPS side, maybe using the stop() and start() methods isn’t the best idea. If that’s the case, the option I can think off, is to create new methods for that eg: gps.sleep() and gps.wake() and call them through the auxboards.control() method. where you can pass a specific command to the sensor in String format.

String control(SensorType wichSensor, String command);

So you can end up with something like this:

auxBoards.control(SENSOR_GPS_FIX_QUALITY, "sleep");
auxBoards.control(SENSOR_GPS_FIX_QUALITY, "wakeup");

and inside the AuxBoards::control() function you can act depending on the received command and call your new functions gps.sleep() and gps.wake().

Hope this helps!
Cheers
Victor

1 Like