Skip to content

Commit

Permalink
Initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlambchop committed Nov 4, 2024
0 parents commit 534a402
Show file tree
Hide file tree
Showing 15 changed files with 717 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Particle Compile Action Workflow
# This workflow uses the Particle compile-action to compile Particle application firmware.
# Make sure to set the particle-platform-name for your project.
# For complete documentation, please refer to https://github.com/particle-iot/compile-action

name: Particle Compile

on:
push:
branches:
- main

jobs:
compile:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

# Particle Compile Action
- name: Compile Firmware
id: compile
uses: particle-iot/compile-action@v1
with:
# Set the particle-platform-name to the platform you're targeting.
# Allowed values: core, photon, p1, electron, argon, boron, xenon, esomx, bsom, b5som, tracker, trackerm, p2, msom
particle-platform-name: 'p2'

# Optional: Upload compiled firmware as an artifact on GitHub.
- name: Upload Firmware as Artifact
uses: actions/upload-artifact@v3
with:
name: firmware-artifact
path: |
${{ steps.compile.outputs.firmware-path }}
${{ steps.compile.outputs.target-path }}
55 changes: 55 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Key files
*.der
*.pem

# Ignore build results and bundles
*.bin
*.zip
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
target/*

# Platform-specific settings
.DS_Store
*.crc_block
*.no_crc

# VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Ignore all local history of files
**/.history

# Windows
Thumbs.db
*.stackdump
[Dd]esktop.ini

# C Prerequisites
*.d

# C Object files
*.o
*.ko
*.obj
*.elf

# C Linker output
*.map

# C Debug files
*.dSYM/
*.su
*.idb
*.pdb
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
117 changes: 117 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Environmental Monitoring Tutorial

## Introduction

Welcome to the **Environmental Monitoring Tutorial**! This blueprint demonstrates how to monitor environmental conditions by measuring temperature and humidity using a Particle device with a **Grove Temperature & Humidity Sensor**. Every 10 seconds, the sensor reads temperature and humidity values, publishing this data to the cloud. Once received, the cloud converts the temperature from Celsius to Fahrenheit and stores it in a time-series database (Ledger). Additionally, an alert is triggered if the temperature exceeds a specified threshold set within Ledger.

This project provides a practical example of IoT-based environmental monitoring, ideal for use cases in smart homes, greenhouses, and industrial monitoring.

## Hardware Requirements

For this project, you’ll need:

