Communicate I/O over I2C

Hi. On my project i started to use I2C to communicate between several devices.
This was ok with 1 or 2 devices but now starting to get up to 9 devices i need to modify some data flow.
1 device is an MCP23017 and i send all individual bits i/o..
Now i want to send I2c combined byte and use 16bit split to split the i/o back into usable input bits.

My problem is only to create output bits from gpio inputs to an output byte over I2c...

So i need a node to send 16 separate switching states to an MCP23017 over I2c with 2 byte.
Eg. 0000 0000 0000 1111 would be 0E or 15....

who can point me in the right direction..

best regards benno

here is a example of joining incoming i/0 in to a object, then converting to a binary string and outputting a hex string.
the incoming gpio need topics link in the inject nodes.

[{"id":"33a4a125.5feda6","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gpio1","payload":"1","payloadType":"num","x":90,"y":4360,"wires":[["f1206efe.98776"]]},{"id":"f1206efe.98776","type":"join","z":"c791cbc0.84f648","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":310,"y":4580,"wires":[["901640e3.170d88"]]},{"id":"d3409c04.3ffeb","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gpio1","payload":"0","payloadType":"num","x":100,"y":4400,"wires":[["f1206efe.98776"]]},{"id":"6717ce0b.5720f8","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gpio2","payload":"1","payloadType":"num","x":80,"y":4480,"wires":[["f1206efe.98776"]]},{"id":"b96edc6b.f39de8","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gpio2","payload":"0","payloadType":"num","x":80,"y":4520,"wires":[["f1206efe.98776"]]},{"id":"55548b7e.06c7cc","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gpio3","payload":"1","payloadType":"num","x":90.33332824707031,"y":4583.66650390625,"wires":[["f1206efe.98776"]]},{"id":"189d1c22.ef16b4","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gpio3","payload":"0","payloadType":"num","x":100.33332824707031,"y":4623.66650390625,"wires":[["f1206efe.98776"]]},{"id":"4b6d363.10c3c48","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gpio4","payload":"1","payloadType":"num","x":100,"y":4680,"wires":[["f1206efe.98776"]]},{"id":"dbb44363.c19a5","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gpio4","payload":"0","payloadType":"num","x":110,"y":4720,"wires":[["f1206efe.98776"]]},{"id":"901640e3.170d88","type":"function","z":"c791cbc0.84f648","name":"","func":"msg.payload = parseInt(Object.values(msg.payload).reverse().join(\"\"), 2).toString(16);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":4580,"wires":[["5e428022.edd948"]]},{"id":"5e428022.edd948","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":4580,"wires":[]}]

Marvelous, Will try it tomorrow morning and come back with the results.

Thanks so far.

Benno

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.