顯示包含「Ameba」標籤的文章。顯示所有文章
顯示包含「Ameba」標籤的文章。顯示所有文章

2023年3月31日星期五

[Ameba] A1 PICO / RTL8720DN (BW16) and Arduino IDE (EN)

RTL8720DN

Realtek RTL8720DN is a wireless chip that supports both Wifi and Bluetooth, with Wifi supporting dual modes (802.11 a/b/g/n 1x1, 2.4GHz & 5GHz) and low-power BLE 5. The processor core is designed with dual processors, integrating ARM V8M Cortex-M33 (instruction set compatible with Cortex-M4F) and ARM V8M Cortex-M23 (compatible with Cortex-M0+). Wifi and BT share the same set of antennas, making hardware design simpler. The BW16 is a SOC module designed based on the RTL8720DN, which connects commonly used pins and uses a PCB antenna to make development easier.

Summary:
The core consists of KM4 Arm Cortex-M4 core @ 200 MHz and KM0 Arm Cortex-M0 core @ 20 MHz. WiFi supports 2.4G and 5G protocols, with a bandwidth range of 2.412-2.484GHz & 5.180-5.825GHz.

  • It supports HT20/HT40 modes
  • low-power mode
  • Bluetooth 5.0 LE
  • with a bandwidth range of 2.402GHz – 2.480GHz.
  • Operating modes include AP, Station, AP/Client. 
  • WiFi and BT share the same antenna.
  • 1 ADC
  • 2 UART interfaces
  • 1 I2C
  • 1 SPI
  • 4 PWM
  • and all pins can be used as GPIO.

 

To make it more convenient to use the RTL8720DN (BW16), I designed the A1 PICO development board.

Development highlights:

  • Built-in USB 5V self-recovery fuse.
  • Battery connection interface JST 2.00mm.It is not convenient to connect a fixed power source in many applications, so it will be more convenient in applications. If USB 5V is connected at the same time, it will automatically switch to USB as the main power source.
  • Because battery applications are required, I specially selected an LDO with good efficiency to maximize the battery's performance. The default voltage range is 3.6V ~ 4.2V.
  • Pre-installed I2C pull-up resistors.When used in I2C applications, pull-up resistors are always needed, and sometimes they cannot be found temporarily. Now, you only need to connect the short circuit pin.
  • Supporting Auto Flash function is also a major modification this time.


Connection diagram

RTL8720DN,BW16,ESP32


UART Driver

CH9102F
https://www.wch.cn/products/CH9102.html

Circuit diagram

RTL8720DN,BW16,ESP32


Arduino IDE

To get started, you need to install the Ameba board support package (BSP) for the Arduino IDE. Follow these steps:

  1. Open the Arduino IDE and click on File -> Preferences.
  2. In the Additional Boards Manager URLs field, enter the following URL:https://github.com/ambiot/ambd_arduino/raw/master/Arduino_package/package_realtek.com_amebad_index.json
  3. Click OK to save the changes.
  4. Next, open the Boards Manager by clicking on Tools -> Board -> Boards Manager.
  5. Search for "ameba" and select the "Realtek AmebaD Boards" package.
  6. Click on Install to install the BSP.
  7. After installation, select the "Ameba RTL8720DN / BW16" board from the Tools -> Board menu.

You are now ready to program the Ameba board using the Arduino IDE.
Please enable the Auto Upload mode as this development board has the Auto flash feature for automatic uploading.


Demo video

Resources


2023年3月29日星期三

[Ameba] RTL8720DN 搭配 TFT_eSPI 控制 ILI9341 顯示器 (Arduino/BW16)

RTL8720DN 與 TFT_eSPI

這期簡單介紹 RTL8720DN 使用 TFT_eSPI 控制 ILI9341 240 x 320 規格的顯示器,目標是顯示 240 x 320 的圖檔。 硬體部分是 A1 Pico 搭配 擴充板

設置 TFT_eSPI

首先, 先行安裝 TFT_eSPI Library ,我這裡安裝的是 V2.5 版本。

安裝完成後,打開 Arduino Library 的位置。如果不知道在哪裡,請在 File / Preferences 找到 Sketchbook location 欄位。這就是目前您的 Arduino Library 的位置。

並找到 TFT_eSPI 的 資料夾,我們要在這裡設定一些項目。

