I need to make a laser security system
When beam broken alarm triggers, camera takes picture and send it to sd module and sd sends it to gsm
Finally gsm sends it to specified phone number.
Here are the connections
OV7670 to Arduino uno
SDA to A4
SCL to A5
VCC to 3.3V
GND to GND
VSYNC to D7
PWR to D8
HS to D9
RESET to D5
SIM800L to Arduino uno
VCC to Powerbank
GND to GND
TX to D3
RX to D2
PWRKEY to D4
SD Module to Arduino uno
VCC to 5V
GND to GND
MISO to MISO
MOSI to MOSI
SCK to SCK
CS to D10
LDR Sensor Module to Arduino uno
VCC to 3.3V
GND to GND
DO to D2
Buzzer to Arduino uno
+ve to D1
-ve to GND
Laser Light Modue to Arduino uno
+ve to 5V
-ve to GND
Are these connections correct? @Grumpy_Mike
Please draw a schematic of your project and post it here. A 'photo of a clear hand drawn circuit is good enough
Like @UKHeliBob said you need to convert that word salad into a diagram, that is the only way that you can check what is actually there and what if anything is missing.
You might want to look at this How to get the best out of this forum before you proceed any further.
Also you are trying to get too much working at once. Take it one step at a time, adding features as you go.
Okay just give me 5 minutes for that
Also can you please review the code I'm using (I'm new to this, very new and I'm facing issues that i unfortunately cannot handle)
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SoftwareSerial.h>
#include <ArduCAM.h>
#define OV7670_VSYNC 7
#define OV7670_PWR 8
#define OV7670_HS 9
#define OV7670_RESET 5
#define LASER_DO 2
#define BUZZER_PIN 1
#define GSM_TX 3
#define GSM_RX 2
#define GSM_PWRKEY 4
#define SD_CS 10
SoftwareSerial gsmSerial(GSM_TX, GSM_RX);
ArduCAM myCAM(OV7670, CS_PIN);
void setup() {
Serial.begin(9600);
pinMode(OV7670_VSYNC, INPUT);
pinMode(OV7670_PWR, OUTPUT);
pinMode(OV7670_HS, INPUT);
pinMode(OV7670_RESET, OUTPUT);
pinMode(GSM_PWRKEY, OUTPUT);
if (!SD.begin(SD_CS)) {
Serial.println("SD card initialization failed!");
return;
}
pinMode(LASER_DO, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
gsmSerial.begin(9600);
myCAM.begin();
myCAM.OV7670_init();
}
void loop() {
if (digitalRead(LASER_DO) == LOW) {
triggerAlarm();
captureImage();
sendImageViaGSM();
}
}
void triggerAlarm() {
digitalWrite(BUZZER_PIN, HIGH);
delay(1000);
digitalWrite(BUZZER_PIN, LOW);
}
void captureImage() {
myCAM.set_mode(MODE_VGA);
myCAM.OV7670_set_JPEG_size(OV7670_320x240);
myCAM.capture("image.jpg");
}
void sendImageViaGSM() {
File imageFile = SD.open("image.jpg", FILE_READ);
if (imageFile) {
gsmSerial.println("AT+CMGF=1");
gsmSerial.println("AT+CMGS="+123456789""); // Replace with recipient's phone number
delay(100);
while (imageFile.available()) {
gsmSerial.write(imageFile.read());
}
imageFile.close();
gsmSerial.println((char)26); // End of message character
delay(5000);
} else {
Serial.println("Error opening image file");
}
}
I have only wrote the connections and connected the OV7670 yet because i faced issues when i did it all at once and i want to confirm things before i proceed. Though I'll send the diagram i just need five minutes. Can you please please review my code
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SoftwareSerial.h>
#include <ArduCAM.h>
#define OV7670_VSYNC 7
#define OV7670_PWR 8
#define OV7670_HS 9
#define OV7670_RESET 5
#define LASER_DO 2
#define BUZZER_PIN 1
#define GSM_TX 3
#define GSM_RX 2
#define GSM_PWRKEY 4
#define SD_CS 10
SoftwareSerial gsmSerial(GSM_TX, GSM_RX);
ArduCAM myCAM(OV7670, CS_PIN);
void setup() {
Serial.begin(9600);
pinMode(OV7670_VSYNC, INPUT);
pinMode(OV7670_PWR, OUTPUT);
pinMode(OV7670_HS, INPUT);
pinMode(OV7670_RESET, OUTPUT);
pinMode(GSM_PWRKEY, OUTPUT);
if (!SD.begin(SD_CS)) {
Serial.println("SD card initialization failed!");
return;
}
pinMode(LASER_DO, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
gsmSerial.begin(9600);
myCAM.begin();
myCAM.OV7670_init();
}
void loop() {
if (digitalRead(LASER_DO) == LOW) {
triggerAlarm();
captureImage();
sendImageViaGSM();
}
}
void triggerAlarm() {
digitalWrite(BUZZER_PIN, HIGH);
delay(1000);
digitalWrite(BUZZER_PIN, LOW);
}
void captureImage() {
myCAM.set_mode(MODE_VGA);
myCAM.OV7670_set_JPEG_size(OV7670_320x240);
myCAM.capture("image.jpg");
}
void sendImageViaGSM() {
File imageFile = SD.open("image.jpg", FILE_READ);
if (imageFile) {
gsmSerial.println("AT+CMGF=1");
gsmSerial.println("AT+CMGS=\"+123456789\""); // Replace with recipient's phone number
delay(100);
while (imageFile.available()) {
gsmSerial.write(imageFile.read());
}
imageFile.close();
gsmSerial.println((char)26); // End of message character
delay(5000);
} else {
Serial.println("Error opening image file");
}
}
This is what i got after using the code tag
Thank you. I hope that you see how much easier to examine and copy the code it is when it is posted in code tags
Yes thank you for explaining it to me. Kindly review it as i am really really worried about this project
If whatever blocks the laser on your system stays in that place, your sketch will keep sending photos until the laser becomes unblocked again. Is this intentional? If not, you'll need to revise this bit and send only one image when the laser becomes blocked for a minute.
Conversely, how long does the laser have to be blocked for it to register as a valid interruption? E.g. what if it is blocked for a tiny instant or appears to be due to a minor power dip. Is it OK your sketch still sends a photo? Or should it ignore such spurious events?
Is it also intentional that while the alarm sounds, the system is blocked and only then it starts making a picture? A second doesn't sound like much, but someone/something could quickly turn around/duck/etc and stay out of view or become unrecognizable.
This is just based on a quick glance; your hardware setup may give rise to more questions/issues.
I need this project just for like 10-12 times, no more than that. The one's who will review and mark my project just wants to see it's working. The questions you raised, they won't bring it up as it's just for temporarily use. Though thank you for letting me know, I'll definitely do something about it to make it more reliable. Also is the program error free? As my partner is supposed to run and test it tomorrow. Also I'm making the diagram for my circuit I'll just post it here. Thank you for replying
No guarantees. You'll have to test it. I wouldn't rely on proof-reading it and then handing it to your partner, untested, in the expectation it'll work. Murphy is pretty much invincible, indestructible and very much alive.
Okay I'll test it and show if i encounter any errors. Thank you again!
Sounds good; looks like you're preparing this carefully so I'm confident you'll succeed. Good luck!
Thank you sir, means alot.
This is the error I'm facing "class ArduCAM has no member capture and OV7670_init (it did not work with begin as well) I'm using library ArduCAM version 1.0.0
My code:
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SoftwareSerial.h>
#include <ArduCAM.h>
#define OV7670_VSYNC 7
#define OV7670_PWR 8
#define OV7670_HS 9
#define OV7670_RESET 5
#define LASER_DO 2
#define BUZZER_PIN 1
#define GSM_TX 3
#define GSM_RX 2
#define GSM_PWRKEY 4
#define SD_CS 10
#define CS_PIN 10
SoftwareSerial gsmSerial(GSM_TX, GSM_RX);
ArduCAM myCAM(OV7670, CS_PIN);
void setup() {
Serial.begin(9600);
pinMode(OV7670_VSYNC, INPUT);
pinMode(OV7670_PWR, OUTPUT);
pinMode(OV7670_HS, INPUT);
pinMode(OV7670_RESET, OUTPUT);
pinMode(GSM_PWRKEY, OUTPUT);
if (!SD.begin(SD_CS)) {
Serial.println("SD card initialization failed!");
return;
}
pinMode(LASER_DO, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
gsmSerial.begin(9600);
myCAM.OV7670_init();
}
void loop() {
if (digitalRead(LASER_DO) == LOW) {
triggerAlarm();
captureImage();
sendImageViaGSM();
}
}
void triggerAlarm() {
digitalWrite(BUZZER_PIN, HIGH);
delay(1000);
digitalWrite(BUZZER_PIN, LOW);
}
void captureImage() {
myCAM.set_mode(MODE_VGA);
myCAM.OV7670_set_JPEG_size(OV7670_320x240);
myCAM.capture("image.jpg");
}
void sendImageViaGSM() {
File imageFile = SD.open("image.jpg", FILE_READ);
if (imageFile) {
gsmSerial.println("AT+CMGF=1");
gsmSerial.println("AT+CMGS=\"+123456789\""); // Replace with recipient's phone number
delay(100);
while (imageFile.available()) {
gsmSerial.write(imageFile.read());
}
imageFile.close();
gsmSerial.println((char)26); // End of message character
delay(5000);
} else {
Serial.println("Error opening image file");
}
}
It's more convenient if you paste (all of) the errors here instead of uploading a photo of a monitor.
Concerning the 'capture' error, if I look at the GitHub repository for this library (Arduino/ArduCAM/ArduCAM.h at master · ArduCAM/Arduino · GitHub), there is only a "sart_capture" function, but it doesn't accept any arguments.
I'd have a look at the examples; pick one for the type of board you use and see if you can get that to work: Arduino/ArduCAM/examples at master · ArduCAM/Arduino · GitHub
On what example did you base this line of core, or did you guess at it? Maybe it was an overly optimistic guess...
Okay I'll check the repository and let you know. It was rather a stupid guess than optimistic i guess.. anyways thank you!
Please note, that you can't connect anything to pins 0 & 1 if you use a Serial in your code.
You also use the pin 2 both for GSM and for LASER:
and pin 10 both as SD_CS and as CS for ArduCAM module:
As a rule, you can't use the same pin for two connections.
If i use serial in my code, can i connect TX and RX pins of SIM800L to D0 and D1? (TX and RX pins of Arduino uno)