Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


chimera

448 posts

Ultimate Geek


#223117 13-Sep-2017 16:12
Send private message

Electronics nerds,...

 

I have an alarm system where I have PIRs that read back to the controller as 9V when triggered and 5.5V when idle.

 

I need to convert from 9V to 3.3V, and 5.5V to 0V (or thereabouts) for GPIO input pins on an ESP8266 chip, as I want to read movement in the various zones, then have that sent as MQTT messages from ESP to OpenHAB which updates with the "date/time of the last movement detected".  I'll be using a Wemos D1 mini board.

 

I can't quite work out the resistor values for R1 and R2 to get the desired results however, there is a very fine tolerance for both and quite possibly not enough variance to differentiate between "high" and "low".  For example:

 

R1 = 6800 ohms, R2 = 900 ohms

 

Vin = 9V, Vout = 1.05V

 

Vin = 5.5V, Vout = 0.64V

 

Would a 3 resistor voltage divider work better?

 

I also can't find the datasheet for the Wemos D1 mini to find what the variance is for pin = LOW vs pin = HIGH, I seem to recall reading in the past LOW is < 0.75V or so.  If anyone knows has a link it would be most appreciated.

 

Anyways, is a voltage divider suitable in this case, or is there another solution that would work better?  I think I read somewhere that I could use MOSFET's to do this?

 

Any ideas?  

 

 

 

Thanks

 

 





 

 


Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic
 1 | 2 | 3 | 4
worzel
4 posts

Wannabe Geek


  #1864614 13-Sep-2017 16:43
Send private message

I suspect you will need to add a pull-down resistor first, and then sort out the voltage divider.

 

Try attaching a resistor between the output and ground.  10k ohms is typical.  That will give you close to 0v when not triggered.  If you still get 9v when triggered you are in business.  If not, try putting the resistor between the output and the supply voltage of the PIR (eg 9v or 12v) instead and see if the voltage goes to 0v when not triggered.

 

Once you have an output that is swinging between something close to 0v and a high voltage, all you need to do is divide the high voltage.  Values of say 3k3 and a 6k8 should work and give you around 3v when triggered.


 
 
 

You will find anything you want at MightyApe (affiliate link).
chimera

448 posts

Ultimate Geek


  #1864630 13-Sep-2017 17:02
Send private message

worzel:

 

I suspect you will need to add a pull-down resistor first, and then sort out the voltage divider.

 

 

LOL. Just tried the pull-down resistor then powered the alarm system back on - however pulling down the voltage at the breadboard (with common ground) pulls the voltage down on the alarm system too - so it caused the siren to go off!!  I suspect that must be a tamper proof setting in case someone decided to cut the wires at the PIR.

 

 





 

 


ubergeeknz
3344 posts

Uber Geek

Trusted
Vocus

  #1864635 13-Sep-2017 17:07
Send private message

Use a zener diode of 6v and a high value pulldown resistor (100k should do)

 

 

 

in ---|<---out---/\/\/\---gnd

 

 

 

 Your current setup will be too low impedance and is affecting the voltage.  You could also try multiplying both resistor values by 10 or 100.  The input impedance on the esp8266 should be extremely high.




chevrolux
4962 posts

Uber Geek
Inactive user


  #1864645 13-Sep-2017 17:38
Send private message

Isn't this where a transistor would be used? So your outputs from the PIR's would go to the base of a transistor and then run your 3.3V to the collector and then emitter out to the chip's input. Or are the voltages to high?

 

... I have no idea. Just thinking out loud.

 

 

 

Edit: You mention MOSFETs - yea thats my thought process above but not sure an actual MOSFET transistor would be required.


chimera

448 posts

Ultimate Geek


  #1864652 13-Sep-2017 17:55
Send private message

Electronics lessons for the day...

 

1. Have adequate lighting where ever you're working

 

2. Don't work in confined spaces and stretch large distances to plug sh$% in, get a chair or a ladder

 

3. Check and double check your connections...

 

 

 

I had a wire for what I thought was GND plugged into 12V DC on the alarm panel, with the other side plugged into PIR output.  No wonder I initially got a negative voltage on my multimeter, too many damn wires!!!  Should have gone to spec savers :-)

 

Anyways, starting this again - I have readings of 8V for active, and 4.3V for idle now...

 

I prefer the MOSFET idea - I just can't for the life of me find the article that gave an overview of how it worked.

 

 





 

 


geocom
587 posts

Ultimate Geek

Subscriber

  #1864702 13-Sep-2017 19:19
Send private message

Any reason why your not using the analog pin on the wemos D1 Mini?

 

R1=1k

 

R2=650

 

At 8v you would end up with 3.152V and at 4.3v you would end up with 1.694V then just do a if analogValue > 2.5 == HIGH

 

Also are you sure the voltages are 8v and 4.3v those seem like odd values.





Geoff E


chimera

448 posts

Ultimate Geek


  #1864722 13-Sep-2017 20:02
Send private message

Analog pins were certainly an option, hadn't ruled them out. Probably a lot easier.

Yes, weird values but that's what they are reading. I actually used my other multimeter to confirm as I thought the same thing.

Thanks




 

 




chimera

448 posts

Ultimate Geek


  #1864793 13-Sep-2017 21:42
Send private message

I'll start from scratch and RTFM first,... just downloaded the alarm manual, the way I read it seems it needs to be 12V for the PIR after all...

 

Click to see full size

 

 





 

 


Aredwood
3885 posts

