​TheBambooke.com​​​​

Nusquam valens est securus

​Bambooke Wx Station

​​Phase One

My background is electrical engineering. However, as a management analyst, it is not easy for my professional development to remain current. So this weather station is my first significant attempt to develop and maintain technical skills. 

​I quickly concluded that the effort should be arduuino microprocessor based with maximum use of Adafruit sensors. I find that Adafruit sensors include libraries that are easy to use and minimizes my weakness of software coding. 

​The hardware for this project is Arduino Uno, ethernet shield, Adafruit prototype shield, Adafruit BME280 sensor, Adafruit AM2315, water sprinkler box  which includes A/C power and ethernet switch, metal tiki torch using red/green led to indicate sleepmode status and bird feeder to house the sensors. The ethernet shield goes thru two ethernet switches before connecting to a Comcast cable modem. The Adruino Uno sleeps (goes into low power mode)  for near 10 minutes then wakes up for approximately 90 seconds to transmit sensor data to Thingspeak.com . I authored the software sketch excluding the watch dog/sleep related portion which was way above my head and developed by Craig Turner  of http://gampageek.blogspot.co.uk .

​Thingspeak.com was chosen to post the live sensor data.  One can find the live sensor data by clinking on the below button.  If you receive a MatLab code error for any of the graphs, refresh the web page. I found the forum to be of great value in resolving my "duh" moments.

Build and installation ​images are below the code.
Live Data
Code

//Reads BME280 and AM2315 sensor data and writes data to the channel fields 1-5 on ThingSpeak.com every XX seconds.
#include
#include
#include "ThingSpeak.h"
#include
#include
#include
#include
#include
#define ledPINgrn 8 //on when reading or sending data
#define ledPINred 6// on when sleeping
Adafruit_AM2315 am2315;
Adafruit_BME280 bme;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
float BME280Temp=0;
float BME280Humi=0;
float Atemp=0;
float Ahumi=0;
float BME280StationPressureMillibars=0;
float BME280EquivSeaLevelPressureMillibars=0;
float BME280Press=0;
int count=0;
/*  Setup For WatchDog and Sleep ================================*/
byte old_ADCSRA;
//watchdog interrupt
ISR(WDT_vect) /*The WDT_vect identifies the watchdog timer's interrupt vector as the identifier that should be used at start of the Interrupt Service Routine(ISR).
Other vector options are  .... */
{
 wdt_disable();// disable watchdog
}
/* Setup for ThingSpeak.com ===========================*/
unsigned long myChannelNumber = 227475;
const char * myWriteAPIKey = "ABZEP8GLZV7VEL7I";
void setup() {
EthernetClient client;
Ethernet.begin(mac);
ThingSpeak.begin(client);
/*Setup for LEDs, heat strip and fan ===================*/
pinMode(Fan,OUTPUT);    /* Prepares Arduino to enable 5 V fan drawing near 300 ma current. Thus need
for power booster shield.  */
pinMode(Heater,OUTPUT); // Prepares Arduino to enable AC power/relay that enables heating strip.
pinMode(ledPINred,OUTPUT); //Red LED in backyard metal "tiki torch-like" item.
pinMode(ledPINgrn,OUTPUT); //Green LED in backyard metal "tiki torch-like" item.
digitalWrite(ledPINred,LOW);
digitalWrite(ledPINgrn,LOW);
Serial.flush();
Serial.begin(19200); 
delay(1000);
 /*Are sensors operating properly? ====================*/
Serial.println("BME280 Test!");
if(!bme.begin()) {
  Serial.println("Could not find a valid BME280 sensor!");
while(1);
}
Serial.flush();
Serial.println("AM2315 Test!");
if(!am2315.begin()) {
  Serial.println("Could not find a valid AM2315 sensor!");
while(1);
Serial.flush();
}
}
void loop() {
Serial.println(" ");
/* Watchdog timer maximum sleep period is 8 second interval, therefore just before 8 seconds is reached,
the Watchdog timer is reset via myLoop, until sleep interval is reached. Then sensor data gathered/sent
to ThingSpeak.com for display.*/
old_ADCSRA=ADCSRA; // save old status of ADC
 //============SLEEP ROUTINES===========
for(int myLoop=0;myLoop<64;myLoop++) /*SLEEP-LOOP loop around and give sleep period of
32 = 300 sec(5 minutes), 64 = 600 sec(10 minutes), 4 = 37 sec(.63 minutes) */
{
digitalWrite(ledPINred,HIGH);//led on when sleep
//disable ADC
ADCSRA=0;
//clear various reset flags
MCUSR=0;
//allow changes, disable reset
WDTCSR=_BV(WDCE)|_BV(WDE);
//set interrupt mode and an interval
WDTCSR=_BV(WDIE)|_BV(WDP3)|_BV(WDP0); //set WDIE, and 8 seconds countdown
wdt_reset(); //kick the dog
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
//turn off brown-out enable in software
MCUCR=_BV(BODS)|_BV(BODSE);
MCUCR=_BV(BODS);
sleep_cpu(); //pleasant dreams :)
}
// cancel sleep as a precaution
sleep_disable();
digitalWrite(ledPINred,LOW); //red led off when not sleeping
//+++++++++++WAKE and CALL SERIAL MONITOR+++++++++++
ADCSRA=old_ADCSRA; //Enable ADC. Need to enable so ADC can get sensor data.
SleepStatus(); //Arduino now awake so showing related message on serial monitor and turns green LED on.
 
 
  delay(16000);
  BME280Temp=(bme.readTemperature()*1.8+32);
  ThingSpeak.writeField(myChannelNumber,1,BME280Temp,myWriteAPIKey);
  delay(16000);
  Atemp=(am2315.readTemperature()*1.8+32);
  ThingSpeak.writeField(myChannelNumber,2,Atemp,myWriteAPIKey);
  delay(16000); 
  BME280Humi=(bme.readHumidity());
  ThingSpeak.writeField(myChannelNumber,3,BME280Humi,myWriteAPIKey);
  delay(16000);
  Ahumi=(am2315.readHumidity());
  ThingSpeak.writeField(myChannelNumber,4,Ahumi,myWriteAPIKey);
  delay(16000);
  BME280StationPressureMillibars=(bme.readPressure()/100);
  BME280EquivSeaLevelPressureMillibars=(BME280StationPressureMillibars+(16/9.2));
  BME280Press=(BME280EquivSeaLevelPressureMillibars*0.02953);
  ThingSpeak.writeField(myChannelNumber,5,BME280Press,myWriteAPIKey);
  digitalWrite(ledPINgrn,LOW); /*Indicates completion of obtaining sensor data and sending data to ThingSpeak.com for display  .*/
 
  Serial.print(BME280Temp,0);
  Serial.print(" F  ");
  Serial.print(Atemp,0);
  Serial.print(" F  ");
  Serial.print(BME280Humi,0);
  Serial.print("%  ");
  Serial.print(Ahumi,0);
  Serial.print("%  ");
  Serial.print(BME280Press,2);
  Serial.println(" InHg");

}
void SleepStatus(){
count=count+1;
Serial.println("");
digitalWrite(ledPINgrn,HIGH);//Green LED on when Arduino awake.
Serial.print("Count ");
Serial.println(count); // printing # of sleep/awake loops
Serial.println("Arduino CPU slept for 10 minutes then woke up to print this message. Approx 122 seconds will be used to send data");
Serial.println();
 
}
Example of Thingspeak.com Display