Jotrin Electronics
Description Quantity Total (USD) Operation
Shopping cart products
Shopping cart products : 0
Home > Technology List > Atmel smart plug reference design of wireless Internet of things desig

Atmel smart plug reference design of wireless Internet of things design requirements

Published time: 2019-12-20 12:02:03

Devices for Internet of things (IoT) applications have some common but critical requirements: simple connection, high level of security, and ease of use.Therefore, designers should carefully study atmel's smart plug reference design as a comprehensive work guide for wireless iot design.

While wired connections are often required for applications facing harsh environments, consumers can now count on reliable and easily set up wireless connections.In terms of security, the requirements today go beyond basic data encryption to include more sophisticated policies for securely adding new devices to trusted networks and ensuring secure communications during normal operations.Finally, any iot device should ultimately meet the application specific sensor or actuator functional requirements.

Here's why Atmel's smart plug reference design is used as a comprehensive working guide for wireless iot design.For designers, it incorporates all the hardware and software needed for a secure internet-connected product.At the same time, the design is a wi-fi-enabled power plug, which shows three main use case models: using its capacitive touch buttons for local control;Control via a mobile app with wi-fi connectivity (with or without cloud connectivity);Or timer based control by using related application scheduled on/off timing.

Unlike many emerging iot starter kits, the Atmel smart plug reference design is available in a cloud-free version.In fact, Atmel offers a version of firmware designed for clustering, but developers need to keep an eye on the trend toward "cloud computing."

In fog computing, the level of control over data processing, storage, and application is performed locally at "edge" locations, not just in the cloud.In addition to implementing "always available" services, this approach reduces service latency, improves security, saves energy, and improves the overall user experience.

The device design

The smart plug design itself consists of three printed circuit boards (PCB) for power supply, MCU and touch control.The MCU board is mounted vertically on the power board and the touch board is connected to the MCU board through a pin connector (figure 1).Atmel offers three versions of the smart plug, which meet us, European and Chinese standards.Three versions are available for each area of the standard plug and socket, but use the same PCB.

Figure 1: Atmel smart plug reference design divides digital circuit and power circuit into separate boards, one third of which is used for LED and QTouch interface.

The touchpad includes wi-fi and power leds as well as a touch sensor based on QTouch technology.QTouch adopts the capacitive touch sensing technology of Atmel, which has the anti-noise capability and environmental tolerance required for reliable performance in less than ideal environment.

The power board includes an AC/DC converter, a DC /DC converter, power measurement circuit, relay and plug and socket.AC/DC converters are designed to convert 100 V/240 VAC input voltage to 12 V/120 mA(typical)DC output to supply power to relays and DC/DC converters.Custom AC/DC converter transformer and the Monolithic Power Systems combine MP020-5 switching voltage stabilizer.

The mp020-5 is an off-line, primary side regulator that provides accurate constant voltage and current regulation without the need for optical couplers or secondary feedback circuits.The DC/DC converter converts the DC voltage level from 12v to 3.3v for the SAMW25 wireless module on the MCU board.

MCU board contains ATSAMW25 wireless module and 32 KHz crystal.It also provides usable packaging on printed circuit boards for external flash devices that are not required for this design.

Secure connection module

The core of the Atmel design is the ATSAMW25 module that combines digital control, connectivity and security functions.Designed as a direct alternative to wi-fi connectivity, this module combines its comprehensive hardware capabilities with integrated software, including applications and security protocols such as transport layer security (TLS), and integrated network services including TCP/IP stacks.In the smart plug design, this module not only provides wi-fi connectivity and security, but also manages smart plug touch buttons, relay control, temperature sensing and protection, LED indicators and timing functions (figure 2).

Figure 2: Atmel smart plug reference design provides a complete iot solution built around the Atmel ATSAMW25 module, providing digital control, connectivity and security functions.

This core module internally utilizes the comprehensive functions integrated in the following three key SoC: Atmel ATSamd21G18A MCU, Atmel atwinc1500b-mu-t transceiver and Atmel ATECC508A encryption verification device.

Based on the low-power ARm cortex-m0 + core, ATSAMD21G18A integrates 256 KB flash memory and 32 KB SRam with a full set of peripherals, including serial, USb, 14-channel 12-bit analog converter (adc) and 10-bit digital analog converter (dac).Atmel atwinc1500b-mu-t is a low-power, single-chip IEEE 802.11b /g/n, 2.4ghz network controller.ATWINC1500 is designed to simplify the integration of wi-fi connections in McU-based designs. It integrates all transceiver signal chains and provides multiple peripheral interfaces, including uart, SPI and i2C for connection to the host MCU.ATECC508A encryption devices will be described below.

For wireless communications, these devices need only a few connections between the SAMD21G MCU and the ATWINC1500 network controller SoC (figure 3).Although SPI connections provide two-way data exchange, this design helps reduce power consumption during quiet periods.For incoming data, ATWINC1500 can wake up the MCU with a break line (IRQn) to notify the MCU to process the received data.For output data, the MCU can wake up the ATWINC1500 processing transfer using a wake line.

