diff --git a/bak/ambd/_common/Example_Guides/GTimer/GTimer - Using The Periodic GTimer.rst b/bak/ambd/_common/Example_Guides/GTimer/GTimer - Using The Periodic GTimer.rst deleted file mode 100644 index 350394d..0000000 --- a/bak/ambd/_common/Example_Guides/GTimer/GTimer - Using The Periodic GTimer.rst +++ /dev/null @@ -1,44 +0,0 @@ -########################################################################## -GTimer - Using The Periodic GTimer -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -| Ameba provides 4 hardware GTimer for users to use. The timers’ resolutions are at microseconds scale. -| The timer can be set to be periodic or for single use. The periodic timers reset periodically, and the single-use timers do not. - -| Open the example, ``“File” → “Examples” → “AmebaGTimer” → “TimerPeriodical”``. Compile and upload to Ameba, and press reset. -| In the Serial Monitor, you can see the counter value is increased periodically. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -| The first argument of begin() is the timer id (0~3). -| The second argument is the value of the timer (in microseconds). - In the example, we fill in 1000000us = 1s. -| The third argument specifies the function to call when the time is up. - In the example, we call the “myhandler” function to increase the counter value by 1 - and print the counter value to serial monitor. - -.. code-block:: c - - GTimer.begin(0, 1 * 1000 * 1000, myhandler); - -The GTimer is periodic by default, therefore “myhandler” function is -called every second. When we want to stop the GTimer, use ``stop()``: - -.. code-block:: c - - GTimer.stop(0); \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/I2C/I2C - Display Data On LCD Screen.rst b/bak/ambd/_common/Example_Guides/I2C/I2C - Display Data On LCD Screen.rst deleted file mode 100644 index ef4505f..0000000 --- a/bak/ambd/_common/Example_Guides/I2C/I2C - Display Data On LCD Screen.rst +++ /dev/null @@ -1,117 +0,0 @@ -########################################################################## -I2C - Display Data On LCD Screen -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - I2C 2×16 LCD - -:raw-html:`

` -**Example** -:raw-html:`

` - -Normally there are many pins on an LCD display, as shown in below -figure. - -.. image:: /media/ambd_arduino/I2C_Display_Data_on_LCD_Screen/image1.png - :align: center - :width: 1058 - :height: 972 - :scale: 72 % - - -An LCD display can be equipped with an additional processing chip to -process the data. The processing chip can connect to a microcontroller -using the I2C interface. - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Display_Data_on_LCD_Screen/image2.png - :align: center - :width: 1429 - :height: 978 - :scale: 71 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Display_Data_on_LCD_Screen/image2-1.png - :align: center - :width: 1434 - :height: 748 - :scale: 93 % - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Display_Data_on_LCD_Screen/image2-3.png - :align: center - :width: 1158 - :height: 621 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Display_Data_on_LCD_Screen/image2-4.png - :align: center - :width: 1244 - :height: 672 - -Open the example in ``“File” → “Examples” → “AmebaWire” → “LCD_HelloWorld”``. -Compile and upload to Ameba, then press the reset button. -Then you can see “Hello World” in the first line, and “Ameba” in the -second line displayed on the LCD screen. - -.. image:: /media/ambd_arduino/I2C_Display_Data_on_LCD_Screen/image3.jpeg - :align: center - :width: 1429 - :height: 978 - :scale: 72 % - -After 8 seconds, you can input to the Serial Monitor the string you -would like to display on the LCD. - -.. image:: /media/ambd_arduino/I2C_Display_Data_on_LCD_Screen/image4.jpeg - :align: center - :width: 1431 - :height: 862 - :scale: 72 % - -For example, we enter “123456789” and press “Send”: - -.. image:: /media/ambd_arduino/I2C_Display_Data_on_LCD_Screen/image5.jpeg - :align: center - :width: 1431 - :height: 851 - :scale: 72 % - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -The required settings of each model of LCD might be different, the -constructor we use in this example is: - -.. code-block:: C - - LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t backlighPin, t_backlighPol pol); - -And the setting parameters are as follows: - -.. code-block:: C - - LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address - -The first parameter 0x27 is the address of I2C. Each of the following 8 -parameters represents the meaning of each bit in a byte, i.e., En is bit -2, Rw is bit 1, Rs is bit 0, d4 is bit 4, and so forth. - -Call ``backlight()`` to light the screen, -Call ``setCursor(0, 0)`` to set the position of the cursor. -LCD inherits the Print class, so we can use ``lcd.print()`` to output string on the screen. - diff --git a/bak/ambd/_common/Example_Guides/I2C/I2C - Receive Data from Arduino UNO.rst b/bak/ambd/_common/Example_Guides/I2C/I2C - Receive Data from Arduino UNO.rst deleted file mode 100644 index 1dc057a..0000000 --- a/bak/ambd/_common/Example_Guides/I2C/I2C - Receive Data from Arduino UNO.rst +++ /dev/null @@ -1,130 +0,0 @@ -########################################################################## -I2C - Receive Data from Arduino UNO -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Arduino UNO x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -In the previous example `“I2C – Communicate with Arduino UNO via -I2C”  `__, Ameba, the I2C -master, transmits data to the Arduino UNO, the I2C slave. -As to this example, Ameba is the I2C master, and receives data from the Arduino -UNO, which is the I2C slave. - -**Setting up Arduino Uno to be I2C Slave** - -First, select Arduino in the Arduino IDE in ``“Tools” → “Board” → -“Arduino Uno”``: -Open ``“Examples” → “Wire” → “slave_sender”`` - -.. image:: /media/ambd_arduino/I2C_Receive_Data_from_Arduino_UNO/image1.png - :align: center - :width: 683 - :height: 1028 - -Then click “Sketch” → “Upload” to compile and upload the example to -Arduino Uno. - -**Setting up Ameba to be I2C Master** - -Next, open another window of Arduino IDE, make sure to choose your -Ameba development board in the IDE: “Tools” → “Board” -Open ``“File” → “Examples” → “AmebaWire” → “MasterReader”`` - -.. image:: /media/ambd_arduino/I2C_Receive_Data_from_Arduino_UNO/image2.png - :align: center - :width: 588 - :height: 1028 - -Click “Sketch” → “Upload” to compile and upload the example to Ameba. - -**Wiring** - -The Arduino example uses A4 as the I2C SDA and A5 as the I2C SCL. -Another important thing is that the GND pins of Arduino and Ameba -should be connected to each other. - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Receive_Data_from_Arduino_UNO/image3.png - :align: center - :width: 1540 - :height: 1051 - :scale: 66 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Receive_Data_from_Arduino_UNO/image3-1.png - :align: center - :width: 882 - :height: 670 - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Receive_Data_from_Arduino_UNO/image3-3.png - :align: center - :width: 923 - :height: 717 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Receive_Data_from_Arduino_UNO/image3-4.png - :align: center - :width: 959 - :height: 690 - -Next, we will observe the data receive by Ameba in the Serial Monitor. -(Note: If you do not know which port the Ameba development board is -connected to, please find it in the Device Manager of Windows first. -Ameba is connected as “mbed Serial Port”. For example, if you find -mbed Serial Port (COM15) means Ameba is connected to port COM15.) - -.. image:: /media/ambd_arduino/I2C_Receive_Data_from_Arduino_UNO/image4.png - :align: center - :width: 434 - :height: 405 - -We select the port in “Tools” → “Port” → “COM15” (the port connected -to Ameba) -Open the Arduino IDE window of the Ameba, go to “Tools” → “Serial -Monitor” to display the messages printed by Ameba. -Press the reset button on Arduino Uno, Arduino Uno now waits for -connection from I2C master. -Then press the reset button on Ameba, Ameba will start to receive -messages from Arduino Uno. And you can see the “hello ” message -printed every half second in serial monitor. -(NOTE: If the message does not show in the Serial Monitor of Ameba, -please close and open the serial monitor again.) - -.. image:: /media/ambd_arduino/I2C_Receive_Data_from_Arduino_UNO/image5.png - :align: center - :width: 649 - :height: 410 - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -You can find detailed information of this example in the documentation -of Arduino: -https://www.arduino.cc/en/Tutorial/MasterReader - -First use ``Wire.begin()`` / ``Wire.begin(address)`` to join the I2C bus as a -master or slave, in the Master case the address is not required. -https://www.arduino.cc/en/Reference/WireBegin - -Next, the Master uses ``Wire.requestFrom()`` to specify from which Slave -to request data. -https://www.arduino.cc/en/Reference/WireRequestFrom - diff --git a/bak/ambd/_common/Example_Guides/I2C/I2C - Scan I2C devices.rst b/bak/ambd/_common/Example_Guides/I2C/I2C - Scan I2C devices.rst deleted file mode 100644 index 651f9b1..0000000 --- a/bak/ambd/_common/Example_Guides/I2C/I2C - Scan I2C devices.rst +++ /dev/null @@ -1,2 +0,0 @@ -I2C - Scan I2C devices -====================== \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/I2C/I2C - Send Data to Arduino UNO.rst b/bak/ambd/_common/Example_Guides/I2C/I2C - Send Data to Arduino UNO.rst deleted file mode 100644 index e49f021..0000000 --- a/bak/ambd/_common/Example_Guides/I2C/I2C - Send Data to Arduino UNO.rst +++ /dev/null @@ -1,133 +0,0 @@ -########################################################################## -I2C - Send Data to Arduino UNO -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Introduction of I2C** -:raw-html:`

` - -There are two roles in the operation of I2C, one is “master”, the -other is “slave”. Only one master is allowed and can be connected -to many slaves. Each slave has its unique address, which is used -in the communication between master and the slave. I2C uses two -pins, one is for data transmission (SDA), the other is for the -clock (SCL). Master uses the SCL to inform slave of the upcoming -data transmission, and the data is transmitted through SDA. The -I2C example was named “Wire” in the Arduino example. - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Arduino UNO x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we use Ameba as the I2C master writer, and use -Arduino as the I2C slave receiver. -When the I2C slave receives string sent from I2C master, it prints the -received string. - -**Setting up Arduino Uno to be I2C Slave** - -First, select Arduino in the Arduino IDE in ``“Tools” → “Board” → “Arduino Uno”`` -Open the “Slave Receiver” example in ``“Examples” → “Wire” → “slave_receiver”``: - -.. image:: /media/ambd_arduino/I2C_Send_data_to_Arduino_UNO/image1.png - :align: center - :width: 578 - :height: 1028 - -Then click ``“Sketch” → “Upload”`` to compile and upload the example to Arduino Uno. - -**Setting up Ameba to be I2C Master** - -Next, open another window of Arduino IDE, make sure to choose your -Ameba development board in the IDE: ``“Tools” → “Board”`` -Then open the “Master Writer” example in ``“File” → “Examples” → -“AmebaWire” → “MasterWriter”`` - -.. image:: /media/ambd_arduino/I2C_Send_data_to_Arduino_UNO/image2.png - :align: center - :width: 588 - :height: 1028 - -Wiring --------- - -The Arduino example uses A4 as the I2C SDA and A5 as the I2C SCL. -Another important thing is that the GND pins of Arduino and Ameba -should be connected to each other. - -**AMB21/ AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Send_data_to_Arduino_UNO/image3.png - :align: center - :width: 1540 - :height: 1051 - :scale: 66 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Send_data_to_Arduino_UNO/image3-1.png - :align: center - :width: 1005 - :height: 743 - :scale: 94 % - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Send_data_to_Arduino_UNO/image3-3.png - :align: center - :width: 923 - :height: 717 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/I2C_Send_data_to_Arduino_UNO/image3-4.png - :align: center - :width: 959 - :height: 690 - -Open the Arduino IDE of the Arduino Uno and open the serial monitor -(“Tools” → “Serial Monitor”). -In the Serial Monitor, you can see the messages printed from Arduino -Uno. -Next, press the reset button on Arduino Uno. Now the Arduino Uno is -waiting for the connection from I2C Master. -We press the reset button on Ameba to start to send messages. Then -observe the serial monitor, you can see the messages show up every -half second. - -.. image:: /media/ambd_arduino/I2C_Send_data_to_Arduino_UNO/image4.png - :align: center - :width: 649 - :height: 410 - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -You can find detailed information of this example in the documentation -of Arduino: -https://www.arduino.cc/en/Tutorial/MasterWriter - -First use Wire.begin()/Wire.begin(address) to join the I2C bus as a -master or slave, in the Master case the address is not required. -https://www.arduino.cc/en/Reference/WireBegin - -Next, the Master uses Wire.beginTransmission(address) to begin a -transmission to the I2C slave with the given address: -https://www.arduino.cc/en/Reference/WireBeginTransmission - -Uses Wire.write() to send data, and finally use Wire.endTransmission() -to end a transmission to a Slave and transmits the bytes that were -queued: -https://www.arduino.cc/en/Reference/WireEndTransmission - diff --git a/bak/ambd/_common/Example_Guides/I2C/I2C - Slave Receive Data from Arduino UNO.rst b/bak/ambd/_common/Example_Guides/I2C/I2C - Slave Receive Data from Arduino UNO.rst deleted file mode 100644 index 8823fc7..0000000 --- a/bak/ambd/_common/Example_Guides/I2C/I2C - Slave Receive Data from Arduino UNO.rst +++ /dev/null @@ -1,2 +0,0 @@ -I2C - Slave Receive Data from Arduino UNO -========================================= \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/I2C/I2C - Slave Send Data to Arduino UNO.rst b/bak/ambd/_common/Example_Guides/I2C/I2C - Slave Send Data to Arduino UNO.rst deleted file mode 100644 index 1612ed9..0000000 --- a/bak/ambd/_common/Example_Guides/I2C/I2C - Slave Send Data to Arduino UNO.rst +++ /dev/null @@ -1,2 +0,0 @@ -I2C - Slave Send Data to Arduino UNO -==================================== \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over TCP.rst b/bak/ambd/_common/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over TCP.rst deleted file mode 100644 index 5c130c5..0000000 --- a/bak/ambd/_common/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over TCP.rst +++ /dev/null @@ -1,93 +0,0 @@ -################################################# -IPv6 – Ameba as IPv6 Server/Client over TCP -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 2 - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -This example shows how Ameba can communicate on the local network using Internet Protocol version 6 over TCP. -Note that this example only works after you have set up the server and then configure the client accordingly. - -**Procedure** - -Step 1. IPv6TCPServer -Open the example, ``“Files” → “Examples” → “WiFi” → “IPv6TCPServer”``. - - |1| - -In the sample code, modify the highlighted section to enter the information required (ssid, password) to -connect to your WiFi network. - - |2| - -Next, upload the code and press the reset button on Ameba once the upload is finished. -Open Serial Monitor and copy the IPv6 address of the Server (the highlighted area) for later use, - - |3| - -Step 2. IPv6TCPClient -Now take the second Ameba D and open another example, ``“Files” → “Examples” → “WiFi” → “IPv6TCPClient”``. - - |4| - -In the sample code, modify the highlighted section to enter the information required (ssid, password) to connect to your WiFi network. - - |5| - -From the previous step, we have obtained the Server’s IPv6 address, now we copy the server’s -IPv6 address to “IPv6TCPClient” example in the highlighted area below, - - |6| - -| Next, upload the code and press the reset button on Ameba once the upload is finished. -| Open Serial Monitor on the port to the second Ameba D, you should see server and client are - sending text message to each other at the same time. - - |7| - - |8| - -.. |1| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image1.png - :width: 1160 - :height: 962 - :scale: 100 % -.. |2| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image2.png - :width: 427 - :height: 490 - :scale: 100 % -.. |3| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image3.png - :width: 602 - :height: 294 - :scale: 100 % -.. |4| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image4.png - :width: 1196 - :height: 957 - :scale: 100 % -.. |5| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image5.png - :width: 431 - :height: 494 - :scale: 100 % -.. |6| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image6.png - :width: 510 - :height: 436 - :scale: 100 % -.. |7| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image7.png - :width: 517 - :height: 271 - :scale: 100 % -.. |8| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image8.png - :width: 518 - :height: 266 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over UDP.rst b/bak/ambd/_common/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over UDP.rst deleted file mode 100644 index 09e26c8..0000000 --- a/bak/ambd/_common/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over UDP.rst +++ /dev/null @@ -1,88 +0,0 @@ -################################################# -IPv6 – Ameba as IPv6 Server/Client over UDP -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 2 - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -This example shows how Ameba can communicate on the local network using Internet Protocol version 6 over UDP. -Note that this example only works after you have set up the server and then configure the client accordingly. - - |1| - -In the sample code, modify the highlighted section to enter the information required (ssid, password) to -connect to your WiFi network. - - |2| - -Next, upload the code and press the reset button on Ameba once the upload is finished. -Open Serial Monitor and copy the IPv6 address of the Server (the highlighted area) for later use, - - |3| - -Step 2. IPv6UDPClient -Now take the second Ameba D and open another example, ``“Files” → “Examples” → “WiFi” → “IPv6UDPClient”``. - - |4| - -In the sample code, modify the highlighted section to enter the information required (ssid, password) to connect to your WiFi network. - - |5| - -From the previous step, we have obtained the Server’s IPv6 address, now we copy the server’s -IPv6 address to “IPv6UDPClient” example in the highlighted area below, - - |6| - -| Next, upload the code and press the reset button on Ameba once the upload is finished. -| Open Serial Monitor on the port to the second Ameba D, you should see server and client are - sending text message to each other at the same time. - - |7| - - |8| - -.. |1| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image1.png - :width: 1158 - :height: 961 - :scale: 100 % -.. |2| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image2.png - :width: 458 - :height: 527 - :scale: 100 % -.. |3| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image3.png - :width: 602 - :height: 294 - :scale: 100 % -.. |4| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image4.png - :width: 1156 - :height: 962 - :scale: 100 % -.. |5| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image5.png - :width: 436 - :height: 491 - :scale: 100 % -.. |6| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image6.png - :width: 471 - :height: 449 - :scale: 100 % -.. |7| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image7.png - :width: 517 - :height: 271 - :scale: 100 % -.. |8| image:: /media/ambd_arduino/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image8.png - :width: 517 - :height: 271 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/MDNS/MDNS - Set up mDNS Client on Arduino IDE.rst b/bak/ambd/_common/Example_Guides/MDNS/MDNS - Set up mDNS Client on Arduino IDE.rst deleted file mode 100644 index 41ccac3..0000000 --- a/bak/ambd/_common/Example_Guides/MDNS/MDNS - Set up mDNS Client on Arduino IDE.rst +++ /dev/null @@ -1,139 +0,0 @@ -################################################# -MDNS - Set up mDNS Client on Arduino IDE -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -mDNS (Multicast DNS) is a protocol used in the local area network. It -delivers the network information like IP address and provided services -to others. mDNS is based on the UDP protocol, and it sends packets to -224.0.0.251 with port 5353 under IPv4 address. The naming style for the -service follows the format: **{Instance Name}.{Protocol Name}.{Domain}** - - - Instance Name: used to identify the name of the service - - Protocol Name: Divided into two parts, the front end is in regard to - the name of the service, and it adds baseline as a prefix. The - rear end is in regard to the transport protocol name it used, and - it also adds baseline as a prefix - - Domain: Local area network in normal cases - -| For example, Arduino IDE adopts the naming for the mDNS service which is - used in OTA as following: **MyAmeba._arduino._tcp.local**  -| Among the - naming example, “MyAmeba” can identify the Ameba device name and the - name “MyAmeba” is changeable. “_arduino._tcp” is the protocol that - Arduino IDE adopts, and the Domain is set as local in common. -| Open the example, ``“File” → “Examples” → “AmebaMDNS” → “mdns_on_arduino_ide”`` -| You need to input ssid and password of the AP because the example will - use WiFi connection. -| And you can find out the naming of the service at - the place where it declares MDNS Service. The example uses the default - name “MyAmeba” and the name is changeable. -| |1| - -Next, go to (“Tools” → -“Port”), and you can find out at least one Serial Port. This port is -simulated by Ameba board via USB. Choose this port and upload the -compiled code to Ameba. - -|2| - -After uploading the code, press the reset -button on Ameba and waiting for Ameba to connect with AP and activate -the mDNS service after a while. You can see the Log at the bottom of the -Serial Monitor. - -|3| - -Then you can find out the added item “Network -Ports” **“MyAmeba at 192.168.1.167 (Ameba RTL8722DM/RTL8722CSM)”**, -“MyAmeba” is the device name we set up, and “IP” is the IP address that -AP assigned to Ameba, the IP address should be the same with the IP -shown in the Serial Monitor. Last, “Ameba RTL8722DM/RTL8722CSM” is the -type name of the board, and it means that Ameba can let Arduino IDE -identify the mDNS service successfully.(We still can not use the -Internet to upload the code, and we will explain this part in the OTA -example.)\ |4| - -| If you cannot find the Network ports on your Arduino IDE, please check: - - - Does your computer in the same local area network with the Ameba? - - Restart the Arduino IDE, and it will find the mDNS service again - - Check the Log in Serial Monitor if the Ameba connects to the AP and - activate mDNS service successfully - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -The program set up the mDNS service in the beginning, the first -parameter is Instance Name, and it is changeable in this example. The -second parameter is the protocol that the service used, and it would be -“_arduino._tcp” for Arduino IDE. The third parameter is Domain, and it -would be “local” in common. The fourth parameter is the port number for -the service, it is 5000 here and we doesn’t use it in the example. - -.. code-block:: C - - MDNSService service("MyAmeba", "_arduino._tcp", "local", 5000); - -After connected to the network, we set up some text fields for the -service. For the following example, “board” is the name of the field, -“ameba_rtl8721d” is the value of the field. “board” is used to let -Arduino IDE check installed SDK to see if it exists known device or not. -We will use the name of the device if there is known device, users can -change “ameba_rtl8721d” to “yun” or other names to find out what’s the -difference if interested. - -.. code-block:: C - - service.addTxtRecord("board", strlen("ameba_rtl8721d"),"ameba_rtl8721d"); - -Then we add three text fields “auth_upload”, “tcp_check”, and -“ssh_upload”, this example does not activate these services. - -.. code-block:: C - - service.addTxtRecord("auth_upload", strlen("no"), "no"); - service.addTxtRecord("tcp_check", strlen("no"), "no"); - service.addTxtRecord("ssh_upload", strlen("no"), "no"); - -Next we activate MDNS - -.. code-block:: C - - MDNS.begin(); - -and register to the mDNS service. - -.. code-block:: C - - MDNS.registerService(service); - -.. |1| image:: /media/ambd_arduino/MDNS_Set_Up_MDNS_Client_On_Arduino_IDE/image1.png - :width: 679 - :height: 623 - :scale: 100 % -.. |2| image:: /media/ambd_arduino/MDNS_Set_Up_MDNS_Client_On_Arduino_IDE/image2.png - :width: 679 - :height: 853 - :scale: 100 % -.. |3| image:: /media/ambd_arduino/MDNS_Set_Up_MDNS_Client_On_Arduino_IDE/image3.png - :width: 704 - :height: 355 - :scale: 100 % -.. |4| image:: /media/ambd_arduino/MDNS_Set_Up_MDNS_Client_On_Arduino_IDE/image4.png - :width: 777 - :height: 853 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/MDNS/index.rst b/bak/ambd/_common/Example_Guides/MDNS/index.rst deleted file mode 100644 index d0052a9..0000000 --- a/bak/ambd/_common/Example_Guides/MDNS/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -MDNS -==== - -.. toctree:: - :maxdepth: 1 - - MDNS - Set up mDNS Client on Arduino IDE - \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Set up MQTT Client over TLS.rst b/bak/ambd/_common/Example_Guides/MQTT/MQTT - Set up MQTT Client over TLS.rst deleted file mode 100644 index c881bb4..0000000 --- a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Set up MQTT Client over TLS.rst +++ /dev/null @@ -1,81 +0,0 @@ -################################### -MQTT - Set up MQTT Client over TLS -################################### - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - -- AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -| In this example, we connect Ameba to a MQTT broker using TLS - authentication. Then send messages as a publisher and receive messages - from as a subscriber. Open the MQTT example ``“File” → “Examples” → - “AmebaMQTTClient” → “MQTT_TLS”`` - - |1| - -| Please modify the WiFi-related parameters to connect to your WiFi network. -| Modify the MQTT parameters to fit your application: - - |2| - -| The “mqttServer” refers to the MQTT-Broker, we use the free MQTT sandbox - “test.mosquitto.org” for testing. -| “clientId” is an identifier for MQTT-Broker to identify the connected device. -| “publishTopic” is the topic of the published message, we use “outTopic” in the - example. The devices subscribe to “outTopic” will receive the message. -| “publishPayload” is the content to be published. -| “subscribeTopic” is to tell MQTT-broker which topic we want to subscribe to. - -| Next, compile the code and upload it to Ameba. Press the reset button, then - open the serial monitor - - |3| - -| After Ameba is connected to MQTT server, it sends the message “hello world” to - “outTopic”. To see the message, use another MQTT client. Refer to the - MQTT_Basic example guide on how to setup a PC-based MQTT client. - -| If you wish to use TLS client authentication in addition to server - authentication, you will need to generate an OpenSSL private key and - obtain a signed certificate from the server. For testing purposes, - signed certificates can be obtained from test.mosquitto.org by following - the guide at https://test.mosquitto.org/ssl/. - -| Replace the character strings “certificateBuff” and “privateKeyBuff” with your - signed certificate and OpenSSL private key, ensuring that they are formatted - the same way as the shown in the example code. Also uncomment the highlighted - code to enable client authentication, and to change the MQTT port number. - - |4| - - |5| - -.. |1| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_Over_TLS/image1.png - :width: 668 - :height: 1028 - :scale: 70 % -.. |2| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_Over_TLS/image2.png - :width: 645 - :height: 846 - :scale: 90 % -.. |3| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_Over_TLS/image3.png - :width: 633 - :height: 476 - :scale: 100 % -.. |4| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_Over_TLS/image4.png - :width: 645 - :height: 846 - :scale: 100 % -.. |5| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_Over_TLS/image5.png - :width: 791 - :height: 846 - :scale: 80 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Set up MQTT Client to Communicate with Broker.rst b/bak/ambd/_common/Example_Guides/MQTT/MQTT - Set up MQTT Client to Communicate with Broker.rst deleted file mode 100644 index 4af420e..0000000 --- a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Set up MQTT Client to Communicate with Broker.rst +++ /dev/null @@ -1,124 +0,0 @@ -#################################################### -MQTT - Set up MQTT Client to Communicate with Broker -#################################################### - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Intro to MQTT** -:raw-html:`

` - -MQTT (Message Queuing Telemetry Transport) is a protocol proposed by IBM -and Eurotech. The introduction in `MQTT Official -Website `__: MQTT is a machine-to-machine -(M2M)/”Internet of Things” connectivity protocol. It was designed as an -extremely lightweight publish/subscribe messaging transport. We can say -MQTT is a protocol designed for IoT. MQTT is based on TCP/IP and -transmits/receives data via publish/subscribe. Please refer to the -figure below: - - |1| - -In the operation of MQTT, there are several roles: - -- **Publisher**: Usually publishers are the devices equipped with sensors - (ex. Ameba). Publishers uploads the data of the sensors to - MQTT-Broker, which serves as a database with MQTT service. - -- **Subscriber**: Subscribers are referred to the devices which receive and - observe messages, such as a laptop or a mobile phone. - -- **Topic**: Topic is used to categorized the messages, for example the - topic of a message can be “PM2.5” or “Temperature”. Subscribers - can choose messages of which topics they want to receive. - -:raw-html:`

` -**Preparation** -:raw-html:`

` - -- AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -| In this example, we connect Ameba to MQTT-Broker. Then send messages as - publisher and receive messages from MQTT-Broker as subscriber. -| Open the MQTT example ``“File” → “Examples” → “AmebaMQTTClient” → - “MQTT_Basic”`` - - |2| - -| Please modify some WiFi-related parameters. -| And some information related to MQTT: - - |3| - -The “mqttServer” refers to the MQTT-Broker, we use the free MQTT sandbox -“test.mosquitto.org” for testing. - - - “clientId” is an identifier for MQTT-Broker to identify the connected device. - - “publishTopic” is the topic of the published message, we use “outTopic” in the example. The devices subscribe to “outTopic” - will receive the message. - - “publishPayload” is the content to be published. - - “subscribeTopic” is to tell MQTT-broker which topic we want to subscribe to. - -| Next, compile the code and upload it to Ameba. Press the reset button, then open the serial monitor - - |4|  - -| After Ameba is connected to MQTT server, it sends the message “hello world” to “outTopic”. -| To see the message, we need another MQTT client. -| Here we use a chrome plugin “MQTTLens” to be the MQTT client. You can find it in google webstore. - - |5| - - -Install and open the MQTTLens, click “+” next -to “Connection” on the left, and fill in the required information - - - **Connection Name**: Used to identify the connection, you can choose a - name you like. - - **Hostname**: The MQTT-Broker server, here we use “iot.eclipse.org” - - **Client ID**: We use the default randomly generated ID. - -| Then click “CREATE CONNECTION”. - - |6| - -| Since we have not registered the topic we want to listen to, we would not receive any messages now. -| Fill in “outTopic” in the “Topic” field and click “Subscribe”. -| Wait for Ameba to send next message (or you can press the reset button). Then you can see the - “hello world” message show up. - - |7| - -.. |1| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image1.png - :width: 1144 - :height: 751 - :scale: 50 % -.. |2| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image2.png - :width: 683 - :height: 1006 - :scale: 70 % -.. |3| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image3.png - :width: 683 - :height: 856 - :scale: 70 % -.. |4| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image4.png - :width: 704 - :height: 355 - :scale: 100 % -.. |5| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image5.png - :width: 1010 - :height: 744 - :scale: 70 % -.. |6| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image6.png - :width: 1208 - :height: 834 - :scale: 60 % -.. |7| image:: /media/ambd_arduino/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image7.png - :width: 1217 - :height: 845 - :scale: 60 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Upload PM2.5 Data to LASS System.rst b/bak/ambd/_common/Example_Guides/MQTT/MQTT - Upload PM2.5 Data to LASS System.rst deleted file mode 100644 index 4de3ef1..0000000 --- a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Upload PM2.5 Data to LASS System.rst +++ /dev/null @@ -1,133 +0,0 @@ -######################################## -MQTT - Upload PM2.5 Data to LASS System -######################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Intro to LASS** -:raw-html:`

