Skip to content

Commit 60d9d89

Browse files
committed
source added
1 parent 5dcc4d3 commit 60d9d89

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include <xCore.h> //add core library
2+
#include <xSW01.h> //add weather sensor library
3+
4+
#if defined(ESP8266)
5+
#define RED RED
6+
#define GREEN GREEN
7+
#define BLUE BLUE
8+
#include <ESP8266WiFi.h>
9+
#define Serial Serial
10+
11+
#elif defined(ARDUINO_SAMD_ZERO)
12+
#define RED CC03_RED
13+
#define GREEN CC03_GREEN
14+
#define BLUE CC03_BLUE
15+
#define Serial SerialUSB
16+
17+
#elif defined(ARDUINO_AVR_PRO)
18+
#define RED CC01_RED
19+
#define GREEN CC01_GREEN
20+
#define BLUE CC01_BLUE
21+
#define Serial Serial
22+
23+
#elif defined(ESP32)
24+
#define RED CW02_RED
25+
#define GREEN CW02_GREEN
26+
#define BLUE CW02_BLUE
27+
#define Serial Serial
28+
#endif
29+
30+
xSW01 SW01;
31+
32+
const int DelayTime = 500; //Defining set delay time that could be used elsewhere in the code
33+
34+
//Create a variable to store the data read from SW01
35+
float dew_point;
36+
37+
void setup(){
38+
39+
//Initialise variables to zero
40+
dew_point = 0;
41+
42+
//Start Serial Monitor
43+
Serial.begin(115200);
44+
45+
//Start I2C communication
46+
Wire.begin();
47+
48+
//Start SW01 Sensor
49+
SW01.begin();
50+
51+
//String intro for project
52+
Serial.println("XinaBox Dew Point Experiment");
53+
Serial.println("____________________________");
54+
55+
//Delay for sensor to normalise
56+
delay(3000);
57+
58+
}
59+
60+
void loop(){
61+
62+
//Read and calculate data from SW01
63+
SW01.poll();
64+
65+
//Request to get humidity, temperature and dew point data then store in the variables
66+
dew_point = SW01.getDewPoint();
67+
68+
69+
//Display recorded data over the Serial Monitor
70+
71+
Serial.print("Dew Point:");
72+
Serial.print(dew_point);
73+
Serial.println("");
74+
75+
delay(5000);
76+
77+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <xCore.h> //add core library
2+
#include <xSW01.h> //add weather sensor library
3+
4+
xSW01 SW01;
5+
6+
const int DelayTime = 500; //Defining set delay time that could be used elsewhere in the code
7+
8+
//Create a variable to store the data read from SW01
9+
float dew_point;
10+
11+
void setup(){
12+
13+
//Initialise variables to zero
14+
dew_point = 0;
15+
16+
//Start Serial Monitor
17+
Serial.begin(115200);
18+
19+
//Start I2C communication
20+
Wire.begin(2, 14);
21+
22+
//Start SW01 Sensor
23+
SW01.begin();
24+
25+
//String intro for project
26+
Serial.println("XinaBox Dew Point Experiment");
27+
Serial.println("____________________________");
28+
29+
//Delay for sensor to normalise
30+
delay(3000);
31+
32+
}
33+
34+
void loop(){
35+
36+
//Read and calculate data from SW01
37+
SW01.poll();
38+
39+
//Request to get humidity, temperature and dew point data then store in the variables
40+
dew_point = SW01.getDewPoint();
41+
42+
43+
//Display recorded data over the Serial Monitor
44+
45+
Serial.print("Dew Point:");
46+
Serial.print(dew_point);
47+
Serial.println("");
48+
49+
delay(5000);
50+
51+
}

0 commit comments

Comments
 (0)