Figure 3: the Atmel ATSAMW25 module integrates MCU with SoC to achieve wi-fi connectivity and security, providing a direct alternative solution for many iot applications.

The ATSAMW25 module requires very few additional components to control the smart plug power relay and interface with the power measurement circuit (figure 4).As shown in the figure, the 52-pin ATSAMW25 module provides a simple interface for the key functions that are processed outside the module.For example, pin 24 is the attached Atmel ATSAMD21G18A MCU that leads to the reset pin, and pins 40 and 41 are used to connect to the power measurement subsystem.In addition, this module provides nine generic input/output (GPIO) pins that developers can program to elicit application-specific functionality.

Figure 4: the Atmel ATSAMW25 module was designed to simplify the integration of wi-fi functionality into the design, requiring fewer external components and providing the minimum number of external connections needed to implement the design.

Unlike bluetooth's one-to-one pairings, wi-fi connections support device sharing, so multiple users can share access and control the device.However, designers can still build custom wi-fi/bluetooth designs by using specialized bluetooth components (such as Atmel ATSAMB11 bluetooth SoC) and related software to enhance the basic smart plug reference design.ATWINC1500 supports 2-wire and 3-wire wi-fi/bluetooth co-existence signals conforming to IEEE 802.15.2-2003 standard.

Finally, Atmel ATM90E26 is used in the power management circuit implemented on the power board.Designed for energy metering, the ATM90E26 integrates a complete analog front-end (AFE) signal chain with a digital signal processor (DsP).By using AFE to perform voltage and current measurements, DSP can calculate real-time power, RMS current, RMS voltage, and accumulated electrical energy.The result is transmitted to ATSAMW25 via the UART port.To isolate the line voltage and the internal power domain, the design includes two optical couplings to protect the connection between ATM90E26 and ATSAMW25 (pins 40 and 41 on the ATSAMW25 module).

The software design

In the smart plug reference design, the main program runs on ATSAMD21G18 MCU embedded in ATSAMW25 module.This software is designed without a real-time operating system (rtos).Instead, all software function blocks run in an infinite loop after initialization.Key MCU software features include wi-fi connectivity through the ATWINC1500 driver;Through ATECC508A driver and software AES library to provide security;Energy measurement via ATM90E26 driver;And touch button control through the Atmel QTouch library.

In the smart plug reference design, the application firmware is divided into two partitions - application 1 and application 2(figure 5).In addition to these application partitions, internal flash memory includes emulated EEPROM for storing user information, wi-fi network information, and usage data.

Figure 5: since the memory encapsulation of the smart plug firmware is relatively small, two copies of the application can coexist within the 256KB flash memory of the ATSAMD21G18 MCU, enabling wireless upgrades without the need for external memory.

After the reset, use a simple bootstrap to determine which application firmware partition to run.From here, the bootstrap code looks at the variables defined in boot.h(listing 1), the bootstrap header file.

Define APPLICAtiON_SIZE (FLASH_SIZE/2UL) // MAIntain two copies in flash


# define APP1_START_ADDRESS 0 x00004000

# define APP2_START_ADDRESS 0 x00020000

/** NVM page to save application area info */


Typedef enum _valid_app {




} valid_app_enum;

Listing 1: the bootstrap header file defines several constants and variables required for a simple bootstrap load process.(source: Atmel Corp.)

The bootstrap code itself checks the APPx_VALID tag (listing 2)

