import subprocess
import yagmail
import os
def capture_image_libcamera(filename="captured.jpg"):
# Capture image using libcamera-still command
subprocess.run(["libcamera-still", "-o", filename, "--nopreview"], check=True)
def send_email_with_attachment(sender, app_password, receiver, subject, message, attachment_path):
yag = yagmail.SMTP(user=sender, password=app_password)
yag.send(
to=receiver,
subject=subject,
contents=message,
attachments=attachment_path
)
print("Email sent successfully!")
def main():
image_file = "captured.jpg"
sender_email = "your_email@gmail.com"
app_password = "your_app_password"
receiver_email = "receiver@example.com"
subject = "Captured Image from Raspberry Pi"
message = "Hi, this is the captured image attached."
# Capture image
print("Capturing image...")
capture_image_libcamera(image_file)
# Send email with attachment
print("Sending email...")
send_email_with_attachment(sender_email, app_password, receiver_email, subject, message, image_file)
# Optionally remove image after sending
if os.path.exists(image_file):
os.remove(image_file)
print("Temporary image file removed.")
if __name__ == "__main__":
main()
Mr. Raj Kumar is a highly experienced Technical Content Engineer with 7 years of dedicated expertise in the intricate field of embedded systems. At Embedded Prep, Raj is at the forefront of creating and curating high-quality technical content designed to educate and empower aspiring and seasoned professionals in the embedded domain.
Throughout his career, Raj has honed a unique skill set that bridges the gap between deep technical understanding and effective communication. His work encompasses a wide range of educational materials, including in-depth tutorials, practical guides, course modules, and insightful articles focused on embedded hardware and software solutions. He possesses a strong grasp of embedded architectures, microcontrollers, real-time operating systems (RTOS), firmware development, and various communication protocols relevant to the embedded industry.
Raj is adept at collaborating closely with subject matter experts, engineers, and instructional designers to ensure the accuracy, completeness, and pedagogical effectiveness of the content. His meticulous attention to detail and commitment to clarity are instrumental in transforming complex embedded concepts into easily digestible and engaging learning experiences. At Embedded Prep, he plays a crucial role in building a robust knowledge base that helps learners master the complexities of embedded technologies.
Leave a Reply