首先下載這個檔案
https://github.com/cold63/TFT_eSPI/blob/master/User_Setups/Setup302_BW16_ILI9341.h

下載完成後,複製到 TFT_eSPI/User_Setups 的位置。
接下來,在 TFT_eSPI 找到 User_Setup_Select.h 並使用 notepad 打開它編輯

找到這一行 ,並在前面給它加註解 //


//#include "User_Setup.h"



在這一系列的 User_Setups 內找出最後一行,並加入底下這一敘述
#include "User_Setups/Setup302_BW16_ILI9341.h"

以下這 3 pin ,就按照實際狀況調整。如果是 A1 Pico 的擴充板,就不需要更改。


#define TFT_CS    9  // Chip select control pin
#define TFT_DC    3  // Data Command control pin
#define TFT_RST   2  // Reset pin (could connect to RST pin)

製作圖片

我們的目標是 240 x 320 pix 的顯示,而且想輸出滿版的畫面。所以,先將圖片製作好。我的圖片是

然後到這個網站
http://www.rinkydinkelectronics.com/t_imageconverter565.php

在 Picture to convert 選擇剛剛製作好的圖片,並上傳。
上傳完畢,再點 Make File 按鈕。便會要求下載 *.C 的 檔案。

開啟 Arduino IDE 並建立 新的Sketch。
在 Arduino IDE 最右邊,有個 點點點

它會要 輸入 file name
我這裡是取名為 sample.h ,或是其他的名字的 *.h
並將剛剛下載的 *.c 打開並全部複製到 sample.h 裡

以下是主程式內容


#include "TFT_eSPI.h"
#include "SPI.h"
#include "sample.h"

TFT_eSPI tft = TFT_eSPI();

void setup() {
  // put your setup code here, to run once:
  tft.init();
  tft.setRotation(1);  // landscape

  tft.fillScreen(TFT_BLACK);

  // Swap the colour byte order when rendering
  tft.setSwapBytes(true);

  // Draw the icons
  tft.pushImage(0, 0, 320, 240, sample);




}

void loop() {
  // put your main code here, to run repeatedly:

}

編譯好並上傳。
以下是呈現的結果。

Github 原始碼

https://github.com/cold63/Arduino_Code/tree/main/ShowLogo_240_320

相關連結

A1 Pico / RTL8720DN
https://www.makdev.net/2021/09/ameba-ameba-bw16-arduino-ide.html

RTL8720DN 二合一擴充板
https://www.makdev.net/2022/09/ameba-bw16-type-c-shield.html

影片展示

 

2023年3月24日星期五

[Ameba] RTL8720DN 與 溫溼度感測 DHT20 實作 (Arduino/BW16)

實作要點

本次實作使用 RTL8720DN 透過 I2C 介面讀取 DHT20 溫溼度感測及在透過 I2C 介面將讀取結果顯示於 OLED SSD1306。

硬體清單

軟體實作

軟體主題有 2 個項目,
OLED SSD1306 及 DHT20.OLED SSD1306 使用 u8g2 程式庫。 DHT20 的程式庫則使用 DFRobot 的 DHT20 程式庫 https://github.com/DFRobot/DFRobot_DHT20 )

u8g2 library 先在 Arduino IDE 裝好 u8g2 程式庫



DHT20 程式庫

準備就緒後,進行程式段。


void setup(){
  Serial.begin(115200);
 
  //Initialize sensor
  while(dht20.begin()){
    Serial.println("Initialize sensor failed");
    delay(1000);
  }
  
  u8g2.begin();
  u8g2.setFont(u8g2_font_8x13_mf);
  u8g2.setFontPosTop();
  fontHigh = u8g2.getMaxCharHeight();
  fontWidth = u8g2.getMaxCharWidth();
  
  u8g2.clear();
  u8g2.setCursor(0,0);
  u8g2.print("temp:");
  u8g2.updateDisplay();
  delay(100);
  u8g2.setCursor(0,fontHigh);
  u8g2.print("Humidity:");
  u8g2.updateDisplay();
}

