miketr3
Posts: 20
Joined: Thu Jan 26, 2017 9:02 am

I2C

Wed Jul 26, 2017 11:55 am

I'm considering a project that would use input from 4 sensors and control 4 solenoids, but I want the option to expand it to more devices. It would seem that I2C would be the best interface option.
This is new territory for me, and lots of stuff I've read has assumed a level of knowledge.

Can anyone recommend a good source of info on the use of both hardware and software using I2C for a beginner, or should I go ask this in the hardware & peripherals forum?

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: I2C

Thu Jul 27, 2017 9:41 am

Start with http://www.hobbytronics.co.uk/mcp23017- ... nder-board that gives you sixteen channels that can control 5V relays.

For the sensors you may not get a choice whether things are SPI or I2C, depending on which sensors you're thinking of using.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

miketr3
Posts: 20
Joined: Thu Jan 26, 2017 9:02 am

Re: I2C

Thu Jul 27, 2017 10:28 am

DougieLawson wrote:
Thu Jul 27, 2017 9:41 am
Start with http://www.hobbytronics.co.uk/mcp23017- ... nder-board that gives you sixteen channels that can control 5V relays.

For the sensors you may not get a choice whether things are SPI or I2C, depending on which sensors you're thinking of using.
Thanks for that. For sensors I'm thinking of
https://www.tindie.com/products/miceuz/ ... re-sensor/
A bit more expensive than those from China, but offer more options.

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: I2C

Thu Jul 27, 2017 1:16 pm

You may find that running more than one of those sensors on a single I²C bus isn't possible. The MCP23017 has three address pins that allow you to change it from 0x20 to 0x27 inclusive on the I²C bus.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

miketr3
Posts: 20
Joined: Thu Jan 26, 2017 9:02 am

Re: I2C

Thu Jul 27, 2017 1:29 pm

DougieLawson wrote:
Thu Jul 27, 2017 1:16 pm
You may find that running more than one of those sensors on a single I²C bus isn't possible. The MCP23017 has three address pins that allow you to change it from 0x20 to 0x27 inclusive on the I²C bus.
According to the technical data it is possible to write a new address to each sensor, they all come with default 0x20

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: I2C

Thu Jul 27, 2017 2:11 pm

miketr3 wrote:
Thu Jul 27, 2017 1:29 pm
DougieLawson wrote:
Thu Jul 27, 2017 1:16 pm
You may find that running more than one of those sensors on a single I²C bus isn't possible. The MCP23017 has three address pins that allow you to change it from 0x20 to 0x27 inclusive on the I²C bus.
According to the technical data it is possible to write a new address to each sensor, they all come with default 0x20
It does seem from the documentation that the sensor has the same range of permitted addresses as the MCP23017, 0x20 - 0x27, this would allow you to have up to 7 sensors with 16 digital outputs (such as relays or LEDs) (also available to be used as inputs), for each sensor you lose from that maximum you could gain another 16 digital I/O channels. If absolutely required additional addresses for sensors or I/O could be made available with I2C multiplexers (with corresponding additional complexity).
Doug.
Building Management Systems Engineer.

miketr3
Posts: 20
Joined: Thu Jan 26, 2017 9:02 am

Re: I2C

Thu Jul 27, 2017 3:14 pm

BMS Doug wrote:
Thu Jul 27, 2017 2:11 pm
miketr3 wrote:
Thu Jul 27, 2017 1:29 pm
DougieLawson wrote:
Thu Jul 27, 2017 1:16 pm
You may find that running more than one of those sensors on a single I²C bus isn't possible. The MCP23017 has three address pins that allow you to change it from 0x20 to 0x27 inclusive on the I²C bus.
According to the technical data it is possible to write a new address to each sensor, they all come with default 0x20
It does seem from the documentation that the sensor has the same range of permitted addresses as the MCP23017, 0x20 - 0x27, this would allow you to have up to 7 sensors with 16 digital outputs (such as relays or LEDs) (also available to be used as inputs), for each sensor you lose from that maximum you could gain another 16 digital I/O channels. If absolutely required additional addresses for sensors or I/O could be made available with I2C multiplexers (with corresponding additional complexity).
Thanks, this is a steep learning curve and I need to find some resources for beginners that will bring me to a level where I can fully understand what you said, lol.

miketr3
Posts: 20
Joined: Thu Jan 26, 2017 9:02 am

Re: I2C

Sat Jul 29, 2017 4:53 pm

DougieLawson wrote:
Thu Jul 27, 2017 9:41 am
Start with http://www.hobbytronics.co.uk/mcp23017- ... nder-board that gives you sixteen channels that can control 5V relays.

For the sensors you may not get a choice whether things are SPI or I2C, depending on which sensors you're thinking of using.
Dougie, this board seems ideal combined with their breakout board as it's a direct connection between the two boards.
However, as I'm a newbie and not wanting to risk damaging anything, I'd thought about putting the following circuit between the two boards.
Attachments
Isolated I2C.jpg
Isolated I2C.jpg (10.49 KiB) Viewed 1110 times

Return to “Beginners”