Skip to content

Commit 8f36330

Browse files
committed
add sensor tutorial as example #6; harmonize ProductUIDs
1 parent 2bd4987 commit 8f36330

File tree

7 files changed

+96
-7
lines changed

7 files changed

+96
-7
lines changed

examples/Example0_LibrarylessCommunication/Example0_LibrarylessCommunication.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// "claim" a unique product ID for your device. It could be something as simple as as your email
2525
// address in reverse, such as "com.gmail.smith.lisa.test-device" or "com.outlook.gates.bill.demo"
2626

27-
#define myProductID "org.coca-cola.soda.vending-machine.v2"
27+
#define myProductID "com.your-company.your-name:your_project"
2828
#define myLiveDemo true
2929

3030
// One-time Arduino initialization

examples/Example1_NotecardBasics/Example1_NotecardBasics.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
// type of device has embedded the Notecard, and by extension which vendor or customer is in charge
4141
// of "managing" it. In order to set this value, you must first register with notehub.io and
4242
// "claim" a unique product ID for your device. It could be something as simple as as your email
43-
// address in reverse, such as "com.gmail.smith.lisa.test-device" or "com.outlook.gates.bill.demo"
43+
// address in reverse, such as "com.gmail.smith.lisa:test-device" or "com.outlook.gates.bill.demo"
4444

45-
#define myProductID "org.coca-cola.soda.vending-machine.v2"
45+
#define myProductID "com.your-company.your-name:your_project"
4646
Notecard notecard;
4747

4848
// One-time Arduino initialization

examples/Example2_PeriodicCommunications/Example2_PeriodicCommunications.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define serialDebugOut Serial
4040

4141
// This is the unique Product Identifier for your device.
42-
#define myProductID "org.coca-cola.soda.vending-machine.v2"
42+
#define myProductID "com.your-company.your-name:your_project"
4343
Notecard notecard;
4444

4545
// Button handling

examples/Example3_InboundPolling/Example3_InboundPolling.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#define serialDebugOut Serial
3434

3535
// This is the unique Product Identifier for your device.
36-
#define myProductID "org.coca-cola.soda.vending-machine.v2"
36+
#define myProductID "com.your-company.your-name:your_project"
3737
Notecard notecard;
3838
#define myLiveDemo true
3939

examples/Example4_InboundInterrupts/Example4_InboundInterrupts.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#define serialDebugOut Serial
3939

4040
// This is the unique Product Identifier for your device.
41-
#define myProductID "org.coca-cola.soda.vending-machine.v2"
41+
#define myProductID "com.your-company.your-name:your_project"
4242
Notecard notecard;
4343
#define myLiveDemo true
4444

examples/Example5_UsingTemplates/Example5_UsingTemplates.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
// of "managing" it. In order to set this value, you must first register with notehub.io and
4242
// "claim" a unique product ID for your device. It could be something as simple as as your email
4343
// address in reverse, such as "com.gmail.smith.lisa.test-device" or "com.outlook.gates.bill.demo"
44-
#define myProductID "org.coca-cola.soda.vending-machine.v2"
44+
#define myProductID "com.your-company.your-name:your_project"
4545
Notecard notecard;
4646

4747
// A sample binary object, just for binary payload simulation
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// Copyright 2019 Blues Inc. All rights reserved.
3+
// Use of this source code is governed by licenses granted by the
4+
// copyright holder including that found in the LICENSE file.
5+
//
6+
// This example contains the complete source for the Sensor Tutorial at dev.blues.io
7+
// https://dev.blues.io/build/tutorials/sensor-tutorial/notecarrier-af/esp32/arduino-wiring/
8+
//
9+
// This tutorial requires an external Adafruit BME680 Sensor.
10+
//
11+
12+
// Include the Arduino library for the Notecard
13+
#include <Notecard.h>
14+
15+
#include <Wire.h>
16+
#include <Adafruit_BME680.h>
17+
18+
Adafruit_BME680 bmeSensor;
19+
20+
//#define serialNotecard Serial1
21+
#define serialDebug Serial
22+
23+
#define productUID "com.your-company.your-name:your_project"
24+
Notecard notecard;
25+
26+
// One-time Arduino initialization
27+
void setup() {
28+
#ifdef serialDebug
29+
delay(2500);
30+
serialDebug.begin(115200);
31+
notecard.setDebugOutputStream(serialDebug);
32+
#endif
33+
34+
// Initialize the physical I/O channel to the Notecard
35+
#ifdef serialNotecard
36+
notecard.begin(serialNotecard, 9600);
37+
#else
38+
Wire.begin();
39+
40+
notecard.begin();
41+
#endif
42+
43+
J *req = notecard.newRequest("hub.set");
44+
JAddStringToObject(req, "product", productUID);
45+
JAddStringToObject(req, "mode", "continuous");
46+
notecard.sendRequest(req);
47+
48+
if (!bmeSensor.begin()) {
49+
serialDebug.println("Could not find a valid BME680 sensor...");
50+
} else {
51+
serialDebug.println("BME680 Connected...");
52+
}
53+
54+
bmeSensor.setTemperatureOversampling(BME680_OS_8X);
55+
bmeSensor.setHumidityOversampling(BME680_OS_2X);
56+
}
57+
58+
void loop() {
59+
if (! bmeSensor.performReading()) {
60+
serialDebug.println("Failed to obtain a reading...");
61+
delay(15000);
62+
return;
63+
}
64+
65+
serialDebug.print("Temperature = ");
66+
serialDebug.print(bmeSensor.temperature);
67+
serialDebug.println(" *C");
68+
69+
serialDebug.print("Humidity = ");
70+
serialDebug.print(bmeSensor.humidity);
71+
serialDebug.println(" %");
72+
73+
J *req = notecard.newRequest("note.add");
74+
if (req != NULL) {
75+
JAddStringToObject(req, "file", "sensors.qo");
76+
JAddBoolToObject(req, "start", true);
77+
78+
J *body = JCreateObject();
79+
if (body != NULL) {
80+
JAddNumberToObject(body, "temp", bmeSensor.temperature);
81+
JAddNumberToObject(body, "humidity", bmeSensor.humidity);
82+
JAddItemToObject(req, "body", body);
83+
}
84+
85+
notecard.sendRequest(req);
86+
}
87+
88+
delay(15000);
89+
}

0 commit comments

Comments
 (0)