[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Arduino code help me /diy/
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /diy/ - Do It yourself

Thread replies: 5
Thread images: 2
File: Arduino_Uno_-_R3.jpg (238 KB, 600x600) Image search: [Google]
Arduino_Uno_-_R3.jpg
238 KB, 600x600
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
>>
>>935644
>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?--
http://cactus.io/hookups/sensors/temperature-humidity/hih6130/hookup-arduino-to-hih6130-temp-humidity-sensor
>>
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
hih6130_TWO.readSensor();
>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
lcd.print(hih6130_TWO.humidity);
>>
>>935716
>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

....HOWEVER...
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.
>>
File: spindo.gif (646 KB, 512x481) Image search: [Google]
spindo.gif
646 KB, 512x481
>>935644
>Fugt Temperatur
> :D D D
Thread replies: 5
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.