Show Posts
Pages: 1 [2] 3 4 ... 11
16  Community / Exhibition / Gallery / Re: weatherstation v1.0 on: June 26, 2013, 03:46:54 pm
thank you, still working on it. id really like to make this a function (heat index) but i keep getting errors.

Code:
HI = -42.379 + 2.04901523*T + 10.14333127*RH - .22475541*T*RH -
    .00683783*T*T - .05481717*RH*RH + .00122874*T*T*RH + .00085282*T*RH*RH -
    .00000199*T*T*RH*RH;
17  Community / Exhibition / Gallery / weatherstation v5.0 on: June 24, 2013, 01:00:34 pm
edit, its now sending floats, which would be the correct way. image update. shutdown adc to try to get more bat life and added bmp085 so all sensors now digital. updated code below.

im sure theres tons of these around, and im really interested in weather stations since taking these readings would be the first step in learning how to control the weather and take over the world. i wish i knew how to optimize code, thats my next step. this station sits outside and uses a dht11 and a mpx4115 pressure sensor and transmits data wireless using the rf24 library. it also writes the data to an eeprom to dump later for spreadsheet usage. i get temperature, humidity, barometer, heat index and dew point. ive put together a serial reader using micro visual studio as a finishing touch for reading out on a laptop. i had a lot of fun making this and now im gonna see how it can be better, especially since i got my 18b20 in the mail today. suggestions appreciated. code below.

im running this entire project off a cellphone battery using an mcp1253 boost/buck ic, at 3.3v, with the atmega328p at 8Mhz ext crystal @ 3.3v.
board file for atmega
Code:
##############################################################

pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328

pro328.upload.protocol=stk500
pro328.upload.maximum_size=32256
pro328.upload.speed=57600

pro328.bootloader.low_fuses=0xFF
pro328.bootloader.high_fuses=0xDE
pro328.bootloader.extended_fuses=0x05
#pro328.bootloader.path=optiboot
#pro328.bootloader.file=optiboot_atmega328_pro_8MHz.hex
pro328.bootloader.path=atmega
pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
pro328.bootloader.unlock_bits=0x3F
pro328.bootloader.lock_bits=0x0F

pro328.build.mcu=atmega328p
pro328.build.f_cpu=8000000L
pro328.build.core=arduino


here is the clock im using, totally compatible with rtc library, sends interupt every minute to wake the system, takes samples, then goes back to sleep for a minute.
http://www.intersil.com/content/dam/Intersil/documents/fn67/fn6755.pdf

Code:
//WeatherStation v4. Lou Rose. 07/04/2013.
/* 07/04/2013: added typedef struct to send floating values
 added support for BMP085 to replace MPX4115 pressure sensor to eliminate
 ADC.
 has support for onewire DS18B20.
 License info below. */
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
//#include <OneWire.h>
//#include <DallasTemperature.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/power.h>
#include <Wire.h>
#include <RTClib.h>
#include <dht.h>
#include <Adafruit_BMP085.h>
//#define ONE_WIRE_BUS 7
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
//variables
typedef struct{
  float T; //temperature
  float RH;
  float HI;
  float DP;
  float pressure;
}
payload;
payload ard1;

//int payload[5];

