ADS1115 as Switch Input

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
lucianors
New user
Posts: 2
Joined: 07 Jun 2020, 15:15

ADS1115 as Switch Input

#1 Post by lucianors » 07 Jun 2020, 15:21

Hello.

I am using a bunch of PCF8574 devices to detect pushes on momentary switches. Unfortunately I ran out of those, so I thought I could use a few spare ADS1115 single ended to the same purpose as this is just input.

Unfortunately, the ADS1115 Analog input plugin doesn't seem to be enough, as it requires at least 1s delay. I hacked the code to remove such restriction, but didn't succeed.

Before I jump into trying to write a plugin for that based on PCF8574 Switch, I am wondering if somebody tried the same before.

User avatar
Ath
Normal user
Posts: 3480
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ADS1115 as Switch Input

#2 Post by Ath » 07 Jun 2020, 16:18

What other I/O boards do you have laying around? Maybe a MCP23017? With that controller you can connect up to 16 buttons (and AFAIR 12 for the PCF8574) when using the Keypad PCF8574/MCP23017 plugin from the Testing build. It may need some careful wiring if the switches aren't close to the controller, as they can't pull to ground on close but have to connect a point in the keypad matrix.
/Ton (PayPal.me)

lucianors
New user
Posts: 2
Joined: 07 Jun 2020, 15:15

Re: ADS1115 as Switch Input

#3 Post by lucianors » 07 Jun 2020, 17:33

Hey

So this is a home automation system. I have 8ch mains detector boards (like this: https://www.aliexpress.com/item/3285379 ... 4c4dOxXHBr) wired to PCF8574, and on the other end, common relay boards also attached to PCF8574. So, the mains momentary switches are pushed the optocoupler of these boards are LOW. So it works fine with inverted logic.

Although since the switches are just for input, I should be able to work with these ADS1115 without much trouble, as this is just input anyways... So, if value is higher than a set threshold, that is 1 or 0, pretty much.

That's unfortunately the only things I have around for now.

Thanks

User avatar
Ath
Normal user
Posts: 3480
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ADS1115 as Switch Input

#4 Post by Ath » 07 Jun 2020, 20:00

Ah, I already was afraid you were going to say something like that :D

When you tried to modify the plugin, did you add 'case PLUGIN_TEN_PER_SECOND:' just above the line with 'case PLUGIN_READ:' so the values are read 10 times per second, and if the response is (still) too slow, you could even try PLUGIN_50_PER_SECOND (the names do as they suggest ;) )
And you might want to add 'sendData(event);' in there too, just before the 'success = true;' statement, to start sending out the value to any controllers configured (maybe that should only happen 'if (function != PLUGIN_READ)', as I think the PLUGIN_READ action already does that sendData call)
(All air-code, didn't test any of the above...)
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ADS1115 as Switch Input

#5 Post by TD-er » 07 Jun 2020, 21:21

Please make sure to only call 'sendData(event);' when there has been a change.
It does set a whole chain of events in motion, so if you call it on every call to PLUGIN_FIFTY_PER_SECOND, then I can tell you it won't run at 50 times a second anymore :)

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests