I got 3 different kind of sensors and they just use VSS, GND, SCL, SDA (Only).
My problem here is that i got just one Atmega328p-pu and there is only 2 pins
that have SDA and SCL wich are A5 and A4, i need all 3 sensors work in the same time
and receive the data to actually combine them and do some "action".
Is there any way to make somehow and connect all 3 sensors in one ATmega328p and get the data.
Am i wrong that you need to connect sensor pins (sda,scl) only at atmega sda and scl or you can use
other analog pins for that? A0 ~ A5.
Each I2C device has a different address. You can usually connect several identical devices because they have other pins which can be tied high or low to set an individual address for each device.
In short, a bus is a shared communication medium on which every device of the network is connected. Different strategies can be adopted to send data to the good device.
Thanks a lot, I'd like to be informed more and more but I don't have a lot of time for that.
Isn't there a tutorial?
You connect all of the sensors to the same two pins.
I'd like to see that in a tutorial how to connect 2 sensors or more just to that 2 pins on the ATmega328
and get data from both sensors and print them on the serial monitor.
I2C bus looks like 2 device communicating each other. I2C BUS
I'll make it more newbe explanation about what i want to do.
I have a temperature sensor module and a compas sensor module, both of them use sda,scl but
the atmega328p have only 2 pins with sda and scl wich are A4, A5. How I'm gonna connect them
to get the data from both sensors ? O_O
Is there a normal answer or tutorial or example of my problem ?
Explain what is the link you send me to what exactly should i look for, or read.
I could search on my own on the internet but i know from experience even if i search about arduino
the links will always come on arduino forum.
So i gave a try to just axplain normaly what's my problem and get a normal answer.
Domino60:
Is there a normal answer or tutorial or example of my problem ?
The link I posted above contains LOADS of pictures all showing MANY devices connected to SDA, SCL and ground. What the devices are is largely irrelevant. This is how they connect.
You can twist wires together, you can use a breadboard. You can solder them together. Heck even use a piece of string soaked in brine if you like. As long as they ALL get conncected to SDA and SCL (and gnd)
I think OP is wondering how to physically connect 2xSDA and 2xSCL when he has only one of each socket at A4 and A5.
See attached pic: brown and yellow from A4 anf A5 to breadboard; 2x browns out to left for 2 devices' SDA and 2x yellow out to right for 2 devices' SCL.
I know how to connect wires you need to be really dumb to not understand what exactly you need to connect.
You have muscles on your body, they are connected each other to actually move and do stuffs
but for that you need what? Brain
I need code.... how to make them to communicate with the atmega328 that's my problem
code, how? and get them in real time not with huge delays
How to get the data from the sensors????
Domino60:
I know how to connect wires you need to be really dumb to not understand what exactly you need to connect.
You have muscles on your body, they are connected each other to actually move and do stuffs
but for that you need what? Brain
I need code.... how to make them to communicate with the atmega328 that's my problem
code, how? and get them in real time not with huge delays
How to get the data from the sensors????
Why the [expletive deleted] didn't you say so 4 hours ago? You kept going on about how to connect 4 wires to 2 pins.... or so we read it, anyway.
What sensors are they?- use the wire library and maybe whatever other library the vendor may have provided.
Follow the vendor's instructions for getting each sensor to run, and do that for each one in the same sketch. As long as they have different addresses they'll be good to go. Run the i2c scanner (look in playground) to check they have different addresses.
The output from the sensors will be in variables as usual. The RTC1307 for example uses a tm structure so you can display hours separately from minutes for example.
Nobody here can provide a generic code to run 3 as yet anonymous sensors.....
Arduino's Wire library which is natively installed with your IDE. Look at the library reference page to know how to send and receive data thru I2C bus using it.
You'll have to look at your devices' datasheet to know more about communication with them specifically.