` - -The LASS stands for “Location Aware Sensor System”. It is an open -project and was started only for the interest of public welfare. Find -detailed -introduction `here `__. -Practically, LASS is based on MQTT protocol to collect all kinds of -uploaded data, and for those who need these data can subscribe top as -well. -Find more LASS information at their `official hackpad `__. - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - PlanTower PMS3003 or PMS5003 x1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we use applications mentioned at our website, -including: - -- `MQTT `__: - a MQTT-Broker to connect to LASS. The Client is “FT1_0XXXX”, the - XXXX are the four last digits of Ameba’s Wi-Fi MAC, and the - outTopic is “LASS/Test/Pm25Ameba/**clientID**\ “, where clientID - is the actual Ameba’s MQTT client ID. - -- `NTP `__: uploaded - data must have time notation - -- `PM2.5 `__: uploaded - data includes PM2.5 information - -Open the example. ``“File” → “Examples” → “AmebaMQTTClient” → -“lass_basic”`` - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image1.png - :align: center - :width: 712 - :height: 1066 - -This example requires internet connection, so make sure you fill in SSID -and PASS into AP information that you wish to connect. -Also, LASS requires GPS information. There is no GPS sensor -included in this example, so you must manually provide GPS information. -Use Google Map to find the coordinates you plan to place your Ameba. You -can see in this example that the latitude is 24.7814033, and the -longitude is 120.9933676 - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image2.png - :align: center - :width: 959 - :height: 668 - -Fill in GPS info at ``gps_lat`` and ``gps_lon``. - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image3.png - :align: center - :width: 679 - :height: 843 - :scale: 83 % - -Then connect sensors according to UART-PlanTower PMS3003 wiring example. - -**AMB21 / AMB22**: - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image4-1.png - :align: center - :width: 1144 - :height: 781 - :scale: 89 % - -**AMB23**: - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image4-2.png - :align: center - :width: 914 - :height: 783 - :scale: 89 % - -**BW16**: - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image4-3.png - :align: center - :width: 968 - :height: 738 - :scale: 94 % - -**BW16-TypeC**: - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image4-4.png - :align: center - :width: 882 - :height: 758 - :scale: 92 % - -Compile the code and upload it to Ameba. After pressing the Reset button, -Ameba will attempt to read PM2.5 data every minute and upload it to LASS -MQTT-Broker. Open Serial Monitor to see the uploaded data, including client -id, topic, and current PM2.5 status. - - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image5.png - :align: center - :width: 649 - :height: 517 - -We can also use MQTTlens to verify if the data is properly uploaded. -Enter “gpssensor.ddns.net” as the MQTT-Broker server and “LASS/Test/PM25/live” -as the subscribe topic to receive data. - -The time uses UTC format, and the PM2.5 data stores in s-d0. In the figure, -s_d0 = 9 represents that the PM2.5 is 9, meaning that the entire publish/subscribe -process is working successfully. - -.. image:: /media/ambd_arduino/MQTT_Upload_PM2.5_Data_To_LASS_System/image6.png - :align: center - :width: 1217 - :height: 839 - :scale: 83 % diff --git a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Use Amazon AWS IoT Shadow Service.rst b/bak/ambd/_common/Example_Guides/MQTT/MQTT - Use Amazon AWS IoT Shadow Service.rst deleted file mode 100644 index 1acf672..0000000 --- a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Use Amazon AWS IoT Shadow Service.rst +++ /dev/null @@ -1,375 +0,0 @@ -######################################### -MQTT - Use Amazon AWS IoT Shadow Service -######################################### - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -| **Introduction** -| Amazon AWS IoT is a cloud IoT service platform: -| Amazon AWS IoT is a platform that enables you to connect devices to AWS - Services and other devices, secure data and interactions, process and - act upon device data, and enable applications to interact with devices - even when they are offline. (https://aws.amazon.com/iot/how-it-works/) -| The service architecture of AWS IoT: -| |1| -| (Picture from http://docs.aws.amazon.com/iot/latest/developerguide/aws-iot-how-it-works.html ) -| In the architecture, Ameba belongs to the upper-left “Things” block. A - TLS secure channel will be established between “Things” and the MQTT - Message Broker. Afterwards, “Things” and “Message Broker” communicate - using MQTT Protocol via this secure channel. Behind the “Message - Broker”, the “Thing Shadows” keeps messages temporarily when Ameba is - offline, and sends the control message to Ameba next time it is - connected. The “Rules Engine” allows you to place restrictions to the - behavior of Things or to connect Things to other services of Amazon. - -| **AWS Management Console** - -| First, create an account and sign up for AWS IoT service:https://aws.amazon.com/ -| Afterwards, log in to the Amazon Management Console and click “IoT Core” found under services → - Internet of Things. - - |2| - -| Then you will enter the home page of AWS IoT. To offer the best service quality, - Amazon offers servers in different regions for users to choose from. -| Click the region dropdown menu at the upper-right: - - |3| - -| Choose a nearby region. - - |4| - -| Then from Services, go to Onboard then Get Started. - - |6| - -| Enter the main page of AWS IoT. Under the Onboard a device, click Get started. - - |5| - -| Click Create single thing - - |7| - -| Fill in “ameba” on the name field. Attributes represent the status of Ameba. - - |8| - -| Under the searchable thing attributes. The value of the attributes can be updated - directly by Ameba or by the control side and control side can request Ameba to - set the attribute to desired value. -| Here we add an attribute named “led” with value “0” and click “Next”. - - |9| - -| Click Skip creating a certificate at this time and then Create thing - - |10| - -| Next, click Policy¸ and create a policy. Policy is used to restrict the functions - that a “thing” can do, it can limit the MQTT actions or specific topic that can - be performed. Learn more about policy: -| http://docs.aws.amazon.com/iot/latest/developerguide/authorization.html -| Here we do not place policy on Ameba. Fill in “amebaPolicy” in the Name field, - “iot:*” in Action field and “*” in resources field. Then “Allow”. Finally, - click “Create”. - - |11| - -| Next, we have to setup the TLS certificate. You can choose to user-defined or generate a - certificate by AWS IoT. In this example we click Create Certificate to generate a TLS - certificate. - - |12| - -| You can see 4 Links. Please download each of the link, “public key”, “private key”, - “Certificate” and “rootCA”. After downloading the 4 files, click Done and go back to - the certificate main page. - - |13| - -| Click Attach a policy in the Actions dropdown menu. - - |14| - -| Choose amebaPolicy and click attach. - - |15| - -| Then go back to the “Actions” drop-down menu at the top right of the - certificates homepage, click on “Attach thing”, select the thing - “ameba” you just created when the window below appears, then click on - “Attach” - - |16| - -| Go back to certificate main page and click Certificate and click Activate - in the Actions drop down menu. - - |17| - -| Next, click Manage, and click Things, then click “ameba” the thing we created just now. -| Click on Interact and View settings. - - |18| - -| Find out the information of Rest API Endpoint to set Amazon Alexa: - - - REST API endpoint: In the value “https://a1a7oo4baosgyy.iot.us-east-1.amazonaws.com/things/ameba/shadow”, - the part “a1a7oo4baosgyy.iot.us-east-1.amazonaws.com” is the MQTT Broker server address. - - MQTT topic:The value “$aws/things/ameba/shadow/update” represents the MQTT topic we will use in the AWS - IoT Shadow service (if we use MQTT only, without AWS IoT Shadow service, then we can specify other topic - name). It is recommended to use “$aws/things/ameba/shadow/update” here. - -**Ameba setting** - -| Open ``“File” → “Examples” → “AmebaMQTTClient” → “Amazon_AWS_IoT_Basic”`` -| In the sample code, modify the highlighted snippet to reflect your WiFi - network settings. - - |19| - -| Then fill in the “thing” name “ameba”. - - |20| - -| And the MQTT Broker server address we found earlier in AWS IoT. - - |21| - -| Next, fill in the root CA used in TLS. Download and make sure the - downloaded root CA contents conforms to the root CA used in the - sketch. - - |22| - -| Next, fill in the certificate we created in the AWS IoT Console (i.e., - client certificate), usually its file name ends with - “-certificate.pem.crt” (e.g., “efae24a533-certificate.pem.crt”). Open - the certificate with a text editor, and adjust its format as follows - to use in the sketch: -| – Add the new line character “\n” at the end of each line. -| – Add double-quote at the beginning and the end of each line. -| – To concatenate each line as a string, add “\” at the end of each - line. -| – The last line ends with semicolon. -| Adjust the format of the private key in the same way and add it to - privateKeyBuff. - - |23| - -**Compile and run** - -| Upload the code and press the reset button on Ameba once the upload is - finished. -| Open the serial monitor in the Arduino IDE and observe as Ameba - connects to the AWS IoT server and sends updates on the LED state - variable. - - |24| - -**Alternatives** - -Ameba can also retrieve the current LED status variable from the AWS -shadow. This is done by sending a message to the “shadow/get” topic. -Refer to the Amazon_AWS_IoT_with_ACK example code for more information. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -| Change led state: -| In this example, we use GPIO interface to control the led. We set - led_pin to 10 and led_state to 1 by default in the sample code. - -.. code-block:: C - - pinMode(led_pin, OUTPUT); - digitalWrite(led_pin, led_state); - -| Set up certificate: -| Note that we use the WiFiSSLClient type of wifiClient. - -.. code-block:: C - - WiFiSSLClient wifiClient; - -| WiFiSSLClient inherits Client, so it can be passed as the parameter of - PubSubClient constructor. -| Next, set up TLS certificate required in connection. - -.. code-block:: C - - wifiClient.setRootCA((unsigned char*)rootCABuff); - wifiClient.setClientCertificate((unsigned char*)certificateBuff,(unsigned char*)privateKeyBuff); - -| Configure MQTT Broker server -| Then MQTT PubClient set MQTT Broker server to connect - -.. code-block:: C - - client.setServer(mqttServer, 8883); - client.setCallback(callback); - -| Connect to MQTT Broker server: -| In ``loop()``, call ``reconnect()`` function and try to connect to MQTT Broker - server and do the certificate verification. - -.. code-block:: C - - while (!client.connected()) { - -| Subscribe & Publish -| Next, subscribe to topics. - -.. code-block:: C - - for (int i=0; i<5; i++) { - client.subscribe(subscribeTopic[i]); - } - -| There are some common topics: -| “$aws/things/ameba/shadow/update/accepted”, -| “$aws/things/ameba/shadow/update/rejected”, -| “$aws/things/ameba/shadow/update/delta”, -| “$aws/things/ameba/shadow/get/accepted”, -| “$aws/things/ameba/shadow/get/rejected” -| Related documentation: -| http://docs.aws.amazon.com/iot/latest/developerguide/thing-shadow-data-flow.html - -| Then publish current status:: - -.. code-block:: C - - sprintf(publishPayload, - "{\"state\":{\"reported\":{\"led\":%d}},\"clientToken\":\"%s\"}", - led_state, clientId); - -.. code-block:: C - - client.publish(publishTopic, publishPayload); - -| Listen to topic and make response: -| In the callback function, we listen to the 5 subscribed topics and - check if there are messages of “/shadow/get/accepted”: - -.. code-block:: C - - if (strstr(topic, "/shadow/get/accepted") != NULL) { - -If there is, the message is from the control side. If the attribute -state in the message is different from current state, publish the new -state. - -.. code-block:: C - - updateLedState(desired_led_state); - -.. |1| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image1.png - :width: 900 - :height: 400 - :scale: 90 % -.. |2| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image2.png - :width: 1898 - :height: 9 - :scale: 50 % -.. |3| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image3.png - :width: 1279 - :height: 984 - :scale: 50 % -.. |4| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image4.png - :width: 1279 - :height: 984 - :scale: 50 % -.. |5| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image5.png - :width: 1898 - :height: 830 - :scale: 50 % -.. |6| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image6.png - :width: 1279 - :height: 986 - :scale: 50 % -.. |7| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image7.png - :width: 1898 - :height: 830 - :scale: 50 % -.. |8| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image8.png - :width: 1898 - :height: 830 - :scale: 50 % -.. |9| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image9.png - :width: 1898 - :height: 830 - :scale: 50 % -.. |10| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image10.png - :width: 1898 - :height: 830 - :scale: 50 % -.. |11| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image11.png - :width: 1898 - :height: 830 - :scale: 50 % -.. |12| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image12.png - :width: 1599 - :height: 800 - :scale: 50 % -.. |13| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image13.png - :width: 1269 - :height: 616 - :scale: 50 % -.. |14| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image19.png - :width: 1898 - :height: 830 - :scale: 50 % -.. |15| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image20.png - :width: 1898 - :height: 830 - :scale: 50 % -.. |16| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image21.png - :width: 1898 - :height: 902 - :scale: 50 % -.. |17| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image18.png - :width: 1279 - :height: 435 - :scale: 50 % -.. |18| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image22.png - :width: 1920 - :height: 753 - :scale: 50 % -.. |19| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image24.png - :width: 639 - :height: 846 - :scale: 70 % -.. |20| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image25.png - :width: 639 - :height: 846 - :scale: 100 % -.. |21| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image26.png - :width: 639 - :height: 846 - :scale: 100 % -.. |22| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image27.png - :width: 639 - :height: 846 - :scale: 100 % -.. |23| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image28.png - :width: 639 - :height: 846 - :scale: 100 % -.. |24| image:: /media/ambd_arduino/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image29.png - :width: 851 - :height: 546 - :scale: 50 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Use Google Cloud IoT.rst b/bak/ambd/_common/Example_Guides/MQTT/MQTT - Use Google Cloud IoT.rst deleted file mode 100644 index 08dc36f..0000000 --- a/bak/ambd/_common/Example_Guides/MQTT/MQTT - Use Google Cloud IoT.rst +++ /dev/null @@ -1,341 +0,0 @@ -########################################################################## -MQTT - Use Google Cloud IoT -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - -- AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Google Cloud IoT Configuration** -:raw-html:`

` - - 1. Select or create a Cloud Platform project In the Google Cloud - Console, select an existing project or create a new project. You will - need a **Project ID** to use with Ameba. - - |1| - - If creating a new - project, enter a project name, and take note of the **Project ID** generated. - - |image1| - - 2. Enable billing for your project Billing - needs to be enabled for your project to use Google Cloud Platform - features. Follow the guide in Google cloud documentation to enable - billing. https://cloud.google.com/billing/docs/how-to/modify-project  - 3. Enable the Cloud IoT Core API In Google Cloud console, click on the top - left menu button and search for IoT Core. - - |image2| - - Click enable to - activate Google Cloud IoT API for your project. - - |image3| - - 4. Create a Cloud Pub\/Sub topic In Google Cloud console, click on the top left menu - button and search for Pub\/Sub. - - |image4| - - Create a new topic for your - project and give it a suitable topic ID. - - |image5| - - - |image6| - - After the - topic is created, go to the permissions tab of the info panel, and add - “cloud-iot@system.gserviceaccount.com” with the role of “Pub\/Sub - Publisher”. - - |image7| - - |image8| - - |image9| - - 5.Create a device registry Go back to the IoT Core settings page and create a new - registry. - - |image10| - - |image11| - - Choose a suitable **Registry ID** and - **\ in which to store data. Remember - the **Registry ID** and **Region**\ for use with Ameba later. For the - Pub/Sub topic, select the topic created in the previous - step. - - |image12| - - 6. Create a public/private key pair Using Openssl in a - terminal in Windows/Linux/MacOs, run the following commands to generate - a private and public key pair. Two files will be created by these - commands, “ec_private.pem” containing the private key, and - “ec_public.pem” containing the public key. - -.. code-block:: console - - $ openssl ecparam -genkey -name prime256v1 -noout -out ec_private.pem - $ openssl ec -in ec_private.pem -pubout -out ec_public.pem - - -|image13| - - Run the next command to extract out the private key, and - remember the highlighted string of hexadecimal numbers for use with - Ameba later. - -.. code-block:: console - - $ openssl ec -in ec_private.pem -noout -text - -|image14| - - 7. Create a device Go back to the IoT Core settings page and - create a new device. - - |image15| - - Give the device a suitable **Device ID** and remember it for use with - Ameba later. - - |image16| - - In the - authentication section of the additional options, upload the previously - generated “ec_public.pem” public key. - - |image17| - - 8. Create a Cloud - Pub/Sub subscription To observe messages sent by Ameba, create a - subscription in Pub/Sub. - - |image18| - - Choose a suitable subscription ID - and select the previously created topic. - - |image19| - -:raw-html:`

` -**Example** -:raw-html:`

` - -| Open the example in ``“File” → “Examples” → “AmebaMQTTClient” → - “Google_Cloud_IoT”``. - - |image20| - -| Enter the required information in the highlighted sections below. - - |image21| - -| In the yellow section, enter the - SSID and password required to connect to your WiFi network. In the green - section, enter the Project ID, server Region, Registry ID and Device ID - previously configured in Google Cloud console. In the blue section, - enter the hexadecimal string previously extracted from the private key. - Upload the code and press the reset button on Ameba once the upload is - finished. Open the serial monitor and observe as Ameba connects and - sends messages to Google Cloud IoT. - - |image22| - -| In Google Cloud console, go to Pub/Sub subscriptions, select the previously - created subscription, and click view messages. Here you can view the messages - sent by Ameba. - - - |image23| - - - |image24| - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -In ``setup()``, we set up RootCA which is required to form a TLS connection -with Google’s servers. - -.. code-block:: c - - wifiClient.setRootCA((unsigned char*)rootCABuff); - -In ``loop()``, each loop checks the Internet status and re-connect to it -when the environment has a problem. - -.. code-block:: c - - if (WiFi.status() != WL_CONNECTED) { - while (WiFi.begin(ssid, pass) != WL_CONNECTED) - { - delay(1000); - } - Serial.println("Connected to wifi"); - } - -To publish messages, mqtt_id , clientPass and pub_topic are required. -mqtt_id is generated by printing the project ID, server location, -registry ID and device ID in the required format: - -.. code-block:: c - - mqtt_id = (char *)malloc(strlen("projects/") + strlen(project_id) + strlen("/locations/us-central1/registries/") + strlen(registry_id) + strlen("/devices/") + strlen(device_id) + 1); - sprintf(mqtt_id, "projects/%s/locations/us-central1/registries/%s/devices/%s", project_id, registry_id, device_id); - -``clientPass`` is generated using a JSON web token (JWT) generator function, -which requires the project ID and current time, and signs it with the -private key: - -.. code-block:: c - - clientPass = CreateJwt(project_id, timeClient.getEpochTime(), priv_key); - -``pub_topic`` is generated by printing the project ID and topic in the -required format: - -.. code-block:: c - - pub_topic = (char *)malloc(strlen("/devices/") + strlen(device_id) + strlen("/events") + 1); - sprintf(pub_topic, "/devices/%s/events", device_id); - -MQTT Server setting: - -.. code-block:: c - - client.setServer(GOOGLE_MQTT_SERVER, GOOGLE_MQTT_PORT); - client.setPublishQos(MQTTQOS1); - client.waitForAck(true); - -Connect to google cloud and publish messages: - -.. code-block:: c - - if (client.connect(mqtt_id, clientUser, clientPass.c_str())){ - // ... - for(int i = 0; i < count; i++){ - // ... - sprintf(payload, "This is Ameba's %d message!!", i); - ret = client.publish(pub_topic, payload); - // ... - } - // ... - client.disconnect(); - } - free(mqtt_id); - free(pub_topic); - -.. |1| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image1.png - :width: 1352 - :height: 1125 - :scale: 50 % -.. |image1| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image2.png - :width: 1181 - :height: 540 - :scale: 50 % -.. |image2| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image3.png - :width: 1352 - :height: 1125 - :scale: 50 % -.. |image3| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image4.png - :width: 1352 - :height: 1125 - :scale: 50 % -.. |image4| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image5.png - :width: 1352 - :height: 1125 - :scale: 50 % -.. |image5| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image6.png - :width: 1352 - :height: 1125 - :scale: 50 % -.. |image6| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image7.png - :width: 1352 - :height: 1125 - :scale: 50 % -.. |image7| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image8.png - :width: 1101 - :height: 916 - :scale: 50 % -.. |image8| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image9.png - :width: 1622 - :height: 1125 - :scale: 50 % -.. |image9| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image10.png - :width: 1622 - :height: 1125 - :scale: 50 % -.. |image10| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image3.png - :width: 1321 - :height: 916 - :scale: 50 % -.. |image11| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image11.png - :width: 1622 - :height: 1125 - :scale: 25 % -.. |image12| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image12.png - :width: 1321 - :height: 916 - :scale: 50 % -.. |image13| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image13.png - :width: 963 - :height: 694 - :scale: 50 % -.. |image14| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image14.png - :width: 963 - :height: 694 - :scale: 50 % -.. |image15| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image15.png - :width: 1622 - :height: 1125 - :scale: 50 % -.. |image16| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image16.png - :width: 1380 - :height: 1125 - :scale: 50 % -.. |image17| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image17.png - :width: 1380 - :height: 1125 - :scale: 50 % -.. |image18| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image18.png - :width: 1380 - :height: 1125 - :scale: 50 % -.. |image19| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image19.png - :width: 1153 - :height: 940 - :scale: 50 % -.. |image20| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image20.png - :width: 737 - :height: 1202 - :scale: 50 % -.. |image21| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image21.png - :width: 737 - :height: 1062 - :scale: 50 % -.. |image22| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image22.png - :width: 732 - :height: 627 - :scale: 50 % -.. |image23| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image23.png - :width: 1586 - :height: 1125 - :scale: 50 % -.. |image24| image:: /media/ambd_arduino/MQTT_Use_Google_Cloud_IoT/image24.png - :width: 1586 - :height: 1125 - :scale: 50 % diff --git a/bak/ambd/_common/Example_Guides/PWM/PWM - Play Music by Buzzer.rst b/bak/ambd/_common/Example_Guides/PWM/PWM - Play Music by Buzzer.rst deleted file mode 100644 index 0ae807d..0000000 --- a/bak/ambd/_common/Example_Guides/PWM/PWM - Play Music by Buzzer.rst +++ /dev/null @@ -1,84 +0,0 @@ -########################################################################## -PWM - Play Music by Buzzer -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Buzzer x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -A sound is composed of volume, tone and timbre. Volume is determined by -the amplitude of the sound wave. Tone is determined by the frequency of -the sound wave. Timbre is determined by the waveform of the sound wave. - -In this example, we use PWM to control the buzzer to emit sound with -desired tone. As PWM outputs square wave, if we wish to emit tone C4 -(frequency=262Hz), we have to make PWM to output square wave with -wavelength 1/262 = 3.8ms: - -.. image:: /media/ambd_arduino/PWM_Play_Music_By_Buzzer/image1.png - :align: center - :width: 710 - :height: 184 - -We use PWM to output sound wave with different frequency, so as to -play music by the buzzer. - -Connect the buzzer to the PWM output pin shown in the following -diagrams. - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/PWM_Play_Music_By_Buzzer/image2.png - :align: center - :width: 1080 - :height: 926 - :scale: 75 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/PWM_Play_Music_By_Buzzer/image3.png - :align: center - :width: 806 - :height: 686 - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/PWM_Play_Music_By_Buzzer/image3-1.png - :align: center - :width: 905 - :height: 678 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/PWM_Play_Music_By_Buzzer/image3-2.png - :align: center - :width: 858 - :height: 712 - -Open the example code in ``“Examples” → “AmebaAnalog” → “TonePlayMelody”`` -Compile and upload to Ameba, press the reset button. Then you can hear -the buzzer playing music. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -Ameba implement the tone() and noTone() API of Arduino: -https://www.arduino.cc/en/Reference/Tone -https://www.arduino.cc/en/Reference/NoTone - -In the sample code, we initiate a melody array, which stores the tones -to make. Another array, noteDurations, contains the length of each tone, -4 represents quarter note (equals to 3000ms/4 = 750ms, and plus an extra -30% time pause), 8 represents eighth note. - diff --git a/bak/ambd/_common/Example_Guides/PWM/PWM - Servo Control.rst b/bak/ambd/_common/Example_Guides/PWM/PWM - Servo Control.rst deleted file mode 100644 index 1785f6a..0000000 --- a/bak/ambd/_common/Example_Guides/PWM/PWM - Servo Control.rst +++ /dev/null @@ -1,86 +0,0 @@ -############################################# -PWM - Servo Control -############################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Servo x 1 (Ex. Tower Pro SG90) - -:raw-html:`

` -**Example** -:raw-html:`

` - -A typical servo has 3 wires, the red wire is for power, black or brown -one should be connected to GND, and the other one is for signal data. We -use PWM signal to control the rotation angle of the axis of the servo. -The frequency of the signal is 50Hz, that is length 20ms. Each servo -defines its pulse bandwidth, which is usually 1ms~2ms. - -To control the rotation angle, for example if 1ms-length pulse rotates -the axis to degree 0, then 1.5 ms pulse rotates the axis to 90 degrees, -and 2 ms pulse rotates the axis to 180 degrees. Furthermore, a servo -defines the “dead bandwidth”, which stands for the required minimum -difference of the length of two consecutive pulse for the servo to work. - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/PWM_Servo_Control/image1.png - :align: center - :width: 1249 - :height: 974 - :scale: 61 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/PWM_Servo_Control/image2.png - :align: center - :width: 800 - :height: 633 - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/PWM_Servo_Control/image2-1.png - :align: center - :width: 809 - :height: 598 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/PWM_Servo_Control/image2-2.png - :align: center - :width: 837 - :height: 620 - -Open the example, ``“File” → “Examples” → “AmebaAnalog” → -“ServoSweep”`` - -This example makes the servo to rotate from degree 0 to 180, and then -rotate back to degree 0. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -The Servo API of Ameba is similar to the API of Arduino. To distinguish -from the original API of Arduino, we name the header file “AmebaServo.h” -and the Class “AmebaServo”, the usage is identical to the Arduino API. - -The default pulse bandwidth of Arduino Servo is 0.5ms~2.4ms, which is -the same as Tower Pro SG90. Therefore, we set the attached pin directly: - -.. code-block:: C - - myservo.attach(9); - -Next, rotate the axis to desired position: - -.. code-block:: C - - myservo.write(pos); - diff --git a/bak/ambd/_common/Example_Guides/UART/UART - Communicate with PC over USB to Serial Module.rst b/bak/ambd/_common/Example_Guides/UART/UART - Communicate with PC over USB to Serial Module.rst deleted file mode 100644 index 17c30ab..0000000 --- a/bak/ambd/_common/Example_Guides/UART/UART - Communicate with PC over USB to Serial Module.rst +++ /dev/null @@ -1,152 +0,0 @@ -########################################################################## -UART - Communicate with PC over USB to Serial Module -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Introduction of UART** -:raw-html:`

