Skip to content

Commit 48f2ed2

Browse files
committed
Merge branch 'V12'
2 parents 5ac3f39 + 67fed2a commit 48f2ed2

File tree

12 files changed

+13254
-8956
lines changed

12 files changed

+13254
-8956
lines changed

.gitignore

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
#################
2+
## SparkFun Useful stuff
3+
#################
4+
5+
## AVR Development
6+
*.eep
7+
*.elf
8+
*.lst
9+
*.lss
10+
*.sym
11+
*.d
12+
*.o
13+
*.srec
14+
*.map
15+
16+
## Notepad++ backup files
17+
*.bak
18+
19+
## BOM files
20+
*bom*
21+
122
#################
223
## Eclipse
324
#################
@@ -33,9 +54,11 @@ local.properties
3354
## Eagle
3455
#############
3556

36-
# Ignore the board and schematic backup files
57+
# Ignore the board and schematic backup files and lock files
3758
*.b#?
3859
*.s#?
60+
*.l#?
61+
*.lck
3962

4063

4164
#################
@@ -135,6 +158,21 @@ Thumbs.db
135158
Desktop.ini
136159

137160

161+
#############
162+
## Mac OS
163+
#############
164+
165+
.DS_Store
166+
167+
168+
#############
169+
## Linux
170+
#############
171+
172+
# backup files (*.bak on Win)
173+
*~
174+
175+
138176
#############
139177
## Python
140178
#############
@@ -166,6 +204,3 @@ pip-log.txt
166204

167205
#Mr Developer
168206
.mr.developer.cfg
169-
170-
# Mac crap
171-
.DS_Store

Production/13585_Weather Shield_V12_Panel.brd

Lines changed: 7577 additions & 0 deletions
Large diffs are not rendered by default.

Production/Weather Shield-Panel-v11.brd

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

firmware/Weather_Shield_Basic/Weather_Shield_Basic.ino renamed to firmware/Retired HTU21D code/Weather_Shield_Basic/Weather_Shield_Basic.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void loop()
6969
//Check Humidity Sensor
7070
float humidity = myHumidity.readHumidity();
7171

