@@ -6,111 +6,45 @@ production floor, or the electrical circuits in a commercial/residential
66setting, having data about electrical usage is a powerful tool for
77making business decisions.
88
9- ![ image] ( img/golioth-power-monitor-with-clamp.jpg )
10-
119Readings from each channel are passed up to Golioth for tracking usage
1210over time. Live "run" time is also reported to show how long a machine
1311has currently been running. This data is also used to report the
1412lifetime "run" time of the equipment being monitored. The delay between
1513readings and the threshold at which the equipment is considered "off"
1614are configurable from the Golioth cloud.
1715
18- ## Local set up
16+ Business use cases and hardware build details are available on [ the IoT
17+ AC Power Monitor Project
18+ Page] ( https://projects.golioth.io/reference-designs/iot-ac-power-monitor/ ) .
1919
20- > Do not clone this repo using git. Zephyr's ` west ` meta tool should be
21- > used to set up your local workspace.
20+ This repository contains the firmware source code and [ pre-built release
21+ firmware
22+ images] ( https://github.com/golioth/reference-design-ac-power-monitor/releases ) .
2223
23- ### Install the Python virtual environment (recommended)
24+ ## Supported Hardware
2425
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- ```
26+ - Nordic nRF9160-DK
27+ - Golioth Aludel Elixir
28+ - Golioth Aludel Mini
3229
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- ```
30+ ### Additional Sensors/Components
4231
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.
32+ - Microchip MCP3201 12-Bit A/D Converter (x2)
33+ - YMCD SCT013 Split Core Current Transformer, 30V/1A (x2)
10034
10135## Golioth Features
10236
10337This app implements:
10438
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
39+ - [ Device Settings
40+ Service ] ( https://docs.golioth.io/firmware/golioth-firmware-sdk/device-settings-service )
41+ - [ Remote Procedure Call
42+ (RPC) ] ( https://docs.golioth.io/firmware/golioth-firmware-sdk/remote-procedure-call )
43+ - [ Stream Client ] ( https://docs.golioth.io/firmware/golioth-firmware-sdk/stream-client )
44+ - [ LightDB State Client ] ( https://docs.golioth.io/firmware/golioth-firmware-sdk/light-db-state/ )
45+ - [ Over-the-Air (OTA) Firmware
46+ Upgrade ] ( https://docs.golioth.io/firmware/golioth-firmware-sdk/firmware-upgrade/firmware-upgrade )
47+ - [ Backend Logging ] ( https://docs.golioth.io/device-management/logging/ )
11448
11549### Settings Service
11650
@@ -123,14 +57,12 @@ The following settings should be set in the Device Settings menu of the
12357
12458 Default value is ` 60 ` seconds.
12559
126- ` ADC_FLOOR_CH0 ` (raw ADC value)
60+ - ` ADC_FLOOR_CH0 ` (raw ADC value)
61+ - ` ADC_FLOOR_CH1 ` (raw ADC value)
62+ Filter out noise by adjusting the minimum reading at which a channel
63+ will be considered "on".
12764
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 `
65+ Default values are ` 0 `
13466
13567### Remote Procedure Call (RPC) Service
13668
@@ -160,13 +92,14 @@ the [Golioth Console](https://console.golioth.io).
16092 - ` 3 ` : ` LOG_LEVEL_INF `
16193 - ` 4 ` : ` LOG_LEVEL_DBG `
16294
163- ### LightDB State and LightDB Stream data
164-
165- #### Time-Series Data (LightDB Stream)
95+ ### Time-Series Stream data
16696
16797Raw 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.
98+ the ` sensor ` path. There readings can each be multiplied by 0.00125 to
99+ convert the values to Amps.
100+
101+ - ` sensor/ch0 ` : Raw ADC reading for channel 0
102+ - ` sensor/ch1 ` : Raw ADC reading for channel 1
170103
171104``` json
172105{
@@ -177,49 +110,160 @@ to convert the values to Amps.
177110}
178111```
179112
180- If your board includes a battery, voltage and level readings will be
181- sent to the ` battery ` endpoint.
113+ If your board includes a battery, voltage and level readings
114+ will be sent to the ` battery ` path.
115+
116+ > [ !NOTE]
117+ > Your Golioth project must have a Pipeline enabled to receive this
118+ > data. See the [ Add Pipeline to Golioth] ( #add-pipeline-to-golioth )
119+ > section below.
182120
183- #### Stateful Data (LightDB State)
121+ ### Stateful Data (LightDB State)
184122
185123The concept of Digital Twin is demonstrated with the LightDB State via
186- the ` state ` path.
124+ the ` state ` path. Values will be updated by the device. The cloud may
125+ read the ` state ` path to determine device status, but only the device
126+ should ever write to that path.
127+
128+ - ` cumulative ` values indicate the sum of all time a current is
129+ detected on a channel throughout all on/off cycles.
130+ - ` live_runtime ` values reflect the time a current has been
131+ continuously detected on the channel since the state of the
132+ equipment being monitored changed from "off" to "on".
187133
188134``` json
189135{
190- "state" : {
191- "cumulative" : {
192- "ch0" : 138141 ,
193- "ch1" : 1913952
136+ "desired" : {
137+ "reset_cumulative" : false
194138 },
195- "live_runtime" : {
196- "ch0" : 0 ,
197- "ch1" : 913826
139+ "state" : {
140+ "cumulative" : {
141+ "ch0" : 3844687 ,
142+ "ch1" : 78148
143+ },
144+ "example_int0" : 0 ,
145+ "example_int1" : 1 ,
146+ "live_runtime" : {
147+ "ch0" : 91582 ,
148+ "ch1" : 0
149+ }
198150 }
199- }
200- }
151+ }```
152+
153+ ## Building the application
154+
155+ ### OTA Firmware Update
156+
157+ This application includes the ability to perform Over-the-Air (OTA)
158+ firmware updates. To do so, you need a binary compiled with a different
159+ version number than what is currently running on the device.
160+
161+ > [!NOTE]
162+ > If a newer release is available than what your device is currently
163+ > running, you may download the pre-compiled binary that ends in
164+ > `_update.bin` and use it in step 2 below.
165+
166+ 1 . Update the version number in the `VERSION` file and perform a
167+ pristine (important) build to incorporate the version change.
168+ 2 . Upload the `build/app/zephyr/zephyr.signed.bin` file as a Package for
169+ your Golioth project.
170+
171+ - Use `main` as the package name.
172+ - Use the same version number from step 1.
173+
174+ 3 . Create a Cohort and add your device to it.
175+ 4 . Create a Deployment for your Cohort using the package name and
176+ version number from step 2.
177+ 5 . Devices in your Cohort will automatically upgrade to the most
178+ recently deployed firmware.
179+
180+ Visit [the Golioth Docs OTA Firmware Upgrade
181+ page](https://docs.golioth.io/firmware/golioth-firmware-sdk/firmware-upgrade/firmware-upgrade)
182+ for more info.
183+
184+ ## Add Pipeline to Golioth
185+
186+ Golioth uses [Pipelines](https://docs.golioth.io/data-routing) to route
187+ stream data. This gives you flexibility to change your data routing
188+ without requiring updated device firmware.
189+
190+ Whenever sending stream data, you must enable a pipeline in your Golioth
191+ project to configure how that data is handled. Add the contents of
192+ `pipelines/cbor-to-lightdb.yml` as a new pipeline as follows (note that
193+ this is the default pipeline for new projects and may already be
194+ present):
195+
196+ > 1. Navigate to your project on the Golioth web console.
197+ > 2. Select `Pipelines` from the left sidebar and click the `Create`
198+ > button.
199+ > 3. Give your new pipeline a name and paste the pipeline configuration
200+ > into the editor.
201+ > 4. Click the toggle in the bottom right to enable the pipeline and
202+ > then click `Create`.
203+
204+ All data streamed to Golioth in CBOR format will now be routed to
205+ LightDB Stream and may be viewed using the web console. You may change
206+ this behavior at any time without updating firmware simply by editing
207+ this pipeline entry.
208+
209+ ## Local set up
210+
211+ > [!IMPORTANT]
212+ > Do not clone this repo using git. Zephyr's `west` meta tool should be
213+ > used to set up your local workspace.
214+
215+ ### Install the Python virtual environment (recommended)
216+
217+ ``` shell
218+ cd ~
219+ mkdir golioth-reference-design-ac-power-monitor
220+ python -m venv golioth-reference-design-ac-power-monitor/.venv
221+ source golioth-reference-design-ac-power-monitor/.venv/bin/activate
222+ pip install wheel west ecdsa
201223```
202224
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.
225+ ### Use ` west ` to initialize and install
226+
227+ ``` shell
228+ cd ~ /golioth-reference-design-ac-power-monitor
229+ west init -m git@github.com:golioth/reference-design-ac-power-monitor.git .
230+ west update
231+ west zephyr-export
232+ pip install -r deps/zephyr/scripts/requirements.txt
233+ ```
206234
207- ## Hardware Variations
235+ ## Building the application
208236
209- ### Nordic nRF9160 DK
237+ Build the Zephyr sample application for the [ Nordic nRF9160
238+ DK] ( https://www.nordicsemi.com/Products/Development-hardware/nrf9160-dk )
239+ (` nrf9160dk_nrf9160_ns ` ) from the top level of your project. After a
240+ successful build you will see a new ` build ` directory. Note that any
241+ changes (and git commits) to the project itself will be inside the ` app `
242+ folder. The ` build ` and ` deps ` directories being one level higher
243+ prevents the repo from cataloging all of the changes to the dependencies
244+ and the build (so no ` .gitignore ` is needed).
210245
211- This reference design may be built for the [ Nordic nRF9160
212- DK] ( https://www.nordicsemi.com/Products/Development-hardware/nrf9160-dk ) .
246+ ### Nordic nRF9160 DK
213247
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.)
248+ > [ !WARNING]
249+ > You must perform a pristine build (use ` -p ` or remove the ` build `
250+ > directory) after changing the firmware version number in the ` VERSION `
251+ > file for the change to take effect.
217252
218253``` text
219254$ (.venv) west build -p -b nrf9160dk/nrf9160/ns --sysbuild app
220255$ (.venv) west flash
221256```
222257
258+ Configure PSK-ID and PSK using the device shell based on your Golioth
259+ credentials and reboot:
260+
261+ ``` text
262+ uart:~$ settings set golioth/psk-id <my-psk-id@my-project>
263+ uart:~$ settings set golioth/psk <my-psk>
264+ uart:~$ kernel reboot cold
265+ ```
266+
223267## External Libraries
224268
225269The following code libraries are installed by default. If you are not
@@ -234,3 +278,8 @@ calls from the C code.
234278 - [ zephyr-network-info] ( https://github.com/golioth/zephyr-network-info )
235279 is a helper library for querying, formatting, and returning network
236280 connection information via Zephyr log or Golioth RPC
281+
282+ ## Have Questions?
283+
284+ Please get in touch with Golioth engineers by starting a new thread on
285+ the [ Golioth Forum] ( https://forum.golioth.io/ ) .
0 commit comments