Things used in this project
Software apps and online services
1-Â STMicroelectronics STM32CubeMX
2-Â STMicroelectronics STM32CubeIDE
3-Â Proteus 8
Exploring Precision Power Monitoring with STM32 ADC and ACS712 Sensor
This project explores the precision power monitoring capabilities facilitated by the STM32 ADC in conjunction with the ACS712 Hall Effect-Based Current Sensor. Much like a skilled conductor guiding an orchestra, this combination harmoniously integrates to deliver precise and efficient power monitoring solutions in embedded systems.
Precision Measurements with ACS712 Current Sensor:
The ACS712 sensor can be used by developers to make power monitoring easier with the STM32 ADC at its core. By combining the ADC‘s strong features with the ACS712‘s precise measurements, analyzing power usage in embedded systems can be made simpler and more reliable.
Real-Time Power Consumption Monitoring:
This integration enables real-time monitoring of power consumption across diverse applications. By optimizing the ADC‘s configuration and utilizing the ACS712‘s accurate measurements, developers can tailor power monitoring solutions to meet specific project requirements effectively.
From industrial automation to IoT deployments, the STM32 ADC and ACS712 Hall Effect-Based Current Sensor present a robust solution for mastering power monitoring in embedded systems.
To begin this project, we’ll first activate Continuous Conversion mode. Next, we’ll set up the ADC for regular mode conversion. Finally, we’ll establish UART communication to send out both the ADC readings and system status
STM32CubeMX Configuration:
- Open CubeMX & Create New Project Choose The Target MCUÂ STM32F103C6Â & Double-Click Its Name
- Go To The Clock Configuration & Set The System Clock To 8MHz
Configuration for theÂ
ADCÂ
Mode:
- In the Categories tab, select the [ADC1, enable IN9]
- In the Parameter settings tab, ADC Settings : Enable Continuous Conversion Mode
- In the Parameter settings tab, ADC_Regular_Conversion Mode: [Enabler Regular Conversion Mode & Number of Conversio : 1 & External Trigger Conversion source : Regular Conversion launched by software & Rank1: channel : 9, sympling Time :1.5 Cycles]
Configuration for theÂ
UART
 Mode:
- Enable USART1 Module (Asynchronous Mode)
- Set the USART1 communication parameters (baud rate =Â 115200, parity=NON, stop bits =1, and word length =8bits)
- Generate The Initialization Code & Open The Project In CubeIDE
- Write The Application Layer Code
STM32CubeIDE Configuration:
/* Includes ------------------------------------------------------------------*/ #include "main.h" * Private variables ---------------------------------------------------------*/ ADC_HandleTypeDef hadc1; UART_HandleTypeDef huart1; /* USER CODE BEGIN PV */ uint16_t readValue; uint8_t MSG[100]; float sensitivity = 0.185; //0.185 for 5A module => datasheet float actual_voltage; //0A -->Vcc*0.5 = 5*0.5 = 2.5V => datasheet float current ; float Input_votage_range =3.3; //3.3v stm32 int ADC_range = 4095; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_ADC1_Init(void); static void MX_USART1_UART_Init(void); int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_ADC1_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ if(HAL_ADC_Start(&hadc1)!=HAL_OK) { Error_Handler(); } /* USER CODE END 2 */ while (1) { while(HAL_ADC_PollForConversion(&hadc1, 1000)!=HAL_OK) { Error_Handler(); } readValue= HAL_ADC_GetValue(&hadc1); //if acual_voltage is not 2.5 V => multiply by factor in my case it is 17.54 actual_voltage= (float) ((readValue* Input_votage_range)/ADC_range)*17.54; current=(actual_voltage-2.5)/sensitivity; sprintf(MSG,"readValue = %d || actual_voltage = %.2f || current value = %.2f\n\r", readValue,actual_voltage,current); HAL_UART_Transmit(&huart1, MSG, sizeof(MSG), 200); HAL_Delay(1000); } }
Proteus Configuration :
- Open Proteus & Create New Project and click next
- Click on Pick Device
- Search for STM32F103C6 & ACS712 & BATTERY & CAP
- Click on Virtual Instruments Mode then choose VIRTUAL TERMINAL & DC AMPERMETRE
- Click on Terminal Mode then choose (DEFAULT & POWER &GROUND)
- finally make the circuit below and start the simulation
That’s all!
If you have any questions or suggestions don’t hesitate to leave a comment below
Heading Title
-
Table of Contents Things used in this projectSoftware apps and online services:Creating an LED Bar-Graph Display System: Integrating STM32 with 74HC595 Shift RegisterExploring the Functionality of the 74HC595 Shift Register:Understanding …
-
Table of Contents Things used in this projectSoftware apps and online services:Multi-Channel ADC Data Acquisition with ADC128S102 and STM32 via SPI Communication | Proteus SimulationExploring the ADC128S102 Analog-to-Digital Converter:Leveraging SPI …
-
Table of Contents Software apps and online services1- STMicroelectronics STM32CubeMX2- STMicroelectronics STM32CubeIDE3- Proteus 8STM32 Integration: Enhancing Ultrasonic Sensing with Timer FunctionalityHC-SR04 PinoutHow the HC-SR04 Ultrasonic Distance Sensor Works?STM32CubeMX Configuration:Configuration for the GPIO Mode:Configuration for …
-
Table of Contents Software apps and online services1-Â STMicroelectronics STM32CubeMX2-Â STMicroelectronics STM32CubeIDE3-Â Proteus 8Exploring Temperature Sensing Applications with STM32 and AD8495:Understanding the AD8495 K-Type Thermocouple Amplifier:Key Features of the AD8495 Amplifier:Powering and Integrating …
-
Table of Contents Things used in this projectSoftware apps and online services:Advancing Temperature Monitoring with STM32 and MAX31856 IntegrationADC Exploring the MAX31856 Thermocouple-to-Digital Converter:Key Features and Capabilities of MAX31856:STM32CubeMX Configuration:STM32CubeIDE …
-
Table of Contents Things used in this projectSoftware apps and online services:Enhancing Temperature Monitoring with STM32 and MAX31855 IntegrationExploring Thermocouple Technology and its Applications:Understanding the MAX31855 Thermocouple Interface Chip: STM32CubeMX …
2 comments
Can you please share the Proteus files ? Thank you.
I will share them as soon as possible