Ai-Thinker-Open / GPRS_C_SDK

Ai-Thinker A9/A9G GPRS (with GPS(A9G)) module C development SDK
https://ai-thinker-open.github.io/GPRS_C_SDK_DOC
MIT License
448 stars 234 forks source link

PM_SleepMode - is it possible to shutdown for X seconds #364

Open medida opened 5 years ago

medida commented 5 years ago

Hi

So i'm looking at saving battery while using the A(G board

I'm currently testing the PM_SleepMode - but i want to know if there is any way to reduce power any more....

Ideally shutdown and restart in X Seconds....

It would be nice if there was some answers to questions posted - This is seems to be nice little product but unless i can get guidance then its not going to be OK moving forward.. Is there anywhere else i can get advice from about this product where there is a more active community?

kjfdebruin commented 5 years ago

I would be interested in this. Did you manage to find out anything?

medida commented 5 years ago

@kjfdebruin i've had no reply from the company but i have had various replies on other posts these post have been usefull

https://github.com/Ai-Thinker-Open/GPRS_C_SDK/issues/333#issuecomment-526040778

https://github.com/Ai-Thinker-Open/GPRS_C_SDK/issues/329#issuecomment-525939185

At the moment i am testing with PM_Sleepmode - but i'm going to try shutting down the GPIO as well this week.

I have also investigated the idea of the microcontroller / p-mosfet which would shut down the entire device until the next time interval - but the ones i have found only have a maximum of 7200 seconds.

Ideally i only want the device to wake up once a day!

kjfdebruin commented 5 years ago

Thanks so much - we want to do exactly the same thing! I'll post on here if I have any success!

medida commented 5 years ago

there is also some activity on there other forum.... http://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=1221&extra=page%3D1

pulkin commented 5 years ago

Just set up the watchdog timer before shutting down your module. Once the watchdog triggers, the module will start up.

medida commented 5 years ago

I've not seen the watchdog timer. Will that wake a unit when it's been powered off?

pulkin commented 5 years ago

It should work like that. The problem is that I was never able to shut down module (it just restarts in my case), at least while it was USB-powered, so I was never able to test whether it wakes up after. The watchdog alone, however, works.

Pasboe commented 4 years ago

The low power for me is to high I'm going to try and use an I2C Realtime Clock IC like a DS3231 with alarm output and very low power usage. This way I can Switch off the A9G completely and wake it up at a programmed date/time.

medida commented 4 years ago

Would you also use a mosfet

Pasboe commented 4 years ago

@medida Depends on the circuit still doing some research :)

medida commented 4 years ago

Hi It seem Ai-Thinker may have done this before.... i'm currently having an email conversation with them and this is their latest reply.

Yes, you can add an extra microcontroller + MOSFET to manager the power to the device.

Our customer do the same thing, but they choose their microcontroller + MOSFET. Do you have your own plan?

Now waiting for them to provide some details - i'll report back when i get further info

medida commented 4 years ago

Ai-Thinkers reply.................... Sorry I don't know more details, one of our customer is using STM series microcontroller. The model name is STM8L152, hope it's helpful.

I currently have an attiny85 and mosfet on order so hoping to make something usable...

punee995 commented 4 years ago

It Shutdown time is between 100ms and 2hour then I recommend to look at TLP5010.

medida commented 4 years ago

@Pasboe have you got any further with using the RTC.

I'm currently trying to get a DS3231 to return the correct time after its been set, but it just won't work.

Any advice greatly appreciated.

Pasboe commented 4 years ago

@medida Sorry I'm looking at a smaller RTC clock like an RX8130. My goal is to design a small as possible PCB. For this moment I'm only work my way trough the examples to learn. I have the A9G running with GPS, GPRS, SMS and GPIO.
Zkemble posted his great project https://github.com/Ai-Thinker-Open/GPRS_C_SDK/issues/396 this helps a lot. I hope the SDK is going to be updated soon and hopefully some bug's solved.

medida commented 4 years ago

@Pasboe thanks for that - I'm currently stuck sending commands to the RTC via the i2c commands.

Nearly all I2C command examples are arduino Wire based - which does not help as the A9G process can take an array of data - but i don't know if thats the correct way to do it.

I can send data without an error - but the timestamp from the RTC does not change.

I can read the datetime stamp from the RTC ( although its not correct ) for example using...... I2C_ReadMem(I2C_ACC, a, 0x00, 1, &pdata[0], 7, t); uint8_t second = pdata[0];

but if i try to update an element of the time it just won;t work

I2C_WriteMem(I2C_ACC, a, 0x06, 1, decToBcd(2020), 1, t);

bcdToDec - is a function to convert the value into the correct format ( i think ) uint8_t bcdToDec(uint8_t val) { // Convert binary coded decimal to normal decimal numbers return ((val / 16 * 10) + (val % 16)); }

second = (second >> 4) * 10 + (second & 0x0F);

Pasboe commented 4 years ago

@medida. I wil start testing I2C soon let you know if I can get it to work. Do you use pull-up resistors for the I2C lines ? Can be a problem if you don't have pull-ups. I have a logic protocol analyser this way I can see if the I2C data is send in the correct way and do some debugging.

medida commented 4 years ago

@Pasboe the code from https://github.com/zkemble/MailboxNotifier/blob/master/firmware/a9g/src/bme280.c helped me get it working better. I'll post the full test code in a day or so ( although a different RTC chip - it may be useful)

I can now set the time and alarms - just need the alarm trigger to fire the right output to then demonstrate its actually triggering something ( e.g. LED )

Pasboe commented 4 years ago

@medida Sounds all good looking forward to you're code.

Pasboe commented 4 years ago

I've managed to read and write to an I2C Eprom. But it took me to long to figure everything out. Loaded the AT firmware back in to the A9G and hooked op an ATMEGA328. Use a mosfet to switch power on/off and if I set the ATMega in low power my current drops to about 0,22uA. Thats fine for me. Now I can store settings into the EEPROM of the ATmega. Only a few hours of programming and I'm receiving and sending SMS messages. Go to low power and wake up by a trigger from my RTC or button. Now designing a PCB.

medida commented 4 years ago

Could I get a pic of your setup. Not sure I follow.

So your using the atmega to control the rtc, but waking the pudding to send sms etc..

Pasboe commented 4 years ago

medida With the default firmware the A9G can be managed with AT commands. This way I turn it into a slave device. Instead running my own code in the A9C I'm putting my code into a ATMega328. I'm using the arduino IDE to write my program and this way have access to a lot of libraries. The only connection between the A9G and ATMega is a serial connection. The idea came from this board: https://www.makerfabs.com/maduino-zero-a9g.html.

Except this board is to big and can't handle low power mode. Can't upload my schematic here sorry,

medida commented 4 years ago

Hi. Thanks for that.

camp-easy commented 5 months ago

hello, can anyone tell me how to shut down the A9G? it is possible to do with the powerkey or it just restart? thanks in advance:)