Micro-controllers, wireless transmission and database
This project assumes you have already installed STM32CubeIDE. You need to have previously done a basic blink sketch with blue-pill using STM32CubeIDE. I have made a complete video from installing STM32CubeIDE to LED blink program. You can watch it by clicking this link. https://www.youtube.com/watch?v=kXg467nVd_A
ADC1 - IN9 (tick)
Parameter Settings --> ADC Settings --> Continuous Conversion Mode (Enabled)
/* USER CODE BEGIN PV */ uint16_t readValue; float sensitivity = 0.1; // 0.1 for 20A Model float rawVoltage; float current; /* USER CODE END PV */ /* USER CODE BEGIN 2 */ HAL_ADC_Start(&hadc1); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { HAL_ADC_PollForConversion(&hadc1,1000); readValue = HAL_ADC_GetValue(&hadc1); rawVoltage = (float) readValue * 3.3 * 2 / 4095; // If rawVoltage is not 2.5Volt, multiply by a factor.In my case it is 1.035 // This is due to tolerance in voltage divider resister & ADC accuracy current =(rawVoltage - 2.5)/sensitivity; HAL_Delay (100); /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */