[SOLVED]MCP23017 - Hall switch

Thread Starter

ghebaur

Joined Jun 17, 2014
35
Hello!

I am trying to build a matrix keypad with Arduino Uno and a MCP23017 port expander. I got the MCP23017 working with the keypad_mc17 library to this poin.

Now i want to use halls sensors instead of pushbuttons and i don't know how to wire them to MCP23017. I have A3144 hall sensors and little knowledge of electronics
I tried using different diagrams but none worked. The MCP23017 has internal pull-up resistors.

Let's say that i had a pushbutton between pins 21 and 22 of MCP23017 and it worked fine, how do i wire the hall sensor to act as a switch to replace the pushbutton?


Datasheets:
http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf
https://www.elecrow.com/download/A3141-2-3-4-Datasheet.pdf
 
Last edited:

AlbertHall

Joined Jun 4, 2014
12,625
Those hall switches have one terminal of the switch connected to ground. You can't connect them in the standard XY matrix configuration used for keypads.
 

AlbertHall

Joined Jun 4, 2014
12,625
If you need 16 or less pushbuttons you could connect one hall switch to each input on the expander chip.
If you need more than 16 then you could use CD4066 to convert the hall output into a floating connection which you can connect as you would a 'normal' switch. This would work but each '4066 contains 4 switches so you are going to need quite a number of them so it might be better to use multiple expanders.
 

Thread Starter

ghebaur

Joined Jun 17, 2014
35
I need 41 switches and i thought it will work without any other components... I thought that the hall sensors can simply replace a simple pushbutton. Then i could use three expanders as you suggested, a switch for each pin. How do i wire the hall sensors in this case?
 

AlbertHall

Joined Jun 4, 2014
12,625
Connect each switch output to its own pin on the expander and turn on the pullups in the expander. Then read the inputs from the expander and any low level indicates a closed hall switch.
 

Thread Starter

ghebaur

Joined Jun 17, 2014
35
Connect each switch output to its own pin on the expander and turn on the pullups in the expander. Then read the inputs from the expander and any low level indicates a closed hall switch.
That's gonna work and i won't need diodes anymore. The downside is that i need to get programming as the library i was using can handle only matrix keypads and i can't get it to to handle more than 10 buttons the way you suggested.
 

Sensacell

Joined Jun 19, 2012
3,784
If you connect the hall switches to opto isolators, they can be connected as a matrix, since the output is floating.

This gets you back to the original matrix software, at the expense of a shit-ton of opto isolators.
 

AlbertHall

Joined Jun 4, 2014
12,625
If you connect the hall switches to opto isolators, they can be connected as a matrix, since the output is floating.

This gets you back to the original matrix software, at the expense of a shit-ton of opto isolators.
Yes but you would have to make sure that they were connected the right way round to the matrix as transistors are not bi-directional like switches.
 
Top