void loop(){
  //Get ambient temperature
  tempValue = dht20.getTemperature();
  Serial.print("temp:"); Serial.print(tempValue);Serial.print("C");
  delay(100);
  
  //clean temp display
  u8g2.setCursor(fontWidth * 5 + 1,0);
  u8g2.print("    ");
  u8g2.updateDisplay();
  //display temp value to oled
  delay(10);
  String tempStr = String(tempValue,2);
  u8g2.setCursor(fontWidth * 5 + 1,0);
  u8g2.print(tempStr + "C");
  u8g2.updateDisplay();
  delay(500);
 
  //Get relative humidity
  humidityValue = dht20.getHumidity()*100;
  Serial.print("  humidity:"); Serial.print(humidityValue);Serial.println(" %RH");
  delay(100);
  
  //clean temp display
  u8g2.setCursor(fontWidth * 9 + 1,fontHigh);
  u8g2.print("    ");
  u8g2.updateDisplay();
  
  //display temp value to oled
  delay(10);
  String humidityStr = String(humidityValue,2);
  u8g2.setCursor(fontWidth * 9 + 1,fontHigh);
  u8g2.print(humidityStr + "%");
  u8g2.updateDisplay();
  delay(1000);
}
RTL8720DN,BW16

Github 原始碼

https://github.com/cold63/Arduino_Code/tree/main/Ameba_DHT20

相關連結

A1 Pico / RTL8720DN
https://www.makdev.net/2021/09/ameba-ameba-bw16-arduino-ide.html

RTL8720DN 擴展板
https://www.makdev.net/2022/09/ameba-bw16-type-c-shield.html

2023年1月4日星期三

[Ameba] RTL8720DN 與 V7RC App 藍芽控制

Ameba 與手機連結

V7RC 是由 嵐奕科技 所開發的 App , 可以在 iOS 及 Android 系統運行。 V7RC App 可透過 藍芽及 WiFi 控制一般遙控車或是遠端控制應用。 在這裡做簡單直覺的範例做為基礎,望在爾後做更多的應用。

首先,開啟 範例
File / Examples / AmebaBLE / BLEUartService

ESP32,RTL8720DN,BW16

直接編譯並上傳至 RTL8720DN

V7RC App

設定連接藍芽

ESP32,RTL8720DN,BW16,V7RC

選定 車輛模式

ESP32,RTL8720DN,BW16,V7RC

開啟 Arduino IDE 的 Serial Monitor

移動 左右舵 及 上下舵
節錄一小段反饋

Received string: SRV1500150015001500#

SRV1500150015001500# 是由 V7RC 反饋的訊息

所以是
SRV (前綴碼) + 4 組 4 位數 + '#' 結束符
所組成的
前綴碼會依不同模式,而有所不同.
例如:
車輛: SRV
坦克: SRT

只要針對反饋的數值做處理就可以對我們的標的做控制。
到這裡,可以操作 左右舵及上下舵 看看有甚麼變化,這裡就不贅述

建立結構


typedef struct{
    bool reciveCMDFlag;
    int  ReciveValue;
    int  Pin;
    AmebaServo Servo;

}_rCMD;

uint8_t DefinePin[2] = {3,12};

定義 3,12 為PWM 輸出腳位

建立 - 解析反饋訊息


void ParseCMDString(String cmd)
{
    int comdLength = cmd.length();
    if(cmd.charAt(comdLength - 1) != '#')
        return;
    if(cmd.indexOf("SRV") > -1 ){
        int x = 3;
        int ValueIndex = 0;
        while(x < comdLength - 1){
            if(x + 3 < comdLength){
                String _NumString = cmd.substring(x,x + 4);
                
                if(ValueIndex < MaxNumValue){
                    if(bleReciveData[ValueIndex].ReciveValue != _NumString.toInt()){
                        bleReciveData[ValueIndex].ReciveValue = _NumString.toInt();
                        bleReciveData[ValueIndex].reciveCMDFlag = true;
                    }
                }
            }
            ValueIndex++;
            x += 4;
            Serial.println();
        }
        
    }
}

這個解析函式,將放在 writeCB call back function 裡
會自動填入 bleReciveDate 這個 Arrary.

當 reciveCMDFlag 為 true , 在 loop()裡就會個別對 sg90 Servo 控制。


