Skip to content

Commit cdb766b

Browse files
authored
Merge pull request #332 from OPEnSLab-OSU/final-hypnos-additions
Final hypnos additions to ino examples
2 parents b1bd713 + 18b9cc5 commit cdb766b

11 files changed

Lines changed: 145 additions & 57 deletions

File tree

‎examples/Internet/Logging/LTEMongoDBBatch/LTEMongoDBBatch.ino‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,38 @@
33
*
44
* MANAGER MUST BE INCLUDED FIRST IN ALL CODE
55
*/
6-
#include "arduino_secrets.h"
76

7+
#include "arduino_secrets.h"
88
#include <Loom_Manager.h>
9-
109
#include <Hardware/Loom_Hypnos/Loom_Hypnos.h>
1110
#include <Internet/Connectivity/Loom_LTE/Loom_LTE.h>
1211
#include <Internet/Logging/Loom_MongoDB/Loom_MongoDB.h>
12+
#include <Sensors/Loom_Analog/Loom_Analog.h>
13+
1314

1415
Manager manager("Device", 1);
1516

1617
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::V3_3, TIME_ZONE::PST);
1718

1819
Loom_LTE lte(manager, NETWORK_NAME, NETWORK_USER, NETWORK_PASS);
19-
Loom_MongoDB mqtt(manager, lte.getClient(), SECRET_BROKER, SECRET_PORT, DATABASE, BROKER_USER, BROKER_PASS, PROJECT);
20+
21+
Loom_MongoDB mqtt(manager, lte, SECRET_BROKER, SECRET_PORT, DATABASE, BROKER_USER, BROKER_PASS, PROJECT);
22+
23+
Loom_Analog analog(manager);
2024

2125
// Enables batch logging with a batch size of 15
2226
Loom_BatchSD batchSD(hypnos, 15);
2327

