LowPower.h not working with Nano clone LGT8F328P

Hi !

I had a well functionning program with the classic Arduino Nano that includes the LowPower.h library, and LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF) was used.

I moved to the LGT8F328P board, I had to install in the hardware file the LGT file to get the proper bootloader (by the way it fixes delay which was 4x too long before). But the powerdown mode is not working at all, the rest of the program is not working either when the powerdown function is written. Without it everything is working fine.

Do you have any idea of the source of my problem ?

Thank you !

I'm pretty sure that LowPower.h is written specifically for Microchip/Atmel processors. As you mention, you're using a clone cpu that is fundamentally different, although somewhat compatible, with the official Microchip ATMega328P. Hence, it is only to be expected that certain functions won't work the same (or at all) on the clone. Conversely, the clone has a few tricks up its sleeve that the Microchip original doesn't.

So in short, don't expect this library to work on a chip it probably was never intended to work with.

2 Likes

Yes. Most "clones" use a genuine AVR chip. This one does not. The chip designers did their best to replicate the functions of the genuine AVR chip, but it's not 100% compatible and this kind of thing is exactly where any differences come to light.

1 Like

Alright that is what I was afraid about haha ! I find a document about the LGT8F microcontroller and at the power management chapter it mentions being able to perform sleep modes. This one interest me :

"When SM [2: 0] is set to 110, the MCU will enter DPS0 mode after executing the SLEEP instruction."

But I have no idea of what is SM [2:0] and all the other stuff...

No doubt this microcontroller can be coaxed into some kind of (probably several) sleep mode, and even get out of it and work again. The question is if you have the time and patience to go through the motions and write a library for it. Personally I'd just get a genuine Microchip 328P and call it a day.

Hey.

Have you managed to find a working library?
I have the same problem. Everything works except sleep modes.

You may get other issues too

  • buy a genuine board !

Yes, that's the best way.

Only that I bought a nice board with NANO and RF24.
It looks really cool. Only problem with sleeping mode.

Yep I find the solution !

LowPower.h is not compatible, though the way the LGT8F328P goes to sleep is the same as any Arduino : I followed this tutorial and it worked perfectly.
It constists in not using any library but to directly change some bit in the sleep mode control register (SMCR).

I had to change some bit value to match my desire, in the tutorial he is using a 8s time delay by calling a certain bit, but I wanted 2s. In this case, to use a certain time with the watchdog, you call the watchdog bit with decimal number when written the program, but the datasheet of both arduino or LGT8F328P shows you how it really works with standard bit (eight "0" or "1"). So you'll need to translate the bit from the datasheet to decimal, and use those decimal on your program.

Here is the LGT8F328P datasheet, look for the Power Management section : https://www.avrfreaks.net/sites/default/files/forum_attachments/LGT8F88P%20LGT8F168P%20LGT8F328P%20arial%20translated.pdf

Also don't hesitate to play with the frequency of the LGT8F328P, I set mine at 8MHz to save extra mA, but going below 8MHz might affect the time for your program to do one loop.

There is something in the specs that caught my attention though... This chip is supposed to deliver 32Mhz even at 1.8v and can out of the box work between 1.8v-5v also there is a version that has a built-in NRF24 radio integrated. Just ordered few of these to test them out but I'm wondering if this chip could beat the pro mini on power consumption.

Really? That's odd. What type designation does that chip have?
Or you do mean a board with both a LGT8F328P and an NRF24? Cause yeah, those are a thing and not very remarkable.

Correct these are boards with both a LGT8F328P and an NRF24. Wondering if this can help for power consumption instead of having a separate component.

Don't think so. Those nRF24L01+ don't have any significant power overhead compared to it being integrated into an experimenter board together with another microcontroller.

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