//======================================================
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
//OneWire oneWire(ONE_WIRE_BUS);
RTC_DS1307 RTC;
Adafruit_BMP085 bmp;
dht DHT;
#define DHTPIN 8
#define DHTTYPE DHT22
// Pass our oneWire reference to Dallas Temperature.
//DallasTemperature sensors(&oneWire);
//DeviceAddress insideThermometer;
//======================================================
void setup(void)
{
  ADCSRA = 0; //disable adc: so it can
  PRR = 0x01; // shutdown  
  radio.begin();
  radio.openWritingPipe(pipe);
  // start serial port
  Serial.begin(9600);
  bmp.begin(); //Serial.print(bmp.readPressure()); pa
  Wire.begin();
  RTC.begin();
  Wire.beginTransmission(0x68); //config register
  Wire.write(0x0E);
  Wire.write(0x1e);
  Wire.endTransmission();
  Wire.beginTransmission(0x68);
  Wire.write(0x0b); //alarm2 addr
  Wire.write(0x80); //data to 0x0b
  Wire.write(0x80); //data to 0x0c
  Wire.write(0x80); //data to 0x0d
  Wire.endTransmission();

  clearAlarm();
  delay(100);
  //  sensors.begin(); // one wire code
  //  sensors.isParasitePowerMode();
  //    if (!sensors.getAddress(insideThermometer, 0))  
  //    {
  //      Serial.println( "Unable to find address for Device 0" );
  //    }

  //  Serial.print("Device 0 Address: ");
  //  printAddress(insideThermometer);
  //  Serial.println();
  //  sensors.setResolution(insideThermometer,12);

  //  Serial.print(sensors.getResolution(insideThermometer),DEC);
  //  Serial.println(" bit-resolution");

  pinMode(2, INPUT);
  digitalWrite(2,HIGH);
  attachInterrupt(0, alarmTriggered, FALLING);
  interrupts();
  Serial.println( "Mission in one minute" );
  delay(2000);
}

void loop(void)
{
  clearAlarm();
  getSample();
  enterSleep();
}

void getSample(){
  int chk = DHT.read22(DHTPIN);
  //  sensors.requestTemperatures(); // Send the command to get temperatures
  //  Serial.print("Temperature for Device 1 is: ");
  //
  //  T=(sensors.getTempF(insideThermometer));
  //  Serial.println(T);
  ard1.T=(Fahrenheit(DHT.temperature));
  ard1.pressure=(bmp.readPressure()*.0002961);
  //  ard1.pressure=analogRead(0);
  //  ard1.pressure=analogRead(0);
  //  ard1.pressure = ((ard1.pressure * .0049 / 5) + .095) / .009;
  //  ard1.pressure = ard1.pressure *.2952997;

  ard1.RH=DHT.humidity;
  //Serial.println((float)DHT.humidity, 2);
  ard1.DP=Fahrenheit(dewPoint(DHT.temperature, DHT.humidity));
  //Serial.println(DP);
  ard1.HI=heatIndex(ard1.T, ard1.RH);
  //Serial.println(HI);

  radio.write( &ard1, sizeof(ard1) );



}

double Fahrenheit(double celsius)
{
  return 1.8 * celsius + 32;
}


//void printAddress(DeviceAddress deviceAddress)
//{
//  for (uint8_t i = 0; i < 8; i++)
//  {
//    // zero pad the address if necessary
//    if (deviceAddress[i] < 16) Serial.print("0");
//    Serial.print(deviceAddress[i], HEX);
//  }
//
//}

void enterSleep(void)
{
  //  Serial.println("sleeping...");
  /* Setup pin2 as an interrupt and attach handler. */

  attachInterrupt(0, alarmTriggered, LOW);
  delay(100);

  set_sleep_mode(SLEEP_MODE_PWR_DOWN);

  sleep_enable();

  sleep_cpu();

  /* The program will continue from here. */

  /* First thing to do is disable sleep. */
  sleep_disable();

}

void alarmTriggered()
{
  //  Serial.println("** ALARM WENT OFF! **");
  detachInterrupt(0);
}
void clearAlarm(){
  Wire.beginTransmission(0x68); // clear alarm af2 bit
  Wire.write(0x0F); //addr
  Wire.write(0x80);
  Wire.endTransmission();
}

// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm
double dewPoint(double celsius, double humidity)
{
  double A0= 373.15/(273.15 + celsius);
  double SUM = -7.90298 * (A0-1);
  SUM += 5.02808 * log10(A0);
  SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
  SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
  SUM += log10(1013.246);
  double VP = pow(10, SUM-3) * humidity;
  double T = log(VP/0.61078);   // temp var
  return (241.88 * T) / (17.558-T);
}

