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

Arduino code help me /diy/

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 5
Thread images: 2

File: Arduino_Uno_-_R3.jpg (238KB, 600x600px) Image search: [Google]
Arduino_Uno_-_R3.jpg
238KB, 600x600px
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 (646KB, 512x481px) Image search: [Google]
spindo.gif
646KB, 512x481px
>>935644
>Fugt Temperatur
> :D D D
Thread posts: 5
Thread images: 2


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.