Uber Geek


  #1864865 14-Sep-2017 00:57

@chimera Use a voltage comparator. The LM339 would be ideal for what you want. You simply feed 2 different voltage levels into it, and an output switches on and off depending on which input has more voltage than the other. Jaycar sell it for $2.40 ZL-3339

 

Connect the LM339 to the 12V supply from the alarm. Use 2 resistors as a voltage divider to get whatever voltage you want as your "changeover voltage" (7V maybe?) Connect that voltage to all of the minus input pins of the comparator. and connect each + input pin to an alarm zone. Since the LM339 is a quad comparator, it will do up to 4 alarm zones.

 

The output pins are open collector, meaning they are either open circuit, or connected to ground. If the ESP8266 has inbuilt pullup resistors on it's inputs, simply connect it's input pins to the comparator outputs. Otherwise just connect 10K resistors between the ESPs 5V rail and the input pins. Because of the open collector design, you can connect the comparator output pins together, if you want to monitor say 4 zones, but you don't need to know which zone got triggered. Just that a zone got triggered.

 

Swap the + and - inputs if you want to swap the output between 0V = zone triggered and 0V = zone normal.

 

Another trick is to use a 10K multi turn variable resistor as a voltage divider. Connect the end terminals to 12V and ground. And the wiper terminal is your reference voltage. So you can then adjust the changeover voltage easily if you want.

 

Remember to link the alarm system ground and the ESPs ground together.






Aredwood
3885 posts

Uber Geek


  #1864867 14-Sep-2017 01:05

Also your alarm system will be using EOL wiring for the sensors, so it can detect if the sensor wires get cut or shorted together. The comparator draws such a tiny current on it's input pins that it won't affect the voltages on the alarm sensor wires.

 

You can also connect multiple comparator inputs to the same alarm zone, but using different reference voltages. If you want to be able to tell the difference between triggered due to the sensor being activated Vs triggered due to tamper.






chimera

448 posts

Ultimate Geek


  #1864889 14-Sep-2017 07:47
Send private message

@Aredwood - thanks heaps for that and for the detail! Makes sense, I'll certainly give that a go!

 

Cheers

 

 





 

 


ubergeeknz
3344 posts

Uber Geek

Trusted
Vocus

  #1865005 14-Sep-2017 09:52
Send private message

That is way more complicated than it needs to be :/

 

honestly a resistor network will do the job, just use higher values (in the 100k range)

 

Or a zener to drop the voltage by a known amount.


kryptonjohn
2523 posts

Uber Geek

Lifetime subscriber

  #1865018 14-Sep-2017 10:11
Send private message

The D1 mini does have one analog (3.2V) a/d input so rather than any tricky-dicky scaling of the two levels just use a two-resistor voltage divider to drop 9v to 3.2V and 5.5V to 2.0V and measure with a/d input.

 

 

 

 [edit typo]


ubergeeknz
3344 posts

Uber Geek

Trusted
Vocus

  #1865135 14-Sep-2017 11:24
Send private message

Let me further elucidate my answer:

 

9v high - 5.5v low

 

 

 

If you use a 6v zener + 100k pulldown

 

1. apparent impedance to the input will be very high, ie it will not be impacted

 

2. 9v will give you 3v at the output (HIGH)

 

3. 5.5v will give you 0v at the output (LOW) because it is not enough to breakdown the reverse bias of the zener

 

4. no need to waste an a/d input or use more active components

 

Choose the value accordingly.  It only needs to be 2v or more to be "high" on a 3.3v digital input.


chimera

448 posts

Ultimate Geek


  #1866300 14-Sep-2017 15:17
Send private message

ubergeeknz:

Let me further elucidate my answer:


9v high - 5.5v low


 


If you use a 6v zener + 100k pulldown



Would a Schottky diode suffice or does it need to be a zener diode because of the reverse biasing?




 

 


 1 | 2 | 3 | 4
Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic





News and reviews »

One New Zealand Extends 3G Switch-off Date
Posted 11-Apr-2024 08:56


Amazon Echo Hub Review
Posted 10-Apr-2024 18:57


Epson Launches New Versatile A4 Desktop Scanners
Posted 10-Apr-2024 15:31


Motorola Mobility Launches New Android Phones in New Zealand
Posted 10-Apr-2024 14:59


Logitech G Unveils the PRO X 60 Gaming Keyboard
Posted 9-Apr-2024 19:01


Logitech Unveils Signature Slim Keyboard and Combo
Posted 9-Apr-2024 13:33


ExpressVPN Launches Aircove Go Portable Router With Built-in VPN
Posted 26-Mar-2024 21:25


Shure MoveMic Review
Posted 25-Mar-2024 12:47


reMarkable 2 Launches at JB Hi-Fi New Zealand
Posted 20-Mar-2024 08:36


Samsung Galaxy S24 Ultra review
Posted 19-Mar-2024 11:37


Google Nest Wifi Pro Review
Posted 16-Mar-2024 11:28


Samsung Galaxy A55 5G and Galaxy A35 5G
Posted 12-Mar-2024 12:41


Cricut EasyPress Mini Zen Blue launches at Spotlight New Zealand
Posted 12-Mar-2024 12:32


Logitech Introduces MX Brio Webcam
Posted 12-Mar-2024 12:24


HP Unveils Broadest Consumer Portfolio of AI-Enhanced Laptops
Posted 3-Mar-2024 18:09









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.







GoodSync is the easiest file sync and backup for Windows and Mac