Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Re: Connecting Multiple I2C Sensors on: February 20, 2013, 02:55:51 pm
That worked out perfectly!  Thanks for the advice!
2  Using Arduino / Networking, Protocols, and Devices / Re: Connecting Multiple I2C Sensors on: February 20, 2013, 12:53:30 pm
Code:
if (millis() % 6000 == 0)
{


Expecting the value of millis to be exactly divisible by 6000 is pretty unreasonable. All your Serial.print()s hide behind this unreasonable assumption.

That is exactly what it was.  How would you recommend taking a reading from my sensors every 5 min with out using a delay?
3  Using Arduino / Networking, Protocols, and Devices / Re: Connecting Multiple I2C Sensors on: February 20, 2013, 11:42:22 am
The problem I am having is what I upload the program, and start my serial monitor nothing comes up... nothing "prints".  Is it something with my if statement that drives the print process?
4  Using Arduino / Networking, Protocols, and Devices / Re: Connecting Multiple I2C Sensors on: February 20, 2013, 10:15:52 am
The libraries you are using seem to know the correct addresses to talk to.

Everything seemed to upload properly.  Does this mean it is good to go?

If so...

Is there a reason why my Serial.print isnt working?
5  Using Arduino / Networking, Protocols, and Devices / Connecting Multiple I2C Sensors on: February 19, 2013, 10:38:02 pm
Hello All,

I'm kinda new to the Arduino world.  I have an Arduino Uno R3.  I have kinda figured out the I2C communication thing.  My current problem is how do I connect multiple I2c sensors to the one controller?  

I have a RTC module, and a BMP085.  Do I need to set my uno as the master, and the devices as slaves? Any help would be great!!

Thank you All

Code:
// REV 1.1.0
// 02-19-2013

// Date and time functions using just software, based on millis() & timer

#include <Wire.h>
#include <RTClib.h>
#include <SimpleTimer.h>
#include <Adafruit_BMP085.h>

const int temp = 0;
const int LED = 13;
const float wind = 1;
RTC_Millis RTC;
Adafruit_BMP085 bmp;


void setup ()
{
  
    Serial.begin(9600);
    pinMode(LED,OUTPUT);
    RTC.begin(DateTime(__DATE__, __TIME__)); //sets the RTC to the date & time this sketch was compiled
    bmp.begin();
    
}

void loop ()
{
    /*  noInterrupts();
        if(millis() % 1200000 == 0)
         RTC.adjust(DateTime(__DATE__, __TIME__));
      interrupts();
  */
  float volt, degC, MPH;
  int room, deadband, setpoint, degF, dispHour, dispDOW, F, Pressure;
  
  MPH = getVoltage(wind);
  
  volt = getVoltage(temp);
  degC = (volt - .5) * 100.0;
  degF = degC * (9.0/5.0) + 32.0;
  
  room = 72;
  deadband = 3;
  setpoint = room - deadband;
  
  F = bmp.readTemperature() * (9.0/5.0) + 32.0;
  
  Pressure = bmp.readPressure() * 0.000295;
  
  
    DateTime now = RTC.now();
      dispHour = now.hour();
      dispDOW = now.dayOfWeek();
          
      // print readings every 5 min.
if (millis() % 6000 == 0)
{
     // RTD Day Of the Week
    if(dispDOW == 0)
      Serial.print("SUN: ");
    if(dispDOW == 1)
      Serial.print("MON: ");
    if(dispDOW == 2)
      Serial.print("TUE: ");
    if(dispDOW == 3)
      Serial.print("WED: ");
    if(dispDOW == 4)
      Serial.print("THU: ");
    if(dispDOW == 5)
      Serial.print("FRI: ");
    if(dispDOW == 6)
      Serial.print("SAT: ");
      
      // RTD Date format D/M/TYYY    
    Serial.print(now.month());
    Serial.print('/');
    Serial.print(now.day());
    Serial.print('/');
    Serial.print(now.year() - 2000);
    Serial.print(' ');
  
     // RTC Time in 12 hour format with AM/PM
    Serial.print((dispHour > 12) ? dispHour - 12 : ((dispHour == 12) ? 12 : dispHour));
    Serial.print(":");
    if (now.minute() < 10)
         Serial.print("0");
    Serial.print(now.minute());
    Serial.print(':');
    if (now.second() < 10)
         Serial.print ("0");
    Serial.print(now.second());
    Serial.print((dispHour<12) ? " AM" : " PM");
    Serial.println();
    
              // Temp Display in Deg F
      Serial.print("  Temp: "); // Temp will be in a format of
      Serial.println(degF);         // ##.#
      
             // BMP Temp Display in Deg F
          Serial.print("    BMP_Temp: ");
          Serial.println(F);    
          
            // Pressure Displayed in inHG
            Serial.print("    ATM Pressure: ");
            Serial.println(Pressure);
            
            // Wind Speed
              Serial.print(  "MPH: ");
              Serial.println(MPH);
      
}
   delay(100);   // next step try to use the RTC to take readings every 5 min.

  
  
    
    if (degF <= setpoint)
  {
    digitalWrite(LED,HIGH);
  }
    if (degF > room)
  {
    digitalWrite(LED,LOW);
  }
  
}

float getVoltage(int pin1)
{
  return (analogRead(pin1) * 0.004882814);
}

float getVoltage(float pin2)
{
   return (analogRead(pin2));
}


Above is my current code for the weather station I am working on.  No advice is bad advice!!

6  Using Arduino / Project Guidance / Re: Using a RTC to take readings on: February 09, 2013, 08:52:22 am
...just ask the RTC what time it is whenever millis tells you it's time to read your sensors.

Code:
// something like below
if (millis() % 6000 == 0)
{
Serial.print (weather data)
}

That worked out perfectly! it only displays the time temp and so on once! and it prints it every 5 min!!


Thank you all for your great ideas! I learned a lot!
7  Using Arduino / Project Guidance / Re: Using a RTC to take readings on: February 08, 2013, 09:18:47 pm
However a word of caution. When the time is (say) 10:05, then the "5 minutes are up" will happen thousands of times (until it becomes 10:06). You also need to check if the time has changed (eg. if the minute now is different from the minute a moment ago).


Would adding the use of my now.second() take care of thousands of readings?

Code:
if(now.minute() /5 ==0 && now.second() ==0)
8  Using Arduino / Project Guidance / Using a RTC to take readings on: February 08, 2013, 08:41:48 pm
Hello All.

I'm a noob programmer for adruino.  I was able to get my i2c RTC working, commuicating, and printing with a Serial.print().

What I am trying to do with my RTC is take reading from a analog temp sensor, an i2c pressure sensor, an analog wind speed sensor, and an i2c compass module.  (More or less its a home built weather station.)

I want the reading to happen every 5 min.  I dont know if I am even heading in the right direction.  Currently I have:

Code:
if(now.minute() == 5,10,15,20,...,55,00)
{
     // RTD Day Of the Week
    if(dispDOW == 0)
      Serial.print("SUN: ");
    if(dispDOW == 1)
      Serial.print("MON: ");
...
...
              // Temp Display in Deg F
      Serial.print("  Temp:  "); // Temp will be in a format of
      Serial.println(degF);         // ##.#
   
        Serial.println(MPH);
       
}

Any thoughts?!
Pages: [1]