Cathy Cathy
Published © MIT

STM32F301VCT6 Industrial Monitoring Controller with High-Spe

This project demonstrates an industrial monitoring platform based on STM32F301VCT6 MCU. It uses the Cortex-M4 processor, high-speed ADC and

IntermediateProtip5 days20
STM32F301VCT6 Industrial Monitoring Controller with High-Spe

Things used in this project

Hardware components

STM32F301VCT6 Development Board
×1
STM32F301VCT6 MCU
×1
0.96-inch OLED Display (SSD1306)
×1
Voltage Regulator Module
Digilent Voltage Regulator Module
×1

Software apps and online services

STM32CUBEPROG
STMicroelectronics STM32CUBEPROG
STM32CubeMX
STM32 HAL Library
STM32F301VCT6 Datasheet & Reference Manual

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter
Oscilloscope (Optional)
Screwdriver Set

Story

Read more

Schematics

STM32F301_Monitoring_Controller_Schematic

Code

STM32F301VCT6 Mini Industrial Monitoring Controller

C#
/*
 * STM32F301VCT6 Mini Industrial Monitoring Controller
 *
 * Features:
 * - ADC Sensor Acquisition
 * - OLED Display
 * - UART Monitoring
 *
 */


#include "main.h"
#include "adc.h"
#include "i2c.h"
#include "usart.h"

#include "oled.h"

#include <stdio.h>


uint32_t adc_value;

float temperature;
float current;


char uart_buffer[100];


void System_Init(void)
{
    HAL_Init();

    SystemClock_Config();

    MX_GPIO_Init();

    MX_ADC1_Init();

    MX_I2C1_Init();

    MX_USART1_UART_Init();


    OLED_Init();

}


float Read_Temperature(void)
{
    /*
     * Example temperature conversion
     * Replace with real sensor calibration
     */

    return 25.0 + (adc_value / 4095.0)*10;

}


float Read_Current(void)
{

    /*
     * Current sensor conversion
     *
     * Example:
     * 0-3.3V ADC
     */

    return (adc_value / 4095.0)*5.0;

}



void Read_Sensors(void)
{

    HAL_ADC_Start(&hadc1);


    HAL_ADC_PollForConversion(
        &hadc1,
        100
    );


    adc_value =
        HAL_ADC_GetValue(&hadc1);



    temperature =
        Read_Temperature();


    current =
        Read_Current();


}



void Display_Data(void)
{

    char line1[20];
    char line2[20];
    char line3[20];


    sprintf(
        line1,
        "Temp: %.1f C",
        temperature
    );


    sprintf(
        line2,
        "Current: %.2fA",
        current
    );


    sprintf(
        line3,
        "STATUS: NORMAL"
    );


    OLED_Clear();


    OLED_ShowString(
        0,
        0,
        line1
    );


    OLED_ShowString(
        0,
        20,
        line2
    );


    OLED_ShowString(
        0,
        40,
        line3
    );


    OLED_Refresh();

}



void UART_Send_Data(void)
{


    sprintf(
        uart_buffer,
        "Temperature=%.1f C Current=%.2f A STATUS=NORMAL\r\n",
        temperature,
        current
    );


    HAL_UART_Transmit(
        &huart1,
        (uint8_t*)uart_buffer,
        strlen(uart_buffer),
        100
    );


}



int main(void)
{


    System_Init();



    while(1)
    {


        Read_Sensors();



        Display_Data();



        UART_Send_Data();



        HAL_Delay(1000);



    }


}

Core Configuration

C#
#include "adc.h"


ADC_HandleTypeDef hadc1;


void MX_ADC1_Init(void)
{


ADC_ChannelConfTypeDef sConfig={0};


hadc1.Instance =
ADC1;


hadc1.Init.Resolution =
ADC_RESOLUTION_12B;


hadc1.Init.ContinuousConvMode =
DISABLE;


HAL_ADC_Init(&hadc1);



sConfig.Channel =
ADC_CHANNEL_1;


sConfig.Rank =
ADC_REGULAR_RANK_1;


sConfig.SamplingTime =
ADC_SAMPLETIME_28CYCLES_5;



HAL_ADC_ConfigChannel(
&hadc1,
&sConfig
);


}

Credits

Cathy Cathy
5 projects • 0 followers
Electronics sourcing expert at lovechip. Focused on component integrity, EOL solutions, and next-gen semiconductor trends.

Comments