Access Watchdog Timer of Raspberry Pi using JAVA

Ot with raspberry p using JAVA

This tutorial is all about using the watchdog timer of Raspberry Pi by using JAVA. For this, we are going to use Pi4J library. Watchdog Timer: “watchdog timer (sometimes called a computer operating properly or COP timer, or simply a watchdog) is an electronic timer that is used to detect and recover from computer malfunctions. During normal operation, the computer regularly resets the watchdog timer to prevent it from elapsing, or “timing out”. If due to a hardware fault or program error, the computer fails to reset the watchdog, the timer will elapse and generate a timeout signal. The timeout signal is used to initiate corrective action or actions. The corrective actions typically include placing the computer system in a safe state and restoring normal system operation.

Source: Wikipedia


public class MainClass {
    public static void main(String[] args) throws IOException, InterruptedException {

        WDTimer watchdog =  WDTimerImpl.getInstance();;

        int timeout = watchdog.getTimeOut();
        System.out.println("Timeout of WatchDog is "+timeout);
        watchdog.setTimeOut(15);//1-15 Seconds
        System.out.println("WatchDog closed.");


Buy Products:
Catch Me On

Bikash Panda

Blogger / Embedded System Developer at WGLabz
A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.
Bikash Panda
Catch Me On

Latest posts by Bikash Panda (see all)

Related posts