What pins?

Arduino Noob here. I think once I get the hardware figured out I can start confusing myself with C code. :D

I have 3 sensors and a LCD shield with buttons. I board I am using is a Mega 2560.

Sensor 1) BMP180 - Has 4 pins. VIN, GND, SCL and SDA. From what I gather it is I2C compliant. I believe I need 3.3v power only to this chip.

Sensor 2) Labeled as GY-521. A 3 axis accelerometer and 3 axis gyro. Has 8 pins. VCC, GND, SLC, SDA, XDA, XCL, ADD, INT. From my reading, either 3.3v or 5v power is OK. Have not found much about this ship. I believe it is I2C compient as well.

Sensor 3) MAP sensor for a Chevy. This will be analog. Runs off of 5v power. VIN, GND and signal.

Display w/ Buttons) Uses 6 digital lines for the display and one analog for the buttons. Also have pins for RST, 3.3v, 5v, 2 GNDs and a VIN.

My question; How do I connect the bits? I know any pin can do in or out. Does it matter what pins I use for what? With 2 I2C devices, how does that work with only a pair of I2C pins? How about splitting power to everything with only one pin marked for 3.3v and one for 5v and a pair for GND?

Any devices that use I2C (aka Wire) are connected in parallel as shown on this page

http://arduino.cc/en/reference/wire

So the BMP180 and the GY-521 are both wired in to SDA and SCL on the Arduino

Power requirements for these devices will depend on whether you are using a module with a voltage regulator built in and level converters or not, i.e are you using bare devices not on a module ??

Re: Motion sensor XDA, XCL, ADD, INT, you many need INT, it depends on what library you intend to use (have you considered what libraries are or are not available for this device?

Re: Map Sensor

Do you mean it runs from 5V and outputs a signal from 0 to 5V on VIN, or does it require a voltage input to device between 0 and 5V (which doesnt make any sense if its a sensor) So assuming it delivers between 0 and 5V from VIN, connect that to A0 on the Arduino

Note. Make sure that VIN doesnt exceed 5v, as most car components run from 12V and often output 12V

Deerhurst: How about splitting power to everything with only one pin marked for 3.3v and one for 5v and a pair for GND?

For prototyping, use breadboard: take 5V from Arduino to one red rail, 3V3 (if you need it) to the other red one, and a wire from Arduino GND to one of the blue ones. Then link the blue ones with a wire, or just wire all components to the same one.

Be careful that you don't draw too much current from Arduino (500mA if my memory serves- don't quote me); might be an idea to get a 5V AC-DC adapter.

rogerClark: Re: Map Sensor

Do you mean it runs from 5V and outputs a signal from 0 to 5V on VIN, or does it require a voltage input to device between 0 and 5V (which doesnt make any sense if its a sensor) So assuming it delivers between 0 and 5V from VIN, connect that to A0 on the Arduino

... as long as A0 is not the analog input pin the LCD+Buttons shield uses for the buttons. :)

Im waiting until I can run into town for some different jumper wires to hook up the display and MAP. I think Im going to have to do some soldering even for prototyping with the MAP. Right now, on my breadboard, I have one rail for 5V and one rail for 3.3v. Each has its own ground as the MEGA has 2 ground pins. I have SDA and SCL powering two small rails with the respective pins on the accel/gyro and barometer chips plugged in. I am running 3.3v to both the barometer and MPU 6050. I have 2 channels of analog to two rails on the breadboard waiting for the display and MAP. I have 6 channels of digital to 6 rails of breadboard for the display. Just need male to female jumpers to hook up the display and map.

Ill get a photo when the internet is being nice again.

Schematic for the display w/ buttons: https://s3.amazonaws.com/linksprite/Shields/16X2+LCD+Keypad+shield/1602+LCD+Shield+Sch.pdf

Eventually it will run with 12v switched DC power. Im sure I can find a spare power adapter at work if I need to. I thought the DC plug on the Mega 2560 was a 6 or 7v minimum.

A0 is recommended for the display but it covers things I do not want covered so it will be remoted a little. Couple inches of wire should be fine. MAP will be on A1.

How far as I transmit I2C without an amplifier? I know it will be different with different wire resistances. Give me a rough number.

@roger; the MAP has 5v (+/-.1v) power in, ground and a signal wire that will send back between 0v and 5v depending on what the sensor "reads". All my stuff, except the MAP is on a little breakout board or what ever it is called. The accel/gyro is a MPU 6050 and the barometer is says GY-68 on one side and BMP180 on the other.

