# Power save with BW16 arduino

**URL:** <https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819>\
**Category:** SDK\
**Tags:** evb-bw16, rtl872xd\
**Created:** [September 27, 2021, 12:25am UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819 "2021-09-27T00:25:59Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [October 12, 2021, 1:26am UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/21 "2021-10-12T01:26:44Z")

</div>

> [@Nguyen\_Thien](#):
>
> Does the Standard SDK have to follow the “29.2.2 IAR Project” steps?

Yes, if you use IAR, please follow the steps there

---

<div class="post-metadata">

**Author:** ![Nguyen\_Thien](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/nguyen_thien/32/658_2.png) [@Nguyen\_Thien](https://forum.amebaiot.com/u/Nguyen_Thien)\
**Post date:** [October 12, 2021, 1:49am UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/22 "2021-10-12T01:49:04Z")

</div>

I have tried it. Edited and download program into chip. But I don’t know has to call example in main function?

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [October 12, 2021, 2:12am UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/23 "2021-10-12T02:12:01Z")

</div>

You can NOT call example in main function.

Each example has its own main function and is a standalone program, so you need to check the example code, and manually put those functional code into your own main.c and then re-compile the program

---

<div class="post-metadata">

**Author:** ![Nguyen\_Thien](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/nguyen_thien/32/658_2.png) [@Nguyen\_Thien](https://forum.amebaiot.com/u/Nguyen_Thien)\
**Post date:** [October 13, 2021, 11:51pm UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/24 "2021-10-13T23:51:55Z")

</div>

hi. @xidameng  
I tried like this:  
Edit macro.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/2ef1b6074173aedaffcd1ba198537ff5c479f168.png).  
After in main.c , I called bt\_config\_app\_init();  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/e2aa57eb66cebf53260d6308ab83c3e584b9afdd.png)  
Already built, dowloaded into BW16. using the WifiConfig app in IOS. But still can’t see the device. Please help me find where is wrong?  
Thanks!  
Thien.

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [October 14, 2021, 7:45am UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/25 "2021-10-14T07:45:15Z")

</div>

Hi @Nguyen_Thien ,

to run the BT Config default example, please follow these steps:

1. In `platform_autoconf.h`, you should enable `CONFIG_BT_EN`, `CONFIG_BT` and `CONFIG_BT_CONFIG`. Thus, it should look like:

```auto
#define CONFIG_BT_EN 1
#define CONFIG_BT 1
#undef CONFIG_BT_PERIPHERAL
#undef CONFIG_BT_CENTRAL
#undef CONFIG_BT_SCATTERNET
#undef CONFIG_BT_BEACON
#define CONFIG_BT_CONFIG 1

```

1. Open the file `rtl8721dhp_intfcfg.c` found in `ambd_sdk-master\component\soc\realtek\amebad\fwlib\usrcfg`, and edit it so that `#define FTL_MEM_CUSTEM 1`
2. You **should not modify** main.c. Instead, you should **use the default** main.c.
3. Compile and upload the images
4. After restarting the board, connect to the serial port, and send this command: `ATBB=1`. You should see a log output that looks something like this:

```auto
#ATBB=1
[ATBB]:_AT_BT_CONFIG_[ON]
Start upperStack
[BT Config Wifi] BT Config Wifi ready
[BT Config Wifi] ADV started
[MEM] After do cmd, available heap 120608

```

1. You can start scanning for the board on the WiFiConfig app. It should be able to find the device

Detailed instructions on how to compile and run BLE examples can be found in [AN0400 Application Note](https://github.com/ambiot/ambd_sdk/blob/master/doc/AN0400%20Ameba-D%20Application%20Note.pdf) Chapter 29.2, and [UM0201 BT User Manual](https://github.com/ambiot/ambd_sdk/blob/master/doc/UM0201%20Ameba%20Common%20BT%20Application%20User%20Manual%20EN.pdf) Chapter 4.3

---

<div class="post-metadata">

**Author:** ![Nguyen\_Thien](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/nguyen_thien/32/658_2.png) [@Nguyen\_Thien](https://forum.amebaiot.com/u/Nguyen_Thien)\
**Post date:** [October 15, 2021, 11:36pm UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/26 "2021-10-15T23:36:01Z")

</div>

Thanks @wyy!  
I use BW16 module. But go to Step 5:  
I don’t know what pins to connect to the serial port.  
I connected the program dowload pins(PA7, PA8) and get the result.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/1165760389655589528f434386ece16a5b5bd9a4.png)  
And tried typing #ATBB=1 but got nothing.  
Thanks.  
Thien.

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [October 16, 2021, 5:05am UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/27 "2021-10-16T05:05:41Z")

</div>

PA7 PA8 are the correct pins.  
Try changing the line ending in Serial monitor to `Carriage return` or `Both NL & CR`

---

<div class="post-metadata">

**Author:** ![Nguyen\_Thien](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/nguyen_thien/32/658_2.png) [@Nguyen\_Thien](https://forum.amebaiot.com/u/Nguyen_Thien)\
**Post date:** [October 17, 2021, 12:00am UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/28 "2021-10-17T00:00:03Z")

</div>

i Tried changing the line ending in Serial monitor to `Carriage return` or `Both NL & CR`  
The result is now:

unknown command ‘ATBB=1’  
[MEM] After do cmd, available heap 163008

![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/1X/ac76a4e4315a16b10999e97faac90dd17cc8e635.png)

I’m using “Serial monitor” of Arduino. Can I change another app?

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [October 17, 2021, 3:34am UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/29 "2021-10-17T03:34:59Z")

</div>

I normally use teraterm, but serial monitor should also work.  
unknown command seems to indicate that the image is not compiled properly, since the code required for it to recognize the command is not there.

---

<div class="post-metadata">

**Author:** ![Nguyen\_Thien](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/nguyen_thien/32/658_2.png) [@Nguyen\_Thien](https://forum.amebaiot.com/u/Nguyen_Thien)\
**Post date:** [October 17, 2021, 11:13pm UTC](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819/30 "2021-10-17T23:13:01Z")

</div>

Hi @wyy , @xidameng  
I’m so glad I did it.  
As you say:“My image is not compiled properly”. I edited it but in the wrong place.  
Thank you very much for the support.  
Thien.

[Previous page](https://forum.amebaiot.com/t/power-save-with-bw16-arduino/819.md?page=1)
