IoT Project AVR
What is AVR Elite?
We at Arshon have years of experience in design and development of IoT products using cloud services such as Amazon Web Service (AWS) technology. In this article we walk you through the details of one of Arshon’s IoT product which is called AVR Elite.
AVR Elite is a product of Torus Power Inc. with AWS Internet of Things capabilities, which is designed and manufactured by Arshon Technology. AVR Elite is a power transformer and voltage stabilizer with embedded web interface over Ethernet and AWS IoT connectivity over WiFi module. AVR Elite stabilizes voltage in the optimal voltage operating range of +/- 4V in North America, and +/- 8V in Europe/Asia/Australia. It also includes several addressable zones in order to monitor and control audio and video systems.
The device consists of a massive toroidal transformer that brings about true isolation along with low source impedance and large enough instantaneous current for audio amplifiers. Consequently, it generates clean AC power output. The firmware performs FFT on output signal and calculates Total Harmonic Distortion (THD) in percentage. The calculated THD value is sent to AWS cloud along with other monitoring data.
Internet of Things Hardware Design
At the core of the AVR device is a Toroidal Transformer with multi-tap input which provides the ability to voltage adjustment by switching between taps. In hardware design we use Electro-mechanical relays to switch between taps to keep the output voltage always in the range and protect the device using the power out of the AVR device. The Tap control mechanism is controlled by a microcontroller on top of other features such as Zone control and Internet connectivity and controls.
Here are some of the picture of boards and assemblies during the prototyping and development of the product:
AWS IoT Cloud Application and AWS IoT Firmware
Each AVR Elite device has its shadow in AWS IoT Core. Media Access Control (MAC) address of each device Ethernet PHY is used as a unique device identifier. Therefore, each device can be detected in the AWS cloud. Each connected device has a credential to access the Device Shadow service. All traffic to and from AWS IoT is encrypted over Transport Layer Security (TLS). AWS Cloud security mechanisms protect data as it moves between AWS IoT and other devices or AWS services. Each AVR Elite device uses X.509 certificate in order to coincide with the AWS IoT connection model. X.509 certificates are digital certificates that use the X.509 public key infrastructure standard to associate a public key with an identity contained in a certificate. All AVR Elite devices support TLS 1.2 implementation and SHA-256 RSA certificate signature validation. There is also the server authentication certificate. The server certificate allows the AVR Elite devices to verify that they’re communicating with AWS IoT and not another server impersonating AWS IoT. RSA 2048-bit key Amazon Root CA endpoint is used by AVR Elite devices.
Device Shadow service is employed by AVR Elite devices to communicate with AWS Cloud. The device shadow of AWS IoT Core is a JSON document used to store and retrieve the current state information for the device. The device shadow consists of two parts: Reported and Desired. The reported part represents the parameter current values, received from the device. The desired part represents the requested desired parameter values. A device will act on Desired values and, thus, the reported values will match the Desired value, eventually.
Therefore, reported and desired attributes of the Device (Thing) Shadow allow observing and modifying the device characteristics in real-time. Also, AWS IoT Core rules are used for recording current device parameter values into AWS DynamoDB database.
Amazon DynamoDB is a NoSQL database service, which is recommended to use conjointly with AWS IoT Core. AWS DynamoDB service provides the opportunity to demonstrate the historical parameter evaluation. Furthermore, AWS DynamoDB database is used for storing the information about Users (owners of AVR Elite devices) and Dealers (distributers/installers of AVR Elite devices) on the Amazon Cloud.
Website and Web App Cloud Dashboard
We use Amazon AWS Cognito service to provide authentication, authorization and member (Dealers and Users) management on the Torus Power Connect web portal. AWS Cognito is applied for member registration, keeping their credentials, sending the temporary password with invitation email, and processing the “change password” and “forgot password” requests.
By combining the mentioned AWS services (IoT Core, DynamoDB, Cognito) with ASP.NET framework, we created the web portal which allows the Users (AVR Elite device owners) to monitor and control their device behavior from desktops, tablets and smart phones. Moreover, the Dealers (AVR Elite device distributers/installers) can remotely adjust and maintain the User’s device.
The User can observe, manage and analyze the behavior of AVR Elite devices on the following web pages: System Status, Live Data, Power Control, Historical Data, Historical Charts, Schedule Management, System Setup, Reporting.
AWS IoT Firmware Communication
The monitoring data is sent to the cloud with AWS Shadow (Subscribe/Publish) MQTT packets every minute (by default but the interval is adjustable). If WiFi internet connection is lost, monitoring data is bundled in a packet with timestamp every second and are stored in external flash for future communication. As soon as the connection is established the stored packets are sent to the cloud with some predefined interval delay between them.
Several controlling data allow users to control addressable zones through website user interface. The changes are reflected on Shadow JSON document and firmware will receive desired changes and will act accordingly. Eventually firmware will update shadow JSON document with new reported values that match requested desired value and will update the AWS cloud.
AWS Over-The-Air (OTA) firmware update
Furthermore, regarding device capabilities, AWS Over-The-Air (OTA) firmware update is also implemented. Thus, any changes or upgrade in firmware is easily transferable to all devices around the globe. The process includes building new firmware image and crypto-sign it for AWS and upload it to AWS bucket. At the end, an OTA job is created in AWS console which includes all devices (things) that need to be updated. When a job is created, the OTA firmware upgrade process is started for all devices. The firmware receives the job and notifies user regarding new firmware upgrade by email and by displaying on embedded LCD on device. As soon as the user opts to receive new firmware by holding button for a few seconds, a download of the firmware file begins.
Device Firmware Functionality
In the project, the firmware is developed on a high-speed Microchip Microcontroller (MCU), PIC32MZ, and application and some of the drivers are running over FreeRTOS. The Atmel WiFi module, WINC1500, is used in device which communicates to MCU through SPI peripheral and communication to the cloud is over MQTT protocol and is secured with SSL/TLS.
In addition to a Wi-Fi module, AVR Elite device consists of an External Flash Drive, PHY device for Ethernet Controller, Energy Meters, several Relays to control outlet zones and transformer steps, USB ports, LCD, Timer/Oscillator, and a Voltage Supervisor.
The External Flash is used to store permanent controlling data, scheduling data, and network settings. Local webpages are accessed through copper Ethernet. Ethernet module receives IP from router and IP is printed on LCD. Users can control device, monitor status, and schedule zones on local webpages. The webpages are also used for calibration and device settings.
Input and output voltages and output current are obtained by sampling RMS values from two separate energy meters and calculating average of samples. The calculated value is divided by some predefined coefficient to produce actual voltage of input and output amperage of current. Upon receiving voltage and current values, regulator tasks make decision based on an algorithm and some predefined settings and if necessary, it will change transformer step for better voltage output. Moreover, the regulator task will turn off all relays if voltage and current are out of safety range.
All information and errors are also printed on USB console. Firmware also receives command from user through USB console and act upon that. The Timer/Oscillator is used to reset MCU if MCU firmware is stuck somewhere in the code and is not generating PWM signal. Also, the Voltage Supervisor is used to turn off main relay for safety if MCU firmware is not responsive.