Arduino Pro Mini + current sensor GY-712 monitor the burnout of lamps
Hello. I want to share one of the projects created on the basis of Arduino. For me, working with current sensors GY-712 was the first time. Before creating this project, a test block was created.
If you are already interested, then continue. Here I will talk about one module, since it’s not very easy to describe and sketch 7 modules. ')
It was those task: 1) Lamps (lanterns) 50-65VT 220V recess or 24V constant; 2) Indication of the lamp (LED on the panel); 3) Sound indication of a burnt out lamp.
The decision was made as follows: We use current sensor GY-712 5A
For reasons: 1) Measures AC and DC; 2) Easy to connect to the controller; 3) Compact; 4) Inexpensive when ordering from China.
Let's look at the scheme:
How the program works.
At start-up, it is checked whether the toggle switch is on, if you turn on a sound signal and a light indication, so that the sensor can be calibrated without load. If the toggle switch is turned off, the prog will give a sound + indication. Next comes the calibration. After calibration - beep.
And the main program starts. Control of the toggle switch, if the control of the lamp load current is on, if the current is above a predetermined threshold, then turn on the indication. If there is no current, then turn off the display and give a sound signal.
Here is a simple diagram without a toggle switch control, just a light indication. This is in case someone just needs a load indicator light - but then you can simply wind the ferrite ring around the wire (make a current transformer) and connect the LED.
Photo tests:
Video test:
A sample program for one module.IDE 1.5.2
float srab = 0.650;
const int currentPin1 = 0; // Analog input from current sensor
const unsigned long sampleTime = 100000UL; // sample over 100ms and 50Hz and 60Hz mains const unsigned long numSamples = 250UL; // choose to keep up const unsigned long sampleInterval = sampleTime / numSamples; // the sampling interval must be longer than ADC conversion time // const int adc_zero = 512; // relative digital zero of the arudino input from ACS712 (could make it a variable and auto-adjust it) int adc_zero1; // Auto Calibration Variable
while (digitalRead (2) == 0) {// If the toggle switch is on, then output a sound and light signal until it is turned off for calibration tone (12,2000,500); digitalWrite (13, HIGH); delay (500); digitalWrite (13, LOW); delay (500); }
tone (12,1500,100); // Sound Start Calibration delay (180); tone (12,1500,100); delay (180); tone (12,1500,100);
//Serial.begin(9600); adc_zero1 = determineVQ (currentPin1); // Quiscent output voltage - ACS712 shows with no load (0 A) digitalWrite (13, HIGH); tone (12,1000,100);
if (digitalRead (2) == 0) {// If the switch is on, then: if (readCurrent (currentPin1, adc_zero1)> srab) // If the current is greater than the specified trigger threshold then: { digitalWrite (13, HIGH); // Enable indicator
} else // Else { if (digitalRead (2) == 0) {// If the toggle switch is still on then: digitalWrite (13, LOW); // Redeem Indicator tone (12,2000,500); } // and beep }
int determineVQ (int PIN) { //Serial.print (ideestimating avg. Quiscent voltage: "); long VQ = 0; // read 5000 samples to stabilize value for (int i = 0; i <5000; i ++) { VQ + = analogRead (PIN); delay (1); // depends on sampling (on filter capacitor), can be 1/80000 (80kHz) max. } Vq / = 5000; //Serial.print(map (VQ, 0, 1023, 0, 5000)); Serial.println ("mV"); return int (VQ); }