Skip to content

Commit 5be3403

Browse files
committed
Simplify DHT sensor build process. Zero out Daytime Protocol msADV parameter.
1 parent 0f6aad2 commit 5be3403

6 files changed

Lines changed: 10 additions & 49 deletions

File tree

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
To test and build the web client project, you can use the following commands:
44
- "`npm run lint`" to inspect the code with TSLint.
5-
- "`npm run build`" to build.
5+
- "`npm run build`" to build _without_ support for temperature/humidity sensor.
6+
- "`npm run build-for-dht`" to build _with_ support for temperature/humidity sensor.
67
- "`npm test`" to run unit tests.
78
- "`npm start`" to serve the app using webpack-dev-server.
89
- "`npm run e2e`" to run Protractor for end-to-end tests.
@@ -22,7 +23,7 @@ By default, the server uses `pool.ntp.org` as an NTP time server. Use the enviro
2223
to changes the time server. Do not use a Google time server, or any other NTP server that implements "leap second
2324
smearing" if you want the Astronomy/Weather Clock to be able to display leap seconds.
2425

25-
To deploy the server along with the web client, use `npm run build` as described above. The
26+
To deploy the server along with the web client, use `npm run build` (or `npm run build-for-dht`) as described above. The
2627
contents of the `dist` directory will be copied into the server's `public` directory.
2728

2829
If you are running the server on a Raspberry Pi, you have the option to provide indoor temperature and
@@ -32,10 +33,7 @@ resistor.
3233

3334
First, you must install the BCM 2835 library as described here: http://www.airspayce.com/mikem/bcm2835/
3435

35-
Then delete the file in the server directory named `package.json`, followed by renaming the file `package.json.for-dht-sensor.json`
36-
to `package.json`. Next run `npm install` from within the server directory.
37-
38-
With your Raspberry Pi shut down, and disconnected from power, connect the DHT22/AM2302 sensor.
36+
Then, with your Raspberry Pi shut down and disconnected from power, connect the DHT22/AM2302 sensor.
3937
The code defaults to assuming the signal lead ("out") of the sensor is connected to GPIO 4 (pin 7 on the GPIO
4038
header). You can use the environment variable `SENSOR_GPIO` to set a different GPIO number.
4139
The `+` lead from the sensor needs to be connect to 5V (I chose pin 2 on the GPIO header) and
@@ -59,7 +57,7 @@ screen saver for this application — in fact, you want the screen to stay o
5957
`xscreensaver` gives you the option of going to your Raspberry Pi's Preferences and *turning off* the default screen blanking that will
6058
otherwise occur.
6159
1. Install an up-to-date node.js. (You can find instructions for this step here: https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp.)
62-
1. Build the client project as described above (`npm run build`).
60+
1. Build the client project as described above (`npm run build-for-dht`, or `npm run build` if you aren't installing the DHT22/AM2302 sensor).
6361
1. Copy the contents of this project's `server/dist` folder to `/home/pi/weather`.
6462
1. If you wish to use an indoor temperature/humidity sensor, follow the previously mentioned
6563
steps to install the BCM 2835 library and connect the sensor.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "aw-clock",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"license": "MIT",
55
"author": "Kerry Shetline <kerry@shetline.com>",
66
"scripts": {
77
"start": "webpack-dev-server --port=4200",
88
"build": "webpack && tsc -b ./server/ && cp -Rp dist/ server/dist/public && copy-node-modules server server/dist",
9+
"build-for-dht": "cd ./server && npm i node-dht-sensor && cd .. && npm run build",
910
"test": "karma start ./karma.conf.js",
1011
"lint": "tslint --project .",
1112
"e2e": "protractor ./protractor.conf.js",

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aw-clock-server",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"license": "MIT",
55
"author": "Kerry Shetline <kerry@shetline.com>",
66
"private": true,

server/package.json.for-dht-sensor.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

server/src/daytime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class Daytime {
5757
break;
5858
}
5959

60-
this.lastTime = [$[1], $[2], isoDate.substr(11, 8), $[4], $[5], $[6], '50 UTC(NIST) *'].join(' ');
60+
this.lastTime = [$[1], $[2], isoDate.substr(11, 8), $[4], $[5], $[6], '0 UTC(NIST) *'].join(' ');
6161

6262
const dstCode = Number($[4]);
6363
const data = {

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
</div>
193193
</div>
194194
<div class="dialog-buttons">
195-
<span class="version-number">1.2.1</span>
195+
<span class="version-number">1.2.2</span>
196196
<button id="settings-reload">Reload</button>
197197
<span>&bull;</span>
198198
<button id="settings-cancel">Cancel</button>

0 commit comments

Comments
 (0)