# CH32V003P4 - Sleep and Wakeup

**URL:** <https://forum.arduino.cc/t/ch32v003p4-sleep-and-wakeup/1290315>\
**Category:** 3rd Party Boards\
**Created:** [August 9, 2024, 10:51pm UTC](https://forum.arduino.cc/t/ch32v003p4-sleep-and-wakeup/1290315 "2024-08-09T22:51:59Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [December 23, 2024, 2:08am UTC](https://forum.arduino.cc/t/ch32v003p4-sleep-and-wakeup/1290315/18 "2024-12-23T02:08:57Z")

</div>

OK, now the situation is different. You fixed the problem that caused the wrong library to be used at the time you made the previous screenshot.

The correct library is now being used, but there is a new problem. The new problem is that the library uses the `ARDUINO_ARCH_CH32` macro to determine whether it is being compiled for a board with a CH32 microcontroller:

> <https://github.com/maxint-rd/Adafruit_SleepyDog/blob/d8dcb3f9ede38ac6e627085ade73d0c056f57cef/Adafruit_SleepyDog.h#L40-L40>

The definition of that macro was added to the " **CH32 MCU EVT Boards**" platform last summer:

> <https://github.com/openwch/arduino_core_ch32/commit/0d344fa01b5d0abe0e92123f10abd439536a4280>
>
> \* add makeboards.py for generating boards.txt
> use the newly generated boards.tx…t
> 
> \* add Adafruit TinyUSB as submodule in libraries
> 
> \* add TinyUSB core support for ch32v20x
> 
> \* added tiyusb usbfs/usbhs for ch32v3
> 
> \* update tinyusb lib
> 
> \* update makeboards.py for CH32L10x\_EVT HSI\_LP

The maintainers of the platform have not made a new release of the platform after that time. So when you install the platform via the Arduino IDE Boards Manager, you get a version that does not define the `ARDUINO_ARCH_CH32` macro. So @maxint-rd's code only works if you manually installed the beta tester version of the " **CH32 MCU EVT Boards**" platform.

We can make the library compatible with the release version of the platform by making a small adjustment of the code. I'll provide instructions you can follow to do that:

1. Use any text editor to open the file at the following path on your hard drive:

```plaintext
c:\Users\julio\Documents\Arduino\libraries\Adafruit_SleepyDog-master/Adafruit_SleepyDog.h

```

2. Change line 40 from this:

```cpp
#elif defined(ARDUINO_ARCH_CH32)

```

to this:

```cpp
#elif defined(ARDUINO_ARCH_CH32) || defined(CH32V00x)

```

3. Save the file.

Now try compiling or uploading your sketch once again. Hopefully this time everything will work as expected.

---

_[View the full topic](https://forum.arduino.cc/t/ch32v003p4-sleep-and-wakeup/1290315)._
