I am starting a project to log cave air movement and barometric pressure. I plan on using a light weight pendulum anemometer that is sensitive enough to detect small air currents. I have a couple of feasibility questions.
-
The cave environment is 48 degrees F and 90% Relative humidity. I will keep the components in a weather proof box. However, to measure barometric pressure and my method of recording the anemometer may expose the components to the cave air. Will they be able to survive in this environment for a month or so?
-
I hacked a printer linear optical encoder to use in order to detect movement of the anemometer. just like this: How to use linear encoders with Arduino. hardware, code, and demo. - YouTube Will this work as a position sensor? or will "0" Wander? Another Idea I had was to use an absolute magnetic encoder which I should be able to weatherproof. Are they accurate enough to detect fractions of a degree?
-
As I have experience, the cave air current varies by the second. I believe I will have to record a data point every 3-5 seconds. There will be two values. Wind sensor position and barometric pressure. Is this possible over a week or two period between downloads?
Any help would be appreciated.
Will they be able to survive in this environment for a month or so?
Yes, if the circuit boards are all "conformally coated" or potted.
See this excellent tutorial on power saving techniques and Edward Mallon's blog on cave sensors.
I found an AS5048A breakout board that uses an SPI interface. The SD card will also use the SPI interface. Any resources on code for 2 SPI connections?
I am making good progress but still have a lot to learn.
Receiving good data from the AS5048a now.
When logging the data received from the AS5048a do I need to close the SPI bus? For example set the AS5048a's CS pin to high and use endTransaction()? Do I declare the value and then use print(value) after closing the bus?
Here is the whole setup:
Arduino Uno
AS5048a (SPI)
Adafruit Data logging Shield w/ RTC (SPI & I2C)
BMP180 Barometric Pressure and Temp Sensor (I2C)
Is this to be too much for the Uno, Mega be a better choice?
It's an Arduino Uno R3. Successfully switched the CS pin on the AS5048a. I will add the logging code after I solve this problem.....
It appears I have a hardware conflict between the data logging shield and the BMP180. The BMP180 and the AS5048a worked together, then I added the data-logging shield and even without code the Uno disconnected itself from the serial port. The RTC works on its own. The Real time clock on the shield and the BMP180 are both I2C. Could I have a pull up problem? Any other thoughts? Maybe I should get a SPI barometer?
I have solved the problem with the RTC and BMP180. I just hooked the BMP180 to the 3.3v supply. All three inputs are working now. Just to log!
I have this project working. I will post photos and code soon for all who are interested. My code may need a little cleaning. Thanks for the help!
Here is my code. I'm sure it could use improving. This has been working in the cave for a couple of days now. I welcome suggestions.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
#include <SPI.h>
#include <RTClib.h>
#include <SD.h>
File logfile;
float result = 0;
unsigned int result1 = 0;
unsigned int result2 = 0;
const int AS5048pin = 9;
const int chipSelect = 10;
SPISettings settingsA(1000000, MSBFIRST, SPI_MODE1);
RTC_DS1307 rtc;
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
void error(char *str)
{
Serial.print("error: ");
Serial.println(str);
}
void setup(void)
{
SPI.begin();
Serial.begin(57600);
pinMode (AS5048pin, OUTPUT);
pinMode (chipSelect, OUTPUT);
pinMode (7, OUTPUT);
bmp.begin();
digitalWrite(AS5048pin, HIGH);
SD.begin(chipSelect);
// create a new file
char filename[] = "LOGGER00.CSV";
for (uint8_t i = 0; i < 100; i++) {
filename[6] = i / 10 + '0';
filename[7] = i % 10 + '0';
if (! SD.exists(filename)) {
// only open a new file if it doesn't exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}
if (! logfile) {
error("couldnt create file");
}
Serial.print("Logging to: ");
Serial.println(filename);
}
void loop(void)
{
DateTime now = rtc.now();
logfile.print(now.year(), DEC);
logfile.print("/");
logfile.print(now.month(), DEC);
logfile.print("/");
logfile.print(now.day(), DEC);
logfile.print(", ");
logfile.print(now.hour(), DEC);
logfile.print(":");
logfile.print(now.minute(), DEC);
logfile.print(":");
logfile.print(now.second(), DEC);
logfile.print(", ");
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();
SPI.beginTransaction(settingsA);
digitalWrite(AS5048pin, LOW);
result1 = SPI.transfer(0xff);
result2 = SPI.transfer(0xff);
digitalWrite(AS5048pin, HIGH);
SPI.endTransaction();
result1 &= 0b00111111;
result1 = result1 << 8;
result = (result1 | result2);
logfile.print(result);
logfile.print(", ");
Serial.println(result);
sensors_event_t event;
bmp.getEvent(&event);
if (event.pressure)
{
logfile.print(event.pressure);
logfile.print(", ");
Serial.println(event.pressure);
float temperature;
bmp.getTemperature(&temperature);
logfile.print(temperature);
logfile.println();
Serial.println(temperature);
}
digitalWrite(7, HIGH);
logfile.flush();
digitalWrite(7, LOW);
delay(4000);
}