If (app_info valid_app = = APP1_VALID) {

App_check_address = APP1_START_ADDRESS;

App_check_address_ptr = (uint32_t *) app_check_address;

} else if (app_info.valid_app == APP2_VALID) {

App_check_address = APP2_START_ADDRESS;

App_check_address_ptr = (uint32_t *) app_check_address;

} else {

/ *

* Factory new device has no valid app flag in EEPROM.

* Application code is in sector 2 for factory new device.

* /

App_check_address = APP2_START_ADDRESS;

App_check_address_ptr = (uint32_t *) app_check_address;


Listing 2: the bootstrap code simply checks which application area (APP1 or APP2) is active and calls this code in the active application area to begin executing the smart plug device software.

Finally, the bootstrap is set to run the code in the appropriate application space and jump to the application.

Thanks to the high integration of the designed SoC, the reference design's memory package is very small.Program memory usage was 83,244 bytes (31.8% of capacity) and data memory usage was only 15,632 bytes (47.7% of capacity).Because of its small size, the design supports the wireless (OTA) upgrades required for typical IoT edge nodes.The 256 KB internal flash memory of ATSAMD21G18A MCU leaves enough space to store the downloaded firmware image while leaving the original firmware intact.Therefore, this reference design does not require an OTA upgrade for external storage.

Atmel provides a complete code package for devices and for android apps.Developers can access the software configuration through Atmel START, the company's online tool for configuring software components and device Settings such as clock and pin layouts.The smart plug configuration comes with a pre-built wi-fi stack, middleware such as encryption services and IO management, and a suite of software drivers (figure 6).

Figure 6: Atmel provides a complete set of software development and debugging tools, including an online tool for configuring software components and device Settings in a designed hardware device set.(photo by Atmel Corp.)

Once configured, the developer exports the project and opens it in the IDE for further software development.For application development, Atmel provides a comprehensive tool chain built around Atmel Studio 7, where code development tools and integrated debugging functions are combined through the Atmel debugger, programmer, and emulator.For smart plug design, the Atmel software framework (ASF) provides apis for wi-fi connectivity, security, communication protocols, sensor readings, and uis.Developers can use Atmel's ASF Explorer to import drivers, communication stacks, and services from the ASF into their projects.The ASF Explorer automatically manages library dependencies to ensure that the required drivers are included in the code package.

Like most emerging iot devices, Atmel smart plugs rely on mobile applications to implement user interfaces for monitoring and control.In fact, Atmel's android app is an integral part of this reference design.With the app, users can manage wi-fi deployments, share devices with multiple users, perform wireless upgrades, turn devices on and off, schedule on/off times, and even view usage history during setup.

Internet of things security mechanism

Atmel android apps play an important role in ensuring safe operations.The Atmel smart plug reference design implements robust security policies that require authentication communication between device and application during setup and normal operation.As the intelligent plug design represents the design of most edge nodes of the Internet of things in terms of function, the reference design provides detailed guidance for the implementation of iot security measures.

This design relies on Atmel ATECC508A hardware encryption engine and software encryption library to implement security functions, including:

Fips186-3 elliptic curve digital signature algorithm (ECDSA) for android applications and smart plug verification;

Diffie-hellman algorithm (ECDH) for the FIPS sp800-56a elliptic curve, which is used to generate session keys and never transfer private keys outside the security key store;

Advanced encryption standard (AES)-128 encryption block link (CBC) mode, used for network communication data encryption and decryption;

Sha-256-based MAC(message verification code) for data integrity checking.

The same security features are implemented in the android app-side software to enable secure communication between the smart plug device and the app.

Key - based encryption puts forward strict requirements for key security in any Internet of things design.In the design of smart plug, ATECC508A encryption device satisfies this requirement through its hardware-based secure encryption key storage and encryption countermeasures.As the design goes into production, key stores (such as those in ATECC508A) will be configured in a secure factory environment and then marketed to ensure private key security.

In the field, the design USES advanced validation schemes to add new smart plug devices to existing networks and exchange data between proven smart plug devices and applications.During the data exchange between the smart plug and the application after mutual verification, the smart plug USES its MAC address and a random number challenge to answer.Since the smart plug will receive the public key of the android application after joining the network (security), ATECC508A can generate an ECDH pre-master key and use the MAC algorithm to randomly generate the key to output the temporary key that is only valid during the session.In turn, ATECC508A USES this session key as an AES key to encrypt the information transmitted to the android app in the reply.Although the security process for adding new smart plug devices is more complex, it follows a similar security philosophy of random key exchange, challenge, and verification.

But for developers, the Atmel driver and API handle the details.For example, you can use the third-party library LibTomCrypt to return encrypted or decrypted data in aes-128 CBC mode by simply calling cademo_aes_crypt() in the ecc508a driver (listing 3).

Static uint8_t cademo_aes_crypt(uint8_t enc_mode, uint8_t* aes_key, uint8_t* plain_txt, uint16_t* plain_txt_size, uint8_t* cypher_txt, uint8_t* iv)


Uint8_t ret = ATCA_SUCCESS;

Uint16_t keysize = AES_KEY_SIZE;

/ / LibTomCrypt

Register_cipher (& aes_desc);

Int32_t cypher_idx = find_cipher (aes, "");

Symmetric_CBC CBC.

Ret = cbc_start(cypher_idx, iv, aes_key, keysize, 0, & CBC);

If (enc_mode == MODE_ENCRYPT) {

Ret = cbc_encrypt(plain_txt, cypher_txt, *plain_txt_size, & CBC);


Else if (enc_mode == MODE_DECRYPT) {

Plain_txt is the encrypted data by calling cademo_aes_crypt(),

While cypher_txt is the place to store decryjournedata. */

Ret = cbc_decrypt(plain_txt, cypher_txt, *plain_txt_size, & CBC);


Return ret.


Listing 3: the Atmel basic code for the smart plug reference design provides a complete set of security implementation routines, such as the above routines for aes-128 CBC mode encryption/decryption.

Here, the call parameters include:

Enc_mode - a flag that defines whether to encrypt or decrypt

Aes_key -- AES password

Plain_txt -- some bytes to encrypt

Plain_txt_size -- the number of bytes to encrypt

Cypher_txt - encrypted text

Iv -- initialization vector for CBC mode


Iot design requires successful functional integration, including connectivity, security, and application resources.By combining a robust iot reference design, new iot developers can quickly accumulate experience, and experienced developers can accelerate the implementation of iot design.Atmel smart plug reference design provides a comprehensive working example for iot design.This design combines hardware and software for wireless connectivity, security, and energy metering to provide insight into the interactions between design components for the Internet of things, and can serve as a starting point for complex custom iot designs.



Account Center

Points Mall


Live Chat

Product comparison

(Supporting the comparison of similar products)
Compare Clear