1. **Particle MCU Development Board** (e.g., Argon, Boron)
[Purchase here](https://store.particle.io/collections/all-products?filter.p.product_type=Development%20Boards)
2. **Grove Temperature & Humidity Sensor (DHT11)**
[Seeed Studio Sensor Details](https://wiki.seeedstudio.com/Grove-TemperatureAndHumidity_Sensor/)
3. **Particle Grove Shield**
[Particle Grove Shield Details](https://docs.particle.io/reference/datasheets/accessories/gen3-accessories/)

The Particle Grove Shield is essential for connecting the Grove sensor to the Particle board without the need for soldering.

## Table of Contents

* [Introduction](#introduction)
* [Hardware Requirements](#hardware-requirements)
* [Tutorial - Getting Started](#tutorial-getting-started)
* [Firmware Details](#firmware-details)
* [Cloud Functionality](#cloud-functionality)
* [Ledger Time-Series Database](#ledger-time-series-database)
* [Temperature Conversion and Alerts](#temperature-conversion-and-alerts)
* [Contributions](#contributions)
* [Change List](#change-list)
* [Supported Hardware](#supported-hardware)

## Tutorial - Getting Started

### 1\. Configure the Grove Shield and Sensor

Connect the **Grove Temperature & Humidity Sensor** to the Grove Shield, then attach the Grove Shield to your Particle device.

### 2\. Set Up and Flash the Firmware

Ensure your Particle device is registered and connected to your Particle account. You can do this via [setup.particle.io](https://setup.particle.io/).

Clone or download this project repository and open it in Visual Studio Code or another code editor with Particle support.

Flash the firmware to your device. You can use Visual Studio Code with the **Cloud Flash** command, or the Particle CLI with the command:

```
particle flash <device_name> environmental-monitoring
```

### 3\. Monitor the Device’s Data and Alerts

With the firmware running, the Particle device will publish temperature (in Celsius) and humidity data to the cloud every 10 seconds.

To view real-time data, open the [Particle Console](https://console.particle.io) or use the serial monitor in Visual Studio Code by running:

```
particle serial monitor --follow
```

Temperature readings exceeding the threshold (e.g., 30°C) will trigger alerts in the cloud, visible in the Console and potentially actionable through notifications.

## Firmware Details

The firmware reads temperature and humidity values from the Grove sensor every 10 seconds and publishes them to the cloud. It uses standard Particle APIs and includes basic logging for ease of troubleshooting.

* **Temperature**: Measured in Celsius from the sensor.
* **Humidity**: Measured as relative humidity (%) from the sensor.
* **Interval**: Data is collected and published every 10 seconds.

## Cloud Functionality

### Ledger Time-Series Database

The **Ledger** service is used to store the published data. Each temperature and humidity reading is saved with a timestamp, allowing for easy analysis and historical review.

* **Database**: Stores temperature and humidity readings over time.
* **Data Format**: Includes both Celsius and converted Fahrenheit temperatures, as well as humidity.

### Temperature Conversion and Alerts

When the cloud receives temperature data, it automatically converts the value from Celsius to Fahrenheit. The system also checks the current temperature against a predefined threshold (e.g., 30°C).

* **Temperature Alert**: Triggers if the temperature exceeds the threshold.
* **Threshold Setting**: Configurable in the Ledger database, allowing real-time adjustment of alert sensitivity.

## Contributions

We welcome contributions to this blueprint! If you'd like to suggest changes, please open a pull request in the [Environmental Monitoring GitHub Repository](https://github.com/particle-iot/environmental-monitoring-tutorial).

### How to Contribute

1. Fork the repository.
2. Make your changes in a new branch.
3. Open a pull request with a detailed description of your changes.

## Change List

* **v1.0.0**: Initial release, with core functionality for environmental monitoring and alert system.

## Supported Hardware

This blueprint supports all **Particle MCU Development Boards** and works specifically with the **Grove Temperature & Humidity Sensor** and **Particle Grove Shield** for seamless sensor integration.

* [Particle MCU Development Boards](https://store.particle.io/collections/all-products?filter.p.product_type=Development%20Boards)
* [Grove Temperature & Humidity Sensor (DHT11)](https://wiki.seeedstudio.com/Grove-TemperatureAndHumidity_Sensor/)
* [Particle Grove Shield](https://docs.particle.io/reference/datasheets/accessories/gen3-accessories/)

## License

This project is licensed under the MIT License. For details, see the LICENSE file in the repository.

- - -

By following this tutorial, you can easily set up an environmental monitoring system that leverages Particle's cloud capabilities and provides actionable insights through data collection and alerting. Happy monitoring!
32 changes: 32 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
application:
name: "environmental-monitoring-tutorial"
version: "1.0.2"
description: "Environmental monitoring tutorial"

firmware:
target: [ gen3 ]
assets: [ ]

cloud:
logic:
- name: "Process Environmental Data"
function: process_temperature.js
scope: product
ledger:
- name: "Configuration"
shortName: configuration
scope: org
defaults: "{ setpoint: 85.0 }"
integrations:
- name: "SMS Alerts"
type: "twilio"
template: "custom"
trigger: "alarm"
url: "api.twilio.com"
requestType: "POST"
twilio:
accountSID: 24235234234
accountUsername: mrlambchop
accountPassword: "$VAULT.TWILIO_PASSWORD"
vault:
secret: "TWILIO_PASSWORD" # Vault-managed password for secure access
19 changes: 19 additions & 0 deletions blueprint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
id: particle/environmental-monitoring
category: tutorial
icon: particle.png
gitrepo: https://github.com/particle-iot/environmental-monitoring-tutorial
name: "Environmental Monitoring Tutorial inc Cloud Storage and Alerting"
shortDescription: CREATE
version: 1.0.1
models: []
language: [ "Particle Wiring", "JavaScript" ]
cloudServices: [ "Ledger", "Logic", "Integrations", "Vault" ]
hardwareDependencies:
- name: Particle Feather based MCU Development Boards (e.g., Argon, Boron)
link: https://store.particle.io/collections/all-products?filter.p.product_type=Development%20Boards
- name: Grove Temperature & Humidity Sensor (DHT11)
link: https://wiki.seeedstudio.com/Grove-TemperatureAndHumidity_Sensor/
- name: Particle Grove Shield
link: https://docs.particle.io/reference/datasheets/accessories/gen3-accessories/
description: |
This Environmental Monitoring Tutorial demonstrates how to use the Seeed Studio Grove Temperature & Humidity Sensor with a Particle device to measure and publish temperature and humidity data to the cloud. The cloud converts Celsius readings to Fahrenheit, stores data in Ledger, and triggers alerts based on user-defined temperature thresholds.
21 changes: 21 additions & 0 deletions lib/Grove_Temperature_And_Humidity_Sensor/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 russgrue

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions lib/Grove_Temperature_And_Humidity_Sensor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Grove_Temperature_And_Humidity_Sensor
=====================================

This is an Particle library for the DHT series of low cost temperature/humidity sensors.

<img src=https://statics3.seeedstudio.com/images/101020011%201.jpg width=300>

[Grove - Temperature & Humidity Sensor (DHT11)](https://www.seeedstudio.com/Grove-Temperature-%26-Humidity-Sensor-%EF%BC%88DHT11%EF%BC%89-p-745.html)



For more information please visit [wiki DHT11](http://wiki.seeedstudio.com/Grove-TemperatureAndHumidity_Sensor/)

----

This demo is licensed under [The MIT License](http://opensource.org/licenses/mit-license.php). Check LINCESE for more information.<br>

Contributing to this software is warmly welcomed. You can do this basically by<br>
[forking](https://help.github.com/articles/fork-a-repo), committing modifications and then [pulling requests](https://help.github.com/articles/using-pull-requests) (follow the links above<br>
for operating guide). Adding change log and your contact into file header is encouraged.<br>
Thanks for your contribution.

Seeed Studio is an open hardware facilitation company based in Shenzhen, China. <br>
Benefiting from local manufacture power and convenient global logistic system, <br>
we integrate resources to serve new era of innovation. Seeed also works with <br>
global distributors and partners to push open hardware movement.<br>

[![Analytics](https://ga-beacon.appspot.com/UA-46589105-3/Grove_Temperature_And_Humidity_Sensor)](https://github.com/igrigorik/ga-beacon)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <Grove_Temperature_And_Humidity_Sensor.h>

//An example of DHT11 for PHOTON

#define DHTPIN D2 // set pin

DHT dht(DHTPIN);

void setup() {
Serial.begin(9600);
Serial.println("DHT11 Begin!!!");

dht.begin();
}

void loop() {
// Wait a few seconds between measurements.
// The sensor reads data slowly.
delay(1000);



//Read Humidity
float h = dht.getHumidity();
// Read temperature as Celsius
float t = dht.getTempCelcius();
// Read temperature as Farenheit
float f = dht.getTempFarenheit();

// Check if any reads failed
if (isnan(h) || isnan(t) || isnan(f))
{
Serial.println("Failed to read from DHT11 sensor!");
return;
}

Serial.print("Humid: ");
Serial.print(h);
Serial.println("% ");
Serial.print("Temp: ");
Serial.print(t);
Serial.println("*C ");
Serial.print("Temp: ");
Serial.print(f);
Serial.println("*F ");
Serial.println();Serial.println();
}
10 changes: 10 additions & 0 deletions lib/Grove_Temperature_And_Humidity_Sensor/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name=Grove_Temperature_And_Humidity_Sensor
version=1.0.7
author=Seeed Studio
maintainer=Seeed Studio <[email protected]>
sentence=Particle library to control Grove DHT11.
license=MIT License
includes=Seeed_DHT11.h
architectures=*
url=https://github.com/Seeed-Studio/Grove_Temperature_And_Humidity_Sensor_DHT11
repository=https://github.com/Seeed-Studio/Grove_Temperature_And_Humidity_Sensor_DHT11.git
Loading

0 comments on commit 534a402

Please sign in to comment.