Show Posts
Pages: [1] 2
1  Using Arduino / Sensors / Re: I2C Pressure Sensor on: June 25, 2013, 01:19:27 am
I appreciate the help as always !!!

Robert,

I have appended the code with lines you mentioned...

Code:
#include "Wire.h"
#define addrs 0x10 // I2C bus address


void setup()
{
Wire.begin();
Serial.begin(9600);
}

void loop()
{
 
   byte lobyte;
   byte hibyte;
 
   

Wire.requestFrom(addrs, 4); // contents of your first four registers
   while(Wire.available() < 4 );          // Check for data from slave
   {   
      delay(5000);
     
      lobyte = Wire.read();       // Read hum high byte
      Serial.println(lobyte, DEC);
      hibyte = Wire.read();      // Read hum low byte
      Serial.println(hibyte, DEC);

//      Hum = toHumidity(hibyte, lobyte);
//      Serial.print("Humidity: ");
//      Serial.println(Hum);
     

      lobyte = Wire.read();       // Read temp high byte
      Serial.println(lobyte, DEC);
      hibyte = Wire.read();      // Read temp low byte
      Serial.println(hibyte, DEC);
     
//     Temp= toTemperature(hibyte, lobyte);
//     Serial.print("Temperature: ");
//     Serial.println(Temp);
   
      delay(1000);
     
      uint8_t n = Wire.requestFrom(addrs, 4);
      Serial.println(n, DEC);
     
     
   }
}   

When i run the program, the serial monitor outputs the following (repeats):

Quote
100
20
98
117
4
100
20
98
117
4

Erdin,

Wrong sensor, i mentioned another Humidity and Temp later on the thread..take a look smiley

Pete
2  Using Arduino / Sensors / Re: I2C Pressure Sensor on: June 21, 2013, 03:47:29 pm
The output was these four values over and over...

87
232
103
29

Hope that helps..

Pete
3  Using Arduino / Sensors / Re: I2C Pressure Sensor on: June 21, 2013, 02:13:22 am
Thanks for the advice Robert, I purchased the logic level converter and finally got it connected earlier today. I ran the I2C scanner tool on the sensor and got a hit at 0X10 address.

When i run the below code, i get the values 87,232,103,29 on the serial monitor. What i find strange is blowing gently on the sensor does not cause any data value variation, which leads me to believe its bogus data, is that a correct assumption ?

Is this just a timing issue, advice ?

Thanks,
Pete


Code:
#include "Wire.h"
#define addrs 0x10 // I2C bus address


void setup()
{
Wire.begin();
Serial.begin(9600);
}

void loop()
{
 
   byte lobyte;
   byte hibyte;
 
   

Wire.requestFrom(addrs, 4); // contents of your first four registers
   while(Wire.available() < 4 );          // Check for data from slave
   {   
      delay(5000);
     
      lobyte = Wire.read();       // Read hum high byte
      Serial.println(lobyte, DEC);
      hibyte = Wire.read();      // Read hum low byte
      Serial.println(hibyte, DEC);

//      Hum = toHumidity(hibyte, lobyte);
//      Serial.print("Humidity: ");
//      Serial.println(Hum);
     

      lobyte = Wire.read();       // Read temp high byte
      Serial.println(lobyte, DEC);
      hibyte = Wire.read();      // Read temp low byte
      Serial.println(hibyte, DEC);
     
//     Temp= toTemperature(hibyte, lobyte);
//     Serial.print("Temperature: ");
//     Serial.println(Temp);
   
      delay(1000);
     
   }
}   
4  Using Arduino / Sensors / Re: I2C Pressure Sensor on: May 06, 2013, 09:17:21 pm
Thanks a lot for your Help Rob, everything worked well and i am learning a lot smiley

At this point i need to incorporate this sensor as well,
http://www.smartec-sensors.com/assets/files/pdf/manuals/SMTH08INv2.2.pdf
http://www.sensorguys.com/pdfs/SMTH08IN.pdf

How do i incorporate both sensors considering they use 3.3V & 5V I2C Systems ?

The datasheet is rather confusing to me, how do i read this sensor, do i need to initiate a "conversion" first ?

Some general help and or skeleton code would be appreciated.

Pete
5  Using Arduino / Displays / Re: I2C Output Not Working ? on: May 06, 2013, 09:10:01 pm
Are you using Pull Up Resistors ?

Things connected properly at the right ports, double check ?

Pete
6  Using Arduino / Sensors / Re: I2C Pressure Sensor on: January 10, 2013, 02:43:44 am
Again Rob, I really appreciate your time and help !!

I appended and modified the code to the following complete sketch:

Code:
#include "Wire.h"
#define addrs 0x78 // I2C bus address


void setup()
{
Wire.begin();
Serial.begin(9600);
}

