using the tx and rx lines

I am looking to use a sure electronics temp humidity sensor that uses i2c. I am looking to comunicate with the device. I have tried some of the wire library but have had no luck.

Can any point me to some pages that will help me to learn to program my 168 to com with the sensor and print the info on a lcd. I have the lcd library figured out mostly just not how to print a responce to the i2c.
Thanks all,
Hugh

You can't generalize how to communicate with any device which uses i2c, so each device is a little bit different to program, so you want to say which i2c sensor you are using.

But normally the method is something like.

int read_io(int cmd_reg)
{
int tmp;
Wire.beginTransmission(io_address);
Wire.send(cmd_reg); // most devices have a command reg , or eeproms have two byte address
Wire.endTransmission(); // now start reading
Wire.requestFrom(io_address, 1); ,< ------ Set the number of bytes to read
tmp=Wire.receive(); // add more if needed or make a loop
return tmp;
} // end of read_io

io_address is the i2c device address

Thanks Peter,
I will give it a try. I have to send $sure humidity to the unit to get the response from the sensor. I am a newbie and really thanks u for the help. any other pointers would also help.
Hugh :slight_smile:

Are you quite sure it is I2C you need because in I2C communications you don't usually send strings like this to devices.

I was just answering the question, but after farther research I'm still no wiser which sensor you are talking about.

There are sensor in searching for sure electronics, which are serial, sp1 , etc , So it could be anything.

thanks everyone
this is the website with the sensor
http://www.sure-electronics.net/download/index.php?name=DC-SS500&type=0

It is a DC-SS500 you can input this into there search on this page and get a data sheet.

I do not know if it is I2C for sure. It uses two lines to communicate over. I can also get the data through two analog signals and convert them through some sort of table. I thought it would be easier just to input the data string as came in and use it to display the current temp and humidity.
thanks again,
Hugh

Hi , No it`s not i2c is serial .

Baud rate 9600
1 start bits
8 data bits
0 parity bits
1 stop bits

http://www.sure-electronics.net/download/DC-SS500_Ver1.0_EN.pdf

Hi , No it`s not i2c is serial .

It appears to also have SPI communications capabilities.

Lefty

Yes , but if you had a choice which one to use serial or SPI , which you would you pick , and is the easiest to program ?

but if you had a choice which one to use serial or SPI

SPI if speed was a requirement, but you are limited in distance of the cabling.

Serial if distance to the sensor is important and you don't need data transfer to be so fast. With humidity there is no hurry as it doesn't change that fast.

and is the easiest to program

Very much the same.

SPI ok I am going to put the sensor and the micro on the same board. So I will not need to travel far with the info. I so need to get the info out of the sensor and into the 328. There I will use it to contol the A/C during the night mostly to dehumidify the air in the house. The temp is usually ok but the humidity rises. I think with the scroll compressor and the fan on a low speed for short periods of time I can dehumidify and save money over just having the temp set so low that it does the same thing with the humidity. sort of a money saving event at night to be a little more comfurtable.
Thanks all,
Hugh

I have this module but I am unable to get an accurate reading, could you show the code you use in your program?
Thank you

I do have the same DC-SS500 temperature and humidity sensor from sure-Electronics.
I tried a lot without success. I want to use the SPI interface with the arduino. The sensor is connected with the 4 Pins of the SPI, 5V and GND. Everything what I receive is a echo from my own command. Please help! Is there is anybody out there who has a working script to read the data? Now I created a website with all the informations about the sensor. Look here:

http://www.kramer-home.de/humidity-sensor-dc-ss500.html

Sorry for the english/german mix on the page. ::slight_smile:

Ralf/German

I have an successful implementation of the serial interface with the DC-SS5500 at;

http://www.phanderson.com/arduino/

PHA

RaKa,

If you haven't figured it out yet it looks like you are not sending the whole command string. The most likely reason you are getting what you send is because the board has echo turned on. You have to send at least 11 bytes (ie '$sure Temp\n') to get a temperature.

Ok, I looked at your programs again and I am doing the same thing to get the same results. >:( I tried extra reads, swapping logic on Chip Select and the only thing that caused more consistent results was slowing the clock rate down. I don't have an oscilliscope (yet) but I wonder if the clock still runs when you aren't transmitting or have the SS_PIN selected.

One thing I did do was tried hooking both 3.3 and 5v up on their respective pins. I tried the 3.3v first and it kept shutting down the Duemilnove (to much draw?). It wasn't till after I tried the 5v that I noticed the note about not using both at the same time. I hope I didn't blow some circuit on the SS5500. I haven't yet put a continuity tester on my wiring to see if I accidently put a short in to the 3.3v while wiring up all the GND pins.

I'm going to try and switch to the Vout method just to get going on the project. I may come back and revisit the UART and SPI methods later. I guess my first attempt again with SPI should include a more powerfull 3.3v supply.

I really want to do SPI because my final project calls for this and an SPI display. Theoretically you can use SPI bus like IC2 with a separate pin for each CS. Each device is supposed to pass on the commands if CS isn't selected . . . like it is doing right now.

I have tried to use pha555 version and can not get anything out of it think it must be wiring. looking at the code and the diagram I am confused.

This is what I did I use two analog inputs and output to a lcd.

This is my code if you can help build onto it let me know.

Thanks all,
Hugh :slight_smile:

/*
Analog input, analog output, serial output
Reads input pin A0 for temp from sensor and outputs degress f
Reads input pin A1 for humidity from sensor and outputs in %

Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.

The circuit:

  • Temp sensor output connected to analog pin 0.
    Humidity sensor output connected to analog pin 1
  • LED connected from digital pin 9 to ground
    LCD connections reset connected to digital pin 12
    enable = D11
    DB4 = D5
    DB5 = D4
    DB6 = D3
    DB7 = D2

created 7 Oct 2010
Modified 7 Oct 2010
by Hugh Coleman

This example code is in the public domain.

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input on pin A0 for temp reading
const int analogOutPin = 9; // Analog output pin that the LED is attached to
const int analogInPinOne = A1; // Analog input pin A1 for humidity reading

int tempValue = 0; // value read from sensor output
int outputValue = 0; // value output to the PWM (analog out)
int humidValue = 0;
int OutPutValueOne = 0;

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();
// initialize serial communications at 9600 bps:
Serial.begin(9600);

}

void loop() {
// read the analog in value:
tempValue = analogRead(analogInPin); //reads the value on analog pin a0:
humidValue = analogRead(analogInPinOne); //reads the value on analog pin a1

// map it to the range of the analog out:
outputValue = map(tempValue, 0, 1023, 0, 255);

// change the analog out value:
analogWrite(analogOutPin, outputValue);

// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(tempValue);

// sets the cursor and prints Temp:
lcd.setCursor(2,0);
lcd.print("Temp"); //outputs Temp to lcd:

// sets the cursor and prints the current temp in F:
lcd.setCursor(11, 0);
lcd.print(tempValue*.155); //calls the tempValue multiplies it times .155:

// sets the cursor and prints Humidity:
lcd.setCursor(0, 1);
lcd.print("Humidity"); //outputs Humidity to lcd:

// sets the cursor and prints the current relative humidity:
lcd.setCursor(11, 1);
lcd.print(humidValue/10); //analog a1 input divided by 10:

// sets the cursor and prints the % sign
lcd.setCursor(14, 1);
lcd.print("%");

// delay 3 seconds:
delay(3000);

Serial.print("\t output = ");
lcd.clear();
Serial.println(outputValue);

}

So I also tried the code from pha. No success.
I got something like T_F = -5061 RH = -5061