Skip to content

Commit

Permalink
Merge branch 'main' of github.com:CivicTechTO/proj-noisemeter-device …
Browse files Browse the repository at this point in the history
…into platformio-only
  • Loading branch information
tcsullivan committed Oct 29, 2024
2 parents 5c72e52 + 0307c10 commit 53e243b
Show file tree
Hide file tree
Showing 31 changed files with 19,232 additions and 224 deletions.
15 changes: 15 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: tRacket
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
52 changes: 0 additions & 52 deletions .github/workflows/dummy_priv_key.pem

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ jobs:
- name: Create header files
run: |
cp "${GITHUB_WORKSPACE}/.github/workflows/dummy_priv_key.pem" "${GITHUB_WORKSPACE}/priv_key.pem"
cp "${GITHUB_WORKSPACE}/noisemeter-device/config.h.example" "${GITHUB_WORKSPACE}/noisemeter-device/config.h"
python "${GITHUB_WORKSPACE}/noisemeter-device/certs.py" -s api.tracket.info > "${GITHUB_WORKSPACE}/noisemeter-device/certs.h"
- name: Build PlatformIO Project (esp32-pcb)
run: pio run -e esp32-pcb

- name: Build PlatformIO Project (esp32-breadboard)
run: pio run -e esp32-breadboard

42 changes: 42 additions & 0 deletions .github/workflows/ota-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: OTA Release

on:
release:
types: [published]

jobs:
generate:
name: Create release-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/[email protected]
with:
python-version: '3.9'
- name: Install Python packages
run: |
pip install --upgrade platformio
pip install --upgrade cryptography
- name: Create files
env:
OTA_KEY: ${{ secrets.OTA_SIGNING_KEY }}
run: |
echo "$OTA_KEY" > "${GITHUB_WORKSPACE}/priv_key.pem"
cp "${GITHUB_WORKSPACE}/noisemeter-device/config.h.example" "${GITHUB_WORKSPACE}/noisemeter-device/config.h"
python "${GITHUB_WORKSPACE}/noisemeter-device/certs.py" -s api.tracket.info > "${GITHUB_WORKSPACE}/noisemeter-device/certs.h"
- name: Build signed firmware
run: pio run -t ota -e esp32-pcb

- name: Upload signed firmware
uses: djn24/add-asset-to-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: 'firmware_signed.bin'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.pio
.vscode
doc
noisemeter-device/config.h
noisemeter-device/secret.h
Expand Down
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
# Project Noisemeter Device
# tRacket: Community-Driven Urban Noise Monitoring