void loop()
{
 
   byte lobyte;
   byte hibyte;
   int Press;
     
   Wire.beginTransmission(addrs);
   Wire.write(1);       
   int x = Wire.endTransmission();

   Serial.print("endTransmission: ");
   Serial.println(x, DEC);
     
   Wire.requestFrom(addrs, 2); // contents of your first two registers
   while(Wire.available() < 2 );          // Check for data from slave
   {   
      delay(1000);
      lobyte = Wire.read();       // Read press high byte
      Serial.println(lobyte, DEC);
      hibyte = Wire.read();      // Read press low byte
      Serial.println(hibyte, DEC);
     
      Press = toPressure(hibyte, lobyte);
      Serial.print("Pressure: ");
      Serial.println(Press);
     
      delay(1000);
   }
   
}
   
   
float toPressure(byte hi, byte lo)
{
  int t = (hi * 256 + lo) & 0x3FFF;  // see pdf, mask 14 bit
 
  float rv = (t - 1638.0) / 30.84 + 600.0;  // (t - 1638.0) * 0.032425422 + 600.0 // faster
  return rv;
 


When the sketch Runs as is, i get the following out on the serial monitor:
Quote
endTransmission: 2
103
177
Pressure: 956
endTransmission: 0

I have two questions...
1. Why is it when i remove the following lines of code, the serial monitor shows nothing, it seems to me it should have no affect ?
Code:
Serial.print("endTransmission: ");
Serial.println(x, DEC);

2. How do i get it to constantly update and report the Pressure instead of only running once ?

Thanks,
Pete
7  Using Arduino / Sensors / Re: I2C Pressure Sensor on: January 09, 2013, 02:55:07 am
Thanks for help so much Rob !!

The following was the result of the serial monitor after running the sketch..

Quote
endTransmission: 2
byte 1: 101
byte 2: 188

endTransmission: 0

Much appreicated smiley
Pete
8  Using Arduino / Sensors / Re: I2C Pressure Sensor on: January 07, 2013, 11:45:26 pm
I ran the sketch you posted Rob and i get all Zeros on the serial monitor..

Quote
0

0

0
9  Using Arduino / Sensors / Re: I2C Pressure Sensor on: January 06, 2013, 09:01:27 pm
Well i have access to their sensor acquisition board (see link below) and when i connect the same sensor i get meaningful data ?

http://www.smartec-sensors.com/assets/files/pdf/manuals/SMTAS02I2CN.PDF

Pete
10  Using Arduino / Sensors / Re: I2C Pressure Sensor on: January 06, 2013, 03:34:27 pm
I ran the below sketch Rob and  it gave me nothing on the serial monitor, but i ran a newer version of the scanner dated June2012 i found on the Arduino resource page and it gave me this..

Quote
I2C Scanner
Scanning...
I2C device found at address 0x78 !
done

Ideas ?

Thanks Much !!
11  Using Arduino / Sensors / Re: I2C Pressure Sensor on: January 05, 2013, 10:29:29 pm
I appreciate everyone's responses !!
I have modified the code as follows and getting nothing on the Serial Monitor..

Code:
#include "Wire.h"
#define addrs 0x78 // I2C bus address


void setup()
{
Wire.begin();
Serial.begin(9600);
}

void loop()
{
 
   byte firstbyte;
   byte secbyte;
     
   Wire.beginTransmission(addrs);
   Wire.write(1);        // move your register pointer back to 0
   Wire.endTransmission();
   
   
   Wire.requestFrom(addrs, 2); // contents of your first two registers
   while (Wire.available() < 2)
   {}
   firstbyte = Wire.read();       // Read press high byte
   secbyte = Wire.read();      // Read press low byte
 
  Serial.print("first byte ");
  Serial.print(firstbyte, BIN);
 
  Serial.print("  sec byte ");
  Serial.println(secbyte, BIN);
 
  delay(500);
}

If i change the while loop to the following below, i get this on the serial monitor " first byte 11111111  sec byte 11111111", which still isn't right  ?

Code:
   Wire.requestFrom(addrs, 2); // contents of your first two registers
   while (Wire.available() )
   {}
   firstbyte = Wire.read();       // Read press high byte
   secbyte = Wire.read();      // Read press low byte

I appreciate the help guys a lot..

Pete


12  Using Arduino / Sensors / Re: I2C Pressure Sensor on: January 03, 2013, 01:33:55 pm
Anyone, some help would really be appreciated  smiley

Pete
13  Using Arduino / Sensors / Re: I2C Pressure Sensor on: January 02, 2013, 03:29:52 pm
I am still getting gibberish on the serial monitor, i think it has something to do with how i am declaring the stored data value/type and how long it is ?

Can someone look at the above sensor data sheet and offer some insight ?

I would really appreciate it smiley Happy New Years to Everyone !!

Pete
14  Using Arduino / Displays / Re: I2C Output Not Working ? on: January 02, 2013, 03:26:48 pm
Thanks guys, i did actually have all 4 leads connected just to the wrong place on the Arduino !!

I used the Digital Lines instead of the Analog ones, its all working now smiley

Thanks,
Pete
15  Using Arduino / Displays / I2C Output Not Working ? on: December 31, 2012, 09:32:50 pm
Hello All,

Happy New Years First off to everyone !!

I am trying to interface two new I2C 20x4 SainSmart to my Arduino Uno and i am having no success.
I have tried connecting the the SDA and SCL with and without pull up resistors (1k & 10k) and in both cases the I2C ID sketch says no I2C devices found and the screens show two horizontal lines.

Additionally, i have run the simple "Blink" sketch with a LED across Pins 4 & 5 to test the outputs and they do indeed work.

Any ideas on how to proceed ? ?

Thanks,
Pete

Pages: [1] 2