Jump to content
Electronics-Lab.com Community

Search the Community

Showing results for tags 'realtek'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Electronics Forums
    • Projects Q/A
    • Datasheet/Parts requests
    • Electronic Projects Design/Ideas
    • Power Electronics
    • Service Manuals
    • Theory articles
    • Electronics chit chat
    • Microelectronics
    • Electronic Resources
  • Related to Electronics
    • Spice Simulation - PCB design
    • Inventive/New Ideas
    • Mechanical constructions/Hardware
    • Sell/Buy electronics - Job offer/requests
    • Components trade
    • High Voltage Stuff
    • Electronic Gadgets
  • General
    • Announcements
    • Feedback/Comments
    • General
  • Salvage Area

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 22 results

  1. With a BLE5.0 & Dual-band WiFi microcontroller, you will never have to worry about re-compiling the code just to change the WiFi ssid and password. Ameba RTL8722 is a BLE5.0 and dual-band WiFi (2.4G & 5G) Iinternet-of-Things (IoT) developing platform that suit the need for many IoT application scenarios. Taking advantge of its BLE + WiFi combination, we can easily change Ameba's WiFi setting and save us great deal of time. Take a look at the short video below to learn more https://youtu.be/TA4A-VXbImo
  2. This is MicroPython project developed using Ameba RTL8722. MicroPython is offically supported on Ameba RTL8722, so through this demo video, we will see how easy and fast it is to develop a simple server socket on Ameba, which would then control other peripheral to perform other tasks. Here we are using a client socket code running on PC to send a 'Hello, world' string via the WiFi network, Ameba receives it and if it is indeed 'Hello, world' then it will blink the LED. Check out the demo video down below, https://youtu.be/pEMkwvw-r18 Code used: #!/usr/bin/env python3 #PC Client code import socket HOST = '' # The server's hostname or IP address PORT = 80 # The port used by the server with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) s.send(bytes('Hello, world','utf8')) #Ameba Code from machine import Pin from wireless import WLAN import time import socket wifi = WLAN(WLAN.STA) wifi.connect("MPSSID","upyameba") led = Pin("PB_4",Pin.OUT) s = socket.SOCK() port = 80 data = ' ' s.bind(port) s.listen() conn, addr = s.accept() while True: data = conn.recv(1024) print(data) if data == b'Hello, world': print('turn on LED 1') for i in range(6): led.toggle() time.sleep_ms(200) if not data: break
  3. MQTT is one of the most popular IoT network protocol thanks to its light-weight and Publish-subscribe model. However, some doubts the security of MQTT as it is usually unprotected to reduce overhead, this can be easily fixed with the use of TLS (Transport Layer Security), here we are using Realtek's RTL8722 dual-band WiFi and BLE5.0 microcontroller as example and see how it achieve security with MQTT, Preparation Ameba x 1 Example 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” Please modify the WiFi-related parameters to connect to your WiFi network. Modify the MQTT parameters to fit your application: 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 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. WiFi microcontroller usually consume a lot more power than ones without WiFi connection. Even in sleep mode, 2 AA batteries would only last a week, but RTL8722 from Realtek has 2 cores, a cortex M4 core handling user application and a cortex M0 core that help to conserve power by entering the deep sleep mode to extend battery life to few months, here is an example of it, Power Management – Enter Deepsleep After Uploading DHT Data To LASS Preparation Ameba x 1 DHT11/DHT22/DHT21 x 1 Example In this example, we will get the humidity and temperature data from DHT, connect to AP, retrieve NTP time, upload the data to LASS MQTT server, then enter deepsleep mode every 10 minutes. Open "File" -> "Examples" -> "AmebaPowerSave" -> "DeepSleepWithDHTLass" Modify detailed settings in the sample code: - Model of DHT sensor: DHT11/DHT22/DHT21 - Connection to WiFi AP: ssid, password - GPS position: latitude & longitude Compile and upload to Ameba. The actual power cosumption depends on many factors such as network condition, the time it takes for the server to respond. In our case, the program completes in 13 seconds, the power consumption of the Ameba Module is 1.3mA. This number is larger than the one we get in the "DeepSleepWithDHT" example. This is because the power consumption of Ameba in operation is usually larger than 29mA, and when Ameba is using wifi connection the power consumption is larger than 68 mA, which are considerably larger than the 0.018 mA power consumption in deepsleep mode. Therefore, we should keep Ameba in the deepsleep mode as far as possible to save energy. To compare the result with the case without entering power-saving mode, we modify the sample code as below. We keep the network connection and get the data from DHC sensor every 10 minutes, then upload the MQTT server. void setup() { dht.begin(); reconnectWiFi(); retrieveNtpTime(); initializeMQTT(); } void loop() { if (gatherHumidityAndTemperature() == DATA_CNT_FOR_UPLOAD) { reconnectWiFi(); while(!sendMQTT()) { delay(1000); } mqttClient.loop(); pDhtData->dataCount = 0; } // store data back to flash memory FlashMemory.update(); delay(measureInterval * 1000); } As a result, the average power consumption is 67 mA. Use 2 AA batteries to compare the results: (We use the Keysight 34465A multimeter in the experiment) According to the result, the energy of 2 AA batteries can only last for about 1 day without power-saving, and it can last about 2.8 months with power-saving. NOTE: In reality, due to the energy loss in the voltage conversion and operation, the actual usage time may be different.
  5. As clean energe continue to attract huge attention due to the foreseeable demise of fossil fuel, harvesting clean energy , particularly solar energy, for embedded system make sense in many IOT applications for its low power consumption and sometime awkward placement, this example will guide you through how to harvest solar energy for an IOT project, Solar Panel – Upload Temperature And Humidity Data To LASS System Preparation Ameba x 1 DHT11 x 1 Solar Panel (1W) x 1 Lipo rider pro x 1 Li-Po battery (1100 mAh) x 1 DS3231 RTC x 1 AMS1117-3.3V x 1 (Optional) Solar Panel The solar panel we use is: http://www.seeedstudio.com/depot/1W-Solar-Panel-80X100-p-633.html The difference of the models with different power is the time it takes to charge the lithium battery. In general, solar panels with 1W power is sufficient for the weather in Taiwan. Lithium Battery In the night, we use lithium battery to provide power. Take the occasional cloudy days into account, we choose the lithium battery of size 1100mAh. Note that batteries with capacity smaller than 500mAh are not recommended. Lithium Charge-Discharge Module In the daytime, besides providing power to Ameba, we expect the solar panel to supply power to charge the lithium battery. On the other hand, if the solar panel cannot provide enough power, we rely on the lithium battery to supply power. Therefore, we need a Charge-Discharge Module for the lithium battery. Here we use Lipo Rider pro, it uses JST 2.0 joint. There are a number of alternatives: Lipo Rider: http://www.seeedstudio.com/depot/Lipo-Rider-v13-p-2403.html PowerBoost 500C: https://www.adafruit.com/product/1944 PowerBoost 1000C: https://www.adafruit.com/product/2465 DS3231 RTC We use DS1307RTC library supports DS1307/ DS1337/DS3231, here we use DS3231. AMS1117-3.3V The default output of Lipo Rider Pro is 5V, hence can be connected to Ameba directly. If you wish to provide only 3.3V to Ameba module to save power, you can use AMS1117 to step-down the voltage to 3.3V. Example In this example, we use solar panel to supply power for Ameba. When the power output of the solar panel exceeds the power demanded by Ameba, surplus power charges the lithium battery, which can supply power at night. Open the sample code in "File" -> "Examples" -> "AmebaMQTTClient" -> "lass_for_dht_plus_ps_nfc" Note that when you choose to supply power only to Ameba module, the 3.3V on Ameba board would be unavailable. For the modules that require 3.3V power, you need to step-down the voltage to 3.3V to supply power. If you do not want to use AMS1117, you can supply power to 5V directly (note this enables DAP and leads to additional power consumption). Another noteworthy point is that the antenna in the figure is cut down from Ameba, and is connected to Ameba through wires. To run the example, a few settings should be done: Please provide the ssid/password for WiFi connection. The clientId of LASS is set to FT_LIVE_12345678 by default, please replace it with a different value. Compile and upload the sample to Ameba and press reset button. Wait for a while, then you should see the data in the website: http://g0vairmap.3203.info/map.html The sample code uses the location of Realtek by default. For the NFC function, you can use your android phone to scan the NFC antenna to download the NFC APP from google play. (Or you can download from: https://play.google.com/store/apps/details?id=com.realtek.sensortag) After the APP is installed successfully, use your phone to scan the Tag to read the latest temperature and humidity. Press the button at the bottom to get the temperature and humidity information of the day. Energy consumption analysis The power efficiency of the solar panel The measure of brightness here is Illuminance(LUX), light with different wave length have different illuminance. We use Halogen bulbs to simulate sun light. In Taiwan, in the time between 10am to 2pm, the measured illuminance is about 100 LUX on average. At 4pm, the measured illuminance is about 10 LUX on average. Using 100W Halogen bulb, we measure 10k LUX illuminance in distance 20cm, and 100k LUX in distance 5cm. However, the shorter the distance between light source and solar panel, the higher the temperature of the solar panel. As the temperature of solar panel increases, the power efficiency decreases. We keep the distance 20cm in our experiment here. When the illuminance is 100k LUX, the solar panel outputs 210mA current, with voltage 4.8V. 4.8V x 0.21 A = 1.008 W. When the illuminance is 10k LUX, the solar panel outputs only 40~60mA current Power consumption of NFC In this example, the NFC function is kept available when Ameba enters deepsleep. The power consumption of NFC is about 7mA, which is considerably high compared with deepsleep. Power consumption of RTC Normally, RTC uses battery to hold the time precision. However, when RTC is connected to Ameba, Ameba enables its I2C interface by default, which leads to additional 2mA power consumption. Total power consumption If you step-down power source to 3.3V and connect to Ameba module, the measured current in deepsleep is 12mA, and long-term average is 13mA. If you supply 5V power to Ameba, the measured current in deepsleep is 17mA, long-term average is 18mA. Besides NFC and RTC, voltage step-down module and LED light also consumes power. Not considering the power consumed by the battery charge-discharge module, assume that the solar panel provides 40mA current and the 1100mAh lithium battery has used up half of its capacity. Then we need 550mA / (210mA - 13mA) = 2.8 hours to fully charge the lithium battery. If the solar panel cannot provide sufficient current output to supply power for Ameba and the lithium battery, and the Ameba board relies on the lithium battery as power source. Then the battery can provide power for 550 mAh / 13mA = 42 hours. Code Reference The program is composed by previous examples. The execution flow is as follows: At the beginning, we setup watchdog and activate a GTimer to feed/kick watchdog every second, and if the total execution flow is not completed in 30 seconds, go into deepsleep. Note that we put the WiFi connection part in the rear of the flow. Since turning on WiFi consumes relatively more power, to design low-power project, it is recommended that put WiFi-unrelated parts at the beginning of the execution flow.
  6. IR (Infrared) is often used in our remote controller to control TV, fans and light etc for its easy-to-use and affordibility. However, we can also use it for some other purposes like sending and receiving sensor data in a close range, and Realtek's Ameba RTL8722 equiped with dual band WiFi and BLE 5.0 also comes with special designed registers just for IR transmissions, here is demo, IR – Infra-Red Receiver And Emitter Preparation Ameba x 1 Grove - Infrared Receiver x 1 Grove - Infrared Emitter x 1 Principle Infra-red refers to the invisible light with wavelength 770nm~1mm. It is commonly used in our life, for example the remote control in our home. In general, the infra-red emitter and receiver specify the frequency used in transmission. There are some widely used frequency regulations such as NEC, Philips RC5, RC6, RCMM, Toshiba, Sharp, JVC, Sony SIRC,...etc. Among them, NEC uses 38KHz frequency and is commonly used in appliances. The demodulator in the IR receiver outputs 0V when it receives signals with specified frequency, otherwise it outputs 3.3V(or 5V). For the IR emitter, it needs to emit signal with specified frequency (generally PWM signal), since IR receiver would only respond to the specified frequency, The figure below shows a complete Infra-red signal emitted from the IR emitter: First it sends the start signal, which contains a start high and a start low. Start high is PWM signal with frequency 38KHz. Start low is digital signal output, usually we output 0V signal for start low. Then it sends the data a byte at a time. A byte is sent in the order from LSB (Least Significant Bit) to MSB (Most Significant Bit). A bit 1 is represented by a 560us-long PWM signal, and stop for 1.69 ms. A bit 0 is represented by a 560us-long PWM signal, and stop for 560 us. When the data transmission is finished, send a bit 1 as the stop bit. At the receiver side, through demodulation, the received PWM signals are converted to general digital input: And those signals other than PWM signals, are put at 3.3V (or 5V). Example: IR receiver For implementation, Ameba uses a GPIO Interrupt pin and hardware Timer 4. Open the example in "File" -> "Examples" -> "AmebaIRSendRecv" -> "recv" In this example, we use Grove Infrared Receiver, other infra-red receiver works similarly. In general, we will use 3 pins: VCC(connects to 3.3V), GND, RX. In the example, we connect RX to D3 (which has GPIO Interrupt function). Wiring diagram: RTL8710 Wiring diagram: Compile the code and upload to Ameba, then press reset. If you have NEC remote control in hand, you can test that whether the Ameba IR receiver works. Or you can follow next example to use another Ameba board to make an IR emitter yourself. Note that the received messages of the IR receiver will be shown on the serial monitor. Example: IR emitter A typical IR emitter has 2 pins. However, the Grove Infrared Emitter has 3 pins: VCC, GND and TX. In practice, we can only use GND and TX. To transmit 38KHz signal in real time, Ameba uses TX of UART to emit the signal. Hence, when we are using Ameba to emit IR signal, D0 pin (UART RX) would be unavailable. Following is the wiring diagram: However, since the TX of UART is usually on 3.3V, this leads to unnecessary power consumption. Therefore, we rearrange the wires to connect Ameba UART TX to the GND pin of Grove Infrared Emitter, and connect the signal wire of emitter to 3.3V: RTL8710 Wiring Diagram: In this case, when the emitter is not emitting signal, GND and TX are both at 3.3V, voltage difference is 0. Open the example "File" -> "Examples" -> "AmebaIRSendRecv" -> "send". Compile and upload to Ameba, and press reset. In this example, the IR emitter emits signal every 2 seconds. You can test it with the previous IR receiver example. Code Reference We refer to Grove infra-red Send Recv library to design our API. The original source code can be found here. Although the API of Ameba looks similar to that of Arduino, the implementation details is different. IR receiver First, we have to specify the pin used to receive data. Since it needs GPIO interrupt, we have to select a pin with GPIO interrupt function. We use D3 pin in the example. IR.Init(pinRecv) In the loop, we keep checking if there is incoming signal. IR.IsDta() When we receive signal, put the data into user buffer. IR.Recv(dta) The format of the buffer: Byte 0: Data length of whole packet. Byte 1: Length of start high, unit is 50us. Byte 2: Length of start low, unit is 50us. Byte 3: The stop length after the PWM signal when the data bit is 1, unit is 50us. Byte 4: The stop length after the PWM signal when the data bit is 0, unit is 50us. Byte 5...: Data. IR emitter Use Send() API to transmit data. The first argument is the data to be transmitted, and the second argument is the frequency(unit is 1K), in the example we use 38KHz. IR.Send(dtaSend, 38) The transmission format of the data: Byte 0: Data length of whole packet. Byte 1: Length of start high, unit is 50us. Byte 2: Length of start low, unit is 50us. Byte 3: The stop length after the PWM signal when the data bit is 1, unit is 50us. Byte 4: The stop length after the PWM signal when the data bit is 0, unit is 50us. Byte 5: Length of data to transmit. Byte 6...: Data to transmit.
  7. RTL8722 MicroPython SDK alpha release It was annouced that the popular MicroPython project has been ported to ameba RTL8722, with support for peripheral control and Python 3 syntax, you may now control RTL8722 not only with Arduino but also with Python language on the REPL. The SDK is currently in alpha stage and WiFi feature is going to release soon. If you are interested , please find links to the SDK on Github at. https://github.com/ambiot/ambd_micropython?fbclid=IwAR0TxWN06-XT88AfIZbPaBOYJ5fyhh3pMOe-X1RC48Tgari0rXn3nHhEyTo Here are introduction and basic examples to this port, MicroPython Ameba RTL8722 Documentation Realtek's RTL8722 is a ARM Cortex-M33 based, dual-band WiFi and BLE 5.0 capable microntroller that is ideal for many IoT applications. This is a alpha version of the MicroPython port for Ameba RTL8722 platform, details of the platform can be found here https://www.amebaiot.com/en/amebad/ 1. How to build firmware? Currently, this SDK only support building on Cygwin or Linux. Before preceed, please make sure that you have already installed GNU make Open Cygwin terminal/Ubuntu terminal and navigate to "\micropython_amebaD\MicroPython_RTL8722\ports\rtl8722" and then type, $ make 2. How to upload? There are 2 methods to upload Ameba D MicroPython image to your Ameba. 2.1 Release folder In the release folder, there is a Double-Click-Me-to-Upload.cmd file. First we right click on it and select 'Edit', and a notepad will open, now check your Ameba's serial COM port on your PC and update the correct one to the third last line of the file, then save the file and close it. Now press RESET button while holding down UART Download button to enter Download Mode, and you can double click Double-Click-Me-to-Upload.cmd now and the uploading will start shortly. 2.2 port/rtl8722 folder 1st, check your ameba Serial/COM port, make sure Ameba D's port name is correctly updated in the UPLOAD_PATH variable in the Makefile; 2nd, press RESET button while holding down UART Download button to enter Download Mode, Then, type following command, $ make upload 3. How to use MicroPython RTL8722 Port? 3.1 Brief introduction to MicroPython RTL8722 port MicroPython distinguishes itself from other compilation-based platforms (Arduino etc.) with its powerful method of real-time interaction with Microcontroller through a built-in feature -- REPL. REPL stands for Read-Evaluation-Print-Loop, it's an interactive prompt that you can use to access and control your microcontroller. REPL has been equipped with other powerful features like tab completion, line editing, auto-indentation, input history and more. It basically functions like the classic Python IDLE but running on microcontroller. To use REPL, simply open any serial terminal software (most common ones are teraterm, putty etc.) on your PC and connect to your microcontroller's serial port, then set baudrate to 115200 before reset the board, then you will see >>> MicroPython prompt appear on the console. Now you may type in any Python script on REPL as long as it's support by MicroPython and your microcontroller's MicroPython port. 3.2 REPL Hotkeys Ctrl + d : Soft reboot MicroPython will perform software reboot, this is useful when your microcontroller is behaving abnormally. This will also run scripts in 'boot.py' once again. Ctrl + e : Paste mode Paste mode allow you to perform pasting a large trunk of code into REPL at once without executing code line by line. This is useful when you have found a MicroPython library and wish to test it out immediately by copy and paste Ctrl + b : Normal mode This hotkey will set REPL back to normal mode. This is useful if you are stuck in certain mode and can not get out. Ctrl + c : Quick cancel This hotkey help you to cancel any input or interrupt currently running code 4. Peripheral Control -- umachine module MicroPython Ameba D port supports rich peripheral feature through the use of umachine module GPIO To control GPIO, import Pin module through umachine. Here pin PB_18 is used as an example to output logic level 0 and 1 and blink 3 times from umachine import Pin a = Pin("PB_18", Pin.OUT) a.value(1) time.sleep_ms(500) a.value(0) time.sleep_ms(500) a.on() time.sleep_ms(500) a.off() time.sleep_ms(500) a.toggle() time.sleep_ms(500) a.toggle() PWM To use PWM (Pulse Width Modulation), import PWM module through umachine. Here pin PA_26 is used as an example to make an LED to slowly brighten up from umachine import Pin, PWM import time as t p = PWM(pin = "PA_26") for i in range(1000): p.pulsewidth(i) # this and following line will be auto indented on REPL t.sleep_ms(2) Delay and Timing Use the time module import time time.sleep(1) # sleep for 1 second time.sleep_ms(500) # sleep for 500 milliseconds time.sleep_us(10) # sleep for 10 microseconds start = time.ticks_ms() # get millisecond counter Timer Use the Timer module through umachine module There are 4 sets of 32KHz General Timers available to user, Timer 0/1/2/3 from umachine import Timer t = Timer(0) # Use Timer 0/1/2/3 only t.start(2000000, t.PERIODICAL) # Set GTimer fired periodically at duration of 2 seconds, printing text on the terminal RTC Use the RTC (Real Time Clock) module through umachine module from umachine import RTC rtc = RTC() rtc.datetime((2020, 12, 31, 4, 23, 58, 59, 0)) # set a specific date and time (year, month, day, weekday(0 for Monday), hour, minute, second, total seconds) rtc.datetime() # get date and time UART Use the UART module through umachine module from umachine import UART uart = UART(tx="PA_21", rx= "PA_22") uart.write('hello') uart.read(5) # read up to 5 bytes I2C Use the I2C (Inter-Integrated Circuit) module through umachine module Note: I2C only works in master mode. from umachine import Pin, I2C i2c = I2C(scl = "PA_25", sda = "PA_26", freq=100000) # configure I2C with pins and freq. of 100KHz i2c.scan() i2c.writeto(8, 'hello') # send 5 bytes to slave with address 8 i2c.readfrom(8, 6) # receive 5 bytes from slave SPI Use the SPI (Serial Peripheral Interface) module through umachine module, currently only support Master mode, default SPI baud rate is 2MHz. from umachine import SPI spi = SPI(0) # Only support 2 sets of SPI -- 0 and 1 spi # type instance name to check for details of the SPI set spi.write(123) # Write number 123 spi.read()
  8. Most of time when we use WiFi, we only use our WiFi device as a "station"(STA) that mainly receive information sent from "access point" (AP). Ameba Microcontroller from Realtek can not only connect to WiFI as a station, but also broadcast its own signal and become an AP, here is how, In AP mode, Ameba can accept at most 3 station connections, and can be set to open mode or security mode (WPA2). Preparation Ameba x 1 Example In this example, we turn on the AP mode of Ameba and connect station to Ameba. Open the WiFi AP example, "File" -> "Examples" -> "AmebaWiFi" -> "WiFiAPMode" In the snippet highlighted in yellow, fill in your SSID, PASSWORD and CHANNEL. The snippet highlighted in pink is the API we used to turn on the AP mode in security mode. If you want to turn on the AP mode in open mode, please modify the code to status = WiFi.apbegin(ssid, channel); Then upload the sample code and press reset, and you can see related information shown in serial monitor. In the figure below, we show the messages shown in serial monitor when two stations connect to Ameba AP in open mode: In the figure below, we show the messages shown in serial monitor when a station connects to Ameba AP in security mode:
  9. Use Ameba As UDP Server When surfing on internet, most of us are using TCP as its reliable and secure, however, UDP could also shine in some other area where speed is more important than integrity, and here is how Realtek's Ameba RTL8722 WiFi+BLE microcontroller works with UDP, Preparation Ameba x 1 Example In this example, we connect Ameba to WiFi and use Ameba to be an UDP server. When Ameba receives a message from UDP client, it replies "acknowledged" message to client. Open the WiFi Web Server example. “File” -> “Examples” -> “AmebaWiFi” -> “WiFiUdpSendReceiveString” Modify related information, including ssid, pass, keyindex Compile the code and upload it to Ameba. After pressing the Reset button, Ameba connects to WiFi and starts the UDP server with port 2390. After the UDP server starts service, Ameba prints the "Starting connection to server" message and waits for client connection. As to the UDP client, we use "sockit" program in the computer to connect to UDP server. Choose client mode and fill in the IP of UDP server (which is the IP of Ameba) and port 2390, then click "UDP Connect". After the connection is established, fill in "Hello World" in the Buf 0 field in sockit and click "Send". Then you can see the Ameba UDP server replies "acknowledged". Code Reference Ameba uses the WiFiUdp class which is compatible with Arduino WiFi Shield, so the Refer to the Arduino tutorial for detailed information about this example. https://www.arduino.cc/en/Tutorial/WiFiSendReceiveUDPString First, use begin() to open an UDP port on Ameba. https://www.arduino.cc/en/Reference/WiFiUDPBegin Use parsePacket() to wait for data from client. https://www.arduino.cc/en/Reference/WiFiUDPParsePacket When a connection is established, use remoteIP() and remotePort() to get the IP and port of the client. https://www.arduino.cc/en/Reference/WiFiUDPRemoteIP https://www.arduino.cc/en/Reference/WiFiUDPRemoteIP Then use read() to read the data sent by client. https://www.arduino.cc/en/Reference/WiFiUDPRead To send reply, use beginPacket(), write(), end(). https://www.arduino.cc/en/Reference/WiFiUDPBeginPacket https://www.arduino.cc/en/Reference/WiFiUDPWrite https://www.arduino.cc/en/Reference/WiFiUDPEndPacket
  10. E-ink display comes in very handy in cutting power consumption when not refreshing the screen, it becomes more power conserving when combined with ARM Cortex M33 microcontroller-- RTL8722 from Realtek. This microcontroller sports dual-band WiFI and BLE 5.0 withh max clock at 200MHz, which make it possible to parse long string of a URL and generate a QR code locally. In this demo, we will show how to generate QR code and display it on a E-ink display. https://youtu.be/KYI5WBmC6ac
  11. Many interesting projects are coded on Arduino IDE thus making it very easy to get a head start with project. Just like Realtek Ameba RTL8722, there are many interesting project worth trying out, like BLE, MQTT with TLS etc. However, once the project grows in length and complexity, it becomes super inconvenient with the lack of code completion, hinting and jumping to definition features that are commonly available on most popular code editors. However, there is actually a way to have all those features with only 3 steps, here is how, (Note: there are probably other ways of achieving the same goal, so share your method if you know a better way;) 1. Go to “preference” under Arduino IDE and select “use external editor” With this option selected, you will see the arduino editor grey out and become unable to edit code anymore, don’t worry, this is ok. 2. Download and open any of your favourite editor which has all these “smart features” In this case, Visual Studio Code is used for demonstration. 3. Create a folder to store all your sketches and add Ameba RTL8722 ‘s arduino library to the workspace (this 3.0.4 is the ameba library folder and it is usually located in you C drive under “C:\Users\YOURUSERNAME\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD”) And also don’t forget to add your own sketch folder to the workspace (here my sketch folder is named “arduino_sketch” as seen above). With these steps done, it will only takes a couple of seconds before the editor parse each and every files in the folders added and link all symbols together. Now you will be able to code in your favourite editor and also to have these convenient features, # Code Completion # Code Hinting # Jump to definition Every time you save the sketch you just modified, just click anywhere of the grey area on the arduino editor and it will be automatically updated with your latest modifications, so you will still be able to one-click compile/download your code using the “Verify” or “Upload” button. Hope you find it useful and share with me how you like to code for Arduino project 🙂
  12. BLE -- WiFi  Config  Demo Video Realtek's RTL8722 microcontroller is a dual-core, dual-band WiFi and BLE 5.0 capable embedded platform suitable for Internet of Things application. For many non-professional developer, setting up WiFi AP information for WiFi microcontroller might be a hassle as there is no user interface to manually select the AP we want. However, RTL8722 has BLE 5.0 which give it an edge to pass WiFi information to the board prior to connecting to WiFi, making WiFi connection as easy as simply tapping few button on your mobile phone, here is how, Materials AmebaD [RTL8722 CSM/DM] x 1 Android / iOS mobile phone Example Introduction In this example, a WiFi configuration service is set up on the Ameba Bluetooth stack. A mobile phone with the configuration app connects to the Ameba device using BLE and configures the Ameba to connect to the correct WiFi access point. Procedure Ensure that the Realtek WiFi configuration app is installed on your mobile phone, it is available at: - Google Play Store: https://play.google.com/store/apps/details?id=com.rtk.btconfig - Apple App Store: https://apps.apple.com/sg/app/easy-wifi-config/id1194919510 Open the example, "Files" -> "Examples" -> “AmebaBLE” -> “BLEWifiConfigService”. Upload the code and press the reset button on Ameba once the upload is finished. On your mobile phone, open the Realtek WiFiConfig app and tap the round button to scan for Ameba boards. Select the correct Ameba board from the scan results. The app will connect to the Ameba board and ask the board to scan for WiFi networks and send the scan results back to the app using BLE. If your phone is currently connected to a WiFi network, the app will ask for the WiFi password to connect the Ameba board to the same WiFi network. Tap “Select AP” to choose another WiFi network, or enter the password and tap continue to connect Ameba to the selected WiFi network. After the Ameba board connects to the WiFi network, the following message will be shown. Tap “Try another AP” to connect to another WiFi network or tap “Confirm” to keep the current WiFi network and disconnect BLE from the Ameba board. Code Reference BLEWifiConfigService is used to create an instance of the WiFi configuration service to run on the Bluetooth device. BLE.configAdvert()->setAdvType(configService.advData()) is used to set the correct advertisement data necessary for the phone app to find the Ameba Bluetooth device.
  13. Lack of security consideration is always debated in DIY projects, but now with Ameba Arduino-- an ARM Cortex M3 based WiFi microcontroller, you can add fingerprint sensor to your personal DIY project and boost its security. Here is a demo Preparation Ameba x 1 AS606 fingerprint identification module x 1 Example In this example, a fingerprint identification module is used to store fingerprints and identify them. This module uses SYNOCHIP AS606 chip, which can store up to 1000 sets of fingerprints. The libraries we need are: https://github.com/ambiot/amb1_arduino/raw/master/Arduino_libraries/AmebaFingerprint.zip For the way to install the library, please refer to the teaching article of the Arduino official website to add the zip file library to Ameba: https://www.arduino.cc/en/Guide/Libraries#toc4 This module uses UART to communicate with AMEBA. In addition to VCC (3.3V) and GND, and using UART TX and RX lines, we turn the module to the back. The RTL8195 example wiring is as follows: The RTL8710 example wiring is as follows: We open the example "File" -> "Examples" -> "AmebaFingerprint" -> "enroll", compile and upload to Ameba and press the Reset button. At this point, open the terminal and you should see the fingerprint identification module message: Then follow the message at the console prompt, we type a letter 'a’ on the keyboard. The console prints the "waiting for valid finger to enroll" message, and you can place your finger on the module window. If the module has correctly collected the fingerprint, then it will ask to remove the fingerprint and then place the same finger on the window. If the fingerprint is collected correctly, the console will mention printfs matched and store the fingerprint. Then you can try to collect more fingerprints from different fingers. Then we have to test whether the fingerprint identification module can successfully identify the fingerprint that has just been stored. We open the example "File" -> "Examples" -> "AmebaFingerprint" -> "fingerprint", compile and upload to Ameba and press Reset button, open the terminal at this time, you should see the message that can find the fingerprint identification module: And the prompt is waiting for the verification fingerprint, at this time, place the same finger just sampled in the fingerprint recognition window. The Console will display the message "Found ID #x with confidence of xx", which means the identification is successful.
  14. One of the challenges of using IoT enabled MCU is the power consumption. However, on Ameba, you can keep the WiFi on while in sleep mode thus enabling power saving and connectivity. Here is a demo of how to achieve WiFi in sleep mode. Preparation Ameba x 1 DHT11/DHT22/DHT21 x 1 Example In deepsleep mode, the WiFi feature of Ameba is disabled. If you want to save power and keep the WiFi connection at the same time, please use the sleep API. Open "File" -> "Examples" -> "AmebaPowerSave" -> "SleepWithDHTUdpServ" Remember to set the ssid & password in the sample code. In this example, Ameba act as an UDP server, it establishes a wifi connection then enter sleep mode. When Ameba receives UDP packets with content "H", it replies the humidity value, and when it receives UDP packets with content "T", it replies the temperature value. When the sleep mode is enabled, Ameba goes to sleep or wakes up automatically. We use the "Sokit" tool to set the IP & port of Ameba, and request for temperature and humidity values in turn. Note that Ameba would check the status of pin D18, if it is connected to the GND, Ameba would not enter sleep mode. We compare the example with/without power-saving: (We use the Keysight 34465A multimeter in the experiment) NOTE: In reality, due to the energy loss in the voltage conversion and operation, the actual usage time may be different.
  15. Ameba RTL8195AM has onboard NFC tag and run on ARM Cortex-M3 core with WiFi, just nice to make use of all these 3 powerful tool to make an useful applicaiton. Many models of Android smart phone support NFC feature, and numerous of NFC applications are developed for inspection and modification of NFC Tag. In this example, we establish NFC connection between Ameba and a smartphone, and open a webpage on the smartphone via a NFC event. Preparation Ameba x 1 Smartphone with NFC feature x 1 Note: Make sure the onboard NFC antenna is safely connected to the module. Then open the example, "File" -> "Examples" -> "AmebaNFC" -> "UriWebPage" and upload, you will see this message when you tap your NFC-enabled phone on Ameba For more details, refer to the offical website at https://www.amebaiot.com/en/ameba-arduino-nfc-open-web/ Also feel free to join the Facebook group to discuss with other makers! https://www.facebook.com/groups/AmebaIoT
  16. With COVID-19 still wreaking havoc globally, causing thousands of deaths, millions hospitalized, any useful medical device is on high demand, especially household medical device like IR non-contact thermometer. Handheld thermometer usually is on high price point and is hard to come by these days, but the components needed to make thermometer are not that expensive, that give us the perfect reason to DIY one during this lockdown period. This ThermoGun project use Ameba Dev. board RTL8710AF from Realtek, which connects to an OLED display to show temperature data obtained from the MLX90615 IR sensor. Pushing the push button not only perform data acquisition and visualization, but also publish the data via MQTT to all subscribers. Note: The MQTT service used in this project is a FREE MQTT broker hosted at cloud.amebaiot.com, which need to register at www.amebaiot.com . Details of registration is at the link below, https://www.amebaiot.com/en/cloud-getting-started/ For details of step-by-step guide and connections, please refer to Github page here, https://github.com/Realtek-AmebaApp/Ameba_Examples/tree/master/RTL8195AM/007_THERMOGUN Demo Video: https://youtu.be/Yl3arBRmyYI
  17. Now that most people stay at home to avoid close contact with potential COVID-19 virus carrier, air quality becomes an important factor to people’s well-being, especially in tropical countries where using air-con is a must during the day, as prolonged use of air-con may do more bad than good to people’s respiration system thus weakening our immunity and make people more susceptible to virus infection. Here I am going to show you how to make a simple yet powerful air quality monitoring system using Realtek Ameba RTL8195AM development board and PM2.5 module, together with a TFT LCD display to create a colourful interface. Preparation § Ameba x 1 § ILI9341 TFT LCD with SPI interface x 1 § Plantower PMS3003 or PMS5003 x 1 Example This example extends previous PM2.5 example to show the PM2.5 concentration on the LCD. Wiring of QVGA TFT LCD: (Note: PMS3003/PMS5003 sensor requires 5V voltage) Open the example, "Files" -> "Examples" -> "AmebaSPI" -> "PM25_on_ILI9341_TFT_LCD" Compile and upload to Ameba, then press the reset button. Then you can see the concentration value of PM1.0, PM2.5 and PM10 on the LCD. Code Reference In this example, first rotate the screen by 90 degrees, and draw the static components such as the circles, the measuring scale and the title text. After the concentration value is detected, it is printed inside the circle. To know more about the details, click the link below, https://www.amebaiot.com/en/ameba-arduino-spi-lcd-pm2-5/
  18. MQTT (Message Queuing Telemetry Transport) is a protocol proposed by IBM and Eurotech. IBM® Watson™ IoT Platform is, by the official definition, “A foundational cloud offering that can connect and control IoT sensors, appliances, homes, and industries. Built on IBM Cloud, Watson IoT Platform provides an extensive set of built-in and add-on tools. Use these tools to process IoT data with real-time and historical analytics, extract key performance indicators (KPIs) from your data, add “smarts” in the cloud for non-smart products, and securely connect your own apps and existing tools to the Watson IoT Platform infrastructure.” (IBM, 2020) This platform provides easy web interface to register, connect and visualize our IOT devices. For quick start and simple try-out, registration is not necessary, we may just run our program to get the device ID needed for this platform. Preparation § Ameba x 1 Example In this example, we will take a look at how to make use of IBM Watson IOT platform for out IOT project. Open the MQTT example “File” -> “Examples” -> “AmebaMQTTClient” -> “ibm_watson_iot_quickstart” Make sure the Wi-Fi information is properly filled in and we are ready to upload the code to ameba. Once uploading finished, open a serial monitor and we shall see information as follows, Important: Please take note of the string of characters on the first line of the picture above -- “clientId:quickstart:iotsample-ameba:ac35ee15608e” “ac35ee15608e” is the device ID as well as the MAC address of the ameba board used here which will NOT be the same for other cases, so make sure to copy down the device ID displayed on your serial monitor. Next, we click the IBM IOT platform link provided here and open our browser: https://quickstart.internetofthings.ibmcloud.com/#/ Paste the device ID we just copied into the box highlighted below, If the device ID keyed in is correct, some fake temperature data that our ameba published will be visualized like this, Done! Now you have FREE and working IOT cloud platform to help you visualize your IOT data in realtime~
  19. This project is the second one in the new IOT project series on Ameba RTL8195AM Dev. Board. The focus of this project is to demonstrates how easy it is for Ameba Wi-Fi Dev. board to communicate with our smart phone via MQTT protocol. Phone to microcontroller communication used to be very difficult as they use totally different hardware interface and phone get its data mainly through the network. Now with a Wi-Fi enabled microcontroller like Ameba RTL8195AM, communication with our phone becomes a bliss. Of course, in this project, only a mini hand-crafted window is used for demonstration purpose but controlling a real window should not be a problem if you simply replace the servo motor with a bigger DC step motor and change the source code accordingly. With this smart curtain system, you may, 1. Remotely control your curtain to open or close instantaneously 2. Check your curtain status according to the MQTT message received 3. Link with the previous weather station project and automate your room from there Hardware List of hardware needed Ameba 1 RTL8195AM x1 Servo motor x1 Jumper wires x3 DIY materials x3 Hardware connection is shown below, for the window, you may use a Lego house as substitute or simply build one using plywood or hard form board, the exact structure can also be found in this folder. Software 1. Check and make sure you have installed the ameba 1 board to Arduino IDE via adding this link into “additional boards manager URLs” under “Preference”, and install it in “board manager” under “Tools”, https://github.com/ambiot/amb1_arduino/raw/master/Arduino_package/package_realtek.com_ameba1_index.json 2. Upload source code to your Ameba1 RTL8195 board using arduino IDE 3. Install a MQTT client App on your smart device (android/iOS) a) To use a MQTT service, you must first get a free MQTT server address b) Go to www.amebaiot.com and register for a user c) Then go to cloud service tab and register your device d) Once approved, the same username and password used for registration can be used to make use of the MQTT service for free 4. Connect to your MQTT server by keying in the correct server address, port number, username and password • For Host name: cloud.amebaiot.com • For Port number: 1883 • For username: same as your amebaiot.com username • For password: same as your amebaiot.com password 5. Key in the topics that you specified in the code, always remember to swap the publish topic and subscribe topic when you want to monitor your microcontroller’s published data.
  20. One of the most useful IoT applications is home security. Imagine a thief cutting your security camera wire while trying to break into your house. This won’t happen if your security system goes wireless and smart. This project demonstrates the capability of Realtek Ameba dev. board to conduct board-to-board communication via MQTT (FREE MQTT broker hosted at cloud.amebaiot.com). With this home security system, you will definitely be alarmed when your window/door is opened by the self-invited as the buzzer will make loud irritating noise while red LED flashes continuously. Of course, this project has left rooms to add your own logic to it. For example, sending MQTT messages to your phone to alert you, or to an IP camera to capture the image of the thief. Hardware Preparation - Ameba1 RTL8195AM x2 - Buzzer x1 - LED (red) x1 - Reed switch x1 - Magnet x1 - Jumpers x6 As 2 boards are needed to implement this project, there are 2 connection illustration as follows, https://github.com/Realtek-AmebaApp/Ameba_Examples/blob/master/RTL8195AM/006_HOME_SECURITY/WindowSecuritySystem_Switch_bb.png https://github.com/Realtek-AmebaApp/Ameba_Examples/blob/master/RTL8195AM/006_HOME_SECURITY/WindowSecuritySystem_Buzzer_bb.png Software Preparation 1. Check and make sure you have installed the ameba 1 board to Arduino IDE via adding this link into “additional boards manager URLs” under “Preference”, and install it in “board manager” under “Tools”, https://github.com/ambiot/amb1_arduino/raw/master/Arduino_package/package_realtek.com_ameba1_index.json 2. Copy the [buzzer source code](https://github.com/Realtek-AmebaApp/Ameba_Examples/blob/master/RTL8195AM/006_HOME_SECURITY/windowSecuritySystem_buzzer_Github.ino) and [switch source code](https://github.com/Realtek-AmebaApp/Ameba_Examples/blob/master/RTL8195AM/006_HOME_SECURITY/windowSecuritySystem_switch_Github.ino) you find in this repository to your Ameba1 RTL8195 boards respectively using arduino IDE 3. In order to connect to WiFi and MQTT server, you need to key in your WiFi SSID, WiFi passowrd, MQTT username and MQTT password, - username: same as your amebaiot.com username - password: same as your amebaiot.com password Done that's it! You have created a simple yet powerful home security system! To watch how how it is done, click link below,
  21. Temperature and humidity are 2 of the most important factors affecting people’s comfort level in an enclosed space. The DHT humidity and temperature sensor can read the ambient temperature and humidity every 2-3 seconds, and then pass the data to Ameba who will forward them to the server using MQTT protocol. Whoever “subscribing” to the right topic gets the data almost instantaneously. Users can then adjust the aircon mode or temperature according to the readings received. An android phone was used as an MQTT client and the Ameba RTL8195 Dev. Board acted as another MQTT client communicating with the android phone. Both clients have to connect to the same MQTT server before proceeding to the next step. The DHT sensor updates its data every 10 seconds to stay as accurate as possible. Once sensor data is received, Ameba then “publishes” the data to the MQTT server where all clients “subscribing” to the right topic gets the data displayed on the console. GitHub page https://github.com/Realtek-AmebaApp/Ameba_Examples/tree/master/RTL8195AM/003_DHT_MQTT Official pages https://www.amebaiot.com.cn/en/ https://www.amebaiot.com/en/ Facebook pages https://www.facebook.com/groups/AmebaIoT/ https://www.facebook.com/groups/AmebaIoTWW/ BiliBili channel https://space.bilibili.com/45777743
  22. This is a simple IoT project based on the “mqtt basic” example that comes with the Arduino package when you install the RTL8195 on Arduino IDE. In this project, simple passive components are used to aid in demonstrating the power of bidirectional communication of MQTT protocol which is widely used in modern IoT applications for its advantages in speedy response and lightweight. In the video, an android tablet was used as a MQTT client and our Ameba RTL8195. Board acted as another MQTT client communicating with the android tablet. Both client have to connect to the same MQTT server before proceeding to the next step, you may choose to set up own MQTT server or using an online free server. Please refer to the video link, GitHub source code, https://github.com/Realtek-AmebaApp/Ameba_Examples/tree/master/RTL8195AM/002_MQTT_BASIC Official pages https://www.amebaiot.com.cn/en/ https://www.amebaiot.com/en/
  • Create New...