Twitter icon
Facebook icon
LinkedIn icon
Google icon
Reddit icon
StumbleUpon icon
Del.icio.us icon

Electrical Measurement in the Cloud

Added to IoTplaybook or last updated on: 02/09/2020
Electrical Measurement in the Cloud

Story

I have done this project for the Secure Everything with Azure Sphere contest, with the Azure Sphere MT3620 Starter Kit design by Avnet.

Things used in this project

Hardware components

Azure Sphere MT3620 Starter Kit
Avnet Azure Sphere MT3620 Starter Kit
 
× 1

Newark

Avnet

0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
 
× 1

ElectroPeak

SparkFun Analog/Digital MUX Breakout - CD74HC4067
SparkFun Analog/Digital MUX Breakout - CD74HC4067
 
× 1

SparkFun

General Purpose Quad Op-Amp
Texas Instruments General Purpose Quad Op-Amp
 
× 1

Newark

TI

 
SCT013-30
 
× 4

Amazon

 
3.5mm stereo jack PCB connector
 
× 5

AliExpress

Software apps and online services

Cloud IoT Core
Google Cloud IoT Core
 
  Google
Microsoft Azure
Microsoft Azure
 
  Microsoft

I used Visual Studio Code + Platformio with the plugin from Georgi Angelov. Here is the information to install it https://github.com/Wiz-IO/platform-azure

It has a lot of features, We are going to use in this project the M7 Core, one of the two M4 cores, two inbuilt ADC, ADC0 to receive the ambient light and ADC1 to receive the signal from the analog multiplexer, Two GPIO pins to select the signal from the analog multiplexer and the I2C interface to connect an OLED display.

I use 4 SCT013-030. The SCT013-030 is a non-invasive current sensor that converts a maximum of 30A in a signal of 1V.

We are going to measure AC current so the output signal goes from -1V to +1V. But our ADC works in a range os 0 to 3.3V so we have to use a circuit to change the voltage. We are going to use an OP amplifier. The LM324 has 4 inside.

I use only one ADC from the board, I need an analog multiplexer to receive the four analog inputs from the 4 sensors.

 inside.

I use only one ADC from the board, I need an analog multiplexer to receive the four analog inputs from the 4 sensors.

I have designed a shield to connect to the Azure Sphere MT3620.

I have divided the code into two. One real-time application runs in one M4 core to read the analogs signals, and send them to the M7 Core that it is running an application that receives the information, updates the OLED display and sends them to the Cloud IoT platform using a secure channel.

In the M4 core, I read the analog signals. The adc0 GPIO41 is the information from the ambient light sensor. In ADC1, GPIO 42 is the output of the analog multiplexer, and GPIO 16 and 17 are used to select the 4 channels of the analog multiplexer.

In order to read the current, we have to read the analog signal during 14 cycles of the signal or more. I use 25 cycles.

In the app_manifest.json it is important to add the id from the M7 application to the "AllowedApplicationConnections" field and all the GPIO.

The M7 core runs a code to receive the information from the M4 core, update the OLED display and send the information to the Google IoT Core using a secure channel.

First I used Azure IoT Central application to receive the data, but the trial expire in a month so I have to change to another cloud service. This is the tutorial I used

It is really easy to do it following the steps.

I move to Google cloud and there the secure channel is based in a JSON Web Token(JWT) authentification. Cloud IoT Core uses public-key authentication and supports the RSA and Elliptic Curve algorithms. Here it is a good tutorial to connect an esp32, I adapt it for the Mt3620 http://nilhcem.com/iot/cloud-iot-core-with-the-esp32-and-arduino

We can use MQTT or HTTP, I use HTTP. To send telemetry events to the Cloud using the HTTP bridge, you have to send a POST request containing base64 encoded data to a given URL. The request must contain an authorization header with a valid JWT generated using your device’s private key.

Following the tutorial, I deploy InfluxDB and Grafana in order to store the data.

Custom parts and enclosures

PCB Design

The power is the current multiply by the voltage in Spain 230V. Grafana does the conversion. Here is a dashboard example.

Schematics

Electrical Shield

Read electrical signal

 

Code

Github repository - Code for the project

 

Robertou2 / azureelectricalmeasure

Project for the Secure Everything with Azure Sphere contest — Read More

Latest commit to the master branch on 11-29-2019 - Download as zip

Credits

Roberto del Campo

  Roberto del Campo

 

Thanks to Georgi Angelov and Gautier MECHLING.

 

Hackster.io

This content is provided by our content partner Hackster.io, an Avnet developer community for learning, programming, and building hardware. Visit them online for more great content like this.

This article was originally published at Hackster.io. It was added to IoTplaybook or last modified on 02/09/2020.