//heat index function
//reference http://www.hpc.ncep.noaa.gov/htl/heatindex_equation.shtml
double heatIndex(double T, double RH)
{
  double result;
  result= -42.379 + 2.04901523*T + 10.14333127*RH - .22475541*T*RH -
    .00683783*T*T - .05481717*RH*RH + .00122874*T*T*RH + .00085282*T*RH*RH -
    .00000199*T*T*RH*RH;
  return result;
}

/*
<Weather Station>
  <2013>  <L.C. ROSE>
 
 
 */



18  Using Arduino / Project Guidance / Re: 16mhz @ 3.3v on: June 23, 2013, 11:40:13 am
You may want to check the difference between mHz and MHz, lest you be disappointed with your device's performance.

sorry bout that, i did not know. thx for the heads up.
19  Community / Products and Services / DS1990A serial id i-button for trade on: June 22, 2013, 10:02:04 pm
i got a bunch of these, brand new, im not gonna use anymore. we originally got them for an access control project. they come in fob's. datasheet here http://datasheets.maximintegrated.com/en/ds/DS1990A.pdf. im looking for temperature i buttons specifically, or i2c rtc's with alarms, or any weather type sensor ie temperature, humidity. i also have the recepticles for these that work well with arduino's. recepticle has two wires, gnd and onewire.
20  Using Arduino / Project Guidance / Re: 16mhz @ 3.3v on: June 22, 2013, 09:57:25 pm
ok thanks guys, ill keep that in mind. i however did get an 8mhz ext crystal board file from someone here on the forums so ive been using that, but im gonna experiment with 16Mhz @ 3.3, i will keep in mind all your advice.
21  Using Arduino / Project Guidance / Re: 16mhz @ 3.3v on: June 18, 2013, 06:10:17 pm
thank you very much gents  smiley-wink

cool board!
22  Using Arduino / Project Guidance / 16Mhz @ 3.3v on: June 18, 2013, 04:13:53 pm
hi quick question, can i run on a breadboard atmega328p w/ ext 16Mhz at 3.3v? with the uno board file loaded?
23  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 16, 2013, 10:42:00 pm
just fyi i got it working correctly using the normal rtc library everyone uses for the 1307 (ie normal version since the other lib only worked on 1.0.2 and below) anyway, fires every second, clears alarm second later. thanks to supremo for figuring this out for me.

Code:
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;

void setup () {
  //  pinMode(16, OUTPUT);
  //  digitalWrite(16, LOW);
  //  pinMode(17, OUTPUT);
  //  digitalWrite(17, HIGH);//use this for piggyback

  Serial.begin(9600);
  Wire.begin();
  RTC.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  RTC.adjust(DateTime(__DATE__, __TIME__));



  Wire.beginTransmission(0x68);     //supremos code
  Wire.write(0x0b); //alarm2 addr   // writes 0x80 to 3 registers which sets alarm 2 fire off when seconds register == 00 ie once a minute
  Wire.write(0x80); //data to 0x0b
  Wire.write(0x80); //data to 0x0c
  Wire.write(0x80); //data to 0x0d
  Wire.endTransmission();

}

void loop () {
  Wire.beginTransmission(0x68);
  Wire.write(0x0f); //status reg addr
  Wire.endTransmission();
  Wire.requestFrom(0x68,1); // read status register to see if alarm fired
  byte statusBuffer=Wire.read();
  byte y = bitRead(statusBuffer,1); //af2 bit indicates alarm2 fired if ==1
  if (y==1)
  {
    Wire.beginTransmission(0x68); // clear alarm af2 bit
    Wire.write(0x0F); //status register normally B10000000, only bits 0 and 1 can be written to, only with a 0, to clr alarms
    Wire.write(0x80);
    Wire.endTransmission();
  }
  gettime();
  delay(1000);

}