` - -UART uses two wire, one for transmitting and the other one for -receiving, so the data transmission is bidirectional. The -communication uses a predefined frequency (baud rate) to transmit -data. In Arduino, UART is called “Serial”. There is only one -hardware UART on Arduino Uno and it is primarily used to read the -log and messages printed by Arduino (so it is also called “Log -UART”). If we use the hardware UART for other purposes, the Log -UART does not have resources to function. To provide more UART -connections, it is possible to use a GPIO pin to simulate the -behavior of UART with a software approach, this is called Software -Serial. Ameba is equipped with several hardware UART ports, but it -is also compatible with the Software Serial library. - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - USB to TTL Adapter x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we use UART to connect USB to TTL adapter to Ameba. -USB to TTL adapter sends data to Ameba, the data would be returned by -Ameba, and showed on the screen. - -**Install USB to TTL Adapter** - -USB to TTL adapter converts USB to serial interface. Normally, there -are at least 4 pins on the adapter, that is 3V3 (or 5V), GND, TX and -RX. Generally, installing the driver for the USB to TTL adapter would -be required before using it. If the adapter uses the chip of FTDI, -Windows will search and install the driver automatically, otherwise, -you may need to install corresponding driver yourself. -Afterwards, open device manager. You can find corresponding serial -port number of the USB to TTL adapter: - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image1.png - :align: center - :width: 456 - :height: 370 - - -**Executing the Example** - -Open the “SoftwareSerialExample” example in ``“File” → “Examples” → -“AmebaSoftwareSerial” → “SoftwareSerial_Basic”``: - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image2.png - :align: center - :width: 683 - :height: 1006 - - -Connect the wire as the following diagrams show. The TX pin of USB to -TTL adapter is connected to the RX of Ameba, and the RX pin of USB to -TTL adapter is connected to the TX of Ameba. - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image3.png - :align: center - :width: 1285 - :height: 1040 - :scale: 67 % - - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image3-1.png - :align: center - :width: 1285 - :height: 1040 - :scale: 67 % - - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image3-3.png - :align: center - :width: 1020 - :height: 705 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image3-4.png - :align: center - :width: 602 - :height: 438 - -Next, open a serial port terminal, such as Putty or Tera Term. (Putty is -used in this example). Open the Putty window, choose “Serial” in -connection type, and specify the port number of the USB to TTL adapter -(e.g. COM8). In the speed field, fill in the baud rate of this -connection. Note that both sides of the connection should use the same -baud rate. In this example we set baud rate 4800. - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image4.png - :align: center - :width: 466 - :height: 448 - -Next, select “Serial” on the left side. Set data bits to 8, stop bits to -1, parity to none, and flow control to none. - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image5.png - :align: center - :width: 466 - :height: 448 -  -Then click Open and press the reset button on Ameba. You can see the -“Hello, world?” message appears in Putty. If characters are typed into -Putty, the input characters would be sent to Serial RX of Ameba by TX of -USB to TTL Adapter, and returned by Serial TX of Ameba. Finally, RX of -USB to TTL Adapter receives the returned characters and prints them in -Putty. Therefore, if you insert “I am fine”, you will get something like -this: - -.. image:: /media/ambd_arduino/UART_Communicate_with_PC_over_USB_to_Serial_Module/image6.png - :align: center - :width: 395 - :height: 248 - - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -First, use ``SoftwareSerial:begin(speed)`` to set the baud rate for the -serial communication: -https://www.arduino.cc/en/Reference/SoftwareSerialBegin - -Use ``write()`` to send data, and use ``SoftwareSerial:available()`` to get the -number of bytes available for reading from a software serial port: -https://www.arduino.cc/en/Reference/SoftwareSerialAvailable - -If there are data available to read, use read() to read from serial -port. - diff --git a/bak/ambd/_common/Example_Guides/UART/UART - PM2.5 Concentration in The Air.rst b/bak/ambd/_common/Example_Guides/UART/UART - PM2.5 Concentration in The Air.rst deleted file mode 100644 index 788cfb5..0000000 --- a/bak/ambd/_common/Example_Guides/UART/UART - PM2.5 Concentration in The Air.rst +++ /dev/null @@ -1,90 +0,0 @@ -######################################################### -UART - PM2.5 Concentration in The Air -######################################################### - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - PlanTower PMS3003 or PMS5003 x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -PMS3003 (or PMS5003) is a sensor of air quality, it can detect the -concentration of those 0.3 to 10 micrometer particulate matters in the -air. The sensor output its data via UART. - -The PMS3003 (or PMS5003) sensor detects the concentration value of PM 1.0, PM 2.5, PM 10. -Take PM 2.5 for example, it stands for the fine particles with a diameter of 2.5 -micrometers or less. - -Open the example in ``“File” → “Examples” → “AmebaSoftwareSerial” → “PMS3003_AirQuality”`` - -.. image:: /media/ambd_arduino/UART_PM2.5_Concentration_in_the_Air/image1.png - :align: center - :width: 777 - :height: 1006 - -There are 8 pins in PMS3003: - -.. image:: /media/ambd_arduino/UART_PM2.5_Concentration_in_the_Air/image2.png - :align: center - :width: 981 - :height: 869 - -PMS3003 requires 5V power, but the working voltage of its IC is 3.3C. -Therefore, the working voltage of Reset, TX, RX, Set are 3.3 as well. If -the “Set” pin is pulled to high, the PMS3003 is put to operating mode. -If the “Set” pin is pulled low, the PMS3003 is put to standby mode. - -TX/RX pins are for UART connection. Under operating mode, PMS3003 output -the data it reads continuously. Each data is of 32 byte, please refer to -the following article for detailed data format -information:  - -https://www.dfrobot.com/wiki/index.php?title=PM2.5_laser_dust_sensor_SKU:SEN0177  - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_PM2.5_Concentration_in_the_Air/image3.png - :align: center - :width: 602 - :height: 440 - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_PM2.5_Concentration_in_the_Air/image3-1.png - :align: center - :width: 602 - :height: 567 - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_PM2.5_Concentration_in_the_Air/image3-2.png - :align: center - :width: 602 - :height: 520 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_PM2.5_Concentration_in_the_Air/image3-3.png - :align: center - :width: 602 - :height: 562 - -In this example, we do not use the “Set” and “Reset” pins. - -Compile the code and upload it to Ameba. After pressing -the Reset button, Ameba starts to output the PM 2.5 data to serial -monitor. - -.. image:: /media/ambd_arduino/UART_PM2.5_Concentration_in_the_Air/image4.png - :align: center - :width: 649 - :height: 410 diff --git a/bak/ambd/_common/Example_Guides/UART/UART - Retrieve GPS Position.rst b/bak/ambd/_common/Example_Guides/UART/UART - Retrieve GPS Position.rst deleted file mode 100644 index 0063f45..0000000 --- a/bak/ambd/_common/Example_Guides/UART/UART - Retrieve GPS Position.rst +++ /dev/null @@ -1,134 +0,0 @@ -########################################################################## -UART - Retrieve GPS Position -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - `Adafruit Ultimate GPS Breakout `__ x 1 - (Refer to `official document `__) - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we use Adafruit Ultimate GPS Breakout. Its data format -is pure text, so we can connect it to USB to TTL Adapter and observe the -output. - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image1.png - :align: center - :width: 1252 - :height: 294 - :scale: 50 % - - - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image2.png - :align: center - :width: 649 - :height: 372 - - -It follows the NMEA sentence format (refer to http://aprs.gids.nl/nmea/) -The GPS signal is weak in indoor environment. -The status that the GPS signal is not received is called “not fix”. -Bring the GPS module outdoors, when the GPS signal is “fix”, -you would get message similar to the figure below. - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image3.png - :align: center - :width: 777 - :height: 425 - -In this example we are only interested in the “$GPRMC (Global Positioning Recommended -Minimum Coordinates)”:  -**$GPRMC,032122.000,A,2446.8181,N,12059.7251,E,0.39,78.89,270116,,,A*53**  -Each field is separated by a comma. - - - First field is the GMT time (Greenwich Mean Time), that is 032122.000 - in this example. The time format is HH:MM:SS.SSS, i.e., - 03:21:22.000. Note that the time zone and the daylight-saving time - adjustment should be handled on your own. - - - Second field represents the status code - - - V: Void (Invalid) - - A: Active, meaning the GPS signal is fix. - - - The third to sixth fields represent the geolocation - -In this example, 2446.8181,N represents 24 degrees 46.8181 minutes north -latitude, and 12059.7251,E represents 120 degrees 59.7251 minutes east -longitude. - -We can search **+24 46.8181’, +120 59.7251’** in Google map -to check whether the position is correct. - - .. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image4.png - :align: center - :width: 1028 - :height: 651 - - - The seventh field is relative speed(knot). 1 knot = 1.852km/hr, in - this example the relative speed is 0.39 knot. - - The eighth field is the moving angle, which is calculated by its - moving orbit. - - The ninth field is the date with format ddMMyy. In this example, - “270116” stands for day 27, January, year 2016. - - The last field is checksum. In the example we have \*53 as checksum. - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image5.png - :align: center - :width: 1295 - :height: 1049 - :scale: 57 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image5-1.png - :align: center - :width: 1100 - :height: 809 - :scale: 74 % - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image5-3.png - :align: center - :width: 842 - :height: 590 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image5-4.png - :align: center - :width: 602 - :height: 476 - -Open the example in ``“Files” → “Examples” → -“AmebaSoftwareSerial” → “Adafruit_GPS_parsing”``. - -Compile and upload to Ameba, then press the reset button. -The result will be output to Serial Monitor: - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image6.png - :align: center - :width: 649 - :height: 410 - - -.. image:: /media/ambd_arduino/UART_Retrieve_GPS_Position/image7.png - :align: center - :width: 649 - :height: 410 - - - diff --git a/bak/ambd/_common/Example_Guides/UART/UART - Set Callback Function For UART Communications.rst b/bak/ambd/_common/Example_Guides/UART/UART - Set Callback Function For UART Communications.rst deleted file mode 100644 index 8b8906a..0000000 --- a/bak/ambd/_common/Example_Guides/UART/UART - Set Callback Function For UART Communications.rst +++ /dev/null @@ -1,101 +0,0 @@ -############################################################################# -UART – Set Callback Function For UART Communications -############################################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - USB to TTL Adapter x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -This example shows how to set a callback function for UART communication -to process the UART data. - -A USB to TTL adapter is required for this example. Ensure that you have -the driver installed and connect it to the Ameba board as shown. - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Set_Callback_Function_For_UART_Communications/image1.png - :align: center - :height: 1130 - :scale: 61 % - - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Set_Callback_Function_For_UART_Communications/image1-1.png - :align: center - :width: 1006 - :height: 798 - :scale: 87 % - - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Set_Callback_Function_For_UART_Communications/image1-3.png - :align: center - :width: 1020 - :height: 705 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/UART_Set_Callback_Function_For_UART_Communications/image1-4.png - :align: center - :width: 602 - :height: 438 - - -Open the example in ``“File” → “Examples” → “AmebaSoftwareSerial” → -“SoftwareSerial_Irq_Callback”`` - -.. image:: /media/ambd_arduino/UART_Set_Callback_Function_For_UART_Communications/image2.png - :align: center - :width: 721 - :height: 1006 - - -Upload the code and press the reset button on Ameba once the upload is -finished. -Next, using a terminal program, such as TeraTerm or PuTTY, open a -serial port and configure it according to the settings. Make sure the -serial port number corresponds to the USB to TTL adapter. - - - Speed: 38400 - - Data: 8 bit - - Parity: none - - Stop bits: 1 bit - - Flow control: none - -.. image:: /media/ambd_arduino/UART_Set_Callback_Function_For_UART_Communications/image3.png - :align: center - :width: 665 - :height: 540 - - -Once the serial port is open, type in the terminal and press the enter -key, and you will see the corresponding output. - -.. image:: /media/ambd_arduino/UART_Set_Callback_Function_For_UART_Communications/image4.png - :align: center - :width: 665 - :height: 540 - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -``mySerial.setAvailableCallback(mySerialCallback);`` is used to set the -function mySerialCallback as a callback function for software serial. -When a new character is received, the callback function checks if the -character corresponds to the enter key, and releases the semaphore if it -is true, which in turn allows the main loop to print out all the -previously received characters. diff --git a/bak/ambd/_common/Example_Guides/WDT/Watchdog - Simple WDG Timer.rst b/bak/ambd/_common/Example_Guides/WDT/Watchdog - Simple WDG Timer.rst deleted file mode 100644 index 0e6fdbc..0000000 --- a/bak/ambd/_common/Example_Guides/WDT/Watchdog - Simple WDG Timer.rst +++ /dev/null @@ -1,90 +0,0 @@ -########################################################################## -Watchdog - Simple WDG Timer -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we will use this simple watchdog timer example runs on -the Ameba RTL8722 module to illustrate how to use the watchdog API. -Before we get into the details of the example, let’s briefly go through -the definition of Watchdog as well as it’s working principles. - -**Watchdog** - -Watchdog Timer (WDT) is a hardware timer that is used to detect the -occurrence of a software fault, then automatically generates a system -reset or a watchdog interrupt on the expiry of a programmed period. - -In layman terms, imagine in the situation while your micro-controller is -confused in an infinity loop, or any case like the micro-controller hang -while performing some tasks. The normal troubleshooting method would be -to press the reset button and jump out of the infinity loop. However, is -it practically impossible to do press on the button all time, therefore, -the watchdog timer that embedded inside the micro-controller would help -with this situation. - - |1| - -**Feed the Dog** - -| If you have a dog in your home. You need to feed that dog at a regular - interval. if you can’t feed one day, it will bite you! And likewise, - this is the working logic behind the watchdog timer. - -| In our example, we created 2 tasks that contain some loop that runs repeatedly, - one is called “Small_Task” and the other is called “Big_Task”. - We are enabling the watchdog timer is loaded with an initial value (5 seconds) - greater than the total delay in the “Small_Task”, but shorter than the “Big_Task”. -| For the successful case, the watchdog is being refreshed/feed within 5 seconds, - however, for the failed case, the loop is under processing and the watchdog is - not being fresh after 5 seconds, which triggers the watchdog (dog barks), - an interrupt is generated to reset the processor. Likewise, the watchdog timer - protects the micro-controller from the hanging case. - -| Then we move to the coding part for this example, for this example, - you will only need the RTL8722CSM/RTL8722DM/RTL8722DM MINI Board itself. - -| Firstly, make sure the correct Ameba development board is selected in - Arduino IDE: ``“Tools” → “Board” → “RTL8722CSM/RTL8722DM” (or “RTL8722DM MINI”)``. - Then open the “Watchdog Timer” example in ``“File” → “Examples” → “AmebaWatchdog” → - “Watchdog Timer”``: - - |2| - -| Upon successfully upload the sample code, open the serial monitor, - and press the reset button. You will find that the “Small_Task” can refresh the - watchdog within the 5 seconds (initialized in the watchdog timer). - However, the “Big_Task” will not be able to refresh the watchdog within 5 seconds, - which the watchdog “barks” then the microcontroller reset. - - |3| - - |4| - -.. |1| image:: /media/ambd_arduino/Watchdog_Simple_WDG_Timer/image1.png - :width: 907 - :height: 552 - :scale: 60 % -.. |2| image:: /media/ambd_arduino/Watchdog_Simple_WDG_Timer/image2.png - :width: 595 - :height: 740 - :scale: 60 % -.. |3| image:: /media/ambd_arduino/Watchdog_Simple_WDG_Timer/image3.png - :width: 383 - :height: 628 - :scale: 100 % -.. |4| image:: /media/ambd_arduino/Watchdog_Simple_WDG_Timer/image4.png - :width: 379 - :height: 419 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/WS2812B/WS2812B - Basics.rst b/bak/ambd/_common/Example_Guides/WS2812B/WS2812B - Basics.rst deleted file mode 100644 index bdca1e4..0000000 --- a/bak/ambd/_common/Example_Guides/WS2812B/WS2812B - Basics.rst +++ /dev/null @@ -1,115 +0,0 @@ -################# -WS2812B - Basics -################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - -- AmebaD [ AMB21 / AMB22 / AMB23 / BW16 ] x1 - -- WS2812B LED Strip / Ring / Stick / Board x1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -Introduction -------------- - -In this example, we will be using the AmebaD board to control the -WS2812B RGB LED, using the SPI peripheral to create the waveform -necessary for the LEDs. - -WS2812B basics allows you to control a single LED with a color or fill -all the LED with the same color. - -Procedure ----------- - -Firstly, connect the WS2812B to the Ameba board as shown in the -following diagrams. - -**AMB21/AMB22 Wiring Diagram:** - -.. image:: /media/ambd_arduino/WS2812B_Basics/image1.png - :align: center - :width: 1234 - :height: 747 - :scale: 90 % - - -**AMB23 Wiring Diagram:** - -.. image:: /media/ambd_arduino/WS2812B_Basics/image2.png - :align: center - :width: 1375 - :height: 724 - :scale: 90 % - -**BW16 Wiring Diagram:** - -.. image:: /media/ambd_arduino/WS2812B_Basics/image3.png - :align: center - :width: 1320 - :height: 685 - -**BW16-TypeC Wiring Diagram:** - -.. image:: /media/ambd_arduino/WS2812B_Basics/image4.png - :align: center - :width: 1381 - :height: 684 - - -To light up one individual LED or multiple LEDs with the same color, use -**WS2812B_Basics**. - -Open the example in ``“File” → “Example” → “AmebaWS2812B” → -“WS2812B_Basics”`` - -.. image:: /media/ambd_arduino/WS2812B_Basics/image5.png - :align: center - :width: 707 - :height: 1005 - -In the sample code, modify **NUM_OF_LEDS** to be the number of LEDs that -you have connected. - -.. image:: /media/ambd_arduino/WS2812B_Basics/image6.png - :align: center - :width: 621 - :height: 457 - -Next, compile and upload to Ameba, then press the reset button. You will -see the first 3 LED light up with red, green, and blue light color -individually and after a while all the LED will be filled with a color. - -.. image:: /media/ambd_arduino/WS2812B_Basics/image7.png - :align: center - :width: 2912 - :height: 512 - :scale: 25 % - -.. image:: /media/ambd_arduino/WS2812B_Basics/image8.png - :align: center - :width: 2908 - :height: 516 - :scale: 25 % - - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -[1] WS2812B Datasheet: - -https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf - - - - - diff --git a/bak/ambd/_common/Example_Guides/WS2812B/WS2812B - Patterns.rst b/bak/ambd/_common/Example_Guides/WS2812B/WS2812B - Patterns.rst deleted file mode 100644 index f57d4f9..0000000 --- a/bak/ambd/_common/Example_Guides/WS2812B/WS2812B - Patterns.rst +++ /dev/null @@ -1,124 +0,0 @@ -#################### -WS2812B - Patterns -#################### - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - -- AmebaD [ AMB21 / AMB22 / AMB23 / BW16 ] x1 - -- WS2812B LED Strip / Ring / Stick / Board x1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -Introduction -------------- - -In this example, we will be using the AmebaD board to control the -WS2812B RGB LED, using the SPI peripheral to create the waveform -necessary for the LEDs. - -WS2812B_Patterns allows you to create different light patterns with many -different colors. - -Procedure ------------ - -Firstly, connect the WS2812B to the Ameba board as shown in the -following diagrams. - -**AMB21/AMB22 Wiring Diagram:** - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image1.png - :align: center - :width: 1234 - :height: 747 - :scale: 90 % - -**AMB23 Wiring Diagram:** - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image2.png - :align: center - :width: 1375 - :height: 724 - :scale: 90 % - -**BW16 Wiring Diagram:** - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image3.png - :align: center - :width: 1320 - :height: 685 - -**BW16-TypeC Wiring Diagram:** - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image4.png - :align: center - :width: 1348 - :height: 709 - -To create different light patterns with many different colors, use -**WS2812B_Patterns**. - -Open the example in ``“File” → “Example” → “AmebaWS2812B” → -“WS2812B_Patterns”`` - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image5.png - :align: center - :width: 707 - :height: 1005 - -In the sample code, modify **NUM_OF_LEDS** to be the number of LEDs that -you have connected. - - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image6.png - :align: center - :width: 833 - :height: 510 - :scale: 70 % - -Next compile and upload to Ameba, then press the reset button. You will -see the WS2812B displaying a color wipe, theater chase, rainbow, and -theater chase rainbow light patterns in loop. - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image7.png - :align: center - :width: 3016 - :height: 544 - :scale: 19 % - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image8.png - :align: center - :width: 2724 - :height: 536 - :scale: 21 % - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image9.png - :align: center - :width: 2888 - :height: 592 - :scale: 20 % - -.. image:: /media/ambd_arduino/WS2812B_Patterns/image10.png - :align: center - :width: 2300 - :height: 528 - :scale: 25 % - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -[1] WS2812B Datasheet: - -https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf - - - diff --git a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Basic Input Output.rst b/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Basic Input Output.rst deleted file mode 100644 index 36e1b80..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Basic Input Output.rst +++ /dev/null @@ -1,59 +0,0 @@ -########################################################################## -Audio Codec – Basic Input Output -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23] x 1 - - Potentiometer x 1 - - Analog microphone x 1 (e.g., Adafruit 1063 / 1064) - - 3.5mm TRS/TRRS breakout x 1 (e.g., Adafruit 2791 / Sparkfun 11570) - -:raw-html:`

` -**Example** -:raw-html:`

` - -| **Procedure** -| Connect the potentiometer, microphone and 3.5mm connector to the RTL8722 - board following the diagram. - -| **AMB21 / AMB22** Wiring Diagram: - - |1| - -| **AMB23** Wiring Diagram: - - |1-1| - -Open the example, ``"Files" → "Examples" → “AmebaAudioCodec” → -“Basic_Input_Output”``. - - |2| - -Upload the code and press the reset button on Ameba once the upload is -finished. - -Connect a pair of wired headphones to the 3.5mm audio jack, blow at the -microphone, and you should hear the sounds picked-up by the microphone -replayed in the headphones. Adjust the potentiometer and the output -volume will change as well. Note: if you are using a microphone with an -amplifier included, such as Adafruit 1063, the amplifier can lead to the -microphone picking up more noise. - -.. |1| image:: /media/ambd_arduino/Audio_Codec_Basic_Input_Output/image1.png - :width: 562 - :height: 468 - :scale: 100 % -.. |1-1| image:: /media/ambd_arduino/Audio_Codec_Basic_Input_Output/image1-1.png - :width: 726 - :height: 783 - :scale: 50 % -.. |2| image:: /media/ambd_arduino/Audio_Codec_Basic_Input_Output/image2.png - :width: 608 - :height: 830 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - FFT.rst b/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - FFT.rst deleted file mode 100644 index 22efda5..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - FFT.rst +++ /dev/null @@ -1,42 +0,0 @@ -########################################################################## -Audio Codec - FFT -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -| **Introduction** -| This example shows how to use the AudioCodec_FFT class to calculate the fast - Fourier transform of a signal to extract the frequencies present in the - signal. - -| **Procedure** -| Open the example, ``"Files" → "Examples" → “AmebaAudioCodec” → “FFT”``. - - |1| - -| Upload the code and press the reset button on Ameba once the upload is - finished. -| Open the serial monitor, and the output results of the AudioCodec_FFT calculation - will be displayed. - - |2| - -.. |1| image:: /media/ambd_arduino/Audio_Codec_FFT/image1.png - :width: 608 - :height: 830 - :scale: 80 % -.. |2| image:: /media/ambd_arduino/Audio_Codec_FFT/image2.png - :width: 639 - :height: 477 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Input FFT.rst b/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Input FFT.rst deleted file mode 100644 index 643d51f..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Input FFT.rst +++ /dev/null @@ -1,60 +0,0 @@ -########################################################################## -Audio Codec - Input FFT -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23] x 1 - - Analog microphone x 1 (e.g., Adafruit 1063 / 1064) - -:raw-html:`

` -**Example** -:raw-html:`

