Home

Awesome

Panasonic-SN-GCJA5

Introduction

Python driver for Panasonic SN-GCJA5 particulate matter (PM) sensor. Tested on Raspberry Pi Zero/Zero W/3B+/4B<br>

Wiring

Panasonic SN-GCJA5 uses JST SM05B-GHS-TB(LF)(SN) connector and requires 3.3V and 5V for direct wiring. Fortunately, Raspberry Pi GPIOs are 3.3V by default and also supports dual power supply voltages, 3.3V and 5V. Please refer to sensor specification sheet and table below for wiring guide.

Sensor Connector PinSymbolRecommended VoltageDescriptionRPi Physical PinRPi I/O
Pin 1TX3.3VUART TX (unused if using I2C protocol)not connected
Pin 2SDA3.3VI2C DataPin 3GPIO2 (I2C1 SDA)
Pin 3SCL3.3VI2C ClockPin 5GPIO3 (I2C1 SCL)
Pin 4GND0VGroundPin 6Ground
Pin 5VDD5VPower supplyPin 45v Power

More details about Raspberry Pi pinout
https://pinout.xyz/

Examples

from time import sleep
from sngcja5 import SNGCJA5


# If SDA and SCL are connected to I2C bus 1, then i2c_bus_no = 1
pm_sensor = SNGCJA5(i2c_bus_no=1)

while True:

    # The get_measurement method returns a dictionary of all measurement value 
    result = pm_sensor.get_measurement()

    print(result)
    '''
    Structure of result
    {
        "sensor_data": {
            "mass_density": {
                "pm1.0": <float>,
                "pm2.5": <float>,
                "pm10": <float>
            },
            "particle_count": {
                "pm0.5": <float>, 
                "pm1.0": <float>, 
                "pm2.5": <float>,
                "pm5.0": <float>, 
                "pm7.5": <float>, 
                "pm10": <float>
            },
            "mass_density_unit": "ug/m3",
            "particle_count_unit": "none" 
        },
        "timestamp": <int> # seconds since the Unix epoch
    }
    '''
    sleep(5)

Dependencies and Installation Instructions

smbus

pip install smbus

Limitation

Currently, this driver only supports I2C protocol