Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Matthias Hertel
Published © CC BY

Build an Inhouse IoT Air Quality Sensor - No Cloud Required

Build a full-functional small IoT device to monitor inhouse air conditions without using cloud services.

IntermediateFull instructions provided4 hours5,071
Build an Inhouse IoT Air Quality Sensor - No Cloud Required

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
BME680 Breakout
Pimoroni BME680 Breakout
×1
PMS5003 Air Particle Sensor by Plantower
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

device and I2c configuration

JSON
"device": {
  "0": {
    "name": "airding",
    "description": "Air Quality Sensor",
    ...
    "i2c-scl": "D2",
    "i2c-sda": "D1"
  }
}

bme680 sensor configuration

JSON
"bme680": {
  "bd": {
    "address": "0x77",
    "readtime": "10s"
  }
}

PMS sensor configuration

JSON
"pms": {
  "pm25": {
    "description": "pm25 particle sensor",
    "pinrx": "D6",
    "pintx": "D5",
    "readtime": "10s"
  }
}

device / network configuration

JSON
{
  ...
  "ota": {
    "0": {
      "port": 8266,
      "passwd": "123",
      "description": "Listen for 'over the air' OTA Updates"
    }
  },
  "ssdp": {
    "0": {
      "Manufacturer": "yourname"
    }
  },
  "ntptime": {
    "0": {
      "readtime": "36h",
      "zone": 2
    }
  }
}

Log element configurations

JSON
{
  "log": {
    "pm": {
      "description": "Log of pm25",
      "filename": "/pmlog.txt",
      "filesize": "10000"
    },
    "aq": {
      "description": "Log of gas quality",
      "filename": "/aqlog.txt",
      "filesize": "10000"
    }
  }
}

Actions for passing sensor values to log elements

JSON
{
  "pms": {
    "pm25": {
      ...
      "onvalue": "log/pm?value=$v"
    }
  },
  "bme680": {
    "bd": {
      ...
      "ongas": "log/aq?value=$v"
    }
  }
}

env.json completed

JSON
{
  "device": {
    "0": {
      "name": "airding",
      "reboottime": "24h",
      "description": "Air Quality Sensor",
      "logfile": 1,
      "led": "D0",
      "button": "D4",
      "i2c-scl": "D2",
      "i2c-sda": "D1"
    }
  },
  "ota": {
    "0": {
      "port": 8266,
      "passwd": "123",
      "description": "Listen for 'over the air' OTA Updates"
    }
  },
  "ssdp": {
    "0": {
    }
  },
  "ntptime": {
    "0": {
      "readtime": "36h",
      "zone": 2
    }
  }
}

config.json completed

JSON
{
  "pms": {
    "pm25": {
      "description": "Air particle sensor",
      "pinrx": "D6",
      "pintx": "D5",
      "readtime": 300,
      "onvalue": "log/pm?value=$v"
    }
  },
  "bme680": {
    "bd": {
      "description": "Environmental sensor",
      "readtime": "300",
      "onpressure": "log/p?value=$v",
      "ongas": "log/aq?value=$v"
    }
  },
  "log": {
    "pm": {
      "description": "Log of pm25",
      "filename": "/pmlog.txt",
      "filesize": "10000"
    },
    "aq": {
      "description": "Log of gas quality",
      "filename": "/aqlog.txt",
      "filesize": "10000"
    },
    "p": {
      "description": "Log of pressure",
      "filename": "/plog.txt",
      "filesize": "10000"
    }
  }
}

HomeDing Library Repository

Credits

Matthias Hertel
2 projects • 5 followers
www.mathertel.de

Comments