Pi Zero SMS gateway case

Pi Zero SMS gateway case

thingiverse

Setting Up a Raspberry Pi SMS to Email Gateway Part 2 Last week we introduced our Raspberry Pi SMS to email gateway project, and showed you how to set up the hardware. In this part of the tutorial, we'll show you how to write the Python code that makes it all work. The code is based on the amazing work done by @markysharks, who created a fantastic module for sending emails using a Raspberry Pi. We're going to build upon his work and add some extra features to make our gateway even more useful. First things first, let's get started with the code. You can find it below or download it from GitHub. import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText # Define your email account details EMAIL_ACCOUNT = "your_email_account" PASSWORD = "your_password" SENDER_EMAIL = "sender_email" RECIPIENT_EMAIL = "recipient_email" def send_email(subject, body): msg = MIMEMultipart() msg['From'] = SENDER_EMAIL msg['To'] = RECIPIENT_EMAIL msg['Subject'] = subject msg.attach(MIMEText(body, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(EMAIL_ACCOUNT, PASSWORD) text = msg.as_string() server.sendmail(SENDER_EMAIL, RECIPIENT_EMAIL, text) server.quit() def main(): # Get the message from the serial console message = read_from_serial() # Parse the message to get the recipient's email address recipient_email = parse_message(message) # Send an email with the message send_email("Raspberry Pi SMS Gateway", "Message received: " + message) def read_from_serial(): # This function reads a message from the serial console. # You'll need to replace this with your own code that talks to your serial device. return "Test message" def parse_message(message): # This function takes a message and returns the recipient's email address. # For now, we're just going to assume it's hardcoded in the script. return "recipient_email@example.com" if __name__ == "__main__": main() # End of code That's it for this tutorial! You should now have a working Raspberry Pi SMS gateway that sends emails when you receive an SMS. In the next part, we'll show you how to use this code with your own serial device and get real-world results. Here are some links to get you started: * The GitHub repository for this project: https://github.com/andypi/raspberry-pi-sms-email-gateway * The Raspberry Pi website: http://www.raspberrypi.org/ * A great tutorial on using a Raspberry Pi with an Arduino board: http://tutorials.jumpstartlab.com/en/routes/arduino-rpi.html Let us know in the comments if you have any questions or need help setting up your own gateway.

Download Model from thingiverse

With this file you will be able to print Pi Zero SMS gateway case with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Pi Zero SMS gateway case.