void loop()
{

    while(Count < MaxNumValue) {
        
            if(bleReciveData[Count].reciveCMDFlag && bleReciveData[Count].Pin == 3){
                bleReciveData[Count].reciveCMDFlag = false;

                int Angle = map(bleReciveData[Count].ReciveValue,1000,2000,0,180);
                bleReciveData[Count].Servo.write(Angle);
            }
            

            if(bleReciveData[Count].reciveCMDFlag && bleReciveData[Count].Pin == 12){
                bleReciveData[Count].reciveCMDFlag = false;

                int Angle = map(bleReciveData[Count].ReciveValue,1000,2000,0,180);
                bleReciveData[Count].Servo.write(Angle);

            }

        
        Count++;
    }
    Count = 0;
    delay(1);
}

 

另外,在原範例的


Rx.setWriteProperty(true);

改為


Rx.setWriteNRProperty(true);

這個範例是控制 2個 SG90 Servo,若控制不同裝置時,例如: 驅動馬達,就要視情況再修改程式

 

原始程式碼

https://github.com/cold63/Arduino_Code/tree/main/V7RC_RTL8720DN

 

相關連結

iOS V7RC App
https://apps.apple.com/tw/app/v7rc/id1390983964
Android V7RC App
https://play.google.com/store/apps/details?id=com.v7idea.v7rcliteandroidsdkversion&hl=zh_TW&gl=US

 

[Ameba] RTL8720DN GPIO 中斷

使用中斷

GPIO 中斷對於 MCU 來說是非常好用的功能,並可以幫助時序的問題。可以用來偵測輸入開關,或是遮斷器的應用,抑或是用來偵測時脈的 Timing。 Ameba 的GPIO 中斷使用方法有稍微的不同,我們用簡單的範例來玩玩看。

觸發點

標準的時脈 (或是另一個說法 -> 方波) ,有上升段 (RISE) 及 下升段 (FALL)。 在 Setup() 就需要指定觸發點在何處,這會和您的電路有關。以這次的範例是以 RTL8720DN 擴展為例,User key 指定 IO Pin 為 6 ,接入開關後接地。 所以觸發點為 下升段(FALL)

波形示意圖

ESP32,RTL8720DN


User Key Button 電路

 

範例說明

範例在 ”File” -> “Example” -> “AmebaGPIO” -> “LED_InterruptCtrl”
打開後先另存 Save as ...
針對 擴展板 修改,指定 IO 6 為 偵測腳,IO 9 為 A1 Pico 的 LED


int button = 6;
int led    = 9;

觸發點為 FALL -> INPUT_IRQ_FALL


pinMode(button, INPUT_IRQ_FALL);

用 digitalSetIrqHandler f指定反饋 function


digitalSetIrqHandler(button, button_handler);

void button_handler(uint32_t id, uint32_t event) {}

這個範例的結果是 按 User Key 並放開,LED 會亮。再按一次 LED 會滅。

範例程式碼

https://github.com/cold63/Arduino_Code/tree/main/Interrupt_Ctrl_LED

 

2022年9月30日星期五

[Ameba] RTL8720DN /BW16 二合一擴展板 Shield

支援兩款 RTL8720DN 開發板

  • A1 Pico - Kevin's Lab 
  • BW16 kit - Ai Thinker

 

 

規劃初衷

希望在實做Iot 應用作品時,可以很輕鬆的接入各種感測器及模組。並全力專心在程式開發上,減少在接線錯誤造成開發時間延宕。且同時保有擴展性,保留排針排及使用 Grove 連接器,使開發板增加擴展性。

硬體規格

  • 尺寸: 81.3 x 81.3 mm
  • 孔位 : Arduino uno 固定孔。
  • 電源輸入 : 6V ~ 18V 
  • 電源連接器: DC Jack 2.1(內正外負) , 可用變壓器(電流建議 >1A) 或是 2 顆 3.7V 鋰電池 (例如 18650) 串聯成 7.4V
  • Grove 接口 x 2 。 1 組 UART , 1 組 I2C

ESP32,BW16,RTL8720DN

BW16,RTL8720DN,ESP32



RTL8720DN,BW16,ESP32


支援外接模組

BW16,RTL8720DN,ESP32
  • PMS5003空氣偵測器
  • L9110S 模組 & TT 馬達
  • TFT LCD  / 240 x 320 Pixel
  • 伺服馬達
  • Buzzer
  • OLED SSD1306
  • RGB LED
  • MPU6050
  • HS-SR04 超音波
  • DHT20 溫溼度感測 / Grove 連接器
  • WS2812 LED


