Use the Onboard Arduino to enable LattePanda 3 Delta to auto power on

userHead Youyou 2024-06-21 22:57:08 955 Views0 Replies

The auto power-on feature of the LattePanda 3 Delta can be enabled in the BIOS.
In addition to setting up the BIOS, we can also use the onboard Arduino to achieve auto power-on. The advantages of this method include: the delay time for auto power-on can be modified through code; it can detect whether the board has actually powered on, and if not, it can repeatedly trigger until the LattePanda 3 Delta powers on.


The following will describe in detail how to achieve this step by step, including wiring methods and reference code.

 

Wiring Diagram

According to the diagram, three Dupont wires are needed in the female header.

 

5V Wire: Connect the Arduino power supply to the 5V stand-by power. This means that as long as the LattePanda board is powered, the onboard Arduino will also be powered and can run programs.

 

SW Wire: Connect the SW pin to the D3 pin of the Arduino. The SW pin acts as a power switch; the Arduino's D3 pin outputs a low-level pulse to pull the SW pin low once, mimicking the press of a power switch.

 

S0 Wire: Connect the S0 Pin to the D2 Pin of the Arduino. The S0 Pin indicates the current state of the board. When the board is powered on, it outputs a high level. The Arduino can detect the level of this pin to determine if the board is truly on. If it is not, the Arduino can repeatedly pull the SW Pin low and check the S0 Pin until the board turns on.

 

 

Sample Code

 

Upload the following Arduino code to the onboard Arduino using the Arduino IDE 1.8.x.

 

const int pinSW = 3;     // SW pin connected to D3
const int pinS0 = 2;     // S0 pin connected to D2
void setup() 
{
 pinMode(pinSW, INPUT);    // Default state, SW pin is high impedance input
 pinMode(pinS0, INPUT);    // Default state, S0 pin is high impedance input
 delay(1000);    // After power up, delay for 1 second before detection 
}
void loop() 
{
 while(digitalRead(pinS0)==0)  // If S0 pin is low, the board is not powered on
 {
   pinMode(pinSW, OUTPUT); // Switch to output mode, ready to pull SW pin low
   digitalWrite(pinSW, LOW);  // Pull SW pin low to simulate pressing the power switch
   delay(500);  // Hold for 500 milliseconds
   digitalWrite(pinSW, HIGH);
   pinMode(pinSW, INPUT);    // End of pull low, restore high impedance input
   delay(2000);   // Wait a while to let the board fully start
 }
 while(1);  // Power on complete, program stops here
}

 

Note

 

1. By following the above steps, you can enable the auto power-on function without modifying the BIOS settings.
2. Since the program includes a feature to check if the LattePanda board has truly started, it significantly improves the success rate of auto power-on.
3. When the Arduino Leonardo is first powered on, it needs to run the bootloader, which takes about 10 seconds and is indicated by the red LED flashing. Therefore, the LattePanda board can only start up after the red LED has finished flashing.