-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5faf8bb
Showing
17 changed files
with
745 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Language: Cpp | ||
BasedOnStyle: LLVM | ||
|
||
AccessModifierOffset: -2 | ||
AllowShortIfStatementsOnASingleLine: false | ||
ColumnLimit: 0 | ||
ContinuationIndentWidth: 2 | ||
FixNamespaceComments: false | ||
IndentAccessModifiers: true | ||
IndentCaseLabels: true | ||
IndentWidth: 2 | ||
NamespaceIndentation: All | ||
PointerAlignment: Left | ||
ReferenceAlignment: Left | ||
TabWidth: 2 | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# These are supported funding model platforms | ||
|
||
github: mathieucarbou | ||
# patreon: # Replace with a single Patreon username | ||
# open_collective: # Replace with a single Open Collective username | ||
# 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 | ||
# otechie: # Replace with a single Otechie username | ||
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
custom: https://paypal.me/mathieucarboufr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "gitsubmodule" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
reviewers: | ||
- "mathieucarbou" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
reviewers: | ||
- "mathieucarbou" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
|
||
name: Continuous Integration | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
cpplint: | ||
name: cpplint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache | ||
uses: actions/cache@v4 | ||
with: | ||
key: ${{ runner.os }}-cpplint | ||
path: ~/.cache/pip | ||
|
||
- name: Pyhton | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: cpplint | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade cpplint | ||
cpplint \ | ||
--repository=. \ | ||
--recursive \ | ||
--filter=-whitespace/line_length,-whitespace/braces,-whitespace/comments,-runtime/indentation_namespace,-whitespace/indent,-readability/braces,-whitespace/newline,-readability/todo,-build/c++11 \ | ||
src | ||
arduino: | ||
name: Arduino | ||
needs: cpplint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- core: esp32:esp32 | ||
board: esp32:esp32:esp32 | ||
eeprom: true | ||
softwareserial: false | ||
index_url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install arduino-cli | ||
run: curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh | ||
|
||
- name: Update core index | ||
run: arduino-cli core update-index --additional-urls "${{ matrix.index_url }}" | ||
|
||
- name: Install core | ||
run: arduino-cli core install --additional-urls "${{ matrix.index_url }}" ${{ matrix.core }} | ||
|
||
- name: Install ArduinoJson | ||
run: arduino-cli lib install ArduinoJson@7.0.2 | ||
|
||
- name: Install MycilaLogger | ||
run: arduino-cli lib install MycilaLogger@2.0.0 | ||
|
||
- name: Build JSYRead | ||
run: arduino-cli compile --library . --warnings all -b ${{ matrix.board }} "examples/JSYRead/JSYRead.ino" | ||
|
||
- name: Build JSYReadAsync | ||
run: arduino-cli compile --library . --warnings all -b ${{ matrix.board }} "examples/JSYReadAsync/JSYReadAsync.ino" | ||
|
||
platformio: | ||
name: PlatformIO | ||
needs: cpplint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- platform: espressif32 | ||
board: esp32dev | ||
eeprom: true | ||
softwareserial: false | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.platformio | ||
~/.cache/pip | ||
key: ${{ runner.os }}-platformio | ||
|
||
- name: Set up Python 3.x | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install PlatformIO | ||
run: pip install platformio | ||
|
||
- name: Install platform "${{ matrix.platform }}" | ||
run: platformio platform install ${{ matrix.platform }} | ||
|
||
- name: Build JSYRead | ||
run: platformio ci "examples/JSYRead/JSYRead.ino" -l '.' -b ${{ matrix.board }} | ||
|
||
- name: Build JSYReadAsync | ||
run: platformio ci "examples/JSYReadAsync/JSYReadAsync.ino" -l '.' -b ${{ matrix.board }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: PlatformIO Dependabot | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# Runs every day at 01:00 | ||
- cron: "0 1 * * *" | ||
|
||
jobs: | ||
dependabot: | ||
runs-on: ubuntu-latest | ||
name: PlatformIO Dependabot | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: run PlatformIO Dependabot | ||
uses: peterus/platformio_dependabot@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
.lh | ||
/.pio | ||
/.vscode/* | ||
!/.vscode/settings.json | ||
/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 2, TabWidth: 2, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 0, AccessModifierOffset: -2, NamespaceIndentation: All, FixNamespaceComments: false, IndentAccessModifiers: true, PointerAlignment: Left, ReferenceAlignment: Left, ContinuationIndentWidth: 2}", | ||
"files.exclude": { | ||
"**/.lh": true | ||
}, | ||
"cSpell.words": [ | ||
"YASOLR" | ||
], | ||
"cmake.configureOnOpen": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
MycilaJSY | ||
|
||
Copyright (C) 2023-2024 Mathieu Carbou | ||
|
||
MycilaJSY is provided under: | ||
|
||
SPDX-License-Identifier: MIT | ||
|
||
Being under the terms of the MIT License according with: | ||
|
||
LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023-2024 Mathieu Carbou | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# MycilaJSY | ||
|
||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
[![Continuous Integration](https://github.com/mathieucarbou/MycilaJSY/actions/workflows/ci.yml/badge.svg)](https://github.com/mathieucarbou/MycilaJSY/actions/workflows/ci.yml) | ||
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/mathieucarbou/library/MycilaJSY.svg)](https://registry.platformio.org/libraries/mathieucarbou/MycilaJSY) | ||
|
||
Arduino / ESP32 library for the JSY-MK-194T single-phase two-way electric energy metering module | ||
|
||
- Sync mode and async mode | ||
- Core, stack size and interval can be configured | ||
- Energy reset | ||
- Custom bauds rate | ||
- Automatically detect and switch bauds rate | ||
- Configurable Serial (Serial2 by default) | ||
- Metrics: | ||
|
||
```c++ | ||
volatile float current1 = 0; // A | ||
volatile float current2 = 0; // A | ||
volatile float energy1 = 0; // kWh | ||
volatile float energy2 = 0; // kWh | ||
volatile float energyReturned1 = 0; // kWh | ||
volatile float energyReturned2 = 0; // kWh | ||
volatile uint8_t frequency = 0; // Hz | ||
volatile float power1 = 0; // W | ||
volatile float power2 = 0; // W | ||
volatile float powerFactor1 = 0; | ||
volatile float powerFactor2 = 0; | ||
volatile float voltage1 = 0; // V | ||
volatile float voltage2 = 0; // V | ||
``` | ||
|
||
## Usage | ||
|
||
See examples and API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <MycilaJSY.h> | ||
|
||
#define KEY_JSY_RX_PIN | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
while (!Serial) | ||
continue; | ||
|
||
Mycila::JSY.begin(17, 16); | ||
} | ||
|
||
void loop() { | ||
Mycila::JSY.read(); | ||
|
||
JsonDocument doc; | ||
Mycila::JSY.toJson(doc.to<JsonObject>()); | ||
serializeJson(doc, Serial); | ||
Serial.println(); | ||
|
||
delay(5000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#define MYCILA_JSY_ASYNC_READ_PAUSE_INTERVAL_MS 60 | ||
#define MYCILA_JSY_ASYNC_CORE 0 | ||
|
||
#include <MycilaJSY.h> | ||
|
||
#define KEY_JSY_RX_PIN | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
while (!Serial) | ||
continue; | ||
|
||
Mycila::JSY.begin(17, 16, true); | ||
} | ||
|
||
void loop() { | ||
JsonDocument doc; | ||
Mycila::JSY.toJson(doc.to<JsonObject>()); | ||
serializeJson(doc, Serial); | ||
Serial.println(); | ||
|
||
delay(5000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "MycilaJSY", | ||
"version": "1.0.0", | ||
"description": "Arduino / ESP32 library for the JSY-MK-194T single-phase two-way electric energy metering module", | ||
"keywords": "JSY,JSY-MK-194,JSY-MK-194T", | ||
"homepage": "https://github.com/mathieucarbou/MycilaJSY", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mathieucarbou/MycilaJSY.git" | ||
}, | ||
"authors": { | ||
"name": "Mathieu Carbou", | ||
"url": "https://github.com/mathieucarbou" | ||
}, | ||
"license": "MIT", | ||
"frameworks": "arduino", | ||
"platforms": [ | ||
"espressif32" | ||
], | ||
"headers": "MycilaJSY.h", | ||
"dependencies": [ | ||
{ | ||
"owner": "bblanchon", | ||
"name": "ArduinoJson", | ||
"version": "^7.0.2", | ||
"platforms": "espressif32" | ||
}, | ||
{ | ||
"owner": "mathieucarbou", | ||
"name": "MycilaLogger", | ||
"version": "^2.0.0", | ||
"platforms": "espressif32" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name=MycilaJSY | ||
version=1.0.0 | ||
author=Mathieu Carbou <mathieu.carbou@gmail.com> | ||
maintainer=Mathieu Carbou <mathieu.carbou@gmail.com> | ||
sentence=Arduino / ESP32 library for the JSY-MK-194T single-phase two-way electric energy metering module | ||
paragraph= | ||
category=Other | ||
url=https://github.com/mathieucarbou/MycilaJSY | ||
architectures=esp32 | ||
license=MIT | ||
depends=ArduinoJson,MycilaLogger |
Oops, something went wrong.