BW16,RTL8720DN,ESP32

注意事項

  • 接入開發板及模組時,請注意電源正負極方向,避免開發板及模組損壞
  • 使用 伺服馬達及 TT 馬達時,請務必使用 外接電源。有防呆機制,只使用 USB 5V 時,伺服馬達及 TT 馬達接口並不會有 5V 輸出。

如何購買

RTL8720DN 擴展板

 

相關

影片展示 :YouTube
開發板 : A1 Pico

 

2022年6月10日星期五

[Ameba] 使用Arduino Wire 基本函式存取 24C02 EEPROM / I2C

什麼是 EEPROM ?

EEPROM 代表電子可擦除式可做讀寫的存儲器。它允許在使用非常少的功率的情況下長時間寫入和存儲值。大多數微控制器甚至在其電路中直接有 EEPROM,例如 ATmega328P(Arduino Uno 芯片),它有 1KB。但如果這還不夠呢?SD 卡具有更大的存儲容量,但也更複雜、體積更大且耗電量更大。

這次的範例使用 Arduino 的 Wire 基本函式, 不套用現成 Library 。從實做中理解控制原理。這次選用型號為 AT24C02B / 儲存空間 2Kbit

Datasheet ( https://ww1.microchip.com/downloads/en/DeviceDoc/doc5126.pdf)

輸出腳位

24C02,Arduino

開發板

此次使用的是 自行開發的 A1 Lite / Realtek RL8720DN 。連結在此 (連結) ,在這就不多做介紹。
在 A1 Lite 使用 I2C 前先將預裝的提升電阻用焊接的方式將 JP2 , JP3 短接起來

A1 Lite,Arduino,RTL8720DN,BW16

接線

AT24C02ConnectA1 Lite
A0GND 
A1GND 
A2GND 
GNDGNDGND
SDA 8
SCL 7
WPGND 
VCC3V33V3

EEPROM I2C 位址

位址為 7-bit 規則 , A0 ~ A2 均接地。 所以位址為 0x50

 

寫入資料

Ameba,I2C

我們要先確認 WP 是否接入 GND。首先送出 EEPROM 的設備位址,0x50 ~ 0x57 之間。根據接線需送出 0x50 (若設備得到正確位址會有 NACK/ACK 反饋)。接著送出數據位址,再送出資料,最後發出 STOP 訊號 endTransmission() 告知 EEPROM 不再繼續。

程式碼


void WriteByte(uint8_t data_addr, uint8_t data)
{
 
  Wire.beginTransmission(EEPROM_ADDRESS);
  Wire.write(data_addr);
  Wire.write(data);
  Wire.endTransmission();
}

讀取資料

Ameba,I2C

首先要先送出 EEPROM 設備位址 及 數據位址。接下來再送出 設備位址,EEPROM 會反饋 1 組(Byte)資料。

程式碼


uint8_t ReadByte(uint8_t data_addr)
{
  uint8_t data;
  Wire.beginTransmission(EEPROM_ADDRESS);
  Wire.write(data_addr);
  Wire.endTransmission();
  Wire.requestFrom(EEPROM_ADDRESS,1);


  if(Wire.available())
  {
    data = Wire.read(); 
  }
  Wire.endTransmission();
 
  return data;
}

綜合以上,組成


  WriteByte(1,0x5A);
  delay(10);
  
  Serial.println(ReadByte(1),HEX);

輸出結果

進階

以 AT24C02 來說, 它是由 8 bytes 組成 一個 page, 以這個型號有 32 page。它可以一次寫入讀取最多 8 bytes 的資料, 我們將改寫程式

寫入資料



void WriteBytes(uint8_t data_addr, uint8_t *data,uint8_t len)
{


  uint8_t x;
  Wire.beginTransmission(EEPROM_ADDRESS);
  Wire.write(data_addr);
  for(x = 0; x < len; x++)
  {
    Wire.write(data[x]);  
  }
  
  Wire.endTransmission();
}

讀取資料


void ReadBytes(uint8_t data_addr,uint8_t *data, int len)
{
  uint8_t x;
  Wire.beginTransmission(EEPROM_ADDRESS);
  Wire.write(data_addr);
  Wire.endTransmission();
  Wire.requestFrom(EEPROM_ADDRESS,len);


  if(Wire.available())
  {
    for(x = 0; x < len;x++)
    {
      data[x] = Wire.read();    
    }
    
  }
  Wire.endTransmission();
  
}

輸出結果

Ameba,I2C

 

 

GitHub 完整程式碼

連結 ( https://github.com/cold63/Arduino_Code/tree/main/I2C_EEPROM )

其他參考

TI 應用手冊 Understanding the I2C Bus (SLVA704 )
連結 ( https://www.ti.com/lit/an/slva704/slva704.pdf )

 

2022年4月30日星期六

[Ameba] A1 Gyro / RTL8720DN / (BW16) 開發板

 

關於 A1 Gyro

為了實現基於 RTL8720DN (BW16 Module) 可以使用在其他不同的 ESP32 shield 上直接使用,所設計的開發板。A1 Gyro 具有 16ch +2 ch的 PWM 信號輸出。您可以透過 A1 Gyro 設計在任何需要 PWM輸出的應用,不論您要設計 小車,坦克車,機械手臂,還是 機械狗。只要 1 片A1 Gyro ,PWM輸出數量已足夠讓您使用。

A1 Gyro 特色

  • 內建 USB/Ext 5V 可自復式保險絲。
  • I2C 介面預裝提升電阻。
  • 使用 CP2102N UART 晶片
  • 支援 Auto flash 功能。
  • 內建 PCA9685 晶片, 有額外的 16 通道 PWM 輸出 (12-bit PWM),可設定晶片的 I2C Address。並有串接 220 ohm 電阻保護晶片輸出,可以直接驅動 伺服器 驅動單顆 LED。
  • 腳位符合 ESP32 38 pin 定義順序,支援 EPS32 擴展板

腳位定義圖

Arduino BW16 ESP32

電路圖

Arduino BW16 ESP32

JUMP 定義說明

定義說明預設
A0 ,A1,A2,A3,A4,A5PCA9685 的 I2C 位址設定0x40
JP1BLINK LED Close
JP2 與 5 (RX )短接Close
JP3與 4 (TX)短接Close


Arduino 安裝

請參考 A1 Lite / RTL8720DN (BW16) 開發板 與 Arduino IDE (連結)

目前已完整驗證過的擴展板

ESP Gyro 擴充板

連結 (https://sites.google.com/view/esp-gyro/ )

Arduino BW16 ESP32

Arduino BW16 ESP32

小車示範影片



如何購買 A1 Gyro 開發板

A1 Gyro (BW16) 開發板


2022年4月18日星期一

[Ameba] A1 Gyro / RTL8720DN (BW16) 開發板

 

關於 A1 Gyro

為了實現基於 RTL8720DN (BW16 Module) 可以使用在其他不同的 ESP32 shield 上直接使用,所設計的開發板。A1 Gyro 具有 16ch +2 ch的 PWM 信號輸出。您可以透過 A1 Gyro 設計在任何需要 PWM輸出的應用,不論您要設計 小車,坦克車,機械手臂,還是 機械狗。只要 1 片A1 Gyro ,PWM輸出數量已足夠讓您使用。

A1 Gyro 特色

  • 內建 USB/Ext 5V 可自復式保險絲。
  • I2C 介面預裝提升電阻。
  • 使用 CP2102N UART 晶片
  • 支援 Auto flash 功能。
  • 內建 PCA9685 晶片, 有額外的 16 通道 PWM 輸出 (12-bit PWM),可設定晶片的 I2C Address。並有串接 220 ohm 電阻保護晶片輸出,可以直接驅動 伺服器 驅動單顆 LED。
  • 腳位符合 ESP32 38 pin 定義順序,支援 EPS32 擴展板

腳位定義圖

Arduino BW16 ESP32

電路圖

Arduino BW16 ESP32

JUMP 定義說明

定義說明預設
A0 ,A1,A2,A3,A4,A5PCA9685 的 I2C 位址設定0x40
JP1BLINK LED Close
JP2 與 5 (RX )短接Close
JP3與 4 (TX)短接Close


Arduino 安裝

請參考 A1 Lite / RTL8720DN (BW16) 開發板 與 Arduino IDE (連結)

目前已完整驗證過的擴展板

ESP Gyro 擴充板

連結 (https://sites.google.com/view/esp-gyro/ )

Arduino BW16 ESP32

Arduino BW16 ESP32

小車示範影片



如何購買 A1 Gyro 開發板

A1 Gyro (BW16) 開發板


2022年1月25日星期二

[Ameba] A1 Lite / RTL8720DN (BW16) 開發板 與 Arduino IDE

關於 A1 Lite

A1 Lite 是基於 RTL8720DN (BW16 Module) 所設計的開發板,而 RTL8720DN 具有 WIFI 4G/5G 及低功耗 BLE 5 的無線功能。與前版本 A1 Pico (點這裡)所使用的 BW16 Module 相同

A1 Lite 設計特色

  • 內建 USB/Ext 5V 可自復式保險絲。
  • I2C 介面預裝提升電阻。
  • 使用 CP2102N UART 晶片。
  • 支援 Auto flash 功能。
  • 簡化腳位,並使用單排半圓孔,可使用排針 或配合電路直接焊接 PCB 上

電路圖

Arduino BW16

腳位連接圖

Arduino BW16

孔位尺寸圖

單位:mm

RTL8720DN BW16

背面 JUMP 說明

NUM用途預設
JP1USER LEDON
JP2I2C 提升電阻OFF
JP3I2C 提升電阻OFF

準備

先安裝 CP2102N 的驅動程式。

連結在這裡
https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers

Windows 系統請下載 CP210x Windows Drivers,會得到一個壓縮檔,依據您的電腦系統 選擇 x64 或是 x86 安裝執行檔。 安裝步驟這裡就不贅述。

RTL8720DN 加入 Arduino
首先將這個網址複製起來 https://github.com/ambiot/ambd_arduino/raw/master/Arduino_package/package_realtek.com_amebad_index.json

打開 Arduino IDE , 點開 File / Preferences

BW16 Arduno

將網址貼上 紅框 處 , 然後點 OK 儲存。

接著在 Tools / Board: / Boards Manager...

在 搜尋列直接輸入" ameba " 就會出現開發板資訊 , 在右側會有 Install 的 按鈕。 因為我的 Arduino IDE 安裝完成,所以出現不一樣字樣。 點 " Install " 開始安裝 會需要等待一些時間, 可以先去泡一杯咖啡再回來。

BW16 Arduino

稍待片刻後,系統就會自動安裝完成。
在 Tools / Board: / Amaba ARM (32bit) Boards 裡, 應該會找到 RTL8720DN (BW16) 這個選項。
到這裡 安裝 RTL8720DN(BW16) 到 Arduino IDE 的部分已經做完了。

置換 upload_image_tool_windows.exe

預設安裝是沒有支援 Auto Flash 功能的,必須手動更新

首先 到 Ameba 的 Github https://github.com/ambiot/ambd_arduino/blob/dev/Ameba_misc/Autoflash_patch/ameba_d_tools_windows/upload_image_tool_windows.exe

BW16

右下角 Download , 就可以下載。如果您是不同於 Windows 系統,則回到上一層選擇適合的平台

置換的方法

開啟檔案總管, 到這個位置。

C:\Users\%USER%\AppData\Local\Arduino15\packages\realtek\tools\ameba_d_tools\1.0.7

您會看到很多檔案在其中 , 一定會有 upload_image_tool_windows.exe 這個檔案

可以先行 備份 再將 剛剛下載的 upload_image_tool_windows.exe 做覆蓋置換過去就可以。

測試 Blink 程式

將開發板連接電腦 USB 並開啟 Arduino IDE 並選好 開發板名稱 及 COM Port 位置

Arduino BW16

程式碼


int YelloLED = 9; //PA15

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(YelloLED, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(YelloLED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(YelloLED, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

然後點選上傳 , 在訊息欄出現以下。自動上傳並自動 RESET。完成



實際測試結果



技術連結


購買 A1 Lite 開發板

蝦皮購物 


官方程式範例

https://bit.ly/bw16_example

官方論壇

https://bit.ly/amebaiot

Ameba Iot Facebook 開發社群

https://bit.ly/amebaiot_groups

2021年9月16日星期四

[Ameba] A1 PICO / RTL8720DN (BW16) 開發板 與 Arduino IDE

物聯網課程即日起開始報名
請點擊這裡! >>

緣起

Realtek RTL8720DN 是一個具有 Wifi + Bluetooth 無線晶片, Wifi 且支援雙模 (802.11 a/b/g/n 1x1, 2.4GHz & 5GHz ) 和低功耗的 BLE 5。處理器內核採用 Dual processor core 設計 集成 ARM V8M Cortex-M33 (指令集相容於 Cortex-M4F) 及 ARM V8M Cortex-M23 (相容於 Cortex-M0+) 。 Wi-Fi 及 BT 是共用一組天線,所以在硬體設計上更為簡便。而 BW16 為 基於 RTL8720DN 所設計的 SOC 模組,將常用的引腳連接出來, 並使用 PCB 天線。使開發輕鬆。

小結

內核組成 KM4 Arm Cortex-M4 core @ 200 MHz 及  KM0 Arm Cortex-M0 core @ 20 MHz

 WiFi 2.4G 及 WiFi 5G 協定  802.11 a/b/g/n 頻寬範圍 : 2.412-2.484GHz & 5.180-5.825GHz

  • 支援 HT20/HT40 模式
  • 支援低功耗式
  • 支援 Bluetooth 5.0 LE , 頻寬範圍 :2.402GHz – 2.480GHz
  • 工作模式 : AP , Station, AP/ Client
  • WiFi 與 BT 共用一組天線
  • 1 個 ADC
  • 2 UART 介面
  • 1 個 I2C
  • 1 個 SPI
  • 4 個 PWM
  • 全部接腳都可成為 GPIO


為了更方便使用 RTL8720DN (BW16),因此我設計了 A1 PICO 開發版。

開發重點

1. 內建 USB 5V 可自複式保險絲。
因為做實驗難免會有誤接短路的問題,尤其是 USB 是直接連接電腦。雖然 USB Hub 也有相對應的保護,多層保護可以減少發生意外機率。

2. 電池連接口 JST 2.00mm 。
在很多應用是不方便連接固定電源,在應用上會更方便。若同時接入 USB 5V 會自動切換 USB 做為主要電源。

3. 因為要使用電池應用, 所以也特別挑選工作效率好的 LDO。使電池發揮最大的效能。預設電壓區間是 3.6V ~ 4.2V

4. 預裝 I2C 提升電阻,在應用於 I2C 時都需要提升電阻,有時臨時還真找不到 。現在只要將短路 pin 接上就好。

5. 支援 Auto flash 功能也是這次修改的重點, 感謝 jojoling 提供好用的程式,讓我可以搭順風車。

連接圖

RTL8720DN,BW16

UART 驅動程式

CH9102F

https://www.wch.cn/products/CH9102.html

CH9102F (本站下載點,不會更新)

Google driver dwonload.

電路圖

RTL8720DN,BW16


RTL8720DN(BW16) 加入 Arduino IDE

首先先將這個網址複製起來
https://github.com/ambiot/ambd_arduino/raw/master/Arduino_package/package_realtek.com_amebad_index.json

打開 Arduino IDE , 點開 File / Preferences

RTL8720DN,BW16

將網址貼上 紅框 處 , 然後點 OK 儲存

接著在 Tools / Board: / Boards Manager...

RTL8720DN,BW16

在 搜尋列直接輸入" ameba " 就會出現開發板資訊 , 在右側會有 Install 的 按鈕。 因為我的 Arduino IDE 安裝完成,所以出現不一樣字樣。 點 " Install " 開始安裝 會需要等待一些時間, 可以先去泡一杯咖啡再回來。

RTL8720DN,BW16

稍待片刻後,系統就會自動安裝完成。
在 Tools / Board: / Amaba ARM (32bit) Boards 裡, 應該會找到 RTL8720DN (BW16) 這個選項。
到這裡 安裝 RTL8720DN(BW16) 到 Arduino IDE 的部分已經做完了。

將開發板連接電腦 USB 並開啟 Arduino IDE 並選好 開發板名稱 及 COM Port 位置

RTL8720DN,BW16

溫馨提醒:

本開發板有 Auto flash 自動上傳功能, 請將 Auto Upload mode 設定為 Enable

RTL8720DN,BW16


測試 Blink 程式


int YelloLED = 9; //PA15

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(YelloLED, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(YelloLED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(YelloLED, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

示範影片



如何購買 A1 Pico 開發板

Buy A1 Pico Board.

開發資源