Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data on demand #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions Arduino_board_code.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

#define BMP085_ADDRESS 0x77 // I2C address of BMP085

#include "D:\Users\reuterc\Desktop\Slow control\Arduino_board_code\FreqCounter\FreqCounter.h"
#include "D:\Users\reuterc\Desktop\Slow control\Arduino_board_code\FreqCounter\FreqCounter.cpp"
#include <FreqCounter.h>

int freq, offset, sens;

Expand Down Expand Up @@ -56,13 +55,20 @@ void setup(){

void loop()
{
//pressure sensor and temperature read out
// check for the command to write data to serial port
if ((!Serial.available()) || (Serial.read() != 'r')) {
return;
}

//
//pressure sensor and temperature read out
//
float temperature = bmp085GetTemperature(bmp085ReadUT()); //MUST be called first
float pressure = bmp085GetPressure(bmp085ReadUP());

//magnetic field sensor read out


//
//magnetic field sensor read out
//
int x,y,z; //triple axis data
float x1,y1,z1,r;

Expand All @@ -72,7 +78,7 @@ void loop()
Wire.endTransmission();


//Read data from each axis, 2 registers per axis
//Read data from each axis, 2 registers per axis
Wire.requestFrom(0x1E, 6);
if(6<=Wire.available()){
x = Wire.read()<<8; //X msb
Expand All @@ -88,21 +94,20 @@ void loop()
z1=((float)z*.73);
r= (sqrt((square(x1))+(square(y1))+(square(z1))));


//humidity sensor readout
//Get Frequency
FreqCounter::f_comp= 8; // Set compensation to 12
FreqCounter::start(1000); // Start counting with gatetime of 1000ms
while (FreqCounter::f_ready == 0) // wait until counter ready
freq=FreqCounter::f_freq; // read result
//
//humidity sensor readout
//
//Get Frequency
FreqCounter::f_comp= 8; // Set compensation to 12
FreqCounter::start(1000); // Start counting with gatetime of 1000ms
while (FreqCounter::f_ready == 0) // wait until counter ready
freq=FreqCounter::f_freq; // read result

//Calculate RH
//float RH = (offset-freq)*sens/4096; //Sure, you can use int - depending on what do you need
//float RH = ((float)(offset -freq))*(float)sens/4096.0;
float RH = ((float)(offset -freq)*sens)/4096.0;

//delay(1000); //wait a second and get values again.

//print out the values as a final step

Serial.print("temperature: ");
Expand Down
Binary file added FreqCounter.zip
Binary file not shown.

This file was deleted.

This file was deleted.

129 changes: 0 additions & 129 deletions FreqCounter/FreqCounter.cpp

This file was deleted.

39 changes: 0 additions & 39 deletions FreqCounter/FreqCounter.h

This file was deleted.