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.




252 posts

Ultimate Geek
+1 received by user: 51

Subscriber

Topic # 223117 13-Sep-2017 16:12
Send private message quote this post

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
1 post

Wannabe Geek


  Reply # 1864614 13-Sep-2017 16:43
Send private message quote this post

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.




252 posts

Ultimate Geek
+1 received by user: 51

Subscriber

  Reply # 1864630 13-Sep-2017 17:02
Send private message quote this post

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.

 

 


 
 
 
 


Fully Operational
3343 posts

Uber Geek
+1 received by user: 1088

Trusted
Vocus
Subscriber

  Reply # 1864635 13-Sep-2017 17:07
Send private message quote this post

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.


3165 posts

Uber Geek
+1 received by user: 978

Subscriber

  Reply # 1864645 13-Sep-2017 17:38
Send private message quote this post

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.




252 posts

Ultimate Geek
+1 received by user: 51

Subscriber

  Reply # 1864652 13-Sep-2017 17:55
Send private message quote this post

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.

 

 


458 posts

Ultimate Geek
+1 received by user: 95

Subscriber

  Reply # 1864702 13-Sep-2017 19:19
One person supports this post
Send private message quote this post

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



252 posts

Ultimate Geek
+1 received by user: 51

Subscriber

  Reply # 1864722 13-Sep-2017 20:02
Send private message quote this post

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



252 posts

Ultimate Geek
+1 received by user: 51

Subscriber

  Reply # 1864793 13-Sep-2017 21:42
Send private message quote this post

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

 

 


1972 posts

Uber Geek
+1 received by user: 629

Subscriber

  Reply # 1864865 14-Sep-2017 00:57
One person supports this post
Send private message quote this post

@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.






1972 posts

Uber Geek
+1 received by user: 629

Subscriber

  Reply # 1864867 14-Sep-2017 01:05
One person supports this post
Send private message quote this post

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.








252 posts

Ultimate Geek
+1 received by user: 51

Subscriber

  Reply # 1864889 14-Sep-2017 07:47
Send private message quote this post

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

 

Cheers

 

 


Fully Operational
3343 posts

Uber Geek
+1 received by user: 1088

Trusted
Vocus
Subscriber

  Reply # 1865005 14-Sep-2017 09:52
Send private message quote this post

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.


997 posts

Ultimate Geek
+1 received by user: 358

Subscriber

  Reply # 1865018 14-Sep-2017 10:11
One person supports this post
Send private message quote this post

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]


Fully Operational
3343 posts

Uber Geek
+1 received by user: 1088

Trusted
Vocus
Subscriber

  Reply # 1865135 14-Sep-2017 11:24
Send private message quote this post

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.




252 posts

Ultimate Geek
+1 received by user: 51

Subscriber

  Reply # 1866300 14-Sep-2017 15:17
Send private message quote this post

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
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



Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

Phone prices rising as users move upmarket
Posted 24-Nov-2017 17:16


Talking net neutrality on RNZ Nine-to-Noon
Posted 24-Nov-2017 12:11


Air New Zealand experiments with blockchain technology
Posted 23-Nov-2017 15:39


Symantec selects Amazon Web Services to deliver cloud security
Posted 23-Nov-2017 10:40


New Zealand Ministry of Education chooses Unisys for cloud-based education resourcing management system
Posted 22-Nov-2017 22:00


Business analytics software powers profits for NZ wine producers
Posted 22-Nov-2017 21:52


Pyrios strikes up alliance with Microsoft integrator UC Logiq
Posted 22-Nov-2017 21:51


The New Zealand IT services ecosystem - it's all digital down here
Posted 22-Nov-2017 21:49


Volvo to supply tens of thousands of autonomous drive compatible cars to Uber
Posted 22-Nov-2017 21:46


From small to medium and beyond: Navigating the ERP battlefield
Posted 21-Nov-2017 21:12


Business owners: ERP software selection starts (and finishes) with you
Posted 21-Nov-2017 21:11


Why I'm not an early adopter
Posted 21-Nov-2017 10:39


Netatmo launches smart home products in New Zealand
Posted 20-Nov-2017 20:06


Huawei Mate 10: Punchy, long battery life, artificial intelligence
Posted 20-Nov-2017 16:30


Propel launch Disney Star Wars Laser Battle Drones
Posted 19-Nov-2017 21:26



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.

Alternatively, you can receive a daily email with Geekzone updates.