Devices & Components
Small plastic box with detachable lids (mine has screws)
three AAA rechargeable batteries
1N4004 diode
General Purpose Transistor NPN
HC-12 USB serial module
6V small solar panel
3.3V regulator
a rain sensor
PCB, wires, solder, KF301-2P plug in screw connector, male&female pcb connectors, glue
three AAA battery holder
HC-12 serial communication module
BH1750
Arduino Pro Mini 328 - 5V/16MHz
SparkFun Atmospheric Sensor Breakout - BME280
Hardware & Tools
Soldering iron (generic)
USB to serial FTDI adapter FT232RL
Drill
Screwdrivers
Project description
Code
Github
https://github.com/adafruit/Adafruit_Sensor
Code snippet #22
text
1_id has_rain humidity_10percentile humidity_30percentile humidity_70percentile humidity_90percentile ... temperature_steady_4 temperature_steady_5 temperature_steady_6 temperature_steady_7 temperature_steady_8 ... 204_27_2017_3 0 36.0 44.8 61.0 63.0 ... NaN NaN NaN NaN NaN 304_28_2017_0 0 68.0 70.0 74.0 75.0 ... 14.0 NaN NaN NaN NaN 404_28_2017_1 0 40.0 45.0 63.2 69.0 ... 20.0 14.0 NaN NaN NaN 504_28_2017_2 0 34.0 35.9 40.0 41.0 ... 29.0 20.0 14.0 NaN NaN 604_28_2017_3 0 36.1 40.6 52.0 54.0 ... 19.0 29.0 20.0 14.0 NaN 704_29_2017_0 0 52.0 54.0 56.0 58.0 ... 26.0 19.0 29.0 20.0 14.0 804_29_2017_1 0 39.4 43.2 54.6 57.0 ... 18.0 26.0 19.0 29.0 20.0 904_29_2017_2 1 41.0 42.0 44.2 47.0 ... 28.0 18.0 26.0 19.0 29.0
Code snippet #18
text
1_id date humidity light pressure rain temperature 2 304_27_2017_03_08 2017-04-27 03:08:36 67.0 0.0 1007.0 0.0 11.0 404_27_2017_03_19 2017-04-27 03:19:05 66.0 0.0 1007.0 0.0 11.0 504_27_2017_03_29 2017-04-27 03:29:34 66.0 0.0 1007.0 0.0 11.0
Github
https://github.com/adafruit/Adafruit_BME280_Library
Github
https://github.com/claws/BH1750
Code snippet #10
text
1conda activate weather 2 3python serial_listener.py 4 5# every 10 minutes you should see data from the weather station coming in : 6 7[Sensor: type(temperature), value(14.3)] 8 9[Sensor: type(pressure), value(1056.0)] 10 11...
Github
https://github.com/danionescu0/home-automation
Code snippet #25
text
1from sklearn.preprocessing import StandardScaler 2 3from sklearn.externals import joblib 4 5.. 6 7scaler = StandardScaler() 8 9X = scaler.fit_transform(X) 10 11... 12 13# of course we should be careful to save the scaled model for later reuse 14 15joblib.dump(scaler, 'model_file_name.save')
Github
https://github.com/rocketscream/Low-Power
Code snippet #5
text
1cd weather-predict 2# create anaconda environment named "weather" with python 3.6.2 3conda create --name weather python=3.6.2 4 5# activate environment 6conda activate weather 7 8# install all packages 9pip install -r requirements.txt
Code snippet #26
text
1from keras.models import Sequential 2 3from keras.layers import Dense 4from keras.layers import Dropout 5... 6input_dimensions = X.shape[1] 7optimizer = 'rmsprop' 8dropout = 0.05 9model = Sequential() 10inner_nodes = int(input_dimensions / 2) 11model.add(Dense(inner_nodes, kernel_initializer='uniform', activation='relu', input_dim=input_dimensions)) 12model.add(Dropout(rate=dropout)) 13model.add(Dense(inner_nodes, kernel_initializer='uniform', activation='relu')) 14model.add(Dropout(rate=dropout)) 15model.add(Dense(1, kernel_initializer='uniform', activation='sigmoid')) 16model.compile(optimizer=optimizer, loss='mean_absolute_error', metrics=['accuracy']) 17 18model.fit(X, y, batch_size=1, epochs=50) 19... 20 21# save the model for later use 22classifier.save('file_model_name')
Code snippet #15
text
1{ 2 "_id" : "04_27_2017_06_17", 3 "humidity" : 65, 4 "date" : ISODate("2017-04-27T06:17:18Z"), 5 "pressure" : 1007, 6 "temperature" : 9, 7 "rain" : 0, 8 "light" : 15 9}
Code snippet #23
text
1from sklearn.model_selection import train_test_split 2 3... 4 5main_data, test_data = train_test_split(dataframe, test_size=percent_test_data) 6 7...
Code snippet #6
text
1mongodb = { 2 'host': 'localhost', 3 'port': 27017 4} 5...
Code snippet #16
text
1client = MongoClient(host, port).weather.datapoints 2 3cursor = client.find( 4 {'$and' : [ 5 {'date' : {'$gte' : start_date}}, 6 {'date' : {'$lte' : end_date}} 7 ]} 8 ) 9data = list(cursor) 10..
Code snippet #16
text
1client = MongoClient(host, port).weather.datapoints 2 3cursor = client.find( 4 5 {'$and' : [ 6 {'date' : {'$gte' : start_date}}, 7 8 {'date' : {'$lte' : end_date}} 9 ]} 10 ) 11data 12 = list(cursor) 13..
Github
https://github.com/rocketscream/Low-Power
Code snippet #2
text
1#include "LowPower.h"<br>#include "SoftwareSerial.h" 2#include "Wire.h" 3#include "Adafruit_Sensor.h" 4#include "Adafruit_BME280.h" 5#include "BH1750.h" 6 7SoftwareSerial serialComm(4, 5); // RX, TX 8Adafruit_BME280 bme; 9BH1750 lightMeter; 10const byte rainPin = A0; 11 12byte sensorsCode = 1; 13/** 14 * voltage level that will pun the microcontroller in deep sleep instead of regular sleep 15 */ 16int voltageDeepSleepThreshold = 4200; 17const byte peripherialsPowerPin = 6; 18char buffer[] = {' ',' ',' ',' ',' ',' ',' '}; 19 20struct sensorData 21 { 22 byte humidity; 23 int temperature; 24 byte rain; 25 int pressure; 26 long voltage; 27 int light; 28 }; 29 30sensorData sensors; 31 32void setup() 33{ 34 Serial.begin(9600); 35 serialComm.begin(9600); 36 pinMode(peripherialsPowerPin, OUTPUT); 37 digitalWrite(peripherialsPowerPin, HIGH); 38 delay(500); 39 if (!bme.begin()) { 40 Serial.println("Could not find a valid BME280 sensor, check wiring!"); 41 while (1) { 42 customSleep(100); 43 } 44 } 45 Serial.println("Initialization finished succesfully"); 46 delay(50); 47 digitalWrite(peripherialsPowerPin, HIGH); 48} 49 50void loop() 51{ 52 updateSenzors(); 53 transmitData(); 54 customSleep(75); 55} 56 57void updateSenzors() 58{ 59 bme.begin(); 60 lightMeter.begin(); 61 delay(300); 62 sensors.temperature = bme.readTemperature(); 63 sensors.pressure = bme.readPressure() / 100.0F; 64 sensors.humidity = bme.readHumidity(); 65 sensors.light = lightMeter.readLightLevel(); 66 sensors.voltage = readVcc(); 67 sensors.rain = readRain(); 68} 69 70void transmitData() 71{ 72 emptyIncommingSerialBuffer(); 73 Serial.print("Temp:");Serial.println(sensors.temperature); 74 Serial.print("Humid:");Serial.println(sensors.humidity); 75 Serial.print("Pressure:");Serial.println(sensors.pressure); 76 Serial.print("Light:");Serial.println(sensors.light); 77 Serial.print("Voltage:");Serial.println(sensors.voltage); 78 Serial.print("Rain:");Serial.println(sensors.rain); 79 transmitSenzorData("T", sensors.temperature); 80 transmitSenzorData("H", sensors.humidity); 81 transmitSenzorData("PS", sensors.pressure); 82 transmitSenzorData("L", sensors.light); 83 transmitSenzorData("V", sensors.voltage); 84 transmitSenzorData("R", sensors.rain); 85} 86 87void emptyIncommingSerialBuffer() 88{ 89 while (serialComm.available() > 0) { 90 serialComm.read(); 91 delay(5); 92 } 93} 94 95void transmitSenzorData(String type, int value) 96{ 97 serialComm.print(type); 98 serialComm.print(sensorsCode); 99 serialComm.print(":"); 100 serialComm.print(value); 101 serialComm.print("|"); 102 delay(50); 103} 104 105void customSleep(long eightSecondCycles) 106{ 107 if (sensors.voltage > voltageDeepSleepThreshold) { 108 delay(eightSecondCycles * 8000); 109 return; 110 } 111 digitalWrite(peripherialsPowerPin, LOW); 112 for (int i = 0; i < eightSecondCycles; i++) { 113 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 114 } 115 digitalWrite(peripherialsPowerPin, HIGH); 116 delay(500); 117} 118 119byte readRain() 120{ 121 byte level = analogRead(rainPin); 122 123 return map(level, 0, 1023, 0, 100); 124} 125 126long readVcc() { 127 // Read 1.1V reference against AVcc 128 // set the reference to Vcc and the measurement to the internal 1.1V reference 129 #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 130 ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); 131 #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) 132 ADMUX = _BV(MUX5) | _BV(MUX0); 133 #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) 134 ADMUX = _BV(MUX3) | _BV(MUX2); 135 #else 136 ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); 137 #endif 138 139 delay(2); // Wait for Vref to settle 140 ADCSRA |= _BV(ADSC); // Start conversion 141 while (bit_is_set(ADCSRA,ADSC)); // measuring 142 uint8_t low = ADCL; // must read ADCL first - it then locks ADCH 143 uint8_t high = ADCH; // unlocks both 144 long result = (high<<8) | low; 145 result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000 146 147 return result; // Vcc in millivolts 148}
Code snippet #5
text
1cd weather-predict 2# create anaconda environment named "weather" 3 with python 3.6.2 4conda create --name weather python=3.6.2 5 6# activate 7 environment 8conda activate weather 9 10# install all packages 11pip install 12 -r requirements.txt
Github
https://github.com/danionescu0/home-automation
Code snippet #25
text
1from sklearn.preprocessing import StandardScaler 2 3from sklearn.externals 4 import joblib 5 6.. 7 8scaler = StandardScaler() 9 10X = scaler.fit_transform(X) 11 12 13... 14 15# of course we should be careful to save the scaled model for 16 later reuse 17 18joblib.dump(scaler, 'model_file_name.save')
Code snippet #22
text
1_id has_rain humidity_10percentile humidity_30percentile humidity_70percentile 2 humidity_90percentile ... temperature_steady_4 temperature_steady_5 3 temperature_steady_6 temperature_steady_7 temperature_steady_8 ... 4 504_27_2017_3 6 0 36.0 44.8 61.0 7 63.0 ... NaN NaN 8 NaN NaN NaN 904_28_2017_0 10 0 68.0 70.0 74.0 11 75.0 ... 14.0 NaN 12 NaN NaN NaN 1304_28_2017_1 14 0 40.0 45.0 63.2 15 69.0 ... 20.0 14.0 16 NaN NaN NaN 1704_28_2017_2 18 0 34.0 35.9 40.0 19 41.0 ... 29.0 20.0 20 14.0 NaN NaN 2104_28_2017_3 22 0 36.1 40.6 52.0 23 54.0 ... 19.0 29.0 24 20.0 14.0 NaN 2504_29_2017_0 26 0 52.0 54.0 56.0 27 58.0 ... 26.0 19.0 28 29.0 20.0 14.0 2904_29_2017_1 30 0 39.4 43.2 54.6 31 57.0 ... 18.0 26.0 32 19.0 29.0 20.0 3304_29_2017_2 34 1 41.0 42.0 44.2 35 47.0 ... 28.0 18.0 36 26.0 19.0 29.0
Github
https://github.com/claws/BH1750
Github
https://github.com/rocketscream/Low-Power
Github
https://github.com/adafruit/Adafruit_BME280_Library
Code snippet #18
text
1_id date humidity light pressure rain temperature 2 304_27_2017_03_08 2017-04-27 03:08:36 67.0 0.0 1007.0 0.0 11.0 404_27_2017_03_19 2017-04-27 03:19:05 66.0 0.0 1007.0 0.0 11.0 504_27_2017_03_29 2017-04-27 03:29:34 66.0 0.0 1007.0 0.0 11.0
Code snippet #26
text
1from keras.models import Sequential 2 3from keras.layers import Dense 4from 5 keras.layers import Dropout 6... 7input_dimensions = X.shape[1] 8optimizer 9 = 'rmsprop' 10dropout = 0.05 11model = Sequential() 12inner_nodes = int(input_dimensions 13 / 2) 14model.add(Dense(inner_nodes, kernel_initializer='uniform', activation='relu', 15 input_dim=input_dimensions)) 16model.add(Dropout(rate=dropout)) 17model.add(Dense(inner_nodes, 18 kernel_initializer='uniform', activation='relu')) 19model.add(Dropout(rate=dropout)) 20model.add(Dense(1, 21 kernel_initializer='uniform', activation='sigmoid')) 22model.compile(optimizer=optimizer, 23 loss='mean_absolute_error', metrics=['accuracy']) 24 25model.fit(X, y, batch_size=1, 26 epochs=50) 27... 28 29# save the model for later use 30classifier.save('file_model_name')
Code snippet #10
text
1conda activate weather 2 3python serial_listener.py 4 5# every 6 10 minutes you should see data from the weather station coming in : 7 8[Sensor: 9 type(temperature), value(14.3)] 10 11[Sensor: type(pressure), value(1056.0)] 12 13...
Code snippet #23
text
1from sklearn.model_selection import train_test_split 2 3... 4 5main_data, test_data = train_test_split(dataframe, test_size=percent_test_data) 6 7...
Code snippet #6
text
1mongodb = { 2 'host': 'localhost', 3 'port': 27017 4} 5...
Code snippet #15
text
1{ 2 "_id" : "04_27_2017_06_17", 3 "humidity" : 65, 4 "date" : ISODate("2017-04-27T06:17:18Z"), 5 "pressure" : 1007, 6 "temperature" : 9, 7 "rain" : 0, 8 "light" : 15 9}
Downloadable files
Fritzing schematic
Fritzing schematic
Schematic
Schematic

Weather station arduino sketch
https://github.com/danionescu0/home-automation/tree/master/arduino-sketches/weatherStation
Schematic
Schematic

Weather station arduino sketch
https://github.com/danionescu0/home-automation/tree/master/arduino-sketches/weatherStation
Fritzing schematic
Fritzing schematic
Comments
Only logged in users can leave comments