The MAP for GM model 16212460 data sheet:

http://www.powerandsignal.com/docs/Products/pressure_sensor_brochure.pdf

It blow my mind that I2c does addressing with 2 pins. To me thats 4 addresses and no data!

How far as I transmit I2C without an amplifier?

About 2 ft

I know it will be different with different wire resistances.

Then you know wrong. It is the capacitance of the cable that limits the distance.

It blow my mind that I2c does addressing with 2 pins.

Stands back so as not to get sprayed. I2C is a protocol based on synchronous data transfer. You can get 255 devoces on an I2C bus each having it's own address. http://en.wikipedia.org/wiki/I%C2%B2C

Grumpy_Mike:
About 2 ft
Then you know wrong. It is the capacitance of the cable that limits the distance.
Stands back so as not to get sprayed.
I2C is a protocol based on synchronous data transfer. You can get 255 devoces on an I2C bus each having it’s own address.
http://en.wikipedia.org/wiki/I²C

Thats not very far but low voltage and low current.

OK, I should have said imaginary resistance or i? I know enough EE stuff to get into trouble but not much embedded systems. Studied the EE curriculum for a few years. Wires do have a resistance per unit and this resistance can change with temperature as well. Different wires will have a difference resistance. Deal a lot with that with wheatstone bridges and force gauges.

255 devices is a lot!

OK, I think I got my wiring figured out. The documentation on the LCD is extremely poor. Playing with the pins to figure out what the pins for the 4 bit digital is. At least Ive figured out how to keep the back lighting on. Before it would turn on then off.

defining pins with LiquidCrystal lcd(8, 9, 4, 5, 6, 7 );

8 is my RS and 9 my E. 4-7 should be data. Nothing, nada. I can unplug them all and still get the same backlight. DOA or am I just missing something?

Update: With the LCD4BIT_mod library I can get gibberish. And it scrolls. The code is supposed to display “Hello world”, wait for 1000 and then count for 1000. Super confused now.

defining pins with LiquidCrystal lcd(8, 9, 4, 5, 6, 7 );

This has noting to do with I2C, so I don’t know what you want to do.

Post the schematic of what you wired up and post the code as well for further help.

Grumpy_Mike: This has noting to do with I2C, so I don't know what you want to do.

Post the schematic of what you wired up and post the code as well for further help.

Nope, uses digital pins. Got it figured out. I think some of my jumpers were bad. Other than that, no idea.

Serial print was not working to find I2C addresses so after getting the display working I just modified that code to display to the LCD.

Its working so far. Lots more to do!

Rather than start a new thread Ill ask here.

I have a MPU6050 and for the life of me I cannot get a number that makes sense or changes logically. Got lots of NULL.

All I want is a simple Pitch and Roll out of it. If I can id like to debounce it a bit so I dont get a bounching number every time I hit a bump.

Any suggestions?

Hi, you can calculate a "running average" of the sensor's value.

To do this, each time you read the sensor, you update the average to be 80% of its current value plus 20% of the new sensor value.

For a more heavily smoothed average use 95% and 5%. For a more reactive value use 50% and 50%. Experiment to see what values suit.

If you find that to smooth out the bumps you have to use very heavy smoothing (99% & 1%) and this makes the average update too slowly, there is a technique to deal with that.

In that technique, each time you take a sensor reading, you calculate the absolute difference between the reading and the current value of the running average. You also keep a second running average of those differences. If the new difference is more than, say, 5 times the average difference, you skip updating the sensor average (but you still update the difference average). Hope that makes sense! Probably easier to code than explain in English!

Paul

Got it accurate within a few degrees which is OK for now.

I am using buttons to select what I want to display. Its in a switch statement. Now that I have my data displaying when I hit the appropriate button how to I break out of that so when I hit the next button it displays that?

Deerhurst: I am using buttons to select what I want to display. Its in a switch statement. Now that I have my data displaying when I hit the appropriate button how to I break out of that so when I hit the next button it displays that?

Show your code first.

edit: FIXED! Just need to do the backlight toggle now.

Current bugs are also listed at the top but are as follows:

All sensors but the accelerometer no longer update - worked this morning before I took it to work with me to find a power adapter. Will update each time I click the button...

Does not show the default screen on start up

Only the inclinometer needs the button to be held to display but updates correctly.

Random artifacts on the display. Some things are not cleared from the display when the next is displayed.

Code: http://pastebin.com/8jxEPmqM

For the life of me I cannot get the back light to change via the button. I can get to work with a short little bit just to do that but not with the rest of everything.