3
\$\begingroup\$

I got three sensors stick from sparkfun : https://www.sparkfun.com/products/10724 which each one got an arduino pro mini that filters the data before to send to a main Arduino.

Like this: enter image description here

and until this point everything works, not even a issue.

But what I want to do next is to connect all the 3 arduinos via I2C to share the filtered data and at this point there is a big issue, the first arduino can acces to 3 Sensors via I2C and it crashes when I start to access to the unique address.

I wanted to make an independent I2C bus that exists only between the Sensor and Arduino pro mini and then another one that share the data to the main Arduino Uno.

So far I got no luck and what I came up to do, is to use a Serial cascade system

http://geodesicsphere.blogspot.co.uk/2012/12/daisy-chaining-serial-connections.html

There is anything I can do to use the I2C bus rather than Serial to share the 3 data filtered by each arduino and send it to the main Arduino UNO ?

\$\endgroup\$
  • 2
    \$\begingroup\$ If I understand what you want correctly, you need to use a bitbanged i2c interface, instead of the hardware one. Use a software i2c library like playground.arduino.cc/Main/SoftwareI2CLibrary, so you can have more than one i2c bus. \$\endgroup\$ – Passerby Aug 2 '15 at 10:40
2
\$\begingroup\$

There are always at least two solutions to a problem.

You could use the USART to communicate between your slave arduinos and the master arduino: you just need to "AND" the TX of the slaves into the RX of the master arduino, and route the TX of the master to all the slaves alike. Then it's a matter of making sure they don't talk all at once, by making the master send first the ID of the slave it wants to talk to, request all the data (only the slave with the matching ID will be programmed to answer), get the data back and turn to the next device.

There are also bus switches/multiplexers, that you can either make yourself out of logic gates or buy ready made chips, to use the same I2C lines between devices with the same address - the selection of the device is made with separate lines in this case, rather than made in software like in the above solution. Doing this you could actually get rid of your slave arduinos (assuming the master arduino has enough code memory, RAM and processor time to do everything you want), that would be cheaper and less tedious to maintain.

Usually you could change the address of the chips by desoldering a selection pin and resoldering it to the opposite level, but I checked and your chips only have 2 possible addresses. Sometimes chips have different addresses hardcoded into different part numbers, so you could desolder a chip and resolder a new one in its place with a different address - however it is not your case.

Finally there are software line drivers. Instead of using the only I2C hardware driver on the pro mini, there are libraries that provide functions to control arbitrary GPIOs in the same way a hardware driver would. They're usually slower than dedicated drivers, but for many applications it's enough, and this is certainly okay for you. http://playground.arduino.cc/Main/SoftwareI2CLibrary

\$\endgroup\$
  • \$\begingroup\$ Thank you, I have got a USART working but I felt like I wanted something more robust than a serial communication. I will give a try to this software i2c. \$\endgroup\$ – max246 Aug 6 '15 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.