72-
if (humidity == 998) //Humidty sensor failed to respond
72+
if (humidity == ERROR_I2C_TIMEOUT) //Humidty sensor failed to respond
7373
{
7474
Serial.println("I2C communication to sensors is not working. Check solder connections.");
7575

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
2+
3+
/*
4+
Weather Shield Example
5+
By: Nathan Seidle
6+
SparkFun Electronics
7+
Date: June 10th, 2016
8+
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
9+
10+
This example prints the current humidity, air pressure, temperature and light levels.
11+
12+
The weather shield is capable of a lot. Be sure to checkout the other more advanced examples for creating
13+
your own weather station.
14+
15+
Updated by Joel Bartlett
16+
03/02/2017
17+
Removed HTU21D code and replaced with Si7021
18+
19+
*/
20+
21+
#include <Wire.h> //I2C needed for sensors
22+
#include "SparkFunMPL3115A2.h" //Pressure sensor - Search "SparkFun MPL3115" and install from Library Manager
23+
#include "SparkFun_Si7021_Breakout_Library.h" //Humidity sensor - Search "SparkFun Si7021" and install from Library Manager
24+
25+
MPL3115A2 myPressure; //Create an instance of the pressure sensor
26+
Weather myHumidity;//Create an instance of the humidity sensor
27+
28+
//Hardware pin definitions
29+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
30+
const byte STAT_BLUE = 7;
31+
const byte STAT_GREEN = 8;
32+
33+
const byte REFERENCE_3V3 = A3;
34+
const byte LIGHT = A1;
35+
const byte BATT = A2;
36+
37+
//Global Variables
38+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
39+
long lastSecond; //The millis counter to see when a second rolls by
40+
41+
void setup()
42+
{
43+
Serial.begin(9600);
44+
Serial.println("Weather Shield Example");
45+
46+
pinMode(STAT_BLUE, OUTPUT); //Status LED Blue
47+
pinMode(STAT_GREEN, OUTPUT); //Status LED Green
48+
49+
pinMode(REFERENCE_3V3, INPUT);
50+
pinMode(LIGHT, INPUT);
51+
52+
//Configure the pressure sensor
53+
myPressure.begin(); // Get sensor online
54+
myPressure.setModeBarometer(); // Measure pressure in Pascals from 20 to 110 kPa
55+
myPressure.setOversampleRate(7); // Set Oversample to the recommended 128
56+
myPressure.enableEventFlags(); // Enable all three pressure and temp event flags
57+
58+
//Configure the humidity sensor
59+
myHumidity.begin();
60+
61+
lastSecond = millis();
62+
63+
Serial.println("Weather Shield online!");
64+
}
65+
66+
void loop()
67+
{
68+
//Print readings every second
69+
if (millis() - lastSecond >= 1000)
70+
{
71+
digitalWrite(STAT_BLUE, HIGH); //Blink stat LED
72+
73+
lastSecond += 1000;
74+
75+
//Check Humidity Sensor
76+
float humidity = myHumidity.getRH();
77+
78+
if (humidity == 998) //Humidty sensor failed to respond
79+
{
80+
Serial.println("I2C communication to sensors is not working. Check solder connections.");
81+
82+
//Try re-initializing the I2C comm and the sensors
83+
myPressure.begin();
84+
myPressure.setModeBarometer();
85+
myPressure.setOversampleRate(7);
86+
myPressure.enableEventFlags();
87+
myHumidity.begin();
88+
}
89+
else
90+
{
91+
Serial.print("Humidity = ");
92+
Serial.print(humidity);
93+
Serial.print("%,");
94+
float temp_h = myHumidity.getTempF();
95+
Serial.print(" temp_h = ");
96+
Serial.print(temp_h, 2);
97+
Serial.print("F,");
98+
99+
//Check Pressure Sensor
100+
float pressure = myPressure.readPressure();
101+
Serial.print(" Pressure = ");
102+
Serial.print(pressure);
103+
Serial.print("Pa,");
104+
105+
//Check tempf from pressure sensor
106+
float tempf = myPressure.readTempF();
107+
Serial.print(" temp_p = ");
108+
Serial.print(tempf, 2);
109+
Serial.print("F,");
110+
111+
//Check light sensor
112+
float light_lvl = get_light_level();
113+
Serial.print(" light_lvl = ");
114+
Serial.print(light_lvl);
115+
Serial.print("V,");
116+
117+
//Check batt level
118+
float batt_lvl = get_battery_level();
119+
Serial.print(" VinPin = ");
120+
Serial.print(batt_lvl);
121+
Serial.print("V");
122+
123+
Serial.println();
124+
}
125+
126+
digitalWrite(STAT_BLUE, LOW); //Turn off stat LED
127+
}
128+
129+
delay(100);
130+
}
131+
132+
//Returns the voltage of the light sensor based on the 3.3V rail
133+
//This allows us to ignore what VCC might be (an Arduino plugged into USB has VCC of 4.5 to 5.2V)
134+
float get_light_level()
135+
{
136+
float operatingVoltage = analogRead(REFERENCE_3V3);
137+
138+
float lightSensor = analogRead(LIGHT);
139+
140+
operatingVoltage = 3.3 / operatingVoltage; //The reference voltage is 3.3V
141+
142+
lightSensor = operatingVoltage * lightSensor;
143+
144+
return (lightSensor);
145+
}
146+
147+
//Returns the voltage of the raw pin based on the 3.3V rail
148+
//This allows us to ignore what VCC might be (an Arduino plugged into USB has VCC of 4.5 to 5.2V)
149+
//Battery level is connected to the RAW pin on Arduino and is fed through two 5% resistors:
150+
//3.9K on the high side (R1), and 1K on the low side (R2)
151+
float get_battery_level()
152+
{
153+
float operatingVoltage = analogRead(REFERENCE_3V3);
154+
155+
float rawVoltage = analogRead(BATT);
156+
157+
operatingVoltage = 3.30 / operatingVoltage; //The reference voltage is 3.3V
158+
159+
rawVoltage = operatingVoltage * rawVoltage; //Convert the 0 to 1023 int to actual voltage on BATT pin
160+
161+
rawVoltage *= 4.90; //(3.9k+1k)/1k - multiple BATT voltage by the voltage divider to get actual system voltage
162+
163+
return (rawVoltage);
164+
}
165+

0 commit comments

Comments
 (0)