File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include < xCore.h> // add core library
2+ #include < xSW01.h> // add weather sensor library
3+ #include < xOD01.h>
4+
5+ #if defined(ESP8266)
6+ #define RED RED
7+ #define GREEN GREEN
8+ #define BLUE BLUE
9+ #include < ESP8266WiFi.h>
10+ #define Serial Serial
11+
12+ #elif defined(ARDUINO_SAMD_ZERO)
13+ #define RED CC03_RED
14+ #define GREEN CC03_GREEN
15+ #define BLUE CC03_BLUE
16+ #define Serial SerialUSB
17+
18+ #elif defined(ARDUINO_AVR_PRO)
19+ #define RED CC01_RED
20+ #define GREEN CC01_GREEN
21+ #define BLUE CC01_BLUE
22+ #define Serial Serial
23+
24+ #elif defined(ESP32)
25+ #define RED CW02_RED
26+ #define GREEN CW02_GREEN
27+ #define BLUE CW02_BLUE
28+ #define Serial Serial
29+ #endif
30+
31+
32+ xSW01 SW01 ;
33+
34+ const int DelayTime = 500 ; // Defining set delay time that could be used elsewhere in the code
35+
36+ // Create a variable to store the data read from SW01
37+ float pressure;
38+
39+ void setup (){
40+
41+ #if defined(ESP8266)
42+ WiFi.forceSleepBegin ();
43+ Wire.begin (2 , 14 );
44+ Wire.setClockStretchLimit (15000 );
45+
46+ #elif defined(ARDUINO_SAMD_ZERO)
47+ Wire.begin ();
48+
49+ #elif defined(ARDUINO_AVR_PRO)
50+ Wire.begin ();
51+
52+ #elif defined(ESP32)
53+ Wire.begin ();
54+
55+ #endif
56+
57+
58+ // Initialise variable to zero
59+ pressure = 0 ;
60+
61+ // Start Serial Monitor
62+ Serial.begin (115200 );
63+
64+ // Start SW01 Sensor
65+ SW01 .begin ();
66+ OLED .begin ();
67+
68+ // String intro for project
69+ OD01 .println (" Barometric Pressure Experiment" );
70+ OD01 .println (" ______________________________________" );
71+
72+ // Delay for sensor to normalise
73+ delay (3000 );
74+
75+ }
76+
77+ void loop (){
78+
79+ // Read and calculate data from SW01
80+ SW01 .poll ();
81+
82+ // Request to get humidity, temperature and dew point data then store in the variables
83+ pressure = SW01 .getPressure ();
84+
85+
86+ // Display recorded data over the Serial Monitor
87+
88+ OD01 .print (" Pressure:" );
89+ OD01 .print (pressure);
90+ OD01 .println (" Pa " );
91+
92+ delay (5000 );
93+
94+ }
95+
Original file line number Diff line number Diff line change 1+ #include < xCore.h> // add core library
2+ #include < xSW01.h> // add weather sensor library
3+ #include < xOD01.h>
4+
5+ xSW01 SW01 ;
6+
7+ const int DelayTime = 500 ; // Defining set delay time that could be used elsewhere in the code
8+
9+ // Create a variable to store the data read from SW01
10+ float pressure;
11+
12+ void setup (){
13+
14+ // Initialise variable to zero
15+ pressure = 0 ;
16+
17+ // Start Serial Monitor
18+ Serial.begin (115200 );
19+
20+ // Start I2C communication
21+ Wire.begin (2 , 14 );
22+
23+ // Start SW01 Sensor
24+ SW01 .begin ();
25+ OLED .begin ();
26+
27+ // String intro for project
28+ OD01 .println (" Pressure Experiment" );
29+ OD01 .println (" ______________________________________" );
30+
31+ // Delay for sensor to normalise
32+ delay (3000 );
33+
34+ }
35+
36+ void loop (){
37+
38+ // Read and calculate data from SW01
39+ SW01 .poll ();
40+
41+ // Request to get humidity, temperature and dew point data then store in the variables
42+ pressure = SW01 .getPressure ();
43+
44+
45+ // Display recorded data over the Serial Monitor
46+
47+ OD01 .print (" Pressure:" );
48+ OD01 .print (pressure);
49+ OD01 .println (" Pa " );
50+
51+ delay (5000 );
52+
53+ }
54+
You can’t perform that action at this time.
0 commit comments