Technology Sharing

[Microcontroller Graduation Project Topic 24048] - Design of Truck Overload Alarm System Based on Microcontroller

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

System functions:

After the system is powered on, the OLED displays "Welcome to the overload alarm system, please wait", and then enters the normal page display after five seconds.

The first line shows the weight value obtained

The second line shows the set weight value

The third line shows the GPS coordinates

The fourth line shows the system status, OK or Alarm

Short press the B3 button to increase the weight setting threshold

Short press the B4 button to reduce the weight setting threshold

After pressing the pressure sensor module, the system buzzer sounds and sends an alarm message to the mobile phone number.

After the mobile phone is connected to the system via the Bluetooth module, the system can periodically report the obtained weight value to the mobile phone.

and system status.

Schematic diagram of main functional modules:

Power clock burning interface:

Microcontroller and key input circuit:

Sensor acquisition circuit:

Display output circuit:

Function Customization Link

System main function module code

Initialization code:

  1. /* USER CODE BEGIN 1 */
  2. /* USER CODE END 1 */
  3. /* MCU Configuration--------------------------------------------------------*/
  4. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  5. HAL_Init();
  6. /* USER CODE BEGIN Init */
  7. InitVar();
  8. /* USER CODE END Init */
  9. /* Configure the system clock */
  10. SystemClock_Config();
  11. /* USER CODE BEGIN SysInit */
  12. /* USER CODE END SysInit */
  13. /* Initialize all configured peripherals */
  14. MX_GPIO_Init();
  15. MX_USART1_UART_Init();
  16. MX_USART2_UART_Init();
  17. MX_USART3_UART_Init();
  18. MX_ADC1_Init();
  19. /* USER CODE BEGIN 2 */
  20. //uart2打开接收中断
  21. HAL_UART_Receive_IT(&huart2, (uint8_t*)&uart2RecBuff, 1);
  22. //uart3打开接收中断
  23. HAL_UART_Receive_IT(&huart3, (uint8_t*)&uart3RecBuff, 1);
  24. InitOled();
  25. InitOledDisp();
  26. //初始化ESP8266
  27. ESP8266_Init();
  28. HAL_Delay(100);
  29. OledFill(0x00); //全屏熄灭
  30. RELAY1_ON();
  31. /* USER CODE END 2 */

Read sensor value;

  1. //读传感器值,AD值
  2. void ReadSensorVal(void)
  3. {
  4. getWeightVal = ReadADCChannel(ADC_CHANNEL_0);
  5. if(getWeightVal>setWeightVal)
  6. {
  7. BUZZER_ON();
  8. sysAlarm = true;
  9. if(sendMessage==false)
  10. {
  11. sendMessage = true;
  12. sim900a_SendMessage();
  13. }
  14. }
  15. else
  16. {
  17. BUZZER_OFF();
  18. sysAlarm = false;
  19. sendMessage = false;
  20. }
  21. }

Update BLE data:

  1. void UpdateBleData(void)
  2. {
  3. static uint8_t bleCnt = 0;
  4. bleCnt++;
  5. if(bleCnt>=BLE_UPDATE_INTER)
  6. {
  7. bleCnt = 0;
  8. printf("GetWeight:%04drn", getWeightVal);
  9. printf("SetWeight:%04drn", setWeightVal);
  10. if(sysAlarm==false)
  11. {
  12. printf("System is OK!rn");
  13. }
  14. else
  15. {
  16. printf("System is NG!rn");
  17. }
  18. }
  19. }

The information provided for this design includes schematic PCB (including three versions: PDF, AD, and EasyEDA), source code, system block diagram, main program flow chart, bill of materials (including manuals of the devices used), functional operation instructions, etc.

Information about each functional module: