Hey all, I am brand new to the world of the Arduino, and I am trying to hook up multiple sensors (barometric, temperature, gyroscope, etc.), read them, and report the values via analog ports. I plan on setting up all of them on a Mega 2560, but I do not understand how to use more than one analog setup (clock+data) at a time. I was wondering if I could get some help with the programming and wiring of multiple analog sensors using an Arduino Uno R3. Any help would be appreciated!!
and I am trying to hook up multiple sensors
Links to the sensors?
but I do not understand how to use more than one analog setup (clock+data) at a time.
Are you talking about I2C communication with the sensors, which are not actually analog sensors?
The sensors I'll be using are: BMP-085 altimeter http://dx.com/p/bmp085-altimeter-atmospheric-pressure-module-for-arduino-158610 ADXL-335 accelerometer http://dx.com/p/adxl335-3-axis-accelerometer-module-167074 DHT-22 humidity/temp sensor http://dx.com/p/dht22-2302-digital-temperature-and-humidity-sensor-module-184847 L3G4200D gyroscope http://learn.parallax.com/KickStart/27911 HMC5883L compass http://learn.parallax.com/KickStart/29133 MS5607 altimeter module http://learn.parallax.com/KickStart/29124 I plan on trying to write all this data to a MicroSD via a Wireless shield http://arduino.cc/en/Main/ArduinoWirelessShield
It is I2C communication-I assumed that it was analog (again, brand new to all this). I just do not understand how the individual pins are assigned in the programming language.
Most of your sensors are I2C. The I2C lines of all these can be connected together. Don't forget you'll need pull-up resistors. Your ADXL335 accelerometer is not I2C, but you can get ones that are. Here's one from Sparkfun http://www.sparkfun.com/products/10955. If you stick with the ADXL335, you'll need to connect the xyz pins to analog pins on the Mega. I2C is not analog but on some Arduino's it is connected to analog pins. On the Mega you'll use pins 20 & 21 for I2C. Wire.h library is used to take care of the I2C communication. The DHT-22 is not I2C, so this is just connected to a separate digital input pin. Since you are new to this I would suggest hooking up only one sensor, writing a test program to get it working. Then doing the same thing for every sensor. Then try combining them into one big program. There's lots of I2C examples around. Here's an article that tells you more about how I2C works http://www.uchobby.com/index.php/2008/09/16/introduction-to-i2c/
Thank you-I will. I'm waiting for all the DX.com items to come in via mail. I have had issues with the Parallax sensors-they work wonderfully individually with the programs given by the manufacturers (see my previous post for the links), but I do not see how to combine them because I do not see how the individual pins are assigned: for example, "const int xPin = 0;const int yPin = 1; const int zPin = 2" for the ADXL335 axis is fairly easy to understand while I do not see pin assignments for the L3G4200L or any Parallax sensor. Also, I've look all over the internet for a wiring scheme/programming examples of how hook up the ADXL335 to communicate in digital-haven't found any yet....any ideas? Thanks again!!
For you sensors that use I2C all you'll see for pins is SDA and SCL. All the SDA pins should be connected together and they will go to pin 20 on the Mega. Similarly, all the SCL pins go to pin 21 on the Mega. You can see the Mega pin assignments here: http://arduino.cc/en/Main/ArduinoBoardMega2560. Look for TWI in the "Input and Output" section.
You'll need 4.7k pullup resistors connected to 5V. One resistor between SDA and 5V and another between SCL and 5V. Check to see if any of your sensors already have built-in pullup resistors (the sparkfun accelerometer link I sent you does this). If they do then you don't need to add your own.
Your program will know which I2C device to communicate with by the devices address. All you your sensors should have a unique address. This is usually assigned by the manufacturer. Your sketch will NOT have anything like #define SDA 20. These pins are coded in the libraries, either Wire.h or one of the supporting libraries. It's all behind the scenes and you don't have to worry about it.
Adafruit has a tutorial on the ADXL335 here: http://learn.adafruit.com/adafruit-analog-accelerometer-breakouts.
I would write a small sketch for each sensor just to get it working. Only wire the one sensor that you are testing, don't wire in the others. Once you test each one, wire up everything together. Then use those same test sketches to test each sensor one at a time with everything wired together. Once that works, then I'd start creating my main sketch to get everything working.