void gettime(){
  DateTime now = RTC.now();
  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(' ');
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();

}

24  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 15, 2013, 02:07:16 pm
well, its just like you suspected. works great with your code smiley, on a side note however, with this library, physical int2pin is pin 1 and pin1 is 2. they are reversed lol. but all is well and im totally happy now. now i can incorporate this piece into my low voltage projects (working on weatherstation). much thanks supremo!!  smiley-grin
25  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 15, 2013, 12:46:31 pm
ok great thx. i got it working using an rtclib https://github.com/MrAlvin/RTClib here, based on your suggestion, i used the part of the library for the dsDS3231. alarm fired. now just gotta figure out how to set for every minute as the examples set for a specific time, but ive made tons of progress thanks to you. appreciate it much supremo.
26  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 15, 2013, 11:30:50 am
thank you very much, sweet, im gonna set it up in a minute and experiment some more. oh also i meant someone more experienced then me, not you supremo, i just re-read that and it didnt sound right, sorry. also, one more thing, im running 3.3 v for supply, im not experienced enough with datasheets, is sda and scl 5 v tolerant?
27  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 15, 2013, 10:14:37 am
ya im still doing something wrong. can someone more experienced pick up one of these from intersil, for free, just sample one out, their soic8. i cant figure this out.
28  Using Arduino / Networking, Protocols, and Devices / i2c rtc writing to addresses need help on: June 14, 2013, 08:32:35 pm
hi, need help please confusion setting in, chip in particular is this ISL12057 @ http://www.intersil.com/content/dam/Intersil/documents/fn67/fn6755.pdf. the rtc itself works fine with the rtc library for the 1307, got the time set np, im trying to set the alarm (int2) for every minute. the datasheet is clear enough but how would you write this?
like this im getting nothing. how would i write to the config register? thanks in advance.
Code:
Wire.beginTransmission(0x68);
Wire.write(0x0B>>8);
Wire.write(0x0B & 0xFF);
Wire.write(0x80);
Wire.endTransmission();
with 0Bh being the addr and 80h being the data.

or
Code:
Wire.beginTransmission(0x68);
Wire.write(0x0b); //addr
Wire.write(0x80); //data
Wire.write(0x0c); //addr
Wire.write(0x80); //data
Wire.write(0x0d); //addr
Wire.write(0x80); //data
Wire.endTransmission();

im probably not initializing them correctly in the config register, any help appreciated.
29  Using Arduino / Programming Questions / Re: Controler hang up then Error:avrdude: stk500_recv(): programmer is not respondin on: June 03, 2013, 07:50:41 pm
i was using a breadboard, i ended up bending my atmega328p pins a bit out, now it works good. let me know if you find a solution for the nano. someone recommended installing a separate arduino environment just for uploading sketches, i forgot where is seen it (its on this forum) but a lot off ppl said that worked for them. im sorry i couldnt have been more help.
30  Using Arduino / Sensors / Re: lm34 on a breadboard, strange stuff on: June 03, 2013, 05:00:27 pm
Quote
I don't understand how you have connected it.
It should be like this:
Both GND to ground (pin 8 and pin 22).
Vcc and Avcc to 5V (pin 7 and pin 20).
100nF to GND and 5V.
Vcc to power the LM34, ground to GND, output to an analog input.

thats how i got it connected.

Quote
I've never ever met 5.0V somewhere on a board. The USB stuff is 4.6-4.9V, standard voltage reglers are 5V +/- 0.2V, every USB port gives different voltage. LM34 operates from 5V min, so a small drop may affect your reading.

im begining to see this.

Quote
You could avoid all this with a digital temperature sensor.

since im looking for somewhat accuracy, i just ordered a ds18b20. lol.

thank you for your input folks, ive learned from this experience smiley
Pages: 1 [2] 3 4 ... 11