1. Hardware scheme
This design consists of STM32 MCU core board circuit, AC voltage current detection module circuit and WIFI module circuit. The AC voltage and AC current values are detected by voltage transformer TV1005M and current transformer TA1005M respectively. After the APP and WiFi modules are connected, AC voltage, AC current, power and power can be displayed on the mobile phone in real time when the power exceeds 200W.When the mobile phone is connected to the WiFi module, the timer is displayed on the mobile phone.
It mainly consists of STM32 single-chip computer core board, AC voltage and current detection module, WIFI module, indicator light; as shown in the figure:
2. Design Functions
(1) 220V municipal power produces weak AC after mutual inductor, after rectifier filtering, it becomes DC, then converts through single-chip AD, and calculates the actual value. Voltage and current acquisition uses voltage mutual inductor TV1005M and current mutual inductor TA1005M, respectively.
(2) 220V municipal power produces weak AC after mutual inductor, after rectifying and filtering, it becomes DC, then converts through single-chip AD, and calculates the actual value. Voltage and current are collected using voltage mutual inductor TV1005M and current mutual inductor TA1005M, respectively.
(3) When the power exceeds 200W, the relay automatically disconnects. When the power does not exceed 200W, the switch of the relay can be controlled manually.
(4) When the APP of the mobile phone is connected with the WiFi module of the device, the timing time is displayed on the mobile phone.
3. Design schematic
(1) The schematic diagram is mainly designed by AD software, as shown in Fig.
4. Software Design
(1) Process Flow Diagram
(2) Main program source code
int main(void) { u16 adcx; float temp; delay_init(); //Delay function initialization uart_init(9600); //Serial Initialization 115200 TIM3_Int_Init(499,7199);//50ms LED_Init(); //Initialize the hardware interface to connect to the LED LED0=0; Adc_Init(); //ADC Initialization RELAY=1; //Relay on relayFlag=1; //Relay status identification delay_ms(4000); printf("AT+CIPMUX=1\r\n"); //Allow Links delay_ms(1000); printf("AT+CIPSERVER=1,8080\r\n"); //Create port number 8080 delay_ms(1000); while(1) { adcx=Get_Adc_Average(ADC_Channel_1,10);// PA1 AC Voltage Detection Port ad Conversion 10 Times Average temp=(float)adcx*(3.3/4096); ACvolt=(unsigned int)(temp*303);//*303 mutual inductor calculated and calibrated with 1K resistance using an oscilloscope if(ACvolt<15) ACvolt=0; adcx=Get_Adc_Average(ADC_Channel_2,10); // PA2 Average temp=(float)adcx*(3.3/4096); if(temp>0.02) { ACcurrent=(unsigned int)((temp-0.02)*3100);//*3950 Mutual inductor calculated enlargement 1000 times and 1K resistance calibrated with oscilloscope detection 0.02 remove fluctuations to prevent misjudgment } else { ACcurrent=0; } if(ACcurrent<50)ACcurrent=0;//Filter current PowerWt=ACvolt*ACcurrent; //power if(dealFlag==1)//Processing flags { dealFlag=0; PowerQd=(float)PowerWt*1/60.0/60.0+PowerQd; //Cumulative charge 1 means 1s because the current has increased 1000 times, so it has also increased 1000 times here and the power unit here is W divided by 1000 kilowatt results in degree 1 degree = 1 kilowatt-hour } if(times>=9999) {times=0;} if(PowerWt/1000>200) { RELAY=0; //Turn off relay relayFlag=0; } sprintf(tabData,"V:%03dA:%05dP:%07luQ:%010.2fT:%04dR:1",ACvolt,ACcurrent,PowerWt,PowerQd,times); if(relayFlag==1) {sprintf(tabData,"V:%03dA:%05dP:%07luQ:%010.2fT:%04dR:1",ACvolt,ACcurrent,PowerWt,PowerQd,times); }//print data else {sprintf(tabData,"V:%03dA:%05dP:%07luQ:%010.2fT:%04dR:0",ACvolt,ACcurrent,PowerWt,PowerQd,times); }//print data printf("AT+CIPSEND=0,42\r\n"); //at command to send fixed byte data delay_ms(200); printf(tabData); //send data delay_ms(200); LED0=!LED0; //Data Sending delay_ms(200); //delayed } }
If you need information, please pay attention to the public number "Single-chip computer instance design", the first page replies to "alcohol" to obtain information;
Bold Style