Part 2 - How to Expand Tasmota/Sonoff Devices with the I2C Protocol - MCP23017 GPIO Expansion - I²C

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
have you run out of GPIO pins on your song basic when I add more to it do you want to add three buttons some additional LEDs button for the light button for up fan a button for down fan but simply don't have enough GPIO pins well here's your solution the mCP 23 zero one seven this is part two of the series of covering the I squared C chips on taz moto so if you missed that video be sure and check out part one of this series let's get to it so the last chip we're gonna talk about is very powerful and we're going to show some various scenarios used because it's an input and output it's just like the other ones you have voltage ground clock and data but where it gets interesting is on this particular breakout board you have B 0 a 0 but B 0 through b7 and a 0 through a 7 do not confuse these with analog inputs these are all digital input and outputs this is the 16 channel board they also make another chip that's also usually in a dip style chip that's 8 channel instead of the 16 channel once you plug it in and see it's actually on the taz moto GUI you actually won't see anything but if you actually go into the console and do the I squared C scan you will see that this if the chip is initialized if it's not you may have to according to the wiki you can change the address of the chip utilizing by grounding the there's up at the top left you'll see there's a 0 1 and 2 and these are you apply the combination of ground or 3.3 volts to utilize the address you want the default address is 0 X 20 and just to note you will need to compile your own taz mota bien file that actually utilizes the mCP 2301 7 so before we get into a little test scenario with this chip this table that will help you out a lot because on the bottom of the chip there's the a 0 through 87 and then the B 0 through b7 and that's going to show you the course bonds to the different pin names and the commands are gonna be using here is called sensor 29 and you can send those sensor 29 through the console or you can also send the sensor 29 through mqtt with the several commands you'll type these at the console for what you want and you always will do sensor 29 if you just want to reset everything you can do sensor 29 reset and/or Center 29 and reset one etc to configure these individually is you'll do sensor 29 and you'll label the pin and the pin mode and whether you have a pull up or not the pin mode there's input it just floats be careful with that because unless you have something that's pulling it up or pulling it down or you have the input and it'll interrupt on change basically the center mqtt message it will send an MQTT message any time it changes from low to high or from high to low so that might be something useful for say a a door that opens and closes then you have the other options of when it changes just to low or it changes just to high and then the pull up is there is 0 or 1 and take note it is a weak internal pull up that's on the chip so if you need something as it has a little more oomph to it may want to do your own external pull up so we're gonna start fresh here what I have here is a touch button that does a latching of high or low I have a am 3 1 2 motion sensor and I have 3 LEDs on a breadboard with some resistors to cut back the load so basically we're gonna have two inputs and then three output we're gonna do sensor 29 0 pin 0 comma 5 for the setup and what that is we're gonna do pin 0 5 is the output and it defaults you can do a add to 0 you know default to off on a reset powerup and our defaults to on and one very important thing about this board is during a reboot it's not gonna just flicker your pins for a split second so since you're 29 pin 0 pin mode 5 and default to off and if you look at the top of the video a sensor 29 pin 0 if you do a t it's gonna toggle and where I'm getting those commands is back in here you'll see you can send an on and off or T to toggle so we'll just do a toggle and you'll see we get our red LED so we'll set up sensor 29 pin 1 comma 5 comma 0 that's my next LED and then we'll do a sensor 29 pin 1 toggle and there's the green LED and then sensor 29 pin 8 because I have it on B 0 comma 5 comma 0 you can figure that as output and we'll do sensor 29 8 comma T and that turns on the white LED if we send over the sensor 29 command with a payload of say 8 T that would actually toggle that you can run that in a node red automation or you could do it in a home assistant kind of sensor 29 we do 8 comma 2 you'll see it toggles it and if you publish it again you see it toggles it back so to do the inputs new sensor 29 pin 3 comma 2 because we want to know when it changes whether it's high to low or low to high and then I do not need to pull up on either of these devices so then we'll do sensor or 29 to comma 2 comma 0 that's my second pin and I want to know when it changes no matter which state and I don't need to pull up now you'll notice once you have those in if you look at the console you'll see this event and it shows you the time and it shows as MC p230 xx interrupts shows you the pin and this is the state went too low it shows you the millisecond since it last had an event so one should be there's the motion triggering and it should toggle back to zero and the button you can see changes and it goes high and then we tell it goes low we can do a rule and the rule if you want to do rule one if we look here we can get the rule they're showing here to use one of these as a button to toggle a power relay but we don't have a power relay on this device change this rule up here so we'll say on event MCPE interrupt d0 why don't we don't want D 0 D 3 if it equals a 1 which means I push that button we're gonna do a publish of MCP slash button 1 in on will get to the value yes and then end on and then we'll rule 1 1 turn it on push that button it published to an MCP slash button 1 topic of the payload of yes one rule of I did already I did on motion which is d2 when it goes to low it's going to do a backlog of sensor 29 it's going to turn 0 pin off and it's going to turn number 1 pin on then if the motion is triggered to do the reverse and that's just going to toggle the red and green lights back and forth every time there's motion so you should see the LED on the left and the motion goes clear it goes green we'll put our hand back and we got red an easy way you can have a trigger different relays or do whatever you can't have other pins trigger other pins on the same board so another rule I worked up when we touch the button it'll actually will turn the white LED on it'll stop the motion from triggering back and forth and I just did a using some back logs and actually in the backlog you actually have it turn rule 1 off when the button is pushed and then when the button is untitled it turns rule 1 back on and you can put as many backlogged commands as you want of course within the confines of the capacity of the rule so if we push the button turns the two LEDs off in terms of white Owen and it stops the motion triggering back and forth if we do turn it off turns the toggling back and forth again of the motion and turns the white LED off that's just a little quick scenario as you can see that quickly add 16 input and output pins did you could use with various buttons or LEDs for your automations using on your Taz motor devices be sure to share in the comments your different ideas you may find to do with this expansion board that truly opens up any Taz moto device or so know for what other type of switch that you're doing so to look at one real use case of the NCP 23 zero one seven on the I fan zero two there's really only two GPIO pins that are easy to get to and that's the TX and rx pins on the programming header so what I did is I took a small proto board and some female header pins i soldered in some jumpers and some male 90-degree headers i soldered in some resistors before the leds should have went with a little more resistance I think I used in up using 4.7 k's or a 3.8 K I believe they're not as bright in real life as they are shown on the video the camera kind of blows out LEDs what I have here is there's three resistive touch buttons behind the panel that are a momentary touch and I have two RGB LEDs so that takes up six output channels and then I also have a white LED for the output you can see here on pins D 9 d 10 these are all lists as the outputs and currently these two are on and what I use the panel for is I use the white light to show if like a doors open in the house one of the LEDs if it's red the dryers on if it's blue the washing machines on if it's purple from the mixture of those two colors then the washer and the dryer is on the other led shows the alarm panel current status whether the alarm is armed or disarmed just showing a simple red or a green for the status of the alarm and you push everything over use an MQTT you can either use the Yama automations to do the mqtt publisher's or you can use no dread like I've done in this example here and the timestamp that's just for me to give buttons to push in if you're not familiar with no dread just for the sake of this video you can see one of my below ones is I'd look for the doors changed on home assistant and I get the door state see the doors are open or closed and then I turn the white light on when I turn the white light off based on the door state and all that's doing it's doing a switch node and setting the payload to 15 T and then it sends it over to the command my son off master bedroom fan o - and it does a command of sensor 29 and so that's all that does the same thing for when the doors change it will sin pin 9 on free to turn the light on or it'll do pin 9 off and it sends those over and you can see on the console we were pushing those buttons it was receiving the commands to toggle the different pins it's just a real simple way to show you how a real scenario where I've used this chip it's a little bonus feature here say for instance you have a temperature sensor or will use this luck sensor you don't always want the value to be sent across through mqtt just if it's the same all the time what if you only want to see it when it's published to a certain special topic only when it changes within a certain Delta well a simple way to do that is utilizing the rules and you don't have to rely on the telemetry or the telemetry time or anything it'll just publish to a new topic based on the actual value of how much of a change you take the sensor which is the BH 1750 you set a rule you say on a luminance sensor type of be a 17:50 pulled straight off the console so with this this one here is you say on b8 1750 illuminance which is going to change is greater than var one what you'll do is you'll store the value in var one so every time it loops through its gonna do a backlog command which is a set of commands so it's going to say store in var one the current value then it will publish to MCU slash lux topic and you can change the sliver topic you want the current value then it says store in var to the actual value then it will add 100 to var 1 and subtract 100 from var 2 then a second rule in the same rule buffer it's very similar says less than var two will store the var two value will publish the value in var one will save the value and will add 100 to var1 and will subtract 100 from 4 to that's what that's doing and setting the men and the max every time the value is meets the threshold so to see that if we look in the console we'll move the sensor here in the light and you can see what it does it published 209 to MCU looks it's set var one as 209 it added 100 that said at 3:09 it subtracted 109 so what would happen is you'll notice because our telemetry messages the lux is changing ever so slightly 155 151 etc but it has to go above 309 or below 109 before it runs the rule again and stores the new min and Max thresholds so you could use this not just to go to a topic you could have it turn on another switch turn on something based if it got too dark or notify you if it got too hot somewhere but on temperature sensor do a humidity for like say turn on a fan if the humidity got too high somewhere say in a bathroom from somebody taking a shower you could do multiple things with the rules because you could publish straight to other topics and it will put this up again it's not gonna continue to publish to this topic until it gets outside of the men and the max utilizing that rule so thanks for watching hopefully there's something you learned here that you can apply to your home be sure to subscribe and hit the bell notification icon so you can catch our next video and you'll take care
Info
Channel: digiblur DIY
Views: 24,456
Rating: undefined out of 5
Keywords: Tasmota, Sonoff, iTead, Sonoff Basic, NodeMCU, Arduino, i2c Sensor, I²C Sensor, Expand Tasmota, More GPIO, Add GPIO, HomeAssistant, Temperature Humidity, AM312 Motion, BME280, MCP23017, digiblur, flash tasmota, smart home, DIY, home automation, ESP8266, Home-Assistant, hassio
Id: r-kZ3OBeRrA
Channel Id: undefined
Length: 16min 18sec (978 seconds)
Published: Mon Nov 12 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.