Skip to content

Commit 55f79ec

Browse files
committed
README: move from ReStructured Text to Markdown
This commit converts README.rst to README.md. No substantive changes have been made. Signed-off-by: Mike Szczys <mike@golioth.io>
1 parent a8b1f67 commit 55f79ec

File tree

2 files changed

+236
-253
lines changed

2 files changed

+236
-253
lines changed

README.md

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
# Golioth AC Power Monitor Reference Design
2+
3+
The Golioth AC Power Monitor reference design includes two channels for
4+
monitoring electrical equipment. Whether applied to machine tools on a
5+
production floor, or the electrical circuits in a commercial/residential
6+
setting, having data about electrical usage is a powerful tool for
7+
making business decisions.
8+
9+
![image](img/golioth-power-monitor-with-clamp.jpg)
10+
11+
Readings from each channel are passed up to Golioth for tracking usage
12+
over time. Live "run" time is also reported to show how long a machine
13+
has currently been running. This data is also used to report the
14+
lifetime "run" time of the equipment being monitored. The delay between
15+
readings and the threshold at which the equipment is considered "off"
16+
are configurable from the Golioth cloud.
17+
18+
## Local set up
19+
20+
> Do not clone this repo using git. Zephyr's `west` meta tool should be
21+
> used to set up your local workspace.
22+
23+
### Install the Python virtual environment (recommended)
24+
25+
``` shell
26+
cd ~
27+
mkdir golioth-reference-design-ac-power-monitor
28+
python -m venv golioth-reference-design-ac-power-monitor/.venv
29+
source golioth-reference-design-ac-power-monitor/.venv/bin/activate
30+
pip install wheel west
31+
```
32+
33+
### Use `west` to initialize and install
34+
35+
``` shell
36+
cd ~/golioth-reference-design-ac-power-monitor
37+
west init -m git@github.com:golioth/reference-design-ac-power-monitor.git .
38+
west update
39+
west zephyr-export
40+
pip install -r deps/zephyr/scripts/requirements.txt
41+
```
42+
43+
## Building the application
44+
45+
Build the Zephyr sample application for the [Nordic nRF9160
46+
DK](https://www.nordicsemi.com/Products/Development-hardware/nrf9160-dk)
47+
(`nrf9160dk_nrf9160_ns`) from the top level of your project. After a
48+
successful build you will see a new `build` directory. Note that any
49+
changes (and git commits) to the project itself will be inside the `app`
50+
folder. The `build` and `deps` directories being one level higher
51+
prevents the repo from cataloging all of the changes to the dependencies
52+
and the build (so no `.gitignore` is needed).
53+
54+
Prior to building, update `VERSION` file to reflect the firmware version
55+
number you want to assign to this build. Then run the following commands
56+
to build and program the firmware onto the device.
57+
58+
> You must perform a pristine build (use `-p` or remove the `build`
59+
> directory) after changing the firmware version number in the `VERSION`
60+
> file for the change to take effect.
61+
62+
``` text
63+
$ (.venv) west build -p -b nrf9160dk/nrf9160/ns --sysbuild app
64+
$ (.venv) west flash
65+
```
66+
67+
Configure PSK-ID and PSK using the device shell based on your Golioth
68+
credentials and reboot:
69+
70+
``` text
71+
uart:~$ settings set golioth/psk-id <my-psk-id@my-project>
72+
uart:~$ settings set golioth/psk <my-psk>
73+
uart:~$ kernel reboot cold
74+
```
75+
76+
## Add Pipeline to Golioth
77+
78+
Golioth uses [Pipelines](https://docs.golioth.io/data-routing) to route
79+
stream data. This gives you flexibility to change your data routing
80+
without requiring updated device firmware.
81+
82+
Whenever sending stream data, you must enable a pipeline in your Golioth
83+
project to configure how that data is handled. Add the contents of
84+
`pipelines/cbor-to-lightdb.yml` as a new pipeline as follows (note that
85+
this is the default pipeline for new projects and may already be
86+
present):
87+
88+
> 1. Navigate to your project on the Golioth web console.
89+
> 2. Select `Pipelines` from the left sidebar and click the `Create`
90+
> button.
91+
> 3. Give your new pipeline a name and paste the pipeline configuration
92+
> into the editor.
93+
> 4. Click the toggle in the bottom right to enable the pipeline and
94+
> then click `Create`.
95+
96+
All data streamed to Golioth in CBOR format will now be routed to
97+
LightDB Stream and may be viewed using the web console. You may change
98+
this behavior at any time without updating firmware simply by editing
99+
this pipeline entry.
100+
101+
## Golioth Features
102+
103+
This app implements:
104+
105+
- Over-the-Air (OTA) firmware updates
106+
- LightDB State for tracking live runtime and cumulative runtime
107+
- LightDB Stream for recording periodic readings from each channel
108+
- Settings Service to adjust the delay between sensor readings and the
109+
ADC floor ("off" threshold above which a device will be considered
110+
"running")
111+
- Remote Logging
112+
- Remote Procedure call (RPC) to reboot the device or set logging
113+
levels
114+
115+
### Settings Service
116+
117+
The following settings should be set in the Device Settings menu of the
118+
[Golioth Console](https://console.golioth.io).
119+
120+
- `LOOP_DELAY_S`
121+
Adjusts the delay between sensor readings. Set to an integer value
122+
(seconds).
123+
124+
Default value is `60` seconds.
125+
126+
`ADC_FLOOR_CH0` (raw ADC value)
127+
128+
`ADC_FLOOR_CH1` (raw ADC value)
129+
130+
> Filter out noise by adjusting the minimum reading at which a channel
131+
> will be considered "on".
132+
>
133+
> Default values are `0`
134+
135+
### Remote Procedure Call (RPC) Service
136+
137+
The following RPCs can be initiated in the Remote Procedure Call menu of
138+
the [Golioth Console](https://console.golioth.io).
139+
140+
- `get_network_info`
141+
Query and return network information.
142+
143+
- `reboot`
144+
Reboot the system.
145+
146+
- `reset_cumulative`
147+
Reset the cumulative "on time" values stored on the device. After
148+
executing, the device will update the cloud's `state/cumulative`
149+
values using the LightDB State service.
150+
151+
- `set_log_level`
152+
Set the log level.
153+
154+
The method takes a single parameter which can be one of the
155+
following integer values:
156+
157+
- `0`: `LOG_LEVEL_NONE`
158+
- `1`: `LOG_LEVEL_ERR`
159+
- `2`: `LOG_LEVEL_WRN`
160+
- `3`: `LOG_LEVEL_INF`
161+
- `4`: `LOG_LEVEL_DBG`
162+
163+
### LightDB State and LightDB Stream data
164+
165+
#### Time-Series Data (LightDB Stream)
166+
167+
Raw Current data for both channels is reported as time-series data on
168+
the `sensor` endpoint. There readings can each be multiplied by 0.00125
169+
to convert the values to Amps.
170+
171+
``` json
172+
{
173+
"sensor": {
174+
"ch0": 11,
175+
"ch1": 447
176+
}
177+
}
178+
```
179+
180+
If your board includes a battery, voltage and level readings will be
181+
sent to the `battery` endpoint.
182+
183+
#### Stateful Data (LightDB State)
184+
185+
The concept of Digital Twin is demonstrated with the LightDB State via
186+
the `state` path.
187+
188+
``` json
189+
{
190+
"state": {
191+
"cumulative": {
192+
"ch0": 138141,
193+
"ch1": 1913952
194+
},
195+
"live_runtime": {
196+
"ch0": 0,
197+
"ch1": 913826
198+
}
199+
}
200+
}
201+
```
202+
203+
- `state` values will be updated by the device. The cloud may read the
204+
`state` path to determine device status, but only the device should
205+
ever write to that path.
206+
207+
## Hardware Variations
208+
209+
### Nordic nRF9160 DK
210+
211+
This reference design may be built for the [Nordic nRF9160
212+
DK](https://www.nordicsemi.com/Products/Development-hardware/nrf9160-dk).
213+
214+
Use the following commands to build and program. (Use the same console
215+
commands from above to provision this board after programming the
216+
firmware.)
217+
218+
``` text
219+
$ (.venv) west build -p -b nrf9160dk/nrf9160/ns --sysbuild app
220+
$ (.venv) west flash
221+
```
222+
223+
## External Libraries
224+
225+
The following code libraries are installed by default. If you are not
226+
using the custom hardware to which they apply, you can safely remove
227+
these repositories from `west.yml` and remove the includes/function
228+
calls from the C code.
229+
230+
- [golioth-zephyr-boards](https://github.com/golioth/golioth-zephyr-boards)
231+
includes the board definitions for the Golioth Aludel-Mini
232+
- [libostentus](https://github.com/golioth/libostentus) is a helper
233+
library for controlling the Ostentus ePaper faceplate
234+
- [zephyr-network-info](https://github.com/golioth/zephyr-network-info)
235+
is a helper library for querying, formatting, and returning network
236+
connection information via Zephyr log or Golioth RPC

0 commit comments

Comments
 (0)