` - -| **Introduction** -| This example shows how to use the FFT class to calculate the fast - Fourier transform of the audio signal recorded by the microphone. - -| **Procedure** -| Connect the microphone to the RTL8722 board following the diagram. - -| **AMB21 / AMB22** Wiring Diagram: - - |1| - -| **AMB23** Wiring Diagram: -| As AMB23 have a built in microphone on the board, there - is no need for any external microphone. - -Next, open the example, ``"Files" → "Examples" → “AmebaAudioCodec” → -“InputFFT”``. - - |2| - -| Upload the code and press the reset button on Ameba once the upload is - finished. -| Open the serial monitor and change the baud rate to 2000000. A stream of - FFT results of audio samples will be displayed. Try playing music or use - a smartphone app to generate a sine wave into the microphone, and you - should be able to see the FFT output change. - - |3| - - -.. |1| image:: /media/ambd_arduino/Audio_Codec_Input_FFT/image1.png - :width: 467 - :height: 466 - :scale: 100 % -.. |2| image:: /media/ambd_arduino/Audio_Codec_Input_FFT/image2.png - :width: 608 - :height: 830 - :scale: 100 % -.. |3| image:: /media/ambd_arduino/Audio_Codec_Input_FFT/image3.png - :width: 1206 - :height: 578 - :scale: 50 % \ No newline at end of file diff --git a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Output Sine Wave.rst b/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Output Sine Wave.rst deleted file mode 100644 index 779215a..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/Audio Codec - Output Sine Wave.rst +++ /dev/null @@ -1,47 +0,0 @@ -########################################################################## -Audio Codec – Output Sine Wave -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23] x 1 - - 3.5mm TRS/TRRS breakout x 1 (e.g., Adafruit 2791 / Sparkfun 11570) - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Procedure** - -| **AMB21 / AMB22** Wiring Diagram: -| Connect the 3.5mm connector to the RTL8722 board following the diagram. - - |1| - -| **AMB23** Wiring Diagram: -| As AMB23 have a built in microphone on the board, there - is no need for any external microphone. - -Open the example, ``"Files" → "Examples" → “AmebaAudioCodec” → -“OutputSineWave”``. - - |2| - -| Upload the code and press the reset button on Ameba once the upload is - finished. -| Connect a pair of wired headphones to the 3.5mm audio jack and you - should hear the generate single sinusoidal tone. - -.. |1| image:: /media/ambd_arduino/Audio_Codec_OutputSineWave/image1.png - :width: 474 - :height: 458 - :scale: 110 % -.. |2| image:: /media/ambd_arduino/Audio_Codec_OutputSineWave/image2.png - :width: 608 - :height: 830 - :scale: 80 % \ No newline at end of file diff --git a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/index.rst b/bak/ambd/bw16-typec/Example_Guides/Audio Codec/index.rst deleted file mode 100644 index 469f1ee..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/Audio Codec/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -Audio Codec -=========== - -.. toctree:: - :maxdepth: 1 - - Audio Codec - Basic Input Output - Audio Codec - FFT - Audio Codec - Input FFT - Audio Codec - Output Sine Wave - \ No newline at end of file diff --git a/bak/ambd/bw16-typec/Example_Guides/IR/IR - Transmit IR NEC Raw Data And Decode.rst b/bak/ambd/bw16-typec/Example_Guides/IR/IR - Transmit IR NEC Raw Data And Decode.rst deleted file mode 100644 index 5f1f4a9..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/IR/IR - Transmit IR NEC Raw Data And Decode.rst +++ /dev/null @@ -1,211 +0,0 @@ -########################################################################## -IR - Transmit IR NEC Raw Data And Decode -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16 ] x 2 - - Grove – Infrared Emitter x1 (Figure 1) - - Grove – Infrared Receiver x1 (Figure 2) - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we use two AmebaD to connect with -an infrared (IR) Emitter and an IR Receiver separately to transmit and -receive IR NEC Raw data. - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image1.jpeg - :align: center - :width: 688 - :height: 686 - :scale: 50 % - -Figure 1: Grove – Infrared Receiver - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image2.png - :align: center - :width: 394 - :height: 323 - -Figure 2: Grove – Infrared Emitter - -On the transmission side, the transmitter will send IR NEC raw data. -The raw data can be seen as consecutive durations of “marks” and -“spaces” (Figure 3) in microseconds (us). - - - Mark: a specific period of sending pulses - - Space: a specific period of sending nothing - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image3.png - :align: center - :width: 531 - :height: 188 - -Figure 3: A typical IR transmission and reception setup implementation - -For more details, please refer to SB-Projects’ topic of `IR Remote -Control Theory `__ to -learn the theory of IR remote controls operation and a collection of IR -protocol descriptions. In this example, we are going to use NEC (Now -Renesas, also known as Japanese Format) as the transmission protocol. - -**NEC Features** - - 8-bit address and 8-bit command length. - - Extended mode available, doubling the address size. - - Address and command are transmitted twice for reliability. - - Pulse distance modulation. - - The carrier frequency of 38kHz. - - Bit time of 1.125ms or 2.25ms. - -**Modulation** -NEC protocol uses Pulse Distance Encoding of the bits for data -communication (Figure 4). A logical “1” is represented by total -duration of 2250us, with 560us of “marks” and (2250-560) us of -“spaces”. While logical ”0” is represented by total duration of -1120us, with 560us “marks” and (1120-560) us of “spaces”. - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image4.png - :align: center - :width: 425 - :height: 125 - -Figure 4: Modulation of NEC - -Since a total number of 32\-bit data together with the header and the end\-bit will be transferred (Figure 5). -If we separate the data in the -time\-frame (in us), there will be ( 2 + 32 ) x 2 + 1 = 69 “marks” \/ -“spaces” to be transmitted (Figure 6), which forms the raw NEC data we -would like to transmit in our Arduino “\*.ino” file. This part of the code can be modified by users. -Details of how to obtain raw data code -for your remote devices, you may refer to `Ken Shirriff’s blog `__, -where it provides multiple libraries provided online. - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image5.png - :align: center - :width: 550 - :height: 110 - -Figure 5: Sample of a Full NEC Data (in logic1 or 0) - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image6.png - :align: center - :width: 830 - :height: 109 - -Figure 6: Sample of a Full NEC RAW Data (in us) - -Figure 7 and 8 shows the pin configuration of IR Emitter and Receiver -with AMB21/AMB22. - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image7.png - :align: center - :width: 764 - :height: 473 - -Figure 7: Pin configuration of IR Emitter and AMB21/AMB22 - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image8.png - :align: center - :width: 721 - :height: 468 - -Figure 8: Pin configuration of the IR Receiver and AMB21/AMB22 - -Figure 9 and Figure 10 shows the pin configuration of IR Emitter and -Receiver with BW16. - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image7-2.png - :align: center - :width: 1302 - :height: 1127 - :scale: 42 % - - -Figure 9: Pin configuration of IR Emitter and BW16 - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image8-2.png - :align: center - :width: 1171 - :height: 1117 - :scale: 42 % - - -Figure 10: Pin configuration of IR Receiver and BW16-TypeC - -Figure 11 and Figure 12 shows the pin configuration of IR Emitter and -Receiver with BW16-TypeC. - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image9.png - :align: center - :width: 856 - :height: 777 - :scale: 61 % - - -Figure 11: Pin configuration of IR Emitter and BW16-TypeC - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image9-2.png - :align: center - :width: 851 - :height: 735 - :scale: 65 % - -Figure 12: Pin configuration of IR Receiver and BW16-TypeC - -After the connection is being set up correctly, we will move to the -coding part for this example. First, make sure the correct Ameba -development board is selected in Arduino IDE: “Tools” → “Board”. - -Open the “IRSendRAW” example in ``“File” → “Examples” → “AmebaIRDevice” -→ “IRSendRAW”`` (Figure 13) and upload to 1st board connected with IR -Emitter: - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image10.png - :align: center - :width: 554 - :height: 537 - -Figure 13: Example Location of IRSendRaw and IRRecvNEC - -After successfully upload the sample code for IRSendRaw, you might need -to upload the IRRecvNEC example for the 2nd board connected with IR -Receiver from ``“File” → “Examples” → “AmebaIRDevice” → “IRRecvNEC”``. - -After opening the serial monitor on the IR Receiver side and press the -reset buttons on two boards, the data “48” will be received every 3 -seconds (due to the delays () function, not compulsory to wait). After -decoding the signal from the receiving Pin D8 and transmitting Pin D9 -with Logic Analyser and Pulse View (Figure 14), the result is also shown -as “48” after decoding the receiving data with IR NEC Protocol. - -.. image:: /media/ambd_arduino/Transmit_IR_NEC_Raw_Data_And_Decode/image11.png - :align: center - :width: 1210 - :height: 163 - -Figure 14: Pulse View results from sending and receiving pin - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -[1] Seeed Official website for Grove – Infrared Receiver -https://wiki.seeedstudio.com/Grove-Infrared_Receiver/ - -[2] Seed Official website for Grove – Infrared Emitter -https://wiki.seeedstudio.com/Grove-Infrared_Emitter/ - -[3] Ken SHirriff’s blog on A Multi-Protocol Infrared Remote Library -for the Arduino -http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html - -[4] SB-Projects: IR Remote Control Project -https://www.sbprojects.net/knowledge/ir/index.php - diff --git a/bak/ambd/bw16-typec/Example_Guides/IR/IR - Transmit IR SONY Data.rst b/bak/ambd/bw16-typec/Example_Guides/IR/IR - Transmit IR SONY Data.rst deleted file mode 100644 index ff7d4e5..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/IR/IR - Transmit IR SONY Data.rst +++ /dev/null @@ -1,154 +0,0 @@ -############################ -IR - Transmit IR Sony Data -############################ - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - -- AmebaD [ AMB21 / AMB22 / BW16 ] x 2 - -- Grove – Infrared Emitter x1 (Figure 1) - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we use one Ameba RTL8722 modules that connecting with -an infrared (IR) Emitter to transmit and receive IR SONY data “0xA90” -(Sony TV power code). For the receiver side, you can either use an -oscilloscope/logic analyser to view the waveform and decode accordingly. - -.. image:: /media/ambd_arduino/IR_Transmit_IR_SONY_Data/image1.png - :align: center - :width: 150 - :height: 150 - -Figure 1: Grove – Infrared Transmitter - -On the transmission side, the transmitter will send IR SONY data. For -more details, please refer to SB-Projects’ topic of IR Remote Control -Theory to learn the theory of IR remote controls operation and a -collection of IR protocol descriptions. In this example, we are going to -use Sony as the transmission protocol. - -**Sony Features** - -- 12-bit version, 7 command bits, 5 address bits. - -- Pulse width modulation. - -- Carrier frequency of 40kHz. - -- Bit time of 1.2ms or 0.6ms. - -**Sony SIRC Modulation** - -The SIRC protocol uses pulse width encoding of the bits. The pulse -representing a logical "1" is a 1200us long burst of the 40kHz carrier, -while the burst width for a logical "0" is 600us long. All bursts are -separated by a 600us long space interval as shown in Figure 2 below. - -.. image:: /media/ambd_arduino/IR_Transmit_IR_SONY_Data/image2.png - :align: center - :width: 338 - :height: 94 - -Figure 2: Sony SIRC Modulation - -**Protocol** - -.. image:: /media/ambd_arduino/IR_Transmit_IR_SONY_Data/image3.png - :align: center - :width: 332 - :height: 83 - -Figure 3: 12-bit Sony SIRC protocol - -The Figure 3 above shows a typical pulse train of the 12-bit SIRC -protocol. With this protocol the LSB is transmitted first. The start -burst is always 2.4ms wide, followed by a standard space of 0.6ms. Apart -from signalling the start of a SIRC message this start burst is also -used to adjust the gain of the IR receiver. Then the 7-bit Command is -transmitted, followed by the 5-bit Device address. In this case Address -1 and Command 19 is transmitted. - -Commands are repeated every 45ms (measured from start to start) for as -long as the key on the remote control is held down. - -Figure 4 shows the pin configuration of IR Emitter with AMB21 / AMB22 -board. - -.. image:: /media/ambd_arduino/IR_Transmit_IR_SONY_Data/image4.png - :align: center - :width: 419 - :height: 301 - -Figure 5: Pin configuration of the IR Emitter and BW16 - -.. image:: /media/ambd_arduino/IR_Transmit_IR_SONY_Data/image5.png - :align: center - :width: 757 - :height: 710 - :scale: 84 % - -Figure 6: Pin configuration of the IR Emitter and BW16-TypeC - -.. image:: /media/ambd_arduino/IR_Transmit_IR_SONY_Data/image6.png - :align: center - :width: 856 - :height: 777 - :scale: 77 % - - -After the connection is being set up correctly, we will move to the -coding part for this example. First, make sure the correct Ameba -development board is selected in Arduino IDE: “Tools” -> “Board”. - -Open the “IRSendSONY” example in “File” -> “Examples” -> “AmebaIRDevice” --> “IRSendSONY” (Figure 6) and upload to the board connected with IR -Emitter: - -.. image:: /media/ambd_arduino/IR_Transmit_IR_SONY_Data/image7.png - :align: center - :width: 440 - :height: 394 - -Figure 6: Example Location of IRSendSONY - -After successfully upload the sample code for IRSendSONY, you could use -oscilloscope or Pulse View software to find out the waveform of the -signal transmitted from the IR Emitter is “0xA90” as shown in Figure -below: - -.. image:: /media/ambd_arduino/IR_Transmit_IR_SONY_Data/image8.png - :align: center - :width: 602 - :height: 325 - -Figure 7: Waveform of IRSendSONY “0xA90” - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -[1] Seed Official website for Grove – Infrared Emitter - -https://wiki.seeedstudio.com/Grove-Infrared_Emitter/ - -[2] Ken SHirriff’s blog on A Multi-Protocol Infrared Remote Library for -the Arduino - -http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html - -[3] SB-Projects: IR Remote Control Project - -https://www.sbprojects.net/knowledge/ir/index.php - -[4] SONY SIRC Protocol - -https://www.sbprojects.net/knowledge/ir/sirc.php - diff --git a/bak/ambd/bw16-typec/Example_Guides/IR/index.rst b/bak/ambd/bw16-typec/Example_Guides/IR/index.rst deleted file mode 100644 index e857661..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/IR/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -IR -== - -.. toctree:: - :maxdepth: 1 - - IR - Transmit IR NEC Raw Data And Decode - IR - Transmit IR SONY Data - \ No newline at end of file diff --git a/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Hello World.rst b/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Hello World.rst deleted file mode 100644 index 1440d42..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Hello World.rst +++ /dev/null @@ -1,61 +0,0 @@ -################################### -TensorFlow Lite - Hello World -################################### - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - LED x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Procedure** - -Download the Ameba customized version of TensorFlow Lite for -Microcontrollers library at -https://github.com/ambiot/tree/master/Arduino_zip_libraries. - -Follow the instructions at https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries to -install it. - -Ensure that the patch files found at -https://github.com/ambiot/tree/master/Ameba_misc/ are also -installed. - -Open the example, ``"Files" → "Examples" → “TensorFlowLite_Ameba” → -“hello_world”``. - - |1| - - -| Upload the code and press the reset button on Ameba once the upload is - finished. -| Connect the LED to digital pin 10 and ground, ensuring that the polarity - is correct. You should see the LED fade in and out rapidly. -| In the Arduino serial plotter, you can see the output value of the - Tensorflow model plotted as a graph, it should resemble a sine wave. - - |2| - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -More information on TensorFlow Lite for Microcontrollers can be found -at: https://www.tensorflow.org/lite/microcontrollers - -.. |1| image:: /media/ambd_arduino/TFL_HelloWorld/image1.png - :width: 556 - :height: 830 - :scale: 70 % -.. |2| image:: /media/ambd_arduino/TFL_HelloWorld/image2.png - :width: 817 - :height: 586 - :scale: 60 % \ No newline at end of file diff --git a/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Magic Wand.rst b/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Magic Wand.rst deleted file mode 100644 index 2ec8983..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Magic Wand.rst +++ /dev/null @@ -1,108 +0,0 @@ -########################################################################## -TensorFlow Lite - Magic Wand -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Adafruit LSM9DS1 accelerometer - - LED x 2 - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Procedure** - -**AMB21 / AMB22** Wiring Diagram: - -Connect the accelerometer and LEDs to the AMB21/AMB22 following the diagram. - -.. image:: /media/ambd_arduino/TFL_MagicWand/image1.jpeg - :align: center - :width: 1027 - :height: 630 - -**AMB23** Wiring Diagram: -For AMB23, we will use the onboard LEDs on the board itself. - -.. image:: /media/ambd_arduino/TFL_MagicWand/image1-1.jpeg - :align: center - :width: 971 - :height: 658 - -**BW16** Wiring Diagram: -For BW16, we will use the onboard LEDs on the board itself. - -.. image:: /media/ambd_arduino/TFL_MagicWand/image1-2.jpeg - :align: center - :width: 859 - :height: 690 - -**BW16-TypeC** Wiring Diagram: -For BW16-TypeC, we will use the onboard LEDs on the board itself. - -.. image:: /media/ambd_arduino/TFL_MagicWand/image1-3.png - :align: center - :width: 980 - :height: 734 - :scale: 95 % - -Download the Ameba customized version of TensorFlow Lite for -Microcontrollers library at -https://github.com/ambiot/tree/master/Arduino_zip_libraries. - -Follow the instructions at https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries to -install it. - -Ensure that the patch files found at -https://github.com/ambiot/tree/master/Ameba_misc/ are also -installed. - -In the Arduino IDE library manager, install the Arduino_LSM9DS1 library. This example has been tested with version 1.1.0 of the LSM9DS1 library. - - -Open the example, ``"Files" → "Examples" → “TensorFlowLite_Ameba” → -“magic_wand”``. - -.. image:: /media/ambd_arduino/TFL_MagicWand/image2.jpeg - :align: center - :width: 556 - :height: 830 - :scale: 84 % - -Upload the code and press the reset button on Ameba once the upload is -finished. - -Holding the accelerometer steady, with the positive x-axis pointing to -the right and the positive z-axis pointing upwards, move it following -the shapes as shown, moving it in a smooth motion over 1 to 2 seconds, -avoiding any sharp movements. - -.. image:: /media/ambd_arduino/TFL_MagicWand/image3.jpeg - :align: center - :width: 777 - :height: 337 - -If the movement is recognised by the Tensorflow Lite model, you should -see the same shape output to the Arduino serial monitor. Different LEDs -will light up corresponding to different recognized gestures. -Note that the wing shape is easy to achieve, while the slope and ring -shapes tend to be harder to get right. - -.. image:: /media/ambd_arduino/TFL_MagicWand/image4.jpeg - :align: center - :width: 639 - :height: 458 - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -More information on TensorFlow Lite for Microcontrollers can be found -at: https://www.tensorflow.org/lite/microcontrollers diff --git a/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Person Detection.rst b/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Person Detection.rst deleted file mode 100644 index 5d0e18a..0000000 --- a/bak/ambd/bw16-typec/Example_Guides/TensorFlow/TensorFlow Lite - Person Detection.rst +++ /dev/null @@ -1,119 +0,0 @@ -########################################################################## -TensorFlow Lite - Person Detection -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Arducam Mini 2MP Plus OV2640 SPI Camera Module x 1 - - LED x 3 - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Procedure** - -**AMB21 / AMB22** Wiring Diagram: -Connect the camera and LEDs to the RTL8722 board following the diagram. - -.. image:: /media/ambd_arduino/TFL_PersonDetection/image1.png - :align: center - :width: 777 - :height: 467 - - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/TFL_PersonDetection/image1-1.png - :align: center - :width: 1067 - :height: 590 - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/TFL_PersonDetection/image1-2.png - :align: center - :width: 967 - :height: 557 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/TFL_PersonDetection/image1-3.png - :align: center - :width: 1360 - :height: 770 - - -Download the Ameba customized version of TensorFlow Lite for -Microcontrollers library at -https://github.com/ambiot/tree/master/Arduino_zip_libraries. - -Follow the instructions at https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries to -install it. - -Ensure that the patch files found at -https://github.com/ambiot/tree/master/Ameba_misc/ are also installed. - -You will also need to install the Ameba_ArduCAM library, found together -with the TensorFlow Lite library. - -In the Arduino IDE library manager, install the JPEGDecoder library. -This example has been tested with version 1.8.0 of the JPEGDecoder -library. - -Once the library has installed, you will need to configure it to disable -some optional components that are not compatible with the RTL8722DM. -Open the following file: - - ``Arduino/libraries/JPEGDecoder/src/User_Config.h`` - -| Make sure that both ``#define LOAD_SD_LIBRARY`` and ``#define - LOAD_SDFAT_LIBRARY`` are commented out, as shown in this excerpt from the - file: - -.. code-block:: c - - //#define LOAD_SD_LIBRARY // Default SD Card library - //#define LOAD_SDFAT_LIBRARY // Use SdFat library instead, so SD Card SPI can be bit bashed - -Open the example, ``"Files" → "Examples" → “TensorFlowLite_Ameba” → -“person_detection”``. - -.. image:: /media/ambd_arduino/TFL_PersonDetection/image2.png - :align: center - :width: 556 - :height: 830 - :scale: 70 % - -User can define the LED pins by using any GPIO pins on the boards. -Upload the code and press the reset button on Ameba once the upload is -finished. - -Once it is running, you should see the blue LED flashing once every few -seconds, indicating that it has finished processing an image. The red -LED will light up if it determines that there is no person in the -previous image captured, and the green LED will light up if it -determines that there is a person. - -The inference results are also output to the Arduino serial monitor, -which appear as follows: - -.. image:: /media/ambd_arduino/TFL_PersonDetection/image3.png - :align: center - :width: 639 - :height: 477 - - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -More information on TensorFlow Lite for Microcontrollers can be found -at: https://www.tensorflow.org/lite/microcontrollers - diff --git a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst index f321ac5..6edf25b 100644 --- a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst +++ b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst @@ -85,7 +85,7 @@ Procedure **AMB26** Wiring Diagram: -|image07| +|image16| .. only:: end amb26 @@ -144,7 +144,7 @@ If you do not have resistors in hand, you can use a level converter instead. The **AMB26** Wiring Diagram: -|image13| +|image17| .. only:: end amb26 @@ -232,3 +232,11 @@ Finally, use the formula to calculate the distance. .. |image15| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image15.png :width: 649 px :height: 372 px +.. |image16| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image16.png + :width: 1557 px + :height: 745 px + :scale: 50% +.. |image17| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image17.png + :width: 1557 px + :height: 744 px + :scale: 50% diff --git a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst index ef38b17..9c40d2f 100644 --- a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst +++ b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst @@ -100,7 +100,7 @@ Take note that if you are using a DHT sensor that is not mounted on a PCB, you w **AMB26** Wiring Diagram: -|image10| +|image12| .. only:: end amb26 @@ -152,3 +152,6 @@ Every time we read the temperature/humidity data, Ameba uses the buffered temper .. |image11| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image11.png :width: 704 px :height: 591 px +.. |image12| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image12.png + :width: 709 px + :height: 645 px diff --git a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst index 3f2e014..8829790 100644 --- a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst +++ b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst @@ -80,7 +80,7 @@ Open the example, ``“Files” → “Examples” → “AmebaGPIO” → “LE **AMB26** Wiring Diagram: -|image06| +|image07| .. only:: end amb26 @@ -147,3 +147,7 @@ In this handler, every time we press and release the button, we trigger an inter .. |image06| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image06.png :width: 594 px :height: 630 px +.. |image07| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image07.png + :width: 1557 px + :height: 864 px + :scale: 50% diff --git a/source/_common/ameba_d/Example_Guides/GTimer/GTimer - Using The Periodic GTimer.rst b/source/_common/ameba_d/Example_Guides/GTimer/GTimer - Using The Periodic GTimer.rst new file mode 100644 index 0000000..92ac6a5 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/GTimer/GTimer - Using The Periodic GTimer.rst @@ -0,0 +1,37 @@ +GTimer - Using The Periodic GTimer +================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +Ameba provides 4 hardware GTimer for users to use. The timers' resolutions are at microseconds scale. +The timer can be set to be periodic or for single use. The periodic timers reset periodically, and the single-use timers do not. + +Open the example, ``“File” → “Examples” → “AmebaGTimer” → “TimerPeriodical”``. Compile and upload to Ameba, and press reset. +In the Serial Monitor, you can see the counter value is increased periodically. + +Code Reference +-------------- + +The first argument of begin() is the timer id (0~3). +The second argument is the value of the timer (in microseconds). In the example, we fill in 1000000us = 1s. +The third argument specifies the function to call when the time is up. In the example, we call the “myhandler” function to increase the counter value by 1 and print the counter value to serial monitor. + +.. code-block:: c++ + + GTimer.begin(0, 1 * 1000 * 1000, myhandler); + +The GTimer is periodic by default, therefore “myhandler” function is called every second. When we want to stop the GTimer, use ``stop()``: + +.. code-block:: c++ + + GTimer.stop(0); \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/GTimer/GTimer - Using the One-Time Gtimer.rst b/source/_common/ameba_d/Example_Guides/GTimer/GTimer - Using the One-Time Gtimer.rst similarity index 56% rename from bak/ambd/_common/Example_Guides/GTimer/GTimer - Using the One-Time Gtimer.rst rename to source/_common/ameba_d/Example_Guides/GTimer/GTimer - Using the One-Time Gtimer.rst index ec87fab..5cfb6e0 100644 --- a/bak/ambd/_common/Example_Guides/GTimer/GTimer - Using the One-Time Gtimer.rst +++ b/source/_common/ameba_d/Example_Guides/GTimer/GTimer - Using the One-Time Gtimer.rst @@ -1,47 +1,40 @@ -########################################################################## -GTimer - Using the One-Time Gtimer -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we will use 4 One-Time GTimer, and pass user data to each timer. - -Open the example ``“File” → “Examples” → “AmebaGTimer” → “TimerOneshot”``. -Compile and upload to Ameba, and press reset. -Then you can see the 4 timer log printed to the serial monitor in series. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -The first argument of begin() is the Timer ID (0~3). The second argument is the value of the timer (in microseconds). -In the example, we fill in 1000000us = 1s. The third argument specifies the function to call when the time is up. -The fourth argument is to set whether this timer is a periodic timer, we use “false” here to begin a single-use timer. -The fifth argument is the user data, we give 0 here to represent that this is timer 0. - -.. code-block:: c - - GTimer.begin(0, 1 * 1000 * 1000, myhandler, false, 0); - -Next, we set up the second timer, which has timer value 2 seconds, and -user data 1. And other timers are set similarly. - -.. code-block:: c - - GTimer.begin(1, 2 * 1000 * 1000, myhandler, false, 1); - -In myhandler function, we print the user data to serial monitor. -Since the 4 timers are separately set to count for 1, 2, 3, 4 seconds, -from 1 second to 4 second, the user data of each timer are printed on -the serial monitor in order. After 4 second, no log will be printed. \ No newline at end of file +GTimer - Using the One-Time Gtimer +================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +In this example, we will use 4 One-Time GTimer, and pass user data to each timer. + +Open the example ``“File” → “Examples” → “AmebaGTimer” → “TimerOneshot”``. +Compile and upload to Ameba, and press reset. +Then you can see the 4 timer log printed to the serial monitor in series. + +Code Reference +-------------- + +The first argument of begin() is the Timer ID (0~3). The second argument is the value of the timer (in microseconds). +In the example, we fill in 1000000us = 1s. The third argument specifies the function to call when the time is up. +The fourth argument is to set whether this timer is a periodic timer, we use “false” here to begin a single-use timer. +The fifth argument is the user data, we give 0 here to represent that this is timer 0. + +.. code-block:: c++ + + GTimer.begin(0, 1 * 1000 * 1000, myhandler, false, 0); + +Next, we set up the second timer, which has timer value 2 seconds, and user data 1. And other timers are set similarly. + +.. code-block:: c++ + + GTimer.begin(1, 2 * 1000 * 1000, myhandler, false, 1); + +In myhandler function, we print the user data to serial monitor. Since the 4 timers are separately set to count for 1, 2, 3, 4 seconds, from 1 second to 4 second, the user data of each timer are printed on the serial monitor in order. After 4 second, no log will be printed. diff --git a/bak/ambd/_common/Example_Guides/GTimer/index.rst b/source/_common/ameba_d/Example_Guides/GTimer/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/GTimer/index.rst rename to source/_common/ameba_d/Example_Guides/GTimer/index.rst diff --git a/source/_common/ameba_d/Example_Guides/I2C/I2C - Display Data On LCD Screen.rst b/source/_common/ameba_d/Example_Guides/I2C/I2C - Display Data On LCD Screen.rst new file mode 100644 index 0000000..e1513bc --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/I2C/I2C - Display Data On LCD Screen.rst @@ -0,0 +1,163 @@ +I2C - Display Data On LCD Screen +================================ + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- I2C 2x16 LCD + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +Normally there are many pins on an LCD display, as shown in below figure. + +|image01| + +An LCD display can be equipped with an additional processing chip to process the data. The processing chip can connect to a microcontroller using the I2C interface. + +**Procedure** +~~~~~~~~~~~~~ + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image02| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image03| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image04| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image05| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image06| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image07| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image08| + +.. only:: end amb26 + +Open the example in ``“File” → “Examples” → “AmebaWire” → “LCD_HelloWorld”``. +Compile and upload to Ameba, then press the reset button. +Then you can see “Hello World” in the first line, and “Ameba” in the +second line displayed on the LCD screen. + +|image09| + +After 8 seconds, you can input to the Serial Monitor the string you would like to display on the LCD. + +|image10| + +For example, we enter “123456789” and press “Send”: + +|image11| + +Code Reference +-------------- + +The required settings of each model of LCD might be different, the constructor we use in this example is: + +.. code-block:: c++ + + LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, + uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, + uint8_t backlighPin, t_backlighPol pol); + +And the setting parameters are as follows: + +.. code-block:: c++ + + LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address + +The first parameter 0x27 is the address of I2C. Each of the following 8 parameters represents the meaning of each bit in a byte, i.e., En is bit 2, Rw is bit 1, Rs is bit 0, d4 is bit 4, and so forth. + +Call ``backlight()`` to light the screen. +Call ``setCursor(0, 0)`` to set the position of the cursor. +LCD inherits the Print class, so we can use ``lcd.print()`` to output string on the screen. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image01.png + :width: 938 px + :height: 814 px + :scale: 80% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image02.png + :width: 1429 px + :height: 978 px + :scale: 60% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image03.png + :width: 1434 px + :height: 748 px + :scale: 60% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image04.png + :width: 1158 px + :height: 621 px + :scale: 80% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image05.png + :width: 1244 px + :height: 672 px + :scale: 70% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image06.png + :width: 633 px + :height: 468 px +.. |image07| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image07.png + :width: 804 px + :height: 461 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image08.png + :width: 602 px + :height: 404 px +.. |image09| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image09.png + :width: 1431 px + :height: 862 px + :scale: 60% +.. |image10| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image10.png + :width: 1431 px + :height: 851 px + :scale: 60% +.. |image11| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Display_Data_on_LCD_Screen/image11.png + :width: 1431 px + :height: 870 px + :scale: 60% diff --git a/source/_common/ameba_d/Example_Guides/I2C/I2C - Receive Data from Arduino UNO.rst b/source/_common/ameba_d/Example_Guides/I2C/I2C - Receive Data from Arduino UNO.rst new file mode 100644 index 0000000..064cb0f --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/I2C/I2C - Receive Data from Arduino UNO.rst @@ -0,0 +1,211 @@ +I2C - Receive Data from Arduino UNO +=================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- Arduino UNO x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +.. only:: amb21 + +In the previous example `“I2C - Communicate with Arduino UNO via I2C” `_, Ameba, the I2C master, transmits data to the Arduino UNO, the I2C slave. Whereas in this example, Ameba is the I2C master, and receives data from the Arduino UNO, which is the I2C slave. + +.. only:: end amb21 + +.. only:: amb23 + +In the previous example `“I2C - Communicate with Arduino UNO via I2C” `_, Ameba, the I2C master, transmits data to the Arduino UNO, the I2C slave. Whereas in this example, Ameba is the I2C master, and receives data from the Arduino UNO, which is the I2C slave. + +.. only:: end amb23 + +.. only:: bw16-typeb + +In the previous example `“I2C - Communicate with Arduino UNO via I2C” `_, Ameba, the I2C master, transmits data to the Arduino UNO, the I2C slave. Whereas in this example, Ameba is the I2C master, and receives data from the Arduino UNO, which is the I2C slave. + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +In the previous example `“I2C - Communicate with Arduino UNO via I2C” `_, Ameba, the I2C master, transmits data to the Arduino UNO, the I2C slave. Whereas in this example, Ameba is the I2C master, and receives data from the Arduino UNO, which is the I2C slave. + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +In the previous example `“I2C - Communicate with Arduino UNO via I2C” `_, Ameba, the I2C master, transmits data to the Arduino UNO, the I2C slave. Whereas in this example, Ameba is the I2C master, and receives data from the Arduino UNO, which is the I2C slave. + +.. only:: end aw-cu488 + +.. only:: amb25 + +In the previous example `“I2C - Communicate with Arduino UNO via I2C” `_, Ameba, the I2C master, transmits data to the Arduino UNO, the I2C slave. Whereas in this example, Ameba is the I2C master, and receives data from the Arduino UNO, which is the I2C slave. + +.. only:: end amb25 + +.. only:: amb26 + +In the previous example `“I2C - Communicate with Arduino UNO via I2C” `_, Ameba, the I2C master, transmits data to the Arduino UNO, the I2C slave. Whereas in this example, Ameba is the I2C master, and receives data from the Arduino UNO, which is the I2C slave. + +.. only:: end amb26 + +**Procedure** +~~~~~~~~~~~~~ + +**Setting up Arduino Uno to be I2C Slave** + +First, select Arduino in the Arduino IDE in ``“Tools” → “Board” → “Arduino Uno”``: + +Open ``“Examples” → “Wire” → “slave_sender”`` + +|image01| + +Then click “Sketch” → “Upload” to compile and upload the example to Arduino Uno. + +**Setting up Ameba to be I2C Master** + +Next, open another window of Arduino IDE, make sure to choose your Ameba development board in the IDE: “Tools” → “Board” + +Open ``“File” → “Examples” → “AmebaWire” → “MasterReader”`` + +|image02| + +Click “Sketch” → “Upload” to compile and upload the example to Ameba. + +**Wiring** + +The Arduino example uses A4 as the I2C SDA and A5 as the I2C SCL. +Another important thing is that the GND pins of Arduino and Ameba should be connected to each other. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image03| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image04| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image05| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image06| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image07| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image08| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image09| + +.. only:: end amb26 + +Next, we will observe the data received by Ameba in the Serial Monitor. +.. note :: If you do not know which port the Ameba development board is connected to, please find it in the Device Manager of Windows first. Ameba is connected as “mbed Serial Port”. For example, if you find mbed Serial Port (COM15), that means Ameba is connected to port COM15. + +|image10| + +We select the port in “Tools” → “Port” → “COM15” (the port connected to Ameba) +Open the Arduino IDE window of the Ameba, go to “Tools” → “Serial +Monitor” to display the messages printed by Ameba. +Press the reset button on Arduino Uno, Arduino Uno now waits for +connection from I2C master. +Then press the reset button on Ameba, Ameba will start to receive +messages from Arduino Uno. And you can see the “hello ” message +printed every half second in serial monitor. + +.. note :: If the message does not show in the Serial Monitor of Ameba, please close and open the serial monitor again. + +|image11| + +Code Reference +-------------- + +You can find detailed information of this example in the documentation of Arduino: +https://www.arduino.cc/en/Tutorial/MasterReader + +First use ``Wire.begin()`` / ``Wire.begin(address)`` to join the I2C bus as a master or slave, in the Master case the address is not required. +https://www.arduino.cc/en/Reference/WireBegin + +Next, the Master uses ``Wire.requestFrom()`` to specify from which Slave to request data. +https://www.arduino.cc/en/Reference/WireRequestFrom + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image01.png + :width: 683 + :height: 1028 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image02.png + :width: 588 + :height: 1028 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image03.png + :width: 1540 px + :height: 1051 px + :scale: 50% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image04.png + :width: 882 px + :height: 670 px +.. |image05| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image05.png + :width: 923 px + :height: 717 px + :scale: 80% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image06.png + :width: 959 px + :height: 690 px + :scale: 80% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image07.png + :width: 546 px + :height: 501 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image08.png + :width: 487 px + :height: 457 px +.. |image09| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image09.png + :width: 519 px + :height: 457 px +.. |image10| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image10.png + :width: 434 + :height: 405 +.. |image11| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image11.png + :width: 649 + :height: 410 diff --git a/source/_common/ameba_d/Example_Guides/I2C/I2C - Scan I2C devices.rst b/source/_common/ameba_d/Example_Guides/I2C/I2C - Scan I2C devices.rst new file mode 100644 index 0000000..1f40a0a --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/I2C/I2C - Scan I2C devices.rst @@ -0,0 +1,52 @@ +I2C - Scan I2C devices +====================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +The example will scan the I2C bus for devices that is connected to Ameba. When a device is found, it will be shown on the serial monitor with the address of the device. + +**Procedure** +~~~~~~~~~~~~~ + +Connect the I2C device to I2C_SDA and I2C_SCL of the board. + +Open the example in “File” → “Examples” → “AmebaWire” → “I2C_Scanner”. + +|image01| + +When the I2C bus detect any I2C device, the serial monitor will show the address of the I2C device as shown below: + +|image02| + +When there is no I2C device connected to the board, the Arduino IDE serial monitor will show the message below. + +|image03| + +Code Reference +-------------- + +You can find detailed information of this example in the documentation of Arduino: +https://playground.arduino.cc/Main/I2cScanner/ + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image01.png + :width: 892 + :height: 933 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image02.png + :width: 657 + :height: 387 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Receive_Data_from_Arduino_UNO/image03.png + :width: 657 px + :height: 382 px diff --git a/source/_common/ameba_d/Example_Guides/I2C/I2C - Send Data to Arduino UNO.rst b/source/_common/ameba_d/Example_Guides/I2C/I2C - Send Data to Arduino UNO.rst new file mode 100644 index 0000000..6b99484 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/I2C/I2C - Send Data to Arduino UNO.rst @@ -0,0 +1,165 @@ +I2C - Send Data to Arduino UNO +============================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- Arduino UNO x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +There are two roles in the operation of I2C, one is “master”, the other is “slave”. Only one master is allowed and can be connected to many slaves. Each slave has its unique address, which is used in the communication between master and the slave. I2C uses two pins, one is for data transmission (SDA), the other is for the clock (SCL). Master uses the SCL to inform slave of the upcoming data transmission, and the data is transmitted through SDA. The I2C example was named “Wire” in the Arduino example. + +**Procedure** +~~~~~~~~~~~~~ + +In this example, we use Ameba as the I2C master writer, and Arduino as the I2C slave receiver. +When the I2C slave receives a string sent from I2C master, it prints the received string. + +**Setting up Arduino Uno to be I2C Slave** + +First, select Arduino in the Arduino IDE in ``“Tools” → “Board” → “Arduino Uno”`` +Open the “Slave Receiver” example in ``“Examples” → “Wire” → “slave_receiver”``: + +|image01| + +Then click ``“Sketch” → “Upload”`` to compile and upload the example to Arduino Uno. + +**Setting up Ameba to be I2C Master** + +Next, open another window of Arduino IDE, make sure to choose your Ameba development board in the IDE: ``“Tools” → “Board”`` +Then open the “Master Writer” example in ``“File” → “Examples” → “AmebaWire” → “MasterWriter”`` + +|image02| + +**Wiring** + +The Arduino example uses A4 as the I2C SDA and A5 as the I2C SCL. + +**Another important thing to note** + +.. note :: The GND pins of Arduino and Ameba should be connected to each other. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image03| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image04| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image05| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image06| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image07| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image08| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image09| + +.. only:: end amb26 + +Open the Arduino IDE of the Arduino Uno and open the serial monitor (“Tools” → “Serial Monitor”). +In the Serial Monitor, you can see the messages printed from Arduino Uno. +Next, press the reset button on Arduino Uno. Now the Arduino Uno is waiting for the connection from I2C Master. +We press the reset button on Ameba to start to send messages. Then observe the serial monitor, you can see the messages show up every half second. + +|image10| + :width: 649 + :height: 410 + +Code Reference +-------------- + +You can find detailed information of this example in the documentation of Arduino: +https://www.arduino.cc/en/Tutorial/MasterWriter + +First use Wire.begin()/Wire.begin(address) to join the I2C bus as a master or slave, in the Master case the address is not required. +https://www.arduino.cc/en/Reference/WireBegin + +Next, the Master uses Wire.beginTransmission(address) to begin a transmission to the I2C slave with the given address: +https://www.arduino.cc/en/Reference/WireBeginTransmission + +Uses Wire.write() to send data, and finally use Wire.endTransmission() to end a transmission to a Slave and transmits the bytes that were queued: +https://www.arduino.cc/en/Reference/WireEndTransmission + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image01.png + :width: 578 + :height: 1028 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image02.png + :width: 588 + :height: 1028 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image03.png + :width: 1540 + :height: 1051 + :scale: 50% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image04.png + :width: 1005 + :height: 743 + :scale: 80% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image05.png + :width: 923 + :height: 717 + :scale: 80% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image06.png + :width: 959 + :height: 690 + :scale: 80% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image07.png + :width: 546 px + :height: 501 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image08.png + :width: 487 + :height: 457 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image09.png + :width: 519 + :height: 457 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Send_data_to_Arduino_UNO/image10.png + :width: 649 + :height: 410 diff --git a/source/_common/ameba_d/Example_Guides/I2C/I2C - Slave Receive Data from Arduino UNO.rst b/source/_common/ameba_d/Example_Guides/I2C/I2C - Slave Receive Data from Arduino UNO.rst new file mode 100644 index 0000000..4d8041e --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/I2C/I2C - Slave Receive Data from Arduino UNO.rst @@ -0,0 +1,198 @@ +I2C - Slave Receive Data from Arduino UNO +========================================= + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- Arduino UNO x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +There are two roles in the operation of I2C, one is “master”, the other is “slave”. Only one master is allowed and can be connected to many slaves. Each slave has its unique address, which is used in the communication between master and the slave. I2C uses two pins, one is for data transmission (SDA), the other is for the clock (SCL). Master uses the SCL to inform slave of the upcoming data transmission, and the data is transmitted through SDA. The I2C example was named “Wire” in the Arduino example. + +**Procedure** +~~~~~~~~~~~~~ + +.. only:: amb21 + +In the previous example `“I2C - Slave Send Data to Arduino UNO `_, Ameba, the I2C master, transmits data to Arduino UNO, the I2C Slave. As to this example, Ameba is the I2C Slave, and receives data from the Arduino UNO, which is the I2C master. + +.. only:: end amb21 + +.. only:: amb23 + +In the previous example `“I2C - Slave Send Data to Arduino UNO” `_, Ameba, the I2C master, transmits data to Arduino UNO, the I2C Slave. As to this example, Ameba is the I2C Slave, and receives data from the Arduino UNO, which is the I2C master. + +.. only:: end amb23 + +.. only:: bw16-typeb + +In the previous example `“I2C - Slave Send Data to Arduino UNO” `_, Ameba, the I2C master, transmits data to Arduino UNO, the I2C Slave. As to this example, Ameba is the I2C Slave, and receives data from the Arduino UNO, which is the I2C master. + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +In the previous example `“I2C - Slave Send Data to Arduino UNO” `_, Ameba, the I2C master, transmits data to Arduino UNO, the I2C Slave. As to this example, Ameba is the I2C Slave, and receives data from the Arduino UNO, which is the I2C master. + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +In the previous example `“I2C - Slave Send Data to Arduino UNO” `_, Ameba, the I2C master, transmits data to Arduino UNO, the I2C Slave. As to this example, Ameba is the I2C Slave, and receives data from the Arduino UNO, which is the I2C master. + +.. only:: end aw-cu488 + +.. only:: amb25 + +In the previous example `“I2C - Slave Send Data to Arduino UNO” `_, Ameba, the I2C master, transmits data to Arduino UNO, the I2C Slave. As to this example, Ameba is the I2C Slave, and receives data from the Arduino UNO, which is the I2C master. + +.. only:: end amb25 + +.. only:: amb26 + +In the previous example `“I2C - Slave Send Data to Arduino UNO” `_, Ameba, the I2C master, transmits data to Arduino UNO, the I2C Slave. As to this example, Ameba is the I2C Slave, and receives data from the Arduino UNO, which is the I2C master. + +.. only:: end amb26 + +**Setting up Arduino Uno to be I2C Master** + +First, select Arduino in the Arduino IDE in “Tools” → “Board” → “Arduino Uno” +Open “Examples” → “Wire” → “master_writer”: + +|image01| + +Then click “Sketch” → “Upload” to compile and upload the example to Arduino Uno. + +**Setting up Ameba to be I2C Slave** + +Next, open another window of Arduino IDE, making sure to choose your Ameba development board in the IDE: “Tools” → “Board” +Then open the “Master Writer” example in “File” → “Examples” → “AmebaWire” → “SlaveReader” + +|image02| + +**Wiring** + +The Arduino example uses A4 as the I2C SDA and A5 as the I2C SCL. +Another important thing to note is that the GND pins of Arduino and Ameba should be connected to each other. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image03| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image04| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image05| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image06| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image07| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image08| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image09| + +.. only:: end amb26 + +Open the Arduino IDE of the Arduino Uno and open the serial monitor (“Tools” → “Serial Monitor”). +Next, press the reset button on Arduino Uno. Now the Arduino Uno (Master) is establishing connection to Ameba (Slave). In the Serial Monitor, you can see the messages printed from Arduino Uno. +We press the reset button on Ameba to start receiving messages from Arduino UNO. Then observe the serial monitor, you can see the messages show up every 0.5 second. + +|image10| + +Code Reference +-------------- + +You can find detailed information of this example in the documentation of Arduino: +https://www.arduino.cc/en/Tutorial/MasterWriter + +First use Wire.begin()/Wire.begin(address) to join the I2C bus as a master or slave, in the Master case the address is not required. +https://www.arduino.cc/en/Reference/WireBegin + +Next, the Master uses Wire.beginTransmission(address) to begin a transmission to the I2C slave with the given address: +https://www.arduino.cc/en/Reference/WireBeginTransmission + +Uses Wire.write() to send data, and finally use Wire.endTransmission() to end a transmission to a Slave and transmits the bytes that were queued: +https://www.arduino.cc/en/Reference/WireEndTransmission + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image01.png + :width: 546 + :height: 868 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image02.png + :width: 596 + :height: 859 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image03.png + :width: 1540 + :height: 1051 + :scale: 50% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image04.png + :width: 1005 + :height: 743 + :scale: 80% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image05.png + :width: 923 + :height: 717 + :scale: 80% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image06.png + :width: 959 + :height: 690 + :scale: 80% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image07.png + :width: 546 px + :height: 501 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image08.png + :width: 487 + :height: 457 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image09.png + :width: 519 + :height: 457 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image10.png + :width: 649 + :height: 410 diff --git a/source/_common/ameba_d/Example_Guides/I2C/I2C - Slave Send Data to Arduino UNO.rst b/source/_common/ameba_d/Example_Guides/I2C/I2C - Slave Send Data to Arduino UNO.rst new file mode 100644 index 0000000..bc23a94 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/I2C/I2C - Slave Send Data to Arduino UNO.rst @@ -0,0 +1,160 @@ +I2C - Slave Send Data to Arduino UNO +==================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- Arduino UNO x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +There are two roles in the operation of I2C, one is “master”, the other is “slave”. Only one master is allowed and can be connected to many slaves. Each slave has its unique address, which is used in the communication between master and the slave. I2C uses two pins, one is for data transmission (SDA), the other is for the clock (SCL). Master uses the SCL to inform slave of the upcoming data transmission, and the data is transmitted through SDA. The I2C example was named “Wire” in the Arduino example. + +**Procedure** +~~~~~~~~~~~~~ + +In this example, we use Ameba as the I2C slave writer, and Arduino as the I2C master receiver. +When the I2C slave receives a string sent from I2C master, it prints the received string. + +**Setting up Arduino Uno to be I2C Master** + +First, select Arduino in the Arduino IDE in “Tools” → “Board” → “Arduino Uno” +Open the “Master Reader” example in “Examples” → “Wire” → “master_reader”: + +|image01| + +Then click “Sketch” → “Upload” to compile and upload the example to Arduino Uno. + +**Setting up Ameba to be I2C Slave** + +Next, open another window of Arduino IDE, making sure to choose your Ameba development board in the IDE: “Tools” → “Board” + +Then open the “Master Writer” example in “File” → “Examples” → “AmebaWire” → “SlaveWriter” + +|image02| + +**Wiring** + +The Arduino example uses A4 as the I2C SDA and A5 as the I2C SCL. +Another important thing to note is that the GND pins of Arduino and Ameba should be connected to each other. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image03| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image04| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image05| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image06| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image07| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image08| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image09| + +.. only:: end amb26 + +Open the Arduino IDE of the Arduino Uno and open the serial monitor (“Tools” → “Serial Monitor”). +Next, press the reset button on Arduino Uno. Now the Arduino Uno (Master) is waiting for the connection from Ameba (Slave). In the Serial Monitor, you can see the messages printed from Arduino Uno. +We press the reset button on Ameba to start transmitting messages to Arduino UNO. Then observe the serial monitor, you can see the messages show up every 0.5 second. + +|image10| + +Code Reference +-------------- + +You can find detailed information of this example in the documentation of Arduino: +https://www.arduino.cc/en/Tutorial/MasterWriter + +First use Wire.begin()/Wire.begin(address) to join the I2C bus as a master or slave, in the Master case the address is not required. +https://www.arduino.cc/en/Reference/WireBegin + +Next, the Master uses Wire.beginTransmission(address) to begin a transmission to the I2C slave with the given address: +https://www.arduino.cc/en/Reference/WireBeginTransmission + +Uses Wire.write() to send data, and finally use Wire.endTransmission() to end a transmission to a Slave and transmits the bytes that were queued: +https://www.arduino.cc/en/Reference/WireEndTransmission + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image01.png + :width: 546 + :height: 868 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image02.png + :width: 596 + :height: 859 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image03.png + :width: 1540 + :height: 1051 + :scale: 50% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image04.png + :width: 1005 + :height: 743 + :scale: 80% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image05.png + :width: 923 + :height: 717 + :scale: 80% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image06.png + :width: 959 + :height: 690 + :scale: 80% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image07.png + :width: 546 px + :height: 501 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image08.png + :width: 487 + :height: 457 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image09.png + :width: 519 + :height: 457 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image10.png + :width: 649 + :height: 410 diff --git a/bak/ambd/_common/Example_Guides/I2C/index.rst b/source/_common/ameba_d/Example_Guides/I2C/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/I2C/index.rst rename to source/_common/ameba_d/Example_Guides/I2C/index.rst diff --git a/source/_common/ameba_d/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over TCP.rst b/source/_common/ameba_d/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over TCP.rst new file mode 100644 index 0000000..ebb031a --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over TCP.rst @@ -0,0 +1,85 @@ +IPv6 - Ameba as IPv6 Server/Client over TCP +=========================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 2 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +This example shows how Ameba can communicate on the local network using Internet Protocol version 6 over TCP. +Note that this example only works after you have set up the server and then configure the client accordingly. + +**Procedure** +~~~~~~~~~~~~~ + +Step 1. IPv6TCPServer +Open the example, ``“Files” → “Examples” → “WiFi” → “IPv6TCPServer”``. + +|image01| + +In the sample code, modify the highlighted section to enter the information required (ssid, password) to connect to your WiFi network. + +|image02| + +Next, upload the code and press the reset button on Ameba once the upload is finished. +Open Serial Monitor and copy the IPv6 address of the Server (the highlighted area) for later use, + +|image03| + +Step 2. IPv6TCPClient +Now take the second Ameba D and open another example, ``“Files” → “Examples” → “WiFi” → “IPv6TCPClient”``. + +|image04| + +In the sample code, modify the highlighted section to enter the information required (ssid, password) to connect to your WiFi network. + +|image05| + +From the previous step, we have obtained the Server's IPv6 address, now we copy the server's IPv6 address to “IPv6TCPClient” example in the highlighted area below, + +|image06| + +Next, upload the code and press the reset button on Ameba once the upload is finished. +Open Serial Monitor on the port to the second Ameba D, you should see server and client are sending text message to each other at the same time. + + +|image07| + +|image08| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image01.png + :width: 1160 + :height: 962 + :scale: 70% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image02.png + :width: 427 + :height: 490 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image03.png + :width: 602 + :height: 294 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image04.png + :width: 1196 + :height: 957 + :scale: 70% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image05.png + :width: 431 + :height: 494 +.. |image06| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image06.png + :width: 510 + :height: 436 +.. |image07| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image07.png + :width: 517 + :height: 271 +.. |image08| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_TCP/image08.png + :width: 518 + :height: 266 diff --git a/source/_common/ameba_d/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over UDP.rst b/source/_common/ameba_d/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over UDP.rst new file mode 100644 index 0000000..325a32d --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/IPv6/IPv6 - Ameba as IPv6 Server Client over UDP.rst @@ -0,0 +1,83 @@ +IPv6 - Ameba as IPv6 Server/Client over UDP +=========================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 2 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +This example shows how Ameba can communicate on the local network using Internet Protocol version 6 over UDP. +Note that this example only works after you have set up the server and then configure the client accordingly. + +**Procedure** +~~~~~~~~~~~~~ + +Step 1. IPv6UDPServer +Open the example, ``“Files” → “Examples” → “WiFi” → “IPv6UDPServer”``. + +|image01| + +In the sample code, modify the highlighted section to enter the information required (ssid, password) to connect to your WiFi network. + +|image02| + +Next, upload the code and press the reset button on Ameba once the upload is finished. +Open Serial Monitor and copy the IPv6 address of the Server (the highlighted area) for later use, + +|image03| + +Step 2. IPv6UDPClient +Now take the second Ameba D and open another example, ``“Files” → “Examples” → “WiFi” → “IPv6UDPClient”``. + +|image04| + +In the sample code, modify the highlighted section to enter the information required (ssid, password) to connect to your WiFi network. + +|image05| + +From the previous step, we have obtained the Server's IPv6 address, now we copy the server's IPv6 address to “IPv6UDPClient” example in the highlighted area below, + +|image06| + +Next, upload the code and press the reset button on Ameba once the upload is finished. +Open Serial Monitor on the port to the second Ameba D, you should see server and client are sending text message to each other at the same time. + +|image07| + +|image08| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image01.png + :width: 1158 + :height: 961 + :scale: 70% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image02.png + :width: 458 + :height: 527 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image03.png + :width: 602 + :height: 294 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image04.png + :width: 1156 + :height: 962 +.. |image05| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image05.png + :width: 436 + :height: 491 +.. |image06| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image06.png + :width: 471 + :height: 449 +.. |image07| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image07.png + :width: 517 + :height: 271 +.. |image08| image:: ../../../../_static/amebad/Example_Guides/IPv6/IPv6_Ameba_As_IPv6_Server_Client_Over_UDP/image08.png + :width: 517 + :height: 271 diff --git a/bak/ambd/_common/Example_Guides/IPv6/index.rst b/source/_common/ameba_d/Example_Guides/IPv6/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/IPv6/index.rst rename to source/_common/ameba_d/Example_Guides/IPv6/index.rst diff --git a/source/_common/ameba_d/Example_Guides/MDNS/MDNS - Set up mDNS Client on Arduino IDE.rst b/source/_common/ameba_d/Example_Guides/MDNS/MDNS - Set up mDNS Client on Arduino IDE.rst new file mode 100644 index 0000000..032979b --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/MDNS/MDNS - Set up mDNS Client on Arduino IDE.rst @@ -0,0 +1,95 @@ +MDNS - Set up mDNS Client on Arduino IDE +======================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +mDNS (Multicast DNS) is a protocol used in the local area network. It delivers the network information like IP address and provided services to others. mDNS is based on the UDP protocol, and it sends packets to 224.0.0.251 with port 5353 under IPv4 address. +The naming style for the service follows the format: : **{Instance Name}.{Protocol Name}.{Domain}** + + - Instance Name: used to identify the name of the service + - Protocol Name: Divided into two parts, the front end is in regard to the name of the service, and it adds baseline as a prefix. The rear end is in regard to the transport protocol name it used, and it also adds baseline as a prefix + - Domain: Local area network in normal cases + +For example, Arduino IDE adopts the naming for the mDNS service which is used in OTA as following: **MyAmeba._arduino._tcp.local** +Among the naming example, “MyAmeba” can identify the Ameba device name and the name “MyAmeba” is changeable. “_arduino._tcp” is the protocol that Arduino IDE adopts, and the Domain is set as local in common. +Open the example, “File” → “Examples” → “AmebaMDNS” → “mdns_on_arduino_ide” +You need to input ssid and password of the AP because the example will use WiFi connection. +And you can find out the naming of the service at the place where it declares MDNS Service. The example uses the default name “MyAmeba” and the name is changeable. + +|image01| + +Next, go to (“Tools” → “Port”), and you can find out at least one Serial Port. This port is simulated by Ameba board via USB. Choose this port and upload the compiled code to Ameba. + +|image02| + +After uploading the code, press the reset button on Ameba and waiting for Ameba to connect with AP and activate the mDNS service after a while. You can see the Log at the bottom of the Serial Monitor. + +|image03| + +Then you can find out the added item **“Network Ports” “MyAmeba at 192.168.1.167 (Ameba RTL8722DM/RTL8722CSM)”**, “MyAmeba” is the device name we set up, and “IP” is the IP address that AP assigned to Ameba, the IP address should be the same with the IP shown in the Serial Monitor. Last, “Ameba RTL8722DM/RTL8722CSM” is the type name of the board, and it means that Ameba can let Arduino IDE identify the mDNS service successfully.(We still can not use the Internet to upload the code, and we will explain this part in the OTA example.) + +|image04| + +If you cannot find the Network ports on your Arduino IDE, please check: + + - Does your computer in the same local area network with the Ameba? + - Restart the Arduino IDE, and it will find the mDNS service again + - Check the Log in Serial Monitor if the Ameba connects to the AP and activate mDNS service successfully + +Code Reference +-------------- + +The program set up the mDNS service in the beginning, the first parameter is Instance Name, and it is changeable in this example. The second parameter is the protocol that the service used, and it would be “_arduino._tcp” for Arduino IDE. The third parameter is Domain, and it would be “local” in common. The fourth parameter is the port number for the service, it is 5000 here and we doesn't use it in the example. + +.. code-block:: c++ + + MDNSService service("MyAmeba", "_arduino._tcp", "local", 5000); + +After connected to the network, we set up some text fields for the service. For the following example, “board” is the name of the field, “ameba_rtl8721d” is the value of the field. “board” is used to let Arduino IDE check installed SDK to see if it exists known device or not. We will use the name of the device if there is known device, users can change “ameba_rtl8721d” to “yun” or other names to find out what's the difference if interested. + +.. code-block:: c++ + + service.addTxtRecord("board", strlen("ameba_rtl8721d"),"ameba_rtl8721d"); + +Then we add three text fields ``“auth_upload”``, ``“tcp_check”``, and ``“ssh_upload”``, this example does not activate these services. + +.. code-block:: c++ + + service.addTxtRecord("auth_upload", strlen("no"), "no"); + service.addTxtRecord("tcp_check", strlen("no"), "no"); + service.addTxtRecord("ssh_upload", strlen("no"), "no"); + +Next we activate MDNS + +.. code-block:: c++ + + MDNS.begin(); + +and register to the mDNS service. + +.. code-block:: c++ + + MDNS.registerService(service); + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/MDNS/MDNS_Set_Up_MDNS_Client_On_Arduino_IDE/image01.png + :width: 679 + :height: 623 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/MDNS/MDNS_Set_Up_MDNS_Client_On_Arduino_IDE/image02.png + :width: 679 + :height: 853 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/MDNS/MDNS_Set_Up_MDNS_Client_On_Arduino_IDE/image03.png + :width: 704 + :height: 355 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/MDNS/MDNS_Set_Up_MDNS_Client_On_Arduino_IDE/image04.png + :width: 777 + :height: 853 diff --git a/source/_common/ameba_d/Example_Guides/MDNS/index.rst b/source/_common/ameba_d/Example_Guides/MDNS/index.rst new file mode 100644 index 0000000..3e3e102 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/MDNS/index.rst @@ -0,0 +1,8 @@ +MDNS +==== + +.. toctree:: + :maxdepth: 1 + + MDNS - Set up mDNS Client on Arduino IDE + \ No newline at end of file diff --git a/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Set up MQTT Client over TLS.rst b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Set up MQTT Client over TLS.rst new file mode 100644 index 0000000..f1932d6 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Set up MQTT Client over TLS.rst @@ -0,0 +1,60 @@ +MQTT - Set up MQTT Client over TLS +================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +In this example, Ameba connect to a MQTT broker using TLS authentication. Then send messages as a publisher and receive messages as a subscriber. + +Open the MQTT example ``“File” → “Examples” →“AmebaMQTTClient” → “MQTT_TLS”`` + +Please modify the WiFi-related parameters and MQTT parameters. + +|image01| + +- “ssid” is the network SSID for internet access. + +- “pass” is the network password for internet access. + +- The “mqttServer” refers to the MQTT-Broker, there is free MQTT sandbox “test.mosquitto.org” for testing. + +- “clientId” is an identifier for MQTT-Broker to identify the connected device. + +- “publishTopic” is the topic of the published message. It is “outTopic” in the example. The devices that subscribed to “outTopic” will receive the message. + +- “publishPayload” is the content to be published. + +- “subscribeTopic” is to tell MQTT-broker which topic to subscribe to by the board. + + +Next, compile the code and upload it to Ameba. Press the reset button, then open the serial monitor. + +|image02| + +After Ameba is connected to MQTT server, it sends the message “hello world” to “outTopic”. To see the message, use another MQTT client. Refer to the MQTT_Basic example guide on how to setup a PC-based MQTT client. + +In addition to use TLS client authentication to server authentication, it requires to generate an OpenSSL private key and obtain a signed certificate from the server. For testing purposes, signed certificates can be obtained from test.mosquitto.org by following the guide at https://test.mosquitto.org/ssl/. + +Replace the character strings “certificateBuff” and “privateKeyBuff” with the signed certificate and OpenSSL private key, ensuring that they are formatted the same way as the shown in the example code. Set “MQTT_TLS_SERVER_AUTH” to be “1”. + + +|image03| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image01.png + :width: 519 + :height: 240 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image02.png + :width: 801 + :height: 289 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image03.png + :width: 256 + :height: 51 diff --git a/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Set up MQTT Client to Communicate with Broker.rst b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Set up MQTT Client to Communicate with Broker.rst new file mode 100644 index 0000000..a63a6e5 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Set up MQTT Client to Communicate with Broker.rst @@ -0,0 +1,188 @@ +MQTT - Set up MQTT Client to Communicate with Broker +==================================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +MQTT (Message Queuing Telemetry Transport) is a protocol proposed by IBM and Eurotech. The introduction in `MQTT Official Website `_: +MQTT is a machine-to-machine (M2M)/”Internet of Things” connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. We can say MQTT is a protocol designed for IoT. MQTT is based on TCP/IP and transmits/receives data via publish/subscribe. + +Please refer to the figure below: + +|image01| + +In the operation of MQTT, there are several roles: + +- **Publisher**: Usually publishers are the devices equipped with sensors (ex. Ameba). Publishers uploads the data of the sensors to MQTT-Broker, which serves as a database with MQTT service. + +- **Subscriber**: Subscribers are referred to the devices which receive and observe messages, such as a laptop or a mobile phone. + +- **Topic**: Topic is used to categorize the messages, for example the topic of a message can be “PM2.5” or “Temperature”. Subscribers can choose messages of which topics they want to receive. + +In this page, there are 3 examples that connect Ameba to MQTT-Broker. Then send messages as publisher and receive messages from MQTT-Broker as subscriber. + +1. MQTT_Basic + +2. MQTT_Auth + +3. MQTT_Publish_In_Callback + +**Procedure** +~~~~~~~~~~~~~ + +**MQTT_Basic example** + + +Open the MQTT example ``“File” → “Examples” → “AmebaMQTTClient” → “MQTT_Basic”`` + +Please modify some WiFi-related parameter and some information related to MQTT: + +|image02| + +- “ssid” is the network SSID for internet access. + +- “pass” is the network password for internet access. + +- The “mqttServer” refers to the MQTT-Broker, there is free MQTT sandbox “test.mosquitto.org” for testing. + +- “clientId” is an identifier for MQTT-Broker to identify the connected device. + +- “publishTopic” is the topic of the published message. It is “outTopic” in the example. The devices that subscribed to “outTopic” will receive the message. + +- “publishPayload” is the content to be published. + +- “subscribeTopic” is to tell MQTT-broker which topic to subscribe to by the board. + +Next, compile the code and upload it to Ameba. Press the reset button, then open the serial monitor. + +|image03| + +After Ameba is connected to MQTT server, it sends the message “hello world” to “outTopic”. To see the message, another MQTT client needs to be set up. + +The “MQTT Explore” is an all-platform application that can be set as the MQTT client. Refer to the website http://mqtt-explorer.com/. + +Click “Connections” at top left to start a new connection setup. “Name” can be customized. Set “Host” as “test.mosquitto.org”. + + +|image04| + +Click “ADVANCED” at bottom for topic setup. Use “outTopic” that same as “publishTopic” of the board. Click “ADD” then “BACK”. + +|image05| + +Click “CONNECT”. The “hello world” message show up at left side. At right side, under “Publish” use “inTopic” same as “sucribeTopic” of the board. Choose “raw” and input “Text hello Ameba”, then click “PUBLISH”. The board will receive the MQTT Explorer published raw message. Note, because of the host is a free public host, the board may receive unexpected messages. + +|image06| + +|image07| + +**MQTT_Auth example** + +Open the MQTT example “File” → “Examples” → “AmebaMQTTClient” → “MQTT_Auth” +Please modify some WiFi-related parameter and some information related to MQTT: + +|image08| + +- “mqttServer” refers to the MQTT-Broker, there is free MQTT auth host provided by amebaiot homepage “cloud.amebaiot.com”. Please visit https://www.amebaiot.com/en/cloud-getting-started/ for account setup. + +- “clientId” is an identifier for MQTT-Broker to identify the connected device. In this case, it is the registered device name. Refer to https://www.amebaiot.com/en/cloud-service/. + +- “clientUser” is the authentication username. In this case, it is the login username of Realtek IoT/Wi-Fi MCU Solutions website. Note, it will be unable to receive message if use the email as “clientUser”. + +- “clientPass” is the authentication password. In this case, it is the login password of Realtek IoT/Wi-Fi MCU Solutions website. + +- The other parameters are same as previous. + +Next, compile the code and upload it to Ameba. Press the reset button, then open the serial monitor. After Ameba is connected to MQTT server, it sends the message “hello world” to “outTopic”. To see the message, another MQTT client needs to be set up. + +Start the MQTT Explore, and setup the auth connection. + +Click “Connections” at top left to start a new connection setup. “Name” can be customized. Set “Host” as “cloud. amebaiot.com”. “Username” and “Password” are same as “clientUser” and “clientPass”. + +|image09| + +Click “ADVANCED” at bottom for topic setup. Use “outTopic” that same as “publishTopic” of the board. Click “ADD” then “BACK”. +Click “CONNECT”. The “hello world” message show up at left side. At right side, under “Publish” use “inTopic” same as “sucribeTopic” of the board. Choose “raw” and input “Text hello Ameba”, then click “PUBLISH”. The board will receive the MQTT Explorer published raw message. Note, “hello world” sometimes is not shown up because the boards connect to MQTT broker before the MQTT Explorer. + +|image10| + +|image11| + +**MQTT_Publish_In_Callback example** + +Open the MQTT example “File” → “Examples” → “AmebaMQTTClient” → “MQTT_Publish_In_Callback” + +Please modify some WiFi-related parameter and some information related to MQTT: + +- All parameters are same as MQTT_Auth example. + +Next, compile the code and upload it to Ameba. Press the reset button, then open the serial monitor. After Ameba is connected to MQTT server, it sends the message “hello world” to “outTopic”. To see the message, another MQTT client needs to be set up. + +Start the MQTT Explore, and setup the auth connection. All setting is same as MQTT_Auth example. + +Click “ADVANCED” at bottom for topic setup. Use “outTopic” that same as “publishTopic” of the board. Click “ADD” then “BACK”. + +Click “CONNECT”. The “hello world” message show up at left side. At right side, under “Publish” use “inTopic” same as “sucribeTopic” of the board. Choose “raw” and input “Text hello Ameba”, then click “PUBLISH”. The board will receive the MQTT Explorer published raw message. Then publish it from the board side and MQTT Explorer will receive at the left side. Note, “hello world” sometimes is not shown up because the boards connect to MQTT broker before the MQTT Explorer. + +|image12| + +|image13| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image01.png + :width: 940 + :height: 619 + :scale: 80% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image02.png + :width: 498 + :height: 182 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image03.png + :width: 671 + :height: 190 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image04.png + :width: 1002 + :height: 654 + :scale: 70% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image05.png + :width: 996 + :height: 655 + :scale: 80% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image06.png + :width: 1000 + :height: 655 + :scale: 80% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image07.png + :width: 664 + :height: 206 +.. |image08| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image08.png + :width: 524 + :height: 217 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image09.png + :width: 998 + :height: 652 + :scale: 80% +.. |image10| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image10.png + :width: 997 + :height: 667 + :scale: 80% +.. |image11| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image11.png + :width: 650 + :height: 193 +.. |image12| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image12.png + :width: 1001 + :height: 653 + :scale: 80% +.. |image13| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image13.png + :width: 650 + :height: 199 diff --git a/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Upload PM2.5 Data to LASS System.rst b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Upload PM2.5 Data to LASS System.rst new file mode 100644 index 0000000..f8d29ec --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Upload PM2.5 Data to LASS System.rst @@ -0,0 +1,146 @@ +MQTT - Upload PM2.5 Data to LASS System +======================================= + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- PlanTower PMS3003 or PMS5003 x1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +The LASS stands for “Location Aware Sensor System”. It is an open project and was started only for the interest of public welfare. + +Practically, LASS is based on MQTT protocol to collect all kinds of uploaded data, and for those who need these data can subscribe top as well. + +In this example, we use applications mentioned at our website, including: + +- MQTT: a MQTT-Broker to connect to LASS. The Client is “FT1_0XXXX”, the XXXX are the four last digits of Ameba's Wi-Fi MAC, and the outTopic is “LASS/Test/Pm25Ameba/clientID“, where clientID is the actual Ameba’s MQTT client ID. + +- NTP: uploaded data must have time notation + +- PM2.5: uploaded data includes PM2.5 information + +**Procedure** +~~~~~~~~~~~~~ + +Open the example. ``“File” → “Examples” → “AmebaMQTTClient” → “lass_basic”`` + +LASS requires GPS information. There is no GPS sensor included in this example, so you must manually provide GPS information. Use Google Map to find the coordinates of where you plan to place your Ameba. You can see in this example that the latitude is 24.7814033, and the longitude is 120.9933676 + +|image01| + +Fill in GPS info at gps_lat and gps_lon. +Then connect sensors according to UART-PlanTower PMS3003 wiring example. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image02| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image03| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image04| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image05| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image06| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image07| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image08| + +.. only:: end amb26 + +Compile the code and upload it to Ameba. After pressing the Reset button, Ameba will attempt to read PM2.5 data every minute and upload it to LASS MQTT-Broker. +Open Serial Monitor to see the uploaded data, including client id, topic, and current PM2.5 status. + +|image09| + +We can also use “MQTT Explorer” to verify if the data is properly uploaded. + +Enter “gpssensor.ddns.net” as the MQTT-Broker server and “LASS/Test/PM25/live” as the subscribe topic to receive data. + +The time uses UTC format, and the PM2.5 data stores in s_d0. In the figure, s_d0 = 9 represents that the PM2.5 is 9, meaning that the entire publish/ subscribe process is working successfully. + +|image10| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image01.png + :width: 959 + :height: 668 + :scale: 80% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image02.png + :width: 1192 + :height: 796 + :scale: 70% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image03.png + :width: 771 + :height: 681 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image04.png + :width: 841 + :height: 640 +.. |image05| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image05.png + :width: 788 + :height: 650 +.. |image06| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image06.png + :width: 602 + :height: 763 +.. |image07| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image07.png + :width: 459 + :height: 467 +.. |image08| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image08.png + :width: 770 + :height: 515 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image09.png + :width: 886 + :height: 316 + :scale: 80% +.. |image10| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image10.png + :width: 1144 + :height: 263 + :scale: 70% diff --git a/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Use Amazon AWS IoT Shadow Service.rst b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Use Amazon AWS IoT Shadow Service.rst new file mode 100644 index 0000000..2b741fb --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Use Amazon AWS IoT Shadow Service.rst @@ -0,0 +1,180 @@ +MQTT - Use Amazon AWS IoT Shadow Service +======================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +Amazon AWS IoT provides cloud services and device support that you can use to implement IoT solutions. AWS provides many cloud services to support IoT-based applications. +AWS IoT Core provides the services that connect your IoT devices to the AWS Cloud so that other cloud services and applications can interact with your internet-connected devices. + +|image01| + +(Picture from https://docs.aws.amazon.com/iot/latest/developerguide/aws-iot-how-it-works.html ) +In the architecture, Ameba belongs to the upper-left “Things” block. A TLS secure channel will be established between “Things” and the MQTT Message Broker. Afterwards, “Things” and “Message Broker” communicate using MQTT Protocol via this secure channel. Behind the “Message Broker”, the “Thing Shadows” keeps messages temporarily when Ameba is offline and sends the control message to Ameba next time it is connected. The “Rules Engine” allows you to place restrictions to the behaviour of Things or to connect Things to other services of Amazon. + +**AWS IoT Core setting** + +First, create an account and sign up for AWS IoT service: https://aws.amazon.com/iot-core/. Afterwards, log in to the Amazon Management Console and click “IoT Core” found under services -> Internet of Things. Then select a nearby region. The is a Get Started online documents to refer for details. Note that the following steps needs to be done. + +- Create thing. Use “ameba” as the thing name. Add “attribute”, use “led” as name and “0” as value. + +- Create policy. Use “amebaPolicy” as name, “iot:*” as action, and “*” as resource ARN. + +- Create TLS certificate. Record “public keys”, “private key”, “certificate” and “root CA”. + +- After active, attach Policy and Thing. + +Find out the information of Rest API Endpoint to set Amazon Alexa: + +- REST API endpoint: + + - For example, in the value “https://a1a7oo4baosgyy.iot.us-east-1.amazonaws.com/things/ameba/shadow”, the part “a1a7oo4baosgyy.iot.us-east-1.amazonaws.com” is the MQTT Broker server address. + +- MQTT topic: + + - For example, the value “$aws/things/ameba/shadow/update” represents the MQTT topic we will use in the AWS IoT Shadow service (if we use MQTT only, without AWS IoT Shadow service, then we can specify other topic name). It is recommended to use “$aws/things/ameba/shadow/update” here. + +**Ameba setting** + +Open “File” → “Examples” → “AmebaMQTTClient” → “Amazon_AWS_IoT_Basic” + +In the sample code, +- Setup the WiFi network SSID and Password. + +- “Thing_Name” set as “ameba”. + +- “mqttServer” set as the MQTT broker server address found earlier in AWS IoT. + +- “rootCABuff” set as the recorded “root CA”. + +- “certificate”. Fill in the recorded certificate (i.e., client certificate), usually its file name ends with “-certificate.pem.crt” (e.g., “efae24a533-certificate.pem.crt”). Open the certificate with a text editor, and adjust its format as follows to use in the sketch: + + - Add the new line character “\n” at the end of each line. + + - Add double-quote at the beginning and the end of each line. + + - To concatenate each line as a string, add “\” at the end of each line. + + - The last line ends with semicolon. + +- “privateKeyBuff”. Adjust the format of the “private key” in the same way as certificate. + +**Compile and run** + +Upload the code and press the reset button on Ameba once the upload is complete. +Open the serial monitor in the Arduino IDE and observe as Ameba connects to the AWS IoT server and sends updates on the LED state variable. + +|image02| + +**Alternatives** + +Ameba can also retrieve the current LED status variable from the AWS shadow. This is done by sending a message to the “shadow/get” topic. Refer to the Amazon_AWS_IoT_with_ACK example code for more information. + +Code Reference +-------------- + +Change led state: +In this example, we use GPIO interface to control the led. We set led_pin to 10 and led_state to 1 by default in the sample code. + +.. code-block:: c++ + + pinMode(led_pin, OUTPUT); + + digitalWrite(led_pin, led_state); + +Set up certificate: +Note that we use the WiFiSSLClient type of wifiClient. + +.. code-block:: c++ + + WiFiSSLClient wifiClient; + +WiFiSSLClient inherits Client, so it can be passed as the parameter of PubSubClient constructor. +Next, set up TLS certificate required in connection. + +.. code-block:: c++ + + wifiClient.setRootCA((unsigned char*)rootCABuff); + + wifiClient.setClientCertificate((unsigned char*)certificateBuff, (unsigned char*)privateKeyBuff); + +Configure MQTT Broker server +Then MQTT PubClient set MQTT Broker server to connect + +.. code-block:: c++ + + client.setServer(mqttServer, 8883); + + client.setCallback(callback); + +Connect to MQTT Broker server: +In loop(), call reconnect() function and try to connect to MQTT Broker server and do the certificate verification. + +.. code-block:: c++ + + while (!client.connected()) { + +Subscribe & Publish +Next, subscribe to topics. + +.. code-block:: c++ + + for (int i=0; i<5; i++) { + + client.subscribe(subscribeTopic[i]); + + } + +There are some common topics: +“$aws/things/ameba/shadow/update/accepted”, + +“$aws/things/ameba/shadow/update/rejected”, + +“$aws/things/ameba/shadow/update/delta”, + +“$aws/things/ameba/shadow/get/accepted”, + +“$aws/things/ameba/shadow/get/rejected” + +Related documentation: +https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html + +Then publish current status: + +.. code-block:: c++ + + sprintf(publishPayload, "{\"state\":{\"reported\":{\"led\":%d}},\"clientToken\":\"%s\"}", led_state, clientId); + + client.publish(publishTopic, publishPayload); + +Listen to topic and make response: +In the callback function, we listen to the 5 subscribed topics and check if there are messages of “/shadow/get/accepted”: + +.. code-block:: c++ + + if (strstr(topic, "/shadow/get/accepted") != NULL) { + +If there is, the message is from the control side. If the attribute state in the message is different from current state, publish the new state. + +.. code-block:: c++ + + updateLedState(desired_led_state); + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image01.png + :width: 639 + :height: 309 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image02.png + :width: 851 + :height: 546 diff --git a/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Use Google Cloud IoT.rst b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Use Google Cloud IoT.rst new file mode 100644 index 0000000..8a828e4 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/MQTT/MQTT - Use Google Cloud IoT.rst @@ -0,0 +1,295 @@ +MQTT - Use Google Cloud IoT +=========================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +1. Select or create a Cloud Platform project +In the Google Cloud Console, select an existing project or create a new project. You will need a Project ID to use with Ameba. + +|image01| + +If creating a new project, enter a project name, and take note of the Project ID generated. + +|image02| + +2. Enable billing for your project + +Billing needs to be enabled for your project to use Google Cloud Platform features. Follow the guide in Google cloud documentation to enable billing. https://cloud.google.com/billing/docs/how-to/modify-project + +3. Enable the Cloud IoT Core API + +In Google Cloud console, click on the top left menu button and search for IoT Core. + +|image03| + +Click enable to activate Google Cloud IoT API for your project. + +|image04| + +4. Create a Cloud Pub/Sub topic +In Google Cloud console, click on the top left menu button and search for Pub/Sub. + +|image05| + +Create a new topic for your project and give it a suitable topic ID. + +|image06| + + +|image07| + +After the topic is created, go to the permissions tab of the info panel, and add “cloud-iot@system.gserviceaccount.com” with the role of “Pub/Sub Publisher”. + +|image08| + +|image09| + +|image10| + +5.Create a device registry +Go back to the IoT Core settings page and create a new registry. + +|image03| + +|image11| + +Choose a suitable **Registry ID** and select a server** Region** in which to store data. Remember the **Registry ID** and **Region** for use with Ameba later. For the Pub/Sub topic, select the topic created in the previous step. + +|image12| + +6. Create a public/private key pair +Using Openssl in a terminal in Windows/Linux/MacOs, run the following commands to generate a private and public key pair. Two files will be created by these commands, “ec_private.pem” containing the private key, and “ec_public.pem” containing the public key. + +.. code-block:: console + + $ openssl ecparam -genkey -name prime256v1 -noout -out ec_private.pem + $ openssl ec -in ec_private.pem -pubout -out ec_public.pem + + +|image13| + +Run the next command to extract out the private key, and remember the highlighted string of hexadecimal numbers for use with Ameba later. + +.. code-block:: console + + $ openssl ec -in ec_private.pem -noout -text + +|image14| + +7. Create a device +Go back to the IoT Core settings page and create a new device. + +|image15| + +Give the device a suitable **Device ID** and remember it for use with Ameba later. + +|image16| + +In the authentication section of the additional options, upload the previously generated “ec_public.pem” public key. + +|image17| + +8. Create a Cloud Pub/Sub subscription +To observe messages sent by Ameba, create a subscription in Pub/Sub. + +|image18| + +Choose a suitable subscription ID and select the previously created topic. + +|image19| + +**Example** +~~~~~~~~~~~ + +Open the example in ``“File” → “Examples” → “AmebaMQTTClient” → “Google_Cloud_IoT”``. + +|image20| + +Enter the required information in the highlighted sections below. + +|image21| + +In the yellow section, enter the SSID and password required to connect to your WiFi network. +In the green section, enter the Project ID, server Region, Registry ID and Device ID previously configured in Google Cloud console. +In the blue section, enter the hexadecimal string previously extracted from the private key. +Upload the code and press the reset button on Ameba once the upload is finished. Open the serial monitor and observe as Ameba connects and sends messages to Google Cloud IoT. + +|image22| + +In Google Cloud console, go to Pub/Sub subscriptions, select the previously created subscription, and click view messages. Here you can view the messages sent by Ameba. + +|image23| + +|image24| + +Code Reference +-------------- + +In ``setup()``, we set up RootCA which is required to form a TLS connection with Google’s servers. + +.. code-block:: c++ + + wifiClient.setRootCA((unsigned char*)rootCABuff); + +In ``loop()``, each loop checks the Internet status and re-connect to it when the environment has a problem. + +.. code-block:: c++ + + if (WiFi.status() != WL_CONNECTED) { + while (WiFi.begin(ssid, pass) != WL_CONNECTED) + { + delay(1000); + } + Serial.println("Connected to wifi"); + } + +To publish messages, mqtt_id , clientPass and pub_topic are required. +mqtt_id is generated by printing the project ID, server location, registry ID and device ID in the required format: + +.. code-block:: c++ + + mqtt_id = (char *)malloc(strlen("projects/") + strlen(project_id) + strlen("/locations/us-central1/registries/") + strlen(registry_id) + strlen("/devices/") + strlen(device_id) + 1); + sprintf(mqtt_id, "projects/%s/locations/us-central1/registries/%s/devices/%s", project_id, registry_id, device_id); + +clientPass is generated using a JSON web token (JWT) generator function, which requires the project ID and current time, and signs it with the private key: + +.. code-block:: c++ + + clientPass = CreateJwt(project_id, timeClient.getEpochTime(), priv_key); + +pub_topic is generated by printing the project ID and topic in the required format: + +.. code-block:: c++ + + pub_topic = (char *)malloc(strlen("/devices/") + strlen(device_id) + strlen("/events") + 1); + sprintf(pub_topic, "/devices/%s/events", device_id); + +MQTT Server setting: + +.. code-block:: c++ + + client.setServer(GOOGLE_MQTT_SERVER, GOOGLE_MQTT_PORT); + client.setPublishQos(MQTTQOS1); + client.waitForAck(true); + +Connect to google cloud and publish messages: + +.. code-block:: c++ + + if (client.connect(mqtt_id, clientUser, clientPass.c_str())){ + // ... + for(int i = 0; i < count; i++){ + // ... + sprintf(payload, "This is Ameba's %d message!!", i); + ret = client.publish(pub_topic, payload); + // ... + } + // ... + client.disconnect(); + } + free(mqtt_id); + free(pub_topic); + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image01.png + :width: 1352 + :height: 1125 + :scale: 60% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image02.png + :width: 1181 + :height: 540 + :scale: 70% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image03.png + :width: 1352 + :height: 1125 + :scale: 60% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image04.png + :width: 1352 + :height: 1125 + :scale: 60% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image05.png + :width: 1352 + :height: 1125 + :scale: 60% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image06.png + :width: 1352 + :height: 1125 + :scale: 60% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image07.png + :width: 1101 + :height: 916 + :scale: 80% +.. |image08| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image08.png + :width: 1622 + :height: 1125 + :scale: 50% +.. |image09| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image09.png + :width: 1622 + :height: 1125 + :scale: 50% +.. |image10| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image10.png + :width: 1321 + :height: 916 + :scale: 60% +.. |image11| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image11.png + :width: 1622 + :height: 1125 + :scale: 50% +.. |image12| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image12.png + :width: 1321 + :height: 916 + :scale: 60% +.. |image13| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image13.png + :width: 963 + :height: 694 + :scale: 80% +.. |image14| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image14.png + :width: 963 + :height: 694 + :scale: 80% +.. |image15| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image15.png + :width: 1622 + :height: 1125 + :scale: 50% +.. |image16| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image16.png + :width: 1380 + :height: 1125 + :scale: 60% +.. |image17| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image17.png + :width: 1380 + :height: 1125 + :scale: 60% +.. |image18| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image18.png + :width: 1380 + :height: 1125 + :scale: 60% +.. |image19| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image19.png + :width: 1153 + :height: 940 + :scale: 70% +.. |image20| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image20.png + :width: 737 + :height: 1202 +.. |image21| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image21.png + :width: 737 + :height: 1062 +.. |image22| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image22.png + :width: 732 + :height: 627 +.. |image23| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image23.png + :width: 1586 + :height: 1125 + :scale: 50% +.. |image24| image:: ../../../../_static/amebad/Example_Guides/MQTT/MQTT_Use_Google_Cloud_IoT/image24.png + :width: 1586 + :height: 1125 + :scale: 50% diff --git a/bak/ambd/_common/Example_Guides/MQTT/index.rst b/source/_common/ameba_d/Example_Guides/MQTT/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/MQTT/index.rst rename to source/_common/ameba_d/Example_Guides/MQTT/index.rst diff --git a/source/_common/ameba_d/Example_Guides/PWM/PWM - Play Music by Buzzer.rst b/source/_common/ameba_d/Example_Guides/PWM/PWM - Play Music by Buzzer.rst new file mode 100644 index 0000000..76303c5 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/PWM/PWM - Play Music by Buzzer.rst @@ -0,0 +1,122 @@ +PWM - Play Music by Buzzer +========================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- Buzzer x1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +A sound is composed of volume, tone and timbre. Volume is determined by the amplitude of the sound wave. Tone is determined by the frequency of the sound wave. Timbre is determined by the waveform of the sound wave. + +In this example, we use PWM to control the buzzer to emit sound with desired tone. As PWM outputs square waves, if we wish to emit tone C4 (frequency=262Hz), we must use PWM to output square waves with wavelength 1/262 = 3.8ms: + +|image01| + +We use PWM to output sound waves with different frequency, so as to play music through the buzzer. +Connect the buzzer to the PWM output pin shown in the following diagrams. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image02| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image03| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image04| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image05| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image06| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image07| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image08| + +.. only:: end amb26 + +Open the example code in ``“Examples” → “AmebaAnalog” → “TonePlayMelody”`` +Compile and upload to Ameba, press the reset button. Then you can hear the buzzer playing music. + +Code Reference +-------------- + +Ameba implement the tone() and noTone() API of Arduino: +https://www.arduino.cc/en/Reference/Tone +https://www.arduino.cc/en/Reference/NoTone + +In the sample code, we initiate a melody array, which stores the tones to make. Another array, noteDurations, contains the length of each tone, 4 represents quarter note (equals to 3000ms/4 = 750ms, and plus an extra 30% time pause), 8 represents eighth note. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image01.png + :width: 710 + :height: 184 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image02.png + :width: 1080 + :height: 926 + :scale: 70% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image03.png + :width: 806 + :height: 686 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image04.png + :width: 905 + :height: 678 +.. |image05| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image05.png + :width: 858 + :height: 712 +.. |image06| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image06.png + :width: 542 + :height: 673 +.. |image07| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image07.png + :width: 457 + :height: 475 +.. |image08| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image08.png + :width: 874 + :height: 721 + \ No newline at end of file diff --git a/source/_common/ameba_d/Example_Guides/PWM/PWM - Servo Control.rst b/source/_common/ameba_d/Example_Guides/PWM/PWM - Servo Control.rst new file mode 100644 index 0000000..98a8790 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/PWM/PWM - Servo Control.rst @@ -0,0 +1,126 @@ +PWM - Servo Control +=================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- Servo x 1 (Ex. Tower Pro SG90) + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +A typical servo has 3 wires, the red wire is for power, black or brown one should be connected to GND, and the other one is for signal data. We use PWM signal to control the rotation angle of the axis of the servo. The frequency of the signal is 50Hz, that is length 20ms. Each servo defines its pulse bandwidth, which is usually 1ms~2ms. + +To control the rotation angle, for example if 1ms-length pulse rotates the axis to degree 0, then 1.5 ms pulse rotates the axis to 90 degrees, and 2 ms pulse rotates the axis to 180 degrees. Furthermore, a servo defines the “dead bandwidth”, which stands for the required minimum difference of the length of two consecutive pulse for the servo to work. + +**Procedure** +~~~~~~~~~~~~~ + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image01| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image02| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image03| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image04| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image05| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image06| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image07| + +.. only:: end amb26 + +Open the example, ``“File” → “Examples” → “AmebaAnalog” → “ServoSweep”`` + +This example makes the servo to rotate from degree 0 to 180, and then rotate back to degree 0. + +Code Reference +-------------- + +The Servo API of Ameba is similar to the API of Arduino. To distinguish Ameba’s Servo API from the original API of Arduino, we name the header file “AmebaServo.h” and the Class “AmebaServo”. Usage is identical to the Arduino API. + +The default pulse bandwidth of Arduino Servo is 0.5ms~2.4ms, which is the same as Tower Pro SG90. Therefore, we set the attached pin directly: + +.. code-block:: c++ + + myservo.attach(9); + +Next, rotate the axis to desired position: + +.. code-block:: c++ + + myservo.write(pos); + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image01.png + :width: 1249 + :height: 974 + :scale: 60% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image02.png + :width: 800 + :height: 633 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image03.png + :width: 809 + :height: 598 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image04.png + :width: 837 + :height: 620 +.. |image05| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image05.png + :width: 631 + :height: 749 +.. |image06| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image06.png + :width: 485 + :height: 450 +.. |image07| image:: ../../../../_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image07.png + :width: 920 + :height: 654 + :scale: 80% diff --git a/bak/ambd/_common/Example_Guides/PWM/index.rst b/source/_common/ameba_d/Example_Guides/PWM/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/PWM/index.rst rename to source/_common/ameba_d/Example_Guides/PWM/index.rst diff --git a/source/_common/ameba_d/Example_Guides/UART/UART - Communicate with PC over USB to Serial Module.rst b/source/_common/ameba_d/Example_Guides/UART/UART - Communicate with PC over USB to Serial Module.rst new file mode 100644 index 0000000..a1f69f5 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/UART/UART - Communicate with PC over USB to Serial Module.rst @@ -0,0 +1,189 @@ +UART - Communicate with PC over USB to Serial Module +==================================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- USB to TTL Adapter x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +UART uses two wires, one for transmitting and the other one for receiving, so the data transmission is bidirectional. The communication uses a predefined frequency (baud rate) to transmit data. In Arduino, UART is called “Serial”. There is only one hardware UART on Arduino UNO and it is primarily used to read the log and messages printed by Arduino (it is also known as “Log UART”). If we use hardware UART for other purposes, the Log UART does not have resources to function. To provide more UART connections, it is possible to use a GPIO pin to simulate the behavior of UART with a software approach, this is called Software Serial. Ameba is equipped with several hardware UART ports, but it is also compatible with the Software Serial Library. + +**Procedure** +~~~~~~~~~~~~~ + +In this example, we use UART to connect USB to TTL adapter to Ameba. +USB to TTL adapter sends data to Ameba, the data would be returned by Ameba, and showed on the screen. + + +**Install USB to TTL Adapter** + +USB to TTL adapter converts USB to serial interface. Normally, there are at least 4 pins on the adapter, that is 3V3 (or 5V), GND, TX and RX. Generally, installing the driver for the USB to TTL adapter would be required before using it. If the adapter uses the chip of FTDI, Windows will search and install the driver automatically, otherwise, you may need to install the corresponding driver yourself. +Afterwards, open your Device Manager. You can find the corresponding serial port number of the USB to TTL adapter: + +|image01| + +**Executing the Example** + +Open the “SoftwareSerialExample” example in ``“File” → “Examples” → “AmebaSoftwareSerial” → “SoftwareSerial_Basic”``: + +|image02| + +SoftwareSerial_DetailSetting + +Open the “SoftwareSerialExample” example in “File” → “Examples” → “AmebaSoftwareSerial” → “SoftwareSerial_DetailSetting”: + +|image03| + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image04| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image05| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image06| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image07| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image08| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image09| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image10| + +.. only:: end amb26 + +Next, open a serial port terminal, such as Putty or Tera Term. (Putty is used in this example). Open the Putty window, choose “Serial” in connection type, and specify the port number of the USB to TTL adapter (e.g. COM8). In the speed field, fill in the baud rate of this connection. + +**SoftwareSerial_Basic** +Note that both sides of the connection should use the same baud rate. In this example we set baud rate to 4800. + +|image11| + +Next, select “Serial” on the left side. Set data bits to 8, stop bits to 1, parity to none, and flow control to none. Then click Open and press the reset button on Ameba. + +|image12| + +**SoftwareSerial_DetailSetting** + +|image13| + +You can see the “Hello, world?” message appears in Putty. + +**SoftwareSerial_Basics** +If characters are typed into Putty, the input characters would be sent to Serial RX of Ameba by TX of USB to TTL Adapter, and returned by Serial TX of Ameba. Finally, RX of USB to TTL Adapter receives the returned characters and prints them in Putty as shown in the picture below. + +**SoftwareSerial_DetailSetting** +If characters are typed into the serial monitor, the input character will print out in the Putty as shown in the picture below. + +|image14| + +Code Reference +-------------- + +First, use ``SoftwareSerial:begin(speed)`` to set the baud rate for the serial communication: +https://www.arduino.cc/en/Reference/SoftwareSerialBegin + +Use ``write()`` to send data, and use ``SoftwareSerial:available()`` to get the number of bytes available for reading from a software serial port: +https://www.arduino.cc/en/Reference/SoftwareSerialAvailable + +If there are data available to read, use read() to read from serial port. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image01.png + :width: 456 + :height: 370 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image02.png + :width: 683 + :height: 1006 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image03.png + :width: 949 + :height: 1033 + :scale: 80% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image04.png + :width: 1538 + :height: 612 + :scale: 50% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image05.png + :width: 1623 + :height: 685 + :scale: 50% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image06.png + :width: 1667 + :height: 749 + :scale: 50% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image07.png + :width: 1595 + :height: 653 + :scale: 50% +.. |image08| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image08.png + :width: 1457 + :height: 848 + :scale: 60% +.. |image09| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image09.png + :width: 1411 + :height: 703 + :scale: 60% +.. |image10| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image10.png + :width: 1577 + :height: 627 + :scale: 50% +.. |image11| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image11.png + :width: 466 + :height: 448 +.. |image12| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image12.png + :width: 466 + :height: 448 +.. |image13| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image13.png + :width: 395 + :height: 248 +.. |image14| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image14.png + :width: 395 + :height: 248 diff --git a/source/_common/ameba_d/Example_Guides/UART/UART - PM2.5 Concentration in The Air.rst b/source/_common/ameba_d/Example_Guides/UART/UART - PM2.5 Concentration in The Air.rst new file mode 100644 index 0000000..13d929d --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/UART/UART - PM2.5 Concentration in The Air.rst @@ -0,0 +1,129 @@ +UART - PM2.5 Concentration in The Air +===================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- PlanTower PMS3003 or PMS5003 x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +PMS3003 or PMS5003 is a sensor of air quality, it can detect the concentration of 0.3 to 10 micrometer particulate matters in the air. The sensor output its data via UART. + +The PMS3003 or PMS5003 sensor detects the concentration value of PM 1.0, PM 2.5, PM 10 particles. For example, PM 2.5 stands for fine particles with a diameter of 2.5 micrometers or less. + +Open the example in ``“File” → “Examples” → “AmebaSoftwareSerial” → “PMS3003_AirQuality”`` + +|image01| + +There are 8 pins in PMS3003: + +|image02| + +PMS3003 requires 5V power, but the working voltage of its IC is 3.3C. Therefore, the working voltage of Reset, TX, RX, Set is 3.3V as well. If the “Set” pin is pulled to high, the PMS3003 is put to operating mode. If the “Set” pin is pulled low, the PMS3003 is put to standby mode. + +TX/RX pins are for UART connection. Under operating mode, PMS3003 outputs the data it reads continuously (Each data is 32 bytes). Please refer to the following article for detailed data format information: + +https://www.dfrobot.com/wiki/index.php?title=PM2.5_laser_dust_sensor_SKU:SEN0177  + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image03| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image04| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image05| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image06| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image07| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image08| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image09| + +.. only:: end amb26 + +In this example, we do not use the “Set” and “Reset” pins. + +Compile the code and upload it to Ameba. After pressing the Reset button, Ameba starts to output the PM 2.5 data to serial monitor. + +|image10| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image01.png + :width: 777 + :height: 1006 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image02.png + :width: 981 + :height: 869 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image03.png + :width: 602 + :height: 440 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image04.png + :width: 602 + :height: 567 +.. |image05| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image05.png + :width: 602 + :height: 520 +.. |image06| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image06.png + :width: 602 + :height: 562 +.. |image07| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image07.png + :width: 629 + :height: 782 +.. |image08| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image08.png + :width: 459 + :height: 467 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image09.png + :width: 770 + :height: 515 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image10.png + :width: 649 + :height: 410 diff --git a/source/_common/ameba_d/Example_Guides/UART/UART - Retrieve GPS Position.rst b/source/_common/ameba_d/Example_Guides/UART/UART - Retrieve GPS Position.rst new file mode 100644 index 0000000..224b3da --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/UART/UART - Retrieve GPS Position.rst @@ -0,0 +1,170 @@ +UART - Retrieve GPS Position +============================ + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- `Adafruit Ultimate GPS Breakout `_ x 1 (Refer to `official document `_) + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +In this example, we use Adafruit Ultimate GPS Breakout. Its data format is pure text, so we can connect it to USB to TTL Adapter and observe the output. + +**Procedure** +~~~~~~~~~~~~~ + +|image01| + +|image02| + +It follows the NMEA sentence format (refer to http://aprs.gids.nl/nmea/)The GPS signal is weak in indoor environment. The status that the GPS signal is not received is called “not fix”. Bring the GPS module outdoors, when the GPS signal is “fix”, you would get a message similar to the figure below. + +|image03| + +In this example we are only interested in the “$GPRMC (Global Positioning Recommended Minimum Coordinates)”: + +**$GPRMC,032122.000,A,2446.8181,N,12059.7251,E,0.39,78.89,270116,,,A*53** +Each field is separated by a comma. + +- First field is the GMT time (Greenwich Mean Time), that is 032122.000 in this example. The time format is HH:MM:SS.SSS, i.e., 03:21:22.000. Note that the time zone and the daylight-saving time adjustment should be handled on your own. + +- Second field represents the status code + + - V: Void (Invalid) + + - A: Active, meaning the GPS signal is fix. + +- The third to sixth fields represent the geolocation + +In this example, 2446.8181,N represents 24 degrees 46.8181 minutes north latitude, and 12059.7251,E represents 120 degrees 59.7251 minutes east longitude. + +We can search **+24 46.8181’, +120 59.7251’** in Google maps to check whether the position is correct. + +|image04| + +- The seventh field is relative speed(knot). 1 knot = 1.852km/hr, in this example the relative speed is 0.39 knot. + +- The eighth field is the moving angle, which is calculated by its moving orbit. + +- The ninth field is the date with format ddMMyy. In this example, “270116” stands for day 27, January, year 2016. + +- The last field is checksum. In the example we have \*53 as checksum. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image05| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image06| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image07| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image08| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image09| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image10| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image11| + +.. only:: end amb26 + +Open the example in ``“Files” → “Examples” → “AmebaSoftwareSerial” → “Adafruit_GPS_parsing”``. + +Compile and upload to Ameba, then press the reset button. +The result will be output to Serial Monitor: + +|image12| + +|image13| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image01.png + :width: 1252 + :height: 294 + :scale: 70% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image02.png + :width: 649 + :height: 372 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image03.png + :width: 777 + :height: 425 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image04.png + :width: 1028 + :height: 651 + :scale: 80% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image05.png + :width: 1295 + :height: 1049 + :scale: 60% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image06.png + :width: 1100 + :height: 809 + :scale: 80% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image07.png + :width: 842 + :height: 590 +.. |image08| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image08.png + :width: 602 + :height: 476 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image09.png + :width: 731 + :height: 780 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image10.png + :width: 430 + :height: 378 +.. |image11| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image11.png + :width: 795 + :height: 582 +.. |image12| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image12.png + :width: 649 + :height: 410 +.. |image13| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image13.png + :width: 649 + :height: 410 + diff --git a/source/_common/ameba_d/Example_Guides/UART/UART - Set Callback Function For UART Communications.rst b/source/_common/ameba_d/Example_Guides/UART/UART - Set Callback Function For UART Communications.rst new file mode 100644 index 0000000..7ec9f37 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/UART/UART - Set Callback Function For UART Communications.rst @@ -0,0 +1,140 @@ +UART - Set Callback Function For UART Communications +==================================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- USB to TTL Adapter x 1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +This example shows how to set a callback function for UART communication to process the UART data. + +A USB to TTL adapter is required for this example. Ensure that you have the driver installed and connect it to the Ameba board as shown. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image01| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image02| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image03| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image04| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image05| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image06| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image07| + +.. only:: end amb26 + +Open the example in ``“File” → “Examples” → “AmebaSoftwareSerial” → “SoftwareSerial_Irq_Callback”`` + +|image08| + + +Upload the code and press the reset button on Ameba once the upload is finished. +Next, using a terminal program, such as TeraTerm or PuTTY, open a serial port and configure it according to the settings. Make sure the serial port number corresponds to the USB to TTL adapter. + +- Speed: 38400 + +- Data: 8 bit + +- Parity: none + +- Stop bits: 1 bit + +- Flow control: none + +|image09| + +Once the serial port is open, type in the terminal and press the enter key, and you will see the corresponding output. + +|image10| + +Code Reference +-------------- + +``mySerial.setAvailableCallback(mySerialCallback);`` is used to set the function mySerialCallback as a callback function for software serial. When a new character is received, the callback function checks if the character corresponds to the enter key, and releases the semaphore if it is true, which in turn allows the main loop to print out all the previously received characters. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image01.png + :width: 602 + :height: 463 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image02.png + :width: 1006 + :height: 798 + :scale: 80% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image03.png + :width: 1020 + :height: 705 + :scale: 80% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image04.png + :width: 602 + :height: 438 +.. |image05| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image05.png + :width: 497 + :height: 549 +.. |image06| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image06.png + :width: 461 + :height: 446 +.. |image07| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image07.png + :width: 759 + :height: 538 +.. |image08| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image08.png + :width: 721 + :height: 1006 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image09.png + :width: 665 + :height: 540 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image10.png + :width: 665 + :height: 540 diff --git a/bak/ambd/_common/Example_Guides/UART/index.rst b/source/_common/ameba_d/Example_Guides/UART/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/UART/index.rst rename to source/_common/ameba_d/Example_Guides/UART/index.rst diff --git a/source/_common/ameba_d/Example_Guides/WDT/Watchdog - Simple WDG Timer.rst b/source/_common/ameba_d/Example_Guides/WDT/Watchdog - Simple WDG Timer.rst new file mode 100644 index 0000000..1cc151a --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/WDT/Watchdog - Simple WDG Timer.rst @@ -0,0 +1,62 @@ +Watchdog - Simple WDG Timer +=========================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +In this example, we will use this simple watchdog timer example runs on the AmebaD Board to illustrate how to use the watchdog API. Before we get into the details of the example, let's briefly go through the definition of Watchdog as well as it's working principles. + +**Watchdog** + +Watchdog Timer (WDT) is a hardware timer that is used to detect the occurrence of a software fault, then automatically generates a system reset or a watchdog interrupt on the expiry of a programmed period. + +In layman terms, imagine in the situation while your micro-controller is confused in an infinity loop, or any case like the micro-controller hang while performing some tasks. The normal troubleshooting method would be to press the reset button and jump out of the infinity loop. However, is it practically impossible to do press on the button all time, therefore, the watchdog timer that embedded inside the micro-controller would help with this situation. + +|image01| + +**Feed the Dog** + +If you have a dog in your home. You need to feed that dog at a regular interval. if you can't feed one day, it will bite you! And likewise, this is the working logic behind the watchdog timer. + +In our example, we created 2 tasks that contain some loop that runs repeatedly, one is called “Small_Task” and the other is called “Big_Task”. We are enabling the watchdog timer is loaded with an initial value (5 seconds) greater than the total delay in the “Small_Task”, but shorter than the “Big_Task”. +For the successful case, the watchdog is being refreshed/feed within 5 seconds, however, for the failed case, the loop is under processing and the watchdog is not being fresh after 5 seconds, which triggers the watchdog (dog barks), an interrupt is generated to reset the processor. Likewise, the watchdog timer protects the micro-controller from the hanging case. + + +Then we move to the coding part for this example, for this example, you will only need the RTL8722CSM/RTL8722DM/RTL8722DM MINI Board itself. + +Firstly, make sure the correct Ameba development board is selected in Arduino IDE: ``“Tools” → “Board” → “RTL8722CSM/RTL8722DM” (or “RTL8722DM MINI”)``. +Then open the “Watchdog Timer” example in ``“File” → “Examples” → “AmebaWatchdog” → “Watchdog Timer”``: + +|image02| + +Upon successfully upload the sample code, open the serial monitor, and press the reset button. You will find that the “Small_Task” can refresh the watchdog within the 5 seconds (initialized in the watchdog timer). However, the “Big_Task” will not be able to refresh the watchdog within 5 seconds, which the watchdog “barks” then the microcontroller reset. + +|image03| + +.. note :: If you are running this example on a different platform, like macOS, you could discover that the code only does 4 dummy tasks during the execution of the big task, instead of 5 indicated above. The number of dummy tasks executed depends on the computer processing speed. The processing speed of various processors can result in varying processing times during code compilation. It is not necessary to compare how many tasks were completed before Ameba was forced to reset from the big task in this case. + +You can also set “#define RUN_CALLBACK_IF_WATCHDOG_BARKS (0)” value be “1”, for customized “my_watchdog_irq_handler”. Write the code inside the handler for execution after “barks”. + +|image04| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/WDT/Watchdog_Simple_WDG_Timer/image01.png + :width: 602 + :height: 405 +.. |image02| image:: ../../../../_static/amebad/Example_Guides/WDT/Watchdog_Simple_WDG_Timer/image02.png + :width: 595 + :height: 740 +.. |image03| image:: ../../../../_static/amebad/Example_Guides/WDT/Watchdog_Simple_WDG_Timer/image03.png + :width: 383 + :height: 628 +.. |image04| image:: ../../../../_static/amebad/Example_Guides/WDT/Watchdog_Simple_WDG_Timer/image04.png + :width: 379 + :height: 419 diff --git a/bak/ambd/_common/Example_Guides/WDT/index.rst b/source/_common/ameba_d/Example_Guides/WDT/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/WDT/index.rst rename to source/_common/ameba_d/Example_Guides/WDT/index.rst diff --git a/source/_common/ameba_d/Example_Guides/WS2812B/WS2812B - Basics.rst b/source/_common/ameba_d/Example_Guides/WS2812B/WS2812B - Basics.rst new file mode 100644 index 0000000..0238aff --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/WS2812B/WS2812B - Basics.rst @@ -0,0 +1,149 @@ +WS2812B - Basics +================ + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- WS2812B LED Strip / Ring / Stick / Board x1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +In this example, we will be using the AmebaD board to control the WS2812B RGB LED, using the SPI peripheral to create the waveform necessary for the LEDs. + +WS2812B basics allows you to control a single LED with a color or fill all the LED with the same color. + +Procedure +---------- + +Firstly, connect the WS2812B to the Ameba board as shown in the following diagrams. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image01| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image02| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image03| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image04| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image05| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image06| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image07| + +.. only:: end amb26 + +To light up one individual LED or multiple LEDs with the same color, use **WS2812B_Basics**. + +Open the example in ``“File” → “Example” → “AmebaWS2812B” → “WS2812B_Basics”`` + +|image08| + +In the sample code, modify **TOTAL_NUM_OF_LEDS** to be the total number of LEDs on the WS2812B module, and modify **NUM_OF_LEDS** to be the number of LEDs that you have connected. + +|image09| + +Next, compile and upload to Ameba, then press the reset button. You will see the first 3 LED light up with red, green, and blue light color individually and after a while all the LED will be filled with a color. + +|image10| + +|image11| + +Code Reference +-------------- + +[1] WS2812B Datasheet: + +https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image01.png + :width: 1234 + :height: 747 + :scale: 70% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image02.png + :width: 1375 + :height: 724 + :scale: 60% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image03.png + :width: 1320 + :height: 685 + :scale: 60% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image04.png + :width: 1381 + :height: 684 + :scale: 60% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image05.png + :width: 957 + :height: 710 + :scale: 80% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image06.png + :width: 1287 + :height: 702 + :scale: 60% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image07.png + :width: 1437 + :height: 616 + :scale: 60% +.. |image08| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image08.png + :width: 724 + :height: 1016 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image09.png + :width: 624 + :height: 293 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image10.png + :width: 2912 + :height: 512 + :scale: 30% +.. |image11| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image11.png + :width: 2908 + :height: 516 + :scale: 30% diff --git a/source/_common/ameba_d/Example_Guides/WS2812B/WS2812B - Patterns.rst b/source/_common/ameba_d/Example_Guides/WS2812B/WS2812B - Patterns.rst new file mode 100644 index 0000000..7053690 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/WS2812B/WS2812B - Patterns.rst @@ -0,0 +1,161 @@ +WS2812B - Patterns +================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 +- WS2812B LED Strip / Ring / Stick / Board x1 + +Example +------- + +**Introduction** +~~~~~~~~~~~~~~~~ + +In this example, we will be using the AmebaD board to control the WS2812B RGB LED, using the SPI peripheral to create the waveform necessary for the LEDs. + +WS2812B basics allows you to control a single LED with a color or fill all the LED with the same color. + +Procedure +----------- + +Firstly, connect the WS2812B to the Ameba board as shown in the following diagrams. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image01| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image02| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image03| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image04| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image05| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image06| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image07| + +.. only:: end amb26 + +To create different light patterns with many different colors, use**WS2812B_Patterns**. + +Open the example in ``“File” → “Example” → “AmebaWS2812B” → “WS2812B_Patterns”`` + +|image08| + +In the sample code, modify **TOTAL_NUM_OF_LEDS** to be the total number of LEDs on the WS2812B module, and modify **NUM_OF_LEDS** to be the number of LEDs that you have connected. + +|image09| + +Next compile and upload to Ameba, then press the reset button. You will see the WS2812B displaying a color wipe, theater chase, rainbow, and theater chase rainbow light patterns in loop. + +|image10| + +|image11| + +|image12| + +|image13| + +Code Reference +-------------- + +[1] WS2812B Datasheet: + +https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image01.png + :width: 1234 + :height: 747 + :scale: 70% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image02.png + :width: 1375 + :height: 724 + :scale: 60% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image03.png + :width: 1320 + :height: 685 + :scale: 60% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image04.png + :width: 1381 + :height: 684 + :scale: 60% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image05.png + :width: 957 + :height: 710 + :scale: 80% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image06.png + :width: 1287 + :height: 702 + :scale: 60% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image07.png + :width: 1437 + :height: 616 + :scale: 60% +.. |image08| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image08.png + :width: 707 + :height: 1005 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image09.png + :width: 620 + :height: 313 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image10.png + :width: 3016 + :height: 544 + :scale: 20% +.. |image11| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image11.png + :width: 2724 + :height: 536 + :scale: 30% +.. |image12| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image12.png + :width: 2300 + :height: 528 + :scale: 30% +.. |image13| image:: ../../../../_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image13.png + :width: 2888 + :height: 592 + :scale: 30% diff --git a/bak/ambd/_common/Example_Guides/WS2812B/index.rst b/source/_common/ameba_d/Example_Guides/WS2812B/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/WS2812B/index.rst rename to source/_common/ameba_d/Example_Guides/WS2812B/index.rst diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image12.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image12.png new file mode 100644 index 0000000..a6d7b89 Binary files /dev/null and b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image12.png differ diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image16.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image16.png new file mode 100644 index 0000000..6e0771d Binary files /dev/null and b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image16.png differ diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image17.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image17.png new file mode 100644 index 0000000..3685c05 Binary files /dev/null and b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image17.png differ diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image07.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image07.png new file mode 100644 index 0000000..ce739c2 Binary files /dev/null and b/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image07.png differ diff --git a/source/_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image08.PNG b/source/_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image08.PNG deleted file mode 100644 index 6fff82e..0000000 Binary files a/source/_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image08.PNG and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image08.png b/source/_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image08.png new file mode 100644 index 0000000..fb8bc0e Binary files /dev/null and b/source/_static/amebad/Example_Guides/I2C/I2C_Slave_Receive_Data_from_Arduino_UNO/image08.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image01.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image01.png index 1236bda..fb3b0a0 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image01.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image01.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image02.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image02.png index 5aefc62..da5b4d2 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image02.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image02.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image03.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image03.png index a80978e..c91c6e0 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image03.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image03.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image04.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image04.png deleted file mode 100644 index 81d1f80..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image04.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image05.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image05.png deleted file mode 100644 index ddb728b..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_Over_TLS/image05.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image02.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image02.png index b8502f3..bd13d4c 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image02.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image02.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image03.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image03.png index bc677fe..bbb35b0 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image03.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image03.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image04.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image04.png index 58ad497..bec6340 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image04.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image04.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image05.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image05.png index ce567ae..16a85c3 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image05.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image05.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image06.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image06.png index 02bd986..7b5bc27 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image06.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image06.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image07.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image07.png index 16f49de..51b93a7 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image07.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image07.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image08.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image08.png new file mode 100644 index 0000000..99a1c4c Binary files /dev/null and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image08.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image09.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image09.png new file mode 100644 index 0000000..3fc9ea1 Binary files /dev/null and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image09.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image10.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image10.png new file mode 100644 index 0000000..460c789 Binary files /dev/null and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image10.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image11.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image11.png new file mode 100644 index 0000000..d167179 Binary files /dev/null and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image11.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image12.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image12.png new file mode 100644 index 0000000..e249012 Binary files /dev/null and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image12.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image13.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image13.png new file mode 100644 index 0000000..f762491 Binary files /dev/null and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Set_Up_MQTT_Client_To_Communicate_With_Broker/image13.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image01.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image01.png index 3891d64..bbdf69d 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image01.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image01.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image02.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image02.png index bbdf69d..a2ac759 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image02.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image02.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image03.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image03.png index 35acba9..7b8edae 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image03.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image03.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image04.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image04.png index 513b4fb..0de85a9 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image04.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image04.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image05.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image05.png index 2cb66fc..99c8860 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image05.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image05.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image06.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image06.png index 2bbb073..f07e449 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image06.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image06.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image07.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image07.png index 63d9e0f..b8d0a7e 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image07.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image07.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image08.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image08.png index b7b8cd0..5c4c30f 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image08.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image08.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image09.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image09.png index 451910f..c231db5 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image09.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image09.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image10.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image10.png index 39224a2..97277c6 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image10.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Upload_PM2.5_Data_To_LASS_System/image10.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image01.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image01.png index 8062729..0bc52b1 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image01.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image01.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image02.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image02.png index 66c6679..a05d269 100644 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image02.png and b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image02.png differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image03.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image03.png deleted file mode 100644 index 3ffdddc..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image03.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image04.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image04.png deleted file mode 100644 index 7e822ba..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image04.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image05.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image05.png deleted file mode 100644 index 464cdd5..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image05.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image06.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image06.png deleted file mode 100644 index ba1d614..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image06.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image07.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image07.png deleted file mode 100644 index 9f2edd2..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image07.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image08.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image08.png deleted file mode 100644 index dcab1d0..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image08.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image09.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image09.png deleted file mode 100644 index f773dfd..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image09.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image10.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image10.png deleted file mode 100644 index e9ad733..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image10.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image11.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image11.png deleted file mode 100644 index e84c1d7..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image11.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image12.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image12.png deleted file mode 100644 index 612fabd..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image12.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image13.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image13.png deleted file mode 100644 index 21e5641..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image13.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image18.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image18.png deleted file mode 100644 index 4e859d7..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image18.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image19.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image19.png deleted file mode 100644 index 559fa2c..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image19.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image20.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image20.png deleted file mode 100644 index 841b07b..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image20.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image21.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image21.png deleted file mode 100644 index 7cb251b..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image21.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image22.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image22.png deleted file mode 100644 index 9a6391d..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image22.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image24.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image24.png deleted file mode 100644 index 0317bc8..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image24.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image25.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image25.png deleted file mode 100644 index 5f62c14..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image25.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image26.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image26.png deleted file mode 100644 index 48e6ab4..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image26.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image27.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image27.png deleted file mode 100644 index c1b9a0c..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image27.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image28.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image28.png deleted file mode 100644 index d5fe993..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image28.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image29.png b/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image29.png deleted file mode 100644 index a05d269..0000000 Binary files a/source/_static/amebad/Example_Guides/MQTT/MQTT_Use_Amazon_AWS_IoT_Shadow_Service/image29.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image07.PNG b/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image07.PNG deleted file mode 100644 index 0eeaadd..0000000 Binary files a/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image07.PNG and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image07.png b/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image07.png new file mode 100644 index 0000000..b63387d Binary files /dev/null and b/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image07.png differ diff --git a/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image08.png b/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image08.png new file mode 100644 index 0000000..45f67b9 Binary files /dev/null and b/source/_static/amebad/Example_Guides/PWM/PWM_Play_Music_by_buzzer/image08.png differ diff --git a/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image06.PNG b/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image06.PNG deleted file mode 100644 index 5f6f5f6..0000000 Binary files a/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image06.PNG and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image06.png b/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image06.png new file mode 100644 index 0000000..8924819 Binary files /dev/null and b/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image06.png differ diff --git a/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image07.png b/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image07.png new file mode 100644 index 0000000..804ca15 Binary files /dev/null and b/source/_static/amebad/Example_Guides/PWM/PWM_Servo_Control/image07.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image04.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image04.png index cf6ed92..516107d 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image04.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image04.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image05.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image05.png index 9d50a38..1631a69 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image05.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image05.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image06.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image06.png index c8b9fe1..4cb2c49 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image06.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image06.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image07.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image07.png index 90dc28f..3f6b2a0 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image07.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image07.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image08.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image08.png index 4a6042e..75e70c9 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image08.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image08.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image09.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image09.png index 3448e57..a2d502b 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image09.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image09.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image10.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image10.png index 860b230..09c92b0 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image10.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image10.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image11.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image11.png index 33243f1..974b12e 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image11.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image11.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image12.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image12.png index 9dde5bd..06a5231 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image12.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image12.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image13.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image13.png index 5dc07db..f2eade9 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image13.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image13.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image14.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image14.png index 9d8707b..8c4a1ac 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image14.png and b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image14.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image15.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image15.png deleted file mode 100644 index c8e41fa..0000000 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image15.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image16.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image16.png deleted file mode 100644 index 974b12e..0000000 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image16.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image17.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image17.png deleted file mode 100644 index 06a5231..0000000 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image17.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image18.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image18.png deleted file mode 100644 index f2eade9..0000000 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image18.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image19.png b/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image19.png deleted file mode 100644 index 8c4a1ac..0000000 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Communicate_with_PC_over_USB_to_Serial_Module/image19.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image09.png b/source/_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image09.png index eb0d991..5c4c30f 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image09.png and b/source/_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image09.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image10.png b/source/_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image10.png new file mode 100644 index 0000000..eb0d991 Binary files /dev/null and b/source/_static/amebad/Example_Guides/UART/UART_PM2.5_Concentration_in_the_Air/image10.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image07.png b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image07.png index 62789a5..39c9d9d 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image07.png and b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image07.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image08.png b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image08.png index 39c9d9d..62789a5 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image08.png and b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image08.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image11.png b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image11.png index 591d8d4..1f49dbc 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image11.png and b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image11.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image12.png b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image12.png index 811bc90..591d8d4 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image12.png and b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image12.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image13.png b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image13.png new file mode 100644 index 0000000..811bc90 Binary files /dev/null and b/source/_static/amebad/Example_Guides/UART/UART_Retrieve_GPS_Position/image13.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image07.png b/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image07.png index e82537d..9508592 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image07.png and b/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image07.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image08.png b/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image08.png index 8bcf148..e82537d 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image08.png and b/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image08.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image09.png b/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image09.png index b1044c9..8bcf148 100644 Binary files a/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image09.png and b/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image09.png differ diff --git a/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image10.png b/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image10.png new file mode 100644 index 0000000..b1044c9 Binary files /dev/null and b/source/_static/amebad/Example_Guides/UART/UART_Set_Callback_Function_For_UART_Communications/image10.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image07.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image07.png index 75dfa63..70f693f 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image07.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image07.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image08.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image08.png index 491b591..75dfa63 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image08.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image08.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image09.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image09.png index 539d28c..491b591 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image09.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image09.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image10.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image10.png index c12c7c3..539d28c 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image10.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image10.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image11.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image11.png new file mode 100644 index 0000000..c12c7c3 Binary files /dev/null and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Basics/image11.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image07.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image07.png index 69831b1..70f693f 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image07.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image07.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image08.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image08.png index 2b68798..69831b1 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image08.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image08.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image09.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image09.png index 084ba2a..2b68798 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image09.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image09.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image10.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image10.png index 8b265d6..084ba2a 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image10.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image10.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image11.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image11.png index 7954cc7..8b265d6 100644 Binary files a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image11.png and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image11.png differ diff --git a/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image13.png b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image13.png new file mode 100644 index 0000000..7954cc7 Binary files /dev/null and b/source/_static/amebad/Example_Guides/WS2812B/WS2812B_Patterns/image13.png differ diff --git a/source/ameba_d/amb21/Example_Guides/index.rst b/source/ameba_d/amb21/Example_Guides/index.rst index 21e22fe..2d1baa1 100644 --- a/source/ameba_d/amb21/Example_Guides/index.rst +++ b/source/ameba_d/amb21/Example_Guides/index.rst @@ -1,25 +1,33 @@ -Example Guides -============== - -.. toctree:: - :maxdepth: 2 - - AmebaMotor/index - AudioCodec/index - Basic/index - BLE/index - Debugging/index - E-Paper/index - Flash Memory/index - GPIO/index - HTTP/index - IR/index - NTP/index - OTA/index - Power Save/index - RTC/index - SPI/index - TensorFlow Lite/index - USB/index - WiFi/index - \ No newline at end of file +Example Guides +============== + +.. toctree:: + :maxdepth: 2 + + AmebaMotor/index + AudioCodec/index + Basic/index + BLE/index + Debugging/index + E-Paper/index + Flash Memory/index + GPIO/index + GTimer/index + HTTP/index + I2C/index + IPv6/index + IR/index + MDNS/index + MQTT/index + NTP/index + OTA/index + Power Save/index + PWM/index + RTC/index + SPI/index + TensorFlow Lite/index + UART/index + USB/index + WDT/index + WiFi/index + WS2812B/index \ No newline at end of file diff --git a/source/ameba_d/amb23/Example_Guides/index.rst b/source/ameba_d/amb23/Example_Guides/index.rst index 5ecb204..52cbae9 100644 --- a/source/ameba_d/amb23/Example_Guides/index.rst +++ b/source/ameba_d/amb23/Example_Guides/index.rst @@ -1,23 +1,32 @@ -Example Guides -============== - -.. toctree:: - :maxdepth: 2 - - AudioCodec/index - Basic/index - BLE/index - Debugging/index - E-Paper/index - FatfsSDIO/index - Flash Memory/index - GPIO/index - HTTP/index - NTP/index - OTA/index - Power Save/index - RTC/index - TensorFlow Lite/index - USB/index - SPI/index - WiFi/index \ No newline at end of file +Example Guides +============== + +.. toctree:: + :maxdepth: 2 + + AudioCodec/index + Basic/index + BLE/index + Debugging/index + E-Paper/index + FatfsSDIO/index + Flash Memory/index + GPIO/index + GTimer/index + HTTP/index + I2C/index + IPv6/index + MDNS/index + MQTT/index + NTP/index + OTA/index + Power Save/index + PWM/index + RTC/index + SPI/index + TensorFlow Lite/index + UART/index + USB/index + WDT/index + WiFi/index + WS2812B/index \ No newline at end of file diff --git a/source/ameba_d/amb25/Example_Guides/index.rst b/source/ameba_d/amb25/Example_Guides/index.rst index a407cce..a38a05c 100644 --- a/source/ameba_d/amb25/Example_Guides/index.rst +++ b/source/ameba_d/amb25/Example_Guides/index.rst @@ -1,21 +1,30 @@ -Example Guides -============== - -.. toctree:: - :maxdepth: 2 - - Basic/index - BLE/index - Debugging/index - E-Paper/index - Flash Memory/index - GPIO/index - HTTP/index - IR/index - NTP/index - OTA/index - Power Save/index - RTC/index - SPI/index - TensorFlow Lite/index - WiFi/index \ No newline at end of file +Example Guides +============== + +.. toctree:: + :maxdepth: 2 + + Basic/index + BLE/index + Debugging/index + E-Paper/index + Flash Memory/index + GPIO/index + GTimer/index + HTTP/index + I2C/index + IPv6/index + IR/index + MDNS/index + MQTT/index + NTP/index + OTA/index + Power Save/index + PWM/index + RTC/index + SPI/index + TensorFlow Lite/index + UART/index + WDT/index + WiFi/index + WS2812B/index \ No newline at end of file diff --git a/source/ameba_d/amb26/Example_Guides/index.rst b/source/ameba_d/amb26/Example_Guides/index.rst index a407cce..a38a05c 100644 --- a/source/ameba_d/amb26/Example_Guides/index.rst +++ b/source/ameba_d/amb26/Example_Guides/index.rst @@ -1,21 +1,30 @@ -Example Guides -============== - -.. toctree:: - :maxdepth: 2 - - Basic/index - BLE/index - Debugging/index - E-Paper/index - Flash Memory/index - GPIO/index - HTTP/index - IR/index - NTP/index - OTA/index - Power Save/index - RTC/index - SPI/index - TensorFlow Lite/index - WiFi/index \ No newline at end of file +Example Guides +============== + +.. toctree:: + :maxdepth: 2 + + Basic/index + BLE/index + Debugging/index + E-Paper/index + Flash Memory/index + GPIO/index + GTimer/index + HTTP/index + I2C/index + IPv6/index + IR/index + MDNS/index + MQTT/index + NTP/index + OTA/index + Power Save/index + PWM/index + RTC/index + SPI/index + TensorFlow Lite/index + UART/index + WDT/index + WiFi/index + WS2812B/index \ No newline at end of file diff --git a/source/ameba_d/aw-cu488/Example_Guides/index.rst b/source/ameba_d/aw-cu488/Example_Guides/index.rst index 7ebf859..e1caffb 100644 --- a/source/ameba_d/aw-cu488/Example_Guides/index.rst +++ b/source/ameba_d/aw-cu488/Example_Guides/index.rst @@ -1,22 +1,31 @@ -Example Guides -============== - -.. toctree:: - :maxdepth: 2 - - AudioCodec/index - Basic/index - BLE/index - Debugging/index - E-Paper/index - Flash Memory/index - GPIO/index - HTTP/index - IR/index - NTP/index - OTA/index - Power Save/index - RTC/index - SPI/index - TensorFlow Lite/index - WiFi/index \ No newline at end of file +Example Guides +============== + +.. toctree:: + :maxdepth: 2 + + AudioCodec/index + Basic/index + BLE/index + Debugging/index + E-Paper/index + Flash Memory/index + GPIO/index + GTimer/index + HTTP/index + I2C/index + IPv6/index + IR/index + MDNS/index + MQTT/index + NTP/index + OTA/index + Power Save/index + PWM/index + RTC/index + SPI/index + TensorFlow Lite/index + UART/index + WDT/index + WiFi/index + WS2812B/index \ No newline at end of file diff --git a/source/ameba_d/bw16-typeb/Example_Guides/index.rst b/source/ameba_d/bw16-typeb/Example_Guides/index.rst index 05eb19f..29edb13 100644 --- a/source/ameba_d/bw16-typeb/Example_Guides/index.rst +++ b/source/ameba_d/bw16-typeb/Example_Guides/index.rst @@ -1,21 +1,30 @@ -Example Guides -============== - -.. toctree:: - :maxdepth: 2 - - Basic/index - BLE/index - Debugging/index - E-Paper/index - Flash Memory/index - GPIO/index - HTTP/index - IR/index - NTP/index - OTA/index - Power Save/index - RTC/index - SPI/index - TensorFlow Lite/index - WiFi/index +Example Guides +============== + +.. toctree:: + :maxdepth: 2 + + Basic/index + BLE/index + Debugging/index + E-Paper/index + Flash Memory/index + GPIO/index + GTimer/index + HTTP/index + I2C/index + IPv6/index + IR/index + MDNS/index + MQTT/index + NTP/index + OTA/index + Power Save/index + PWM/index + RTC/index + SPI/index + TensorFlow Lite/index + UART/index + WDT/index + WiFi/index + WS2812B/index diff --git a/source/ameba_d/bw16-typec/Example_Guides/IR/IR - Transmit IR NEC Raw Data and Decode.rst b/source/ameba_d/bw16-typec/Example_Guides/IR/IR - Transmit IR NEC Raw Data and Decode.rst new file mode 100644 index 0000000..205c94c --- /dev/null +++ b/source/ameba_d/bw16-typec/Example_Guides/IR/IR - Transmit IR NEC Raw Data and Decode.rst @@ -0,0 +1,149 @@ +IR - Transmit IR NEC Raw Data and Decode +======================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [ AMB21 / AMB22 / BW16 / AW-CU488 Thing Plus / AMB25 / AMB26 ] x 2 + +- Grove - Infrared Emitter x1 (Figure 1) + +- Grove - Infrared Receiver x1 (Figure 2) + +Example +------- + +In this example, we use two AmebaD boards that connecting with an infrared (IR) Emitter and an IR Receiver separately to transmit and receive IR NEC Raw data. + +|image01| + +Figure 1: Grove - Infrared Receiver + +|image02| + +Figure 2: Grove - Infrared Emitter + +On the transmission side, the transmitter will send IR NEC raw data. The raw data can be seen as consecutive durations of “marks” and “spaces” (Figure 3) in microseconds (us). + +- Mark: a specific period of sending pulses + +- Space: a specific period of sending nothing + +|image03| + +Figure 3: A typical IR transmission and reception setup implementation + +For more details, please refer to SB-Projects' topic of `IR Remote Control Theory `_ to learn the theory of IR remote controls operation and a collection of IR protocol descriptions. In this example, we are going to use NEC (Now Renesas, also known as Japanese Format) as the transmission protocol. + +**NEC Features** + +- 8-bit address and 8-bit command length. + +- Extended mode available, doubling the address size. + +- Address and command are transmitted twice for reliability. + +- Pulse distance modulation. + +- The carrier frequency of 38kHz. + +- Bit time of 1.125ms or 2.25ms. + +**Modulation** + +NEC protocol uses Pulse Distance Encoding of the bits for data communication (Figure 4). A logical “1” is represented by total duration of 2250us, with 560us of “marks” and (2250-560) us of “spaces”. While logical ”0” is represented by total duration of 1120us, with 560us “marks” and (1120-560) us of “spaces”. + +|image04| + +Figure 4: Modulation of NEC + +Since a total number of 32-bit data together with the header and the end-bit will be transferred (Figure 5). + +If we separate the data in the time-frame (in us), there will be ( 2 + 32 ) x 2 + 1 = 69 “marks” / “spaces” to be transmitted (Figure 6), which forms the raw NEC data we would like to transmit in our Arduino “\*.ino” file. This part of the code can be modified by users. Details of how to obtain raw data code for your remote devices, you may refer to `Ken Shirriff's blog `_, where it provides multiple libraries provided online. + +|image05| + +Figure 5: Sample of a Full NEC Data (in logic1 or 0) + +|image06| + +Figure 6: Sample of a Full NEC RAW Data (in us) + +**IR Emitter** + +|image11| + +**IR receiver** + +|image12| + +After the connection is being set up correctly, we will move to the coding part for this example. First, make sure the correct Ameba development board is selected in Arduino IDE: “Tools” → “Board”. + +Open the “IRSendRAW” example in “File” → “Examples” → “AmebaIRDevice” → “IRSendRAW” and upload to 1st board connected with IR Emitter: + +|image19| + +After successfully upload the sample code for IRSendRaw, you might need to upload the IRRecvNEC example for the 2nd board connected with IR Receiver from “File” → “Examples” → “AmebaIRDevice” → “IRRecvNEC”. + +After opening the serial monitor on the IR Receiver side and press the reset buttons on two boards, the data “48” will be received every 3 seconds (due to the delays () function, not compulsory to wait). After decoding the signal from the receiving Pin D8 and transmitting Pin D9 with Logic Analyser and Pulse View, the result is also shown +as “48” after decoding the receiving data with IR NEC Protocol. + +|image20| + +Code Reference +-------------- + +| [1] Seeed Official website for Grove - Infrared Receiver +| https://wiki.seeedstudio.com/Grove-Infrared_Receiver/ + +| [2] Seed Official website for Grove - Infrared Emitter +| https://wiki.seeedstudio.com/Grove-Infrared_Emitter/ + +| [3] Ken SHirriff's blog on A Multi-Protocol Infrared Remote Library for the Arduino +| http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html + +| [4] SB-Projects: IR Remote Control Project +| https://www.sbprojects.net/knowledge/ir/index.php + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image01.png + :width: 688 + :height: 686 + :scale: 70 % +.. |image02| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image02.png + :width: 394 + :height: 323 + :scale: 100 % +.. |image03| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image03.png + :width: 531 + :height: 188 + :scale: 100 % +.. |image04| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image04.png + :width: 425 + :height: 125 + :scale: 100 % +.. |image05| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image05.png + :width: 550 + :height: 110 + :scale: 100 % +.. |image06| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image06.png + :width: 830 + :height: 109 + :scale: 100 % +.. |image11| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image11.png + :width: 856 + :height: 777 +.. |image12| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image12.png + :width: 851 + :height: 735 +.. |image19| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image19.png + :width: 554 + :height: 537 + :scale: 100 % +.. |image20| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_NEC_Raw_Data_And_Decode/image20.png + :width: 1210 + :height: 163 + :scale: 80 % diff --git a/source/ameba_d/bw16-typec/Example_Guides/IR/IR - Transmit IR Sony Data.rst b/source/ameba_d/bw16-typec/Example_Guides/IR/IR - Transmit IR Sony Data.rst new file mode 100644 index 0000000..3e4347b --- /dev/null +++ b/source/ameba_d/bw16-typec/Example_Guides/IR/IR - Transmit IR Sony Data.rst @@ -0,0 +1,103 @@ +IR - Transmit IR Sony Data +========================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [ AMB21 / AMB22 / BW16 / AW-CU488 Thing Plus / AMB25 / AMB26 ] x 2 + +- Grove - Infrared Emitter x1 (Figure 1) + +Example +------- + +In this example, we use one AmebaD board that connecting with an infrared (IR) Emitter to transmit and receive IR SONY data “0xA90” (Sony TV power code). For the receiver side, you can either use an oscilloscope/logic analyser to view the waveform and decode accordingly. + +|image01| + +Figure 1: Grove - Infrared Transmitter + +On the transmission side, the transmitter will send IR SONY data. For more details, please refer to SB-Projects' topic of IR Remote Control Theory to learn the theory of IR remote controls operation and a collection of IR protocol descriptions. In this example, we are going to use Sony as the transmission protocol. + +**Sony Features** + +- 12-bit version, 7 command bits, 5 address bits. + +- Pulse width modulation. + +- Carrier frequency of 40kHz. + +- Bit time of 1.2ms or 0.6ms. + +**Sony SIRC Modulation** + +The SIRC protocol uses pulse width encoding of the bits. The pulse representing a logical "1" is a 1200us long burst of the 40kHz carrier, while the burst width for a logical "0" is 600us long. All bursts are separated by a 600us long space interval as shown in Figure 2 below. + +|image02| + +Figure 2: Sony SIRC Modulation + +**Protocol** + +|image03| + +Figure 3: 12-bit Sony SIRC protocol + +The Figure 3 above shows a typical pulse train of the 12-bit SIRC protocol. With this protocol the LSB is transmitted first. The start burst is always 2.4ms wide, followed by a standard space of 0.6ms. Apart from signalling the start of a SIRC message this start burst is also used to adjust the gain of the IR receiver. Then the 7-bit Command is transmitted, followed by the 5-bit Device address. In this case Address 1 and Command 19 is transmitted. + +Commands are repeated every 45ms (measured from start to start) for as long as the key on the remote control is held down. + +|image06| + +After the connection is being set up correctly, we will move to the coding part for this example. First, make sure the correct Ameba development board is selected in Arduino IDE: “Tools” -> “Board”. + +Open the “IRSendSONY” example in “File” -> “Examples” -> “AmebaIRDevice” -> “IRSendSONY” and upload to the board connected with IR Emitter: + +|image10| + +After successfully upload the sample code for IRSendSONY, you could use oscilloscope or Pulse View software to find out the waveform of the signal transmitted from the IR Emitter is “0xA90” as shown in Figure below: + +|image11| + +Code Reference +-------------- + +| [1] Seed Official website for Grove - Infrared Emitter +| https://wiki.seeedstudio.com/Grove-Infrared_Emitter/ + +| [2] Ken SHirriff's blog on A Multi-Protocol Infrared Remote Library for the Arduino +| http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html + +| [3] SB-Projects: IR Remote Control Project +| https://www.sbprojects.net/knowledge/ir/index.php + +| [4] SONY SIRC Protocol +| https://www.sbprojects.net/knowledge/ir/sirc.php + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_Sony_Data/image01.png + :width: 150 + :height: 150 + :scale: 100 % +.. |image02| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_Sony_Data/image02.png + :width: 338 + :height: 94 + :scale: 100 % +.. |image03| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_Sony_Data/image03.png + :width: 322 + :height: 83 + :scale: 100 % +.. |image06| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_Sony_Data/image06.png + :width: 856 + :height: 777 +.. |image10| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_Sony_Data/image10.png + :width: 440 + :height: 394 + :scale: 100 % +.. |image11| image:: ../../../../_static/amebad/Example_Guides/IR/IR_Transmit_IR_Sony_Data/image11.png + :width: 1610 + :height: 244 + :scale: 70 % diff --git a/source/ameba_d/bw16-typec/Example_Guides/IR/index.rst b/source/ameba_d/bw16-typec/Example_Guides/IR/index.rst new file mode 100644 index 0000000..b6aac7c --- /dev/null +++ b/source/ameba_d/bw16-typec/Example_Guides/IR/index.rst @@ -0,0 +1,9 @@ +IR +== + +.. toctree:: + :maxdepth: 1 + + IR - Transmit IR NEC Raw Data and Decode + IR - Transmit IR Sony Data + \ No newline at end of file diff --git a/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Hello World.rst b/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Hello World.rst new file mode 100644 index 0000000..b820c9e --- /dev/null +++ b/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Hello World.rst @@ -0,0 +1,46 @@ +TensorFlow Lite - Hello World +============================= + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / BW16 / AW-CU488 Thing Plus / AMB25 / AMB26] x 1 + +- LED x 1 + +Example +------- + +Download the Ameba customized version of TensorFlow Lite for Microcontrollers library at https://github.com/Ameba-AIoT/ameba-arduino-d/blob/master/Arduino_zip_libraries/Ameba_TensorFlowLite.zip. + +Follow the instructions at https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries to install it. + +Ensure that the patch files found at https://github.com/Ameba-AIoT/ameba-arduino-d/tree/master/Ameba_misc/TensorFlowLite_patch are also installed. + +Open the example, "Files" → "Examples" → “TensorFlowLite_Ameba” → “hello_world”. + +|image01| + +| Upload the code and press the reset button on Ameba once the upload is finished. +| Connect the LED to digital pin 10 and ground, ensuring that the polarity is correct. You should see the LED fade in and out rapidly. +| In the Arduino serial plotter, you can see the output value of the Tensorflow model plotted as a graph, it should resemble a sine wave. + +|image02| + +Code Reference +-------------- + +More information on TensorFlow Lite for Microcontrollers can be found at: https://www.tensorflow.org/lite/microcontrollers + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Hello_World/image01.png + :width: 1201 + :height: 1791 + :scale: 50 % +.. |image02| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Hello_World/image02.png + :width: 1880 + :height: 1349 + :scale: 40 % \ No newline at end of file diff --git a/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Magic Wand.rst b/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Magic Wand.rst new file mode 100644 index 0000000..b8a59f4 --- /dev/null +++ b/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Magic Wand.rst @@ -0,0 +1,74 @@ +TensorFlow Lite - Magic Wand +============================ + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / BW16 / AW-CU488 Thing Plus / AMB25 / AMB26] x 1 + +- Adafruit LSM9DS1 accelerometer + +- LED x 2 + +Example +------- + +Wiring Diagram: + +Connect the accelerometer and LEDs to the BW16 according to the diagram below. + +|image04| + +Download the Ameba customized version of TensorFlow Lite for Microcontrollers library at https://github.com/Ameba-AIoT/ameba-arduino-d/blob/master/Arduino_zip_libraries/Ameba_TensorFlowLite.zip. + +|image08| + +Follow the instructions at https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries to install it. + +Ensure that the patch files found at https://github.com/Ameba-AIoT/ameba-arduino-d/tree/master/Ameba_misc/TensorFlowLite_patch are also installed. + +In the Arduino IDE library manager, install the Arduino_LSM9DS1 library. This example has been tested with version 1.1.0 of the LSM9DS1 library. + +Open the example, "Files" → "Examples" → “TensorFlowLite_Ameba” → “magic_wand”. + +|image09| + +Upload the code and press the reset button on Ameba once the upload is finished. + +Holding the accelerometer steady, with the positive x-axis pointing to the right and the positive z-axis pointing upwards, move it following the shapes as shown, moving it in a smooth motion over 1 to 2 seconds, avoiding any sharp movements. + +|image10| + +If the movement is recognised by the Tensorflow Lite model, you should see the same shape output to the Arduino serial monitor. Different LEDs will light up corresponding to different recognized gestures. Note that the wing shape is easy to achieve, while the slope and ring shapes tend to be harder to get right. + +|image11| + +Code Reference +-------------- + +More information on TensorFlow Lite for Microcontrollers can be found at: https://www.tensorflow.org/lite/microcontrollers + +.. |image04| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Magic_Wand/image04.png + :width: 980 + :height: 734 + :scale: 80 % +.. |image08| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Magic_Wand/image08.png + :width: 583 + :height: 329 + :scale: 100 % +.. |image09| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Magic_Wand/image09.png + :width: 556 + :height: 830 + :scale: 100 % +.. |image10| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Magic_Wand/image10.png + :width: 777 + :height: 337 + :scale: 100 % +.. |image11| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Magic_Wand/image11.png + :width: 639 + :height: 458 + :scale: 100 % \ No newline at end of file diff --git a/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Person Detection.rst b/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Person Detection.rst new file mode 100644 index 0000000..da4efef --- /dev/null +++ b/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/TensorFlow Lite - Person Detection.rst @@ -0,0 +1,67 @@ +TensorFlow Lite - Person Detection +================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [ AMB21 / AMB22 / AMB23 / BW16 / AW-CU488 Thing Plus / AMB25 / AMB26 ] x 1 + +- Arducam Mini 2MP Plus OV2640 SPI Camera Module x 1 + +- LED x 3 + +Example +------- + +Wiring Diagram: + +Connect the camera and LEDs to the Ameba board according to the diagram below. + +|image04| + +1. Download the Ameba customized version of TensorFlow Lite for Microcontrollers library at https://github.com/Ameba-AIoT/ameba-arduino-d/blob/master/Arduino_zip_libraries/Ameba_TensorFlowLite.zip. Follow the instructions at https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries to install it. + +2. Download Ameba_ArduCAM library at https://github.com/Ameba-AIoT/ameba-arduino-d/blob/master/Arduino_zip_libraries/Ameba_ArduCAM.zip. Follow the instructions at https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries to install it. + +3. In the Arduino IDE library manager, install the "JPEGDecoder" library. This example has been tested with version 1.8.0 of the JPEGDecoder library. Once the library has installed, you will need to configure it to disable some optional components that are not compatible with the RTL8722DM. Open the following file: ``Arduino/libraries/JPEGDecoder/src/User_Config.h`` Make sure that both ``#define LOAD_SD_LIBRARY`` and ``#define LOAD_SDFAT_LIBRARY`` are commented out, as shown in this excerpt from the file: + +.. code-block:: c + + //#define LOAD_SD_LIBRARY // Default SD Card library + //#define LOAD_SDFAT_LIBRARY // Use SdFat library instead, so SD Card SPI can be bit bashed + +4. Applying the patch files found at https://github.com/Ameba-AIoT/ameba-arduino-d/tree/master/Ameba_misc/TensorFlowLite_patch by following the “readme.txt” under the same path. + +Open the example, "Files" → "Examples" → “TensorFlowLite_Ameba” → “person_detection”. + +|image08| + +| User can define the LED pins by using any GPIO pins on the boards. +| Upload the code and press the reset button on Ameba once the upload is finished. + +| Once it is running, you should see the blue LED flashing once every few seconds, indicating that it has finished processing an image. +| The red LED will light up if it determines that there is no person in the previous image captured, and the green LED will light up if it determines that there is a person. + +| The inference results are also output to the Arduino serial monitor, which appear as follows: + +|image09| + +Code Reference +-------------- + +More information on TensorFlow Lite for Microcontrollers can be found at: https://www.tensorflow.org/lite/microcontrollers + +.. |image04| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Person_Detection/image04.png + :width: 1360 + :height: 770 + :scale: 60% +.. |image08| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Person_Detection/image08.png + :width: 556 + :height: 830 +.. |image09| image:: ../../../../_static/amebad/Example_Guides/TensorFlowLite/TensorFlow_Lite_Person_Detection/image09.png + :width: 639 + :height: 477 diff --git a/bak/ambd/bw16-typec/Example_Guides/TensorFlow/index.rst b/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/index.rst similarity index 94% rename from bak/ambd/bw16-typec/Example_Guides/TensorFlow/index.rst rename to source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/index.rst index 66e2058..cdeaf32 100644 --- a/bak/ambd/bw16-typec/Example_Guides/TensorFlow/index.rst +++ b/source/ameba_d/bw16-typec/Example_Guides/TensorFlow Lite/index.rst @@ -1,10 +1,10 @@ -TensorFlow Lite -=============== - -.. toctree:: - :maxdepth: 1 - - TensorFlow Lite - Hello World - TensorFlow Lite - Magic Wand - TensorFlow Lite - Person Detection +TensorFlow Lite +=============== + +.. toctree:: + :maxdepth: 1 + + TensorFlow Lite - Hello World + TensorFlow Lite - Magic Wand + TensorFlow Lite - Person Detection \ No newline at end of file diff --git a/source/ameba_d/bw16-typec/Example_Guides/index.rst b/source/ameba_d/bw16-typec/Example_Guides/index.rst index f152630..a533e39 100644 --- a/source/ameba_d/bw16-typec/Example_Guides/index.rst +++ b/source/ameba_d/bw16-typec/Example_Guides/index.rst @@ -1,19 +1,31 @@ -Example Guides -============== - -.. toctree:: - :maxdepth: 2 - - Basic/index - BLE/index - Debugging/index - E-Paper/index - Flash Memory/index - GPIO/index - HTTP/index - NTP/index - OTA/index - Power Save/index - RTC/index - SPI/index - WiFi/index +Example Guides +============== + +.. toctree:: + :maxdepth: 2 + + Basic/index + BLE/index + Debugging/index + E-Paper/index + Flash Memory/index + GPIO/index + GTimer/index + HTTP/index + I2C/index + IPv6/index + IR/index + MDNS/index + MQTT/index + NTP/index + OTA/index + Power Save/index + PWM/index + RTC/index + SPI/index + TensorFlow Lite/index + UART/index + WDT/index + WiFi/index + WS2812B/index + diff --git a/source/custom_script.py b/source/custom_script.py index 5bd8d46..ed76a48 100644 --- a/source/custom_script.py +++ b/source/custom_script.py @@ -14,7 +14,8 @@ , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' - , '_common/ameba_d/Example_Guides/GPIO'], + , '_common/ameba_d/Example_Guides/GPIO', '_common/ameba_d/Example_Guides/GTimer', '_common/ameba_d/Example_Guides/I2C', '_common/ameba_d/Example_Guides/IPv6', '_common/ameba_d/Example_Guides/MDNS' + , '_common/ameba_d/Example_Guides/MQTT', '_common/ameba_d/Example_Guides/PWM', '_common/ameba_d/Example_Guides/UART', '_common/ameba_d/Example_Guides/WDT', '_common/ameba_d/Example_Guides/WS2812B'], 'amb23': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' @@ -23,7 +24,8 @@ , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' - , '_common/ameba_d/Example_Guides/GPIO'], + , '_common/ameba_d/Example_Guides/GPIO', '_common/ameba_d/Example_Guides/GTimer', '_common/ameba_d/Example_Guides/I2C', '_common/ameba_d/Example_Guides/IPv6', '_common/ameba_d/Example_Guides/MDNS' + , '_common/ameba_d/Example_Guides/MQTT', '_common/ameba_d/Example_Guides/PWM', '_common/ameba_d/Example_Guides/UART', '_common/ameba_d/Example_Guides/WDT', '_common/ameba_d/Example_Guides/WS2812B'], 'amb25': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' @@ -32,7 +34,8 @@ , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' - , '_common/ameba_d/Example_Guides/GPIO'], + , '_common/ameba_d/Example_Guides/GPIO', '_common/ameba_d/Example_Guides/GTimer', '_common/ameba_d/Example_Guides/I2C', '_common/ameba_d/Example_Guides/IPv6', '_common/ameba_d/Example_Guides/MDNS' + , '_common/ameba_d/Example_Guides/MQTT', '_common/ameba_d/Example_Guides/PWM', '_common/ameba_d/Example_Guides/UART', '_common/ameba_d/Example_Guides/WDT', '_common/ameba_d/Example_Guides/WS2812B'], 'amb26': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' @@ -41,7 +44,8 @@ , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' - , '_common/ameba_d/Example_Guides/GPIO'], + , '_common/ameba_d/Example_Guides/GPIO', '_common/ameba_d/Example_Guides/GTimer', '_common/ameba_d/Example_Guides/I2C', '_common/ameba_d/Example_Guides/IPv6', '_common/ameba_d/Example_Guides/MDNS' + , '_common/ameba_d/Example_Guides/MQTT', '_common/ameba_d/Example_Guides/PWM', '_common/ameba_d/Example_Guides/UART', '_common/ameba_d/Example_Guides/WDT', '_common/ameba_d/Example_Guides/WS2812B'], 'bw16-typeb': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' @@ -50,7 +54,8 @@ , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' - , '_common/ameba_d/Example_Guides/GPIO'], + , '_common/ameba_d/Example_Guides/GPIO', '_common/ameba_d/Example_Guides/GTimer', '_common/ameba_d/Example_Guides/I2C', '_common/ameba_d/Example_Guides/IPv6', '_common/ameba_d/Example_Guides/MDNS' + , '_common/ameba_d/Example_Guides/MQTT', '_common/ameba_d/Example_Guides/PWM', '_common/ameba_d/Example_Guides/UART', '_common/ameba_d/Example_Guides/WDT', '_common/ameba_d/Example_Guides/WS2812B'], 'aw-cu488': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' @@ -59,7 +64,8 @@ , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' - , '_common/ameba_d/Example_Guides/GPIO'], + , '_common/ameba_d/Example_Guides/GPIO', '_common/ameba_d/Example_Guides/GTimer', '_common/ameba_d/Example_Guides/I2C', '_common/ameba_d/Example_Guides/IPv6', '_common/ameba_d/Example_Guides/MDNS' + , '_common/ameba_d/Example_Guides/MQTT', '_common/ameba_d/Example_Guides/PWM', '_common/ameba_d/Example_Guides/UART', '_common/ameba_d/Example_Guides/WDT', '_common/ameba_d/Example_Guides/WS2812B'], 'bw16-typec': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' @@ -68,7 +74,8 @@ , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' - , '_common/ameba_d/Example_Guides/GPIO'], + , '_common/ameba_d/Example_Guides/GPIO', '_common/ameba_d/Example_Guides/GTimer', '_common/ameba_d/Example_Guides/I2C', '_common/ameba_d/Example_Guides/IPv6', '_common/ameba_d/Example_Guides/MDNS' + , '_common/ameba_d/Example_Guides/MQTT', '_common/ameba_d/Example_Guides/PWM', '_common/ameba_d/Example_Guides/UART', '_common/ameba_d/Example_Guides/WDT', '_common/ameba_d/Example_Guides/WS2812B'], } def create_folder(folder_name):