28+
2429
// Called when the interrupt is triggered
25-
void isrTrigger(){
30+
void isrTrigger()
31+
{
2632
hypnos.wakeup();
2733
}
2834

29-
void setup() {
3035

36+
void setup()
37+
{
3138
// Start serial
3239
manager.beginSerial();
3340

@@ -42,15 +49,16 @@ void setup() {
4249

4350
// Register the ISR and attach to the interrupt
4451
hypnos.registerInterrupt(isrTrigger);
45-
4652
}
4753

48-
void loop() {
54+
55+
void loop()
56+
{
4957
// Set the RTC interrupt alarm to wake the device in 10 seconds
5058
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 10));
5159

5260
// Measure data from connected sensors
53-
manager.measure()
61+
manager.measure();
5462

5563
// Package data
5664
manager.package();
@@ -64,8 +72,6 @@ void loop() {
6472
// Pass batch SD along to the MQTT module
6573
mqtt.publish(batchSD);
6674

67-
68-
6975
// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
7076
hypnos.reattachRTCInterrupt();
7177

‎examples/Internet/Logging/WiFiMongoDB/WiFiMongoDB.ino‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,39 @@
33
*
44
* MANAGER MUST BE INCLUDED FIRST IN ALL CODE
55
*/
6-
#include "arduino_secrets.h"
76

7+
#include "arduino_secrets.h"
88
#include <Loom_Manager.h>
9-
109
#include <Internet/Connectivity/Loom_Wifi/Loom_Wifi.h>
1110
#include <Internet/Logging/Loom_MongoDB/Loom_MongoDB.h>
11+
#include <Hardware/Loom_Hypnos/Loom_Hypnos.h>
12+
1213

1314
Manager manager("Device", 1);
1415

16+
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::V3_3, TIME_ZONE::PST);
17+
1518
Loom_WIFI wifi(manager, CommunicationMode::CLIENT, SECRET_SSID, SECRET_PASS);
16-
Loom_MongoDB mqtt(manager, wifi.getClient(), SECRET_BROKER, SECRET_PORT, DATABASE, BROKER_USER, BROKER_PASS, PROJECT);
1719

18-
void setup() {
20+
Loom_MongoDB mqtt(manager, wifi, SECRET_BROKER, SECRET_PORT, DATABASE, BROKER_USER, BROKER_PASS, PROJECT);
21+
22+
23+
void setup()
24+
{
1925
manager.beginSerial();
26+
27+
hypnos.enable();
28+
2029
manager.initialize();
2130
}
2231

23-
void loop() {
32+
33+
void loop()
34+
{
2435
manager.measure();
36+
2537
manager.package();
38+
2639
manager.display_data();
2740

2841
mqtt.publish();

‎examples/Internet/Logging/WiFiMongoDBBatch/WiFiMongoDBBatch.ino‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,31 @@
33
*
44
* MANAGER MUST BE INCLUDED FIRST IN ALL CODE
55
*/
6-
#include "arduino_secrets.h"
76

7+
#include "arduino_secrets.h"
88
#include <Loom_Manager.h>
9-
109
#include <Hardware/Loom_Hypnos/Loom_Hypnos.h>
1110
#include <Internet/Connectivity/Loom_Wifi/Loom_Wifi.h>
1211
#include <Internet/Logging/Loom_MongoDB/Loom_MongoDB.h>
12+
#include <Sensors/Loom_Analog/Loom_Analog.h>
13+
1314

1415
Manager manager("Device", 1);
1516

1617
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::V3_3, TIME_ZONE::PST);
1718

1819
Loom_WIFI wifi(manager, CommunicationMode::CLIENT, SECRET_SSID, SECRET_PASS);
19-
Loom_MongoDB mqtt(manager, wifi.getClient(), SECRET_BROKER, SECRET_PORT, DATABASE, BROKER_USER, BROKER_PASS, PROJECT);
20+
21+
Loom_MongoDB mqtt(manager, wifi, SECRET_BROKER, SECRET_PORT, DATABASE, BROKER_USER, BROKER_PASS, PROJECT);
22+
23+
Loom_Analog analog(manager);
2024

2125
// Enables batch logging with a batch size of 15
2226
Loom_BatchSD batchSD(hypnos, 15);
2327

24-
void setup() {
2528

29+
void setup()
30+
{
2631
// Start serial
2732
manager.beginSerial();
2833

@@ -36,7 +41,9 @@ void setup() {
3641
manager.initialize();
3742
}
3843

39-
void loop() {
44+
45+
void loop()
46+
{
4047
// Package data
4148
manager.package();
4249

‎examples/Radios/LoRa/BatchTransmission/Receive/Receive.ino‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,35 @@
33
*
44
* MANAGER MUST BE INCLUDED FIRST IN ALL CODE
55
*/
6-
#include <Loom_Manager.h>
76

7+
#include <Loom_Manager.h>
88
#include <Radio/Loom_LoRa/Loom_LoRa.h>
9+
#include <Hardware/Loom_Hypnos/Loom_Hypnos.h>
10+
911

1012
Manager manager("Device", 0);
1113

14+
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::V3_3, TIME_ZONE::PST);
15+
1216
// Create a new lora instance using the instance number as the address
1317
Loom_LoRa lora(manager);
1418

19+
1520
int packetNumber = 0;
1621

17-
void setup() {
22+
23+
void setup()
24+
{
1825
manager.beginSerial();
26+
27+
hypnos.enable();
28+
1929
manager.initialize();
2030
}
2131

22-
void loop() {
32+
33+
void loop()
34+
{
2335
/* Handle each individual packet being received from the batch transmit */
2436
do{
2537
if(lora.receiveBatch(5000, &packetNumber)){

‎examples/Radios/LoRa/BatchTransmission/Transmit/Transmit.ino‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
*
44
* MANAGER MUST BE INCLUDED FIRST IN ALL CODE
55
*/
6-
#include <Loom_Manager.h>
76

7+
#include <Loom_Manager.h>
88
#include <Hardware/Loom_Hypnos/Loom_Hypnos.h>
99
#include <Hardware/Loom_BatchSD/Loom_BatchSD.h>
1010
#include <Radio/Loom_LoRa/Loom_LoRa.h>
1111

12+
1213
Manager manager("Device", 1);
1314

1415
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::V3_3, TIME_ZONE::PST);
@@ -19,27 +20,28 @@ Loom_LoRa lora(manager);
1920
// Create a batch size of 15
2021
Loom_BatchSD batch(hypnos, 15);
2122

22-
void setup() {
23+
24+
void setup()
25+
{
2326
manager.beginSerial();
2427

25-
// Set a reference to the batchSD object
26-
lora.setBatchSD(batch);
28+
lora.setBatchSD(batch); // Set a reference to the batchSD object
2729

2830
hypnos.enable();
2931

3032
manager.initialize();
3133
}
3234

33-
void loop() {
35+
36+
void loop()
37+
{
3438
manager.package();
39+
3540
manager.display_data();
3641

37-
// Log the hypnos to the SD card
38-
hypnos.logToSD();
42+
hypnos.logToSD(); // Log the hypnos to the SD card
3943

40-
// Send the current JSON document to address 0
41-
lora.sendBatch(0);
44+
lora.sendBatch(0); // Send the current JSON document to address 0
4245

43-
// Wait 5 seconds between transmits
44-
manager.pause(5000);
46+
manager.pause(5000); // Wait 5 seconds between transmits
4547
}

‎examples/Sensors/Analog/Analog/Analog.ino‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
* MANAGER MUST BE INCLUDED FIRST IN ALL CODE
66
*/
77

8-
98
#include <Loom_Manager.h>
10-
119
#include <Sensors/Loom_Analog/Loom_Analog.h>
10+
#include <Hardware/Loom_Hypnos/Loom_Hypnos.h>
1211

1312

1413
Manager manager("Device", 1);
1514

15+
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::V3_3, TIME_ZONE::PST);
16+
1617
// Reads the battery voltage
1718
Loom_Analog analog(manager);
1819

@@ -22,16 +23,21 @@ Loom_Analog analog(manager);
2223
// Read the battery voltage, A2 and A4
2324
//Loom_Analog analog(manager, A2, A4);
2425

25-
void setup() {
2626

27+
void setup()
28+
{
2729
// Start the serial interface
2830
manager.beginSerial();
2931

32+
hypnos.enable();
33+
3034
// Initialize the manager
3135
manager.initialize();
3236
}
3337

34-
void loop() {
38+
39+
void loop()
40+
{
3541
// put your main code here, to run repeatedly:
3642

3743
// Measure the data from the sensors

‎examples/Sensors/I2C/ADS1115/ADS1115.ino‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@
44
* MANAGER MUST BE INCLUDED FIRST IN ALL CODE
55
*/
66

7-
87
#include <Loom_Manager.h>
9-
108
#include <Sensors/I2C/Loom_ADS1115/Loom_ADS1115.h>
9+
#include <Hardware/Loom_Hypnos/Loom_Hypnos.h>
10+
1111

1212
Manager manager("Device", 1);
1313

14+
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::V3_3, TIME_ZONE::PST);
15+
1416
// Manger Instance, Enable Analog, Enable DIfferential, Gain
1517
Loom_ADS1115 ads(manager);
1618

17-
void setup() {
1819

20+
void setup()
21+
{
1922
// Start the serial interface and wait for the user to open the serial monitor
2023
manager.beginSerial();
24+
25+
// Enable hypnos for RTC
26+
hypnos.enable();
2127

2228
// Initialize the manager
2329
manager.initialize();
24-
2530
}
2631

27-
void loop() {
32+
33+
void loop()
34+
{
2835
// Measure the data from the sensors
2936
manager.measure();
3037

@@ -36,5 +43,4 @@ void loop() {
3643

3744
// Wait for 5 seconds
3845
manager.pause(5000);
39-
4046
}

‎examples/Sensors/I2C/DFMultiGasSensor/DFMultiGasSensor.ino‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,35 @@
33
*/
44
#include <Loom_Manager.h>
55
#include <Sensors/I2C/Loom_DFMultiGasSensor/Loom_DFMultiGasSensor.h>
6+
#include <Hardware/Loom_Hypnos/Loom_Hypnos.h>
67

78

89
// If the sensor is freezing on init try disconnecting the power and re-connecting it
910
Manager manager("Device", 1);
1011

12+
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::V3_3, TIME_ZONE::PST);
13+
1114
// MANAGER, I2C ADDRESS, INIT RETRY LIMIT, USE MUX
1215
Loom_DFMultiGasSensor gas(manager, 0x77, 10, false);
1316

14-
void setup() {
17+
18+
void setup()
19+
{
1520
manager.beginSerial();
21+
22+
hypnos.enable();
23+
1624
manager.initialize();
1725
}
1826

19-
void loop() {
27+
28+
void loop()
29+
{
2030
manager.measure();
31+
2132
manager.package();
33+
2234
manager.display_data();
35+
2336
manager.pause(5000);
2437
}

0 commit comments

Comments
 (0)