[Civic Tech TO](https://civictech.ca/)
This repository contains all source code and hardware design files for the [tRacket](https://tracket.info/) noise sensor.

## Overview

This repo contains all source code and design files for the Project Noisemeter Data-Gathering Devices, which are being developed by a group of volunteers at Civic Tech Toronto. The purpose of the device is to gather data about urban noise levels and upload that data to the cloud, whereupon the data can be made available to citizens, activists and lawmakers to help inform public policy around noise bylaws.
Environmental noise, especially in urban settings, is a [known public health concern](https://www.toronto.ca/wp-content/uploads/2017/11/8f98-tph-How-Loud-is-Too-Loud-Health-Impacts-Environmental-Noise.pdf):

The first-generation device is based around an arduino microcontroller and a MEMS microphone module, which sends audio data over I2S protocol. The device is to be hosted by volunteers at their home or place of work, where it will stay, long-term, to gather noise data and upload it. Currently, the device requires USB power and a WiFi connection in order to operate. Future devices may differ in both respects.
> The growing body of evidence indicates that exposure to excessive environmental
noise does not only impact quality of life and cause hearing loss but also has other health impacts, such as cardiovascular effects, cognitive impacts, sleep disturbance and mental health effects.

We will try to maintain up-to-date documentation within each hardware/version folder so that volunteers can more easily help out with the project.
The tRacket noise sensor continuous monitors ambient sound levels (in [decibels](https://en.wikipedia.org/wiki/Decibel), dBA) and sends these measurements to an [online dashboard](https://dashboard.tracket.info/locations) ([also on GitHub](https://github.com/CivicTechTO/tRacket-dashboard)). Our goal is to help local communities better understand the sound levels and extreme noise events that they experience day to day.

The project has been started and is maintained by volunteers from the [CivicTech Toronto](http://www.civictech.ca) community.

## Privacy

We followed Privacy by Design principles in setting up the data collection.

1. The sound meter devices are deployed on private properties in residential areas at different locations in the city. We are **not publishing exact device locations**.
2. The devices **do not record sound** only sound levels in A-weighted decibel levels (dBA)(https://en.wikipedia.org/wiki/Decibel).
3. We calculate minimum and maximum sound levels at 5 minute intervals on the device and **only broadcast these aggregate values** (along wiht the device ID) to a database.

## Source Code

The [noisemeter-device](/noisemeter-device) folder contains the device's source code. The code can be built with the Arduino IDE or PlatformIO, and supports two ESP32 targets: a "breadboard" target for the early prototype, and a "pcb" target for the official circuit boards. See the source code's [BUILD.md](/noisemeter-device/BUILD.md) file for build instructions. The source code is released under the [GNU GPL v3 license](/noisemeter-device/LICENSE).
The [noisemeter-device](/noisemeter-device) folder contains the device's source code, which is written in C++ and can be built using [PlatformIO](https://platformio.org/). Build instructions are available [in the online documentation](https://civictechto.github.io/tRacket-sensor/md_noisemeter_device_BUILD.html).

The source code is released under the [GNU GPL v3 license](/noisemeter-device/LICENSE).

## Hardware Files

The [hardware](/hardware) folder contains design files and documentation for each iteration of the noisemeter hardware. The PCBs are made using [KiCAD](https://www.kicad.org/) and are released under an [open hardware license](/hardware/pcb-rev2/LICENSE).
The [hardware](/hardware) folder contains design files and documentation for each iteration of the noisemeter hardware. The PCBs are designed using [KiCAD](https://www.kicad.org/).

The hardware design files are released under an [open hardware license](/hardware/pcb-rev2/LICENSE).

## Current Points of Contact for the project:
## For Developers

(May be subject to change)
* Check out the [Issues page](https://github.com/CivicTechTO/proj-noisemeter-device/issues) to see current bugs and feature requests. Any contributions are welcome!
* Online documentation of the firmware [is available here](https://civictechto.github.io/tRacket-sensor/).

- Gabe Sawnhey (Project Lead)
- Nick Barnard (Arduino)
- Clyne Sullivan (Arduino)
- Mitch Bechtel (API & Cloud DB)
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Security Policy

## Reporting a Vulnerability

Security vulnerabilities should be reported by emailing `[email protected]`.
13 changes: 13 additions & 0 deletions bringup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# Run this script with a newly manufactured tRacket board connected to give it
# a unique storage encryption key and flash the latest firmware.
# The "tail" command will show the board's UUID; this needs to be added to the
# server for device registration.

dd if=/dev/urandom of=hmac_key bs=1 count=32
echo "BURN" | pio pkg exec -- espefuse.py --port /dev/ttyACM0 burn_key BLOCK4 hmac_key HMAC_UP
rm hmac_key
pio run -t upload
tail -F /dev/ttyACM0

19 changes: 8 additions & 11 deletions build_hooks.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
Import("env")

env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.bin",
env.VerboseAction(
env.AddCustomTarget(
name="ota",
dependencies="$BUILD_DIR/${PROGNAME}.bin",
actions=[
"openssl dgst -sha256 -sign priv_key.pem -keyform PEM -out $BUILD_DIR/${PROGNAME}.sig -binary $BUILD_DIR/${PROGNAME}.bin",
"Creating OTA signature...")
)

env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.bin",
env.VerboseAction(
"cat $BUILD_DIR/${PROGNAME}.sig $BUILD_DIR/${PROGNAME}.bin > ${PROGNAME}_signed.bin",
"Creating ${PROGNAME}_signed.bin")
"cat $BUILD_DIR/${PROGNAME}.sig $BUILD_DIR/${PROGNAME}.bin > ${PROGNAME}_signed.bin"
],
title="OTA Signing",
description="Create a signed OTA update"
)

Loading

0 comments on commit 53e243b

Please sign in to comment.