Hey diy people - first time posting here so sorry if this is the wrong place to ask. I currently have two sensors (HIH6130) with an arduino UNO - plus an LCD. I can get the first sensor to get the humidity and temperatuer and display it, but i have no idea how to get the second sensor to start working, I've hooked it up to the arduino, but I can't make the code work. Help me out please!
Here's the code: http://pastebin.com/c7whSpzp
P.S. Don't mind the comments
>P.S. Don't mind the comments
I can't understand em anyway ;)
1) To clarify what it is you are trying to do: what you want is to have two of the same kinds of sensors hooked up at the same time? And to be able to read either one of them?
2) Are your sensors I2C ones, like these?--
Not really familiar with arduino, but I think...
>ADD something like:
byte address = 0x27; //EXISTING STATEMENT
byte address_TWO = 0x??; //Change address to match pin
HIH6130 hih6130(address); //EXISTING STATEMENT
HIH6130 hih6130_TWO(address_TWO); //hih6130_TWO = name for 2nd sensor
>then in main:
hih6130.readSensor(); //EXISTING STATEMENT
>then add appropriate lines to the lcd section anywhere there's a hih6130 reference,
>you'll also have to add setCurser() statements to display it at a new place. like:
lcd.setCursor(0,1); //EXISTING STATEMENT
lcd.print(hih6130.humidity); //EXISTING STATEMENT
lcd.setCursor(?,?); //determine an appropriate location
>HIH6130 hih6130(address); //EXISTING STATEMENT
above is the way you would do the basic code.
in that statement, the "HIH6130" part is the class of the object you are creating, and "hih6130" is the name of the particular instance.
you can name the instance anything you want, as long as each instance has a unique name.
So you could do like this instead:
>HIH6130 sensor_1(address_1); // this is the first sensor
>HIH6130 sensor_2(address_2); // this is the second sensor
all the same kinds of devices on an I2C bus also need to have different addresses. (note address_1 and address_2 above)
if you only use one of a particular device then you can usually just leave it on its default address, but if you want two of the devices, you must change the (hex) address of one of them.
Some I2C devices have a DIP or solder pads that you can connect to alter the device address. Those are easier to set.
The HIH6130 has some way of electronic mode (entering into command mode) to do this, apparently. I've not used them so I dunno exactly what to do. OP must go find this out.
The Sparkfun page for this breakout board has a link to documentation on how to enter into command mode and change the I2C address. It doesn't give the code you need, but there may be a code example online somewhere.