---
title: Send Email from the Propeller 2 Using the IoT Gateway on Raspberry Pi
description: "![](/qbi/Send Email From The Propeller 2 Using The IoT Gateway On Raspberry Pi - Parallax_files/Email-Send-Banner.jpg) > **Note:** This Quick Byte is an application of the IoT Gateway’s email feature using a CM2302 Temperature and Humidity Sensor. A [Propeller 2 Live…"
url: "https://obex.parallax.com/docs/quick-bytes/propeller-2/send-email-from-the-propeller-2-using-the-iot-gateway-on-raspberry-pi/"
updated: "2026-09-29"
category: Propeller 2
---

# Send Email from the Propeller 2 Using the IoT Gateway on Raspberry Pi

![](/qbi/Send Email From The Propeller 2 Using The IoT Gateway On Raspberry Pi - Parallax_files/Email-Send-Banner.jpg)

> **Note:** This Quick Byte is an application of the IoT Gateway’s email feature using a CM2302 Temperature and Humidity Sensor. A [Propeller 2 Live Forum on YouTube](https://www.youtube.com/watch?v=Lli32Zkeo2o) provides a detailed presentation of the entire IoT Gateway (as of February 2022). The complete, detailed, setup process of the full P2 IoT Gateway on a Raspberry Pi (email, web control, etc) is documented on the [IronSheep P2 IoT Gateway GitHub](https://github.com/ironsheep/P2-RPi-IoT-gateway). Use this Quick Byte in conjunction with those two resources for a fully informed, successful setup! 

[Propeller 2 - Raspberry Pi IOT Gateway: E-mail Send Demo](https://www.youtube.com/embed/Vnn5ezleq54?feature=oembed)

##### Description

The Propeller 2 IoT (Internet of Things) Gateway lets the P2 securely send an email through the Raspberry Pi (RPi) to one or more recipients. This Quick Byte demonstrates the email feature by using a [CM2302 Temperature and Humidity Sensor](https://www.parallax.com/product/cm2302-digital-temperature-humidity-sensor/).  As a P2 beginner and first-time Raspberry Pi user, the new skills I acquired were basic Linux commands to navigate directory structures and using Nano to edit files.     

The Spin2 source code for this project is available below and can be easily adapted for other uses. Applications with the P2 could include monitoring of many analog inputs or sensors in remote locations.

Benefits of the P2 RPi IoT Gateway for email:

- Easy setup on Raspberry Pi consists of configuring Python scripts from GitHub
- Uses external SendGrid account with API key; no password or login credentials stored on the P2 or RPi
- Compatible with the low-cost Pi Zero for production projects using the P2 Edge 
- Hardware connection is serial I/O between the P2 and RPi
- Lightweight Spin2 driver communicates with the scripts on Raspberry Pi; configure the top-level object with your email addresses and content
- Spin2 driver supports the use of formatted strings for sending numerical values
- RPi configuration and P2 programming can also be done remotely using SSH/VNC access to Raspberry Pi with Eric Smith’s FlexProp installed for P2 programming

The setup process for this project can be done in the following sequence:

- Raspberry Pi configuration. Loading Python scripts and running the IoT Gateway Create a SendGrid account and configure an API key. The code and documentation for this are found on [IronSheep P2 IoT Gateway GitHub](https://github.com/ironsheep/P2-RPi-IoT-gateway)
- Propeller 2 circuit building and connection to RPi
  - P2 P0 to RPi P25 (serial Rx to Pi)
  - P2 P1 to RPi P24 (serial Tx to Pi)
  - P2 P8 to CM2302 Temperature and Humidity Sensor (also connect the sensor to Vdd and Vss)
  - [Test the CM2302 as a subsystem using this Quick Byte](https://www.parallax.com/dht11-dht22-cm2302-object/)
- Load the example code and send an e-mail (following is using Propeller Tool; FlexProp is similar) 
  - Insert your own e-mail addresses in the Spin2 code
  - Press F11 to compile and flash
  - Press F12 to open Parallax Serial Terminal. Within Parallax Serial Terminal, press a key in the transmit pane to refresh the display and send the email

Connection between P2 Edge, CM2302 Temperature and Humidity Sensor, and Raspberry Pi:

![](/qbi/Send Email From The Propeller 2 Using The IoT Gateway On Raspberry Pi - Parallax_files/IoT-Gateway-Email-1.jpg)

Insert your email addresses in the highlighted lines in the sample code DAT section:

```spin2
DAT { our email and hardware ID strings }

p2HardwareID    byte    "P2 Edge - GWDemo1",0

emailTo         byte    "kgracey@parallax.com",0
emailFrom       byte    "kgracey@parallax.com",0
emailSubj       byte    "Message from the Propeller 2",0
emailBody       byte    0[1024]
                       ' 1K bytes to format the email text
```

E-mail sample:

![](/qbi/Send Email From The Propeller 2 Using The IoT Gateway On Raspberry Pi - Parallax_files/email.jpg)

##### Parts Used

- [P2 Edge Module](https://www.parallax.com/product/p2-edge-module/)
- [P2 Edge Breadboard](https://www.parallax.com/product/p2-edge-module-breadboard/)
- [CM2302 Temperature and Humidity Sensor](https://www.parallax.com/product/cm2302-digital-temperature-humidity-sensor/)

##### Source Code

- [CM2302 E-mail Send Demo Using P2 RPi IoT Gateway (Spin2 archive)](/qbi/downloads/CM2302-E-mail-Using-P2-IoT-Gateway-202200523.zip)

##### Programming Language

- [Spin 2](https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/)
- [PASM2](https://docs.google.com/spreadsheets/d/1_vJk-Ad569UMwgXTKTdfJkHYHpc1rZwxB-DcIiAZNdk/)

##### Tools and Operating System

- [Propeller Tool for Windows](https://www.parallax.com/package/propeller-tool-software-for-windows-spin-assembly-2/)
- [FlexProp for Windows, Mac and Linux](https://www.patreon.com/totalspectrum)

##### Additional Resources

- [Propeller 2 Spin Documentation](https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit)
- [Propeller 2 Live Forum Video: IoT Gateway for the P2 with Raspberry Pi](https://youtu.be/Lli32Zkeo2o)

##### Document Author

- Ken Gracey

##### Source Code Author

- Stephen Moraco
- Ken Gracey
- Jon McPhalen
