|
このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。 |
The Sparkfun ESP8266 "Thing" has been around for a while now. It is just one of many ways to enjoy the ESP8266 半導体素子.
The "Thing" has one 献身的な analog input pin. Nota Bene: It should not be 支配するd to more than 1.0v... at least in the Sparkfun 8266 based "Thing" board... but I 嫌疑者,容疑者/疑う the 制限 is ありふれた to many 8266 boards. This page is about that. It is a sub-page, off of another page I've 用意が出来ている for you, which speaks about ESP 8266 Things more 一般に.
Put the に引き続いて in your program...
analogRead(A0)
... and it will return 0 to 1023, depending upon the voltage 現在の on the pin labeled "ADC".
That's "it", 専門家s. You now know "all about" the Thing's analog input. Just before you go....
My first success with my own remote sensing and 支配(する)/統制する across the internet was with my Arduserver.
It is a simple デモ 一括, now 器具/実施するd on a variety of 壇・綱領・公約s. It lets you turn an LED on or off, and lets you "see" that you were successful by the LED's 影響 upon a light sensor, also connected to the Arduserver.
The "Thing" is a little depressing, because with a Thing, anyone can get an Arduserver running in about half an hour. It used to be harder!
Just 説. So... "Bye, 専門家s".
The 残り/休憩(する) of the page is a little help for novices who understand they need to be careful about the 1.0v 限界.
If you are a novice, with electronics, the 1.0 volt 限界 should make a a little nervous... but don't let it 脅す you away from the analog input all together.
The diagram at the left illustrates a voltage divider.
We can draw from the Thing itself as a source of 3v3... as long as we are not greedy! (We'll come 支援する to that.)
We need the "ground" (or "0v") part of 外部の 回路・連盟s which are going to be connected to any Thing work that we're doing to be connected to the "ground" ("GND") of the Thing. (This "all the grounds must be connected" fact is one of those "everyone knows" things that people いつかs don't bother to について言及する. Think about ELECTRONS flowing in CIRCUITS. No way to flow out, around, and 支援する again to where you started, and nothing 電気の will "work". So connect grounds.)
The wire 示すd "Out" is an OUTPUT from what we're doing, which would go INTO the analog input of the Thing. (But don't connect anything yet!)
The analog input of the Thing is between pins 16 and 15, at the upper 権利 of the Thing, as 現在のd at the 最高の,を越す of my main page about the Sparkfun ESP8266 Thing. It is 示すd "ADC", which stands for "Analog to 数字表示式の Converter". As long as you don't connect more than 1.0v here, you can 手段 the voltage "inside" your Thing program...
analogRead(A0)
.. will do. But it is good practice to use "指名するs" for things, so, in the webserver デモ from Sparkfun, for instance, 早期に in the program, the line....
const int ANALOG_PIN = A0;
... 始める,決めるs "ANALOG_PIN" up as a "指名する" for A0. And, in that program, when the programmer wants the Thing to look at the voltage on A0, he/ she says...
analogRead(ANALOG_PIN)
What do you get 支援する? If you say "analogRead(ANALOG_PIN)" when the voltage on that pin is 1.0v, you get 1023 支援する
voltage 0.5v... you get 512
voltage 0.0v... you get 0
and, in between... in between!
So! Now we know how to READ voltages at the ADC pin. And the webserver デモ already has the ソフトウェア we need for some "playing.
Here's another copy of the diagram we had before.
If you 麻薬中毒の that up, and used a 20k resistor for R1 and a 1K resistor for R2, you would be in pretty good 形態/調整.
First and 真っ先の, the 現在の flowing from 3v3 to ground through the resistors would not be too large. If you used 20 OHMs and 1 OHM resistors for R1 and R2, at best everything would grind to a 停止(させる), and at worst, you would 損失 the voltage regulator inside your Thing.
The Thing CAN 供給(する) SMALL 量s of 現在の for your 目的s. I need, soon, to look up what the upper 限界 is, and keep 跡をつける of what 現在の 需要・要求するs I am making with my 事業/計画(する)s. For now, I am just taking it on 約束 that as long as I have at least 10k between the source of my 現在のs and the ground wires they flow too, the Thing should not be over-強調する/ストレスd.
So... first 支配する... don't create a path of such low 抵抗 that the 現在の will get high.
Good news! As long as the voltage 適用するd to the ADC pin is not more than 1 volt, the 現在の which will flow in along that 回路・連盟 is 事実上 nil, and you don't need to worry about it. (If that were not true, all the 計算/見積りs would be much more tiresome. As things stand, you just 追加する the 抵抗s R1 and R2, use the voltage which you know is 3V3 (3.3 volts), and 適用する Mr. Ohms 法律.... 現在の will equal the voltage 運動ing the flow divided by the 抵抗 to the flow. The answer will be in amps, if the voltage and 抵抗 were 供給(する)d in volts and ohms. If you have, say, 5 volts, and a 抵抗 of 100 ohms, you had better be ready for a 0.05 amp 現在の. (The 力/強力にする 供給(する), for instance, needs to be "good for" 0.05 amp... 50mA. And the wires. A 50mA 現在の would not faze an "ordinary" 力/強力にする 供給(する) or wire... but you wouldn't want to ask an Arduino pin to pass that much 現在の. They are delicate. "Good for" up to 20mA... MAX. (It isn't a good idea to operate at 19mA). And "20 mA per pin" isn't the only 支配する you must keep. Depending on 正確に/まさに which Arduino you are working with, having 10 pins each carrying 15mA (under the PER PIN 限界) would be a bad idea.
So... we've 調査するd the 現在の 面s. Now for the VOLTAGE 面s...
If you had the 回路・連盟 shown, and R1 was 10k and r2 were 1k, and 3V3 at "the 最高の,を越す" of the 回路・連盟, the voltage at "生産(高)" would be ABOUT 0.33 volts. 電気の engineers talk about "voltage 減少(する)". Between the "最高の,を越す" of the 回路・連盟, and the 底(に届く), ground, all of the voltage "goes away". In this 事例/患者, in two 行う/開催する/段階s: Some is "lost" between "the 最高の,を越す" and "生産(高)". The 残り/休憩(する) is "lost" between "生産(高)" and ground. How much is lost in each 行う/開催する/段階 depends on the 抵抗 of each 行う/開催する/段階. As the 抵抗 of the upper 行う/開催する/段階 here is ten times the 抵抗 of the lower 行う/開催する/段階, ten times as much voltage 減少(する) will occur across the 最高の,を越す 行う/開催する/段階.
Putting it crudely, but in a form that is perhaps more easily "believed", intuitively, than the formal 決まり文句/製法:
For our 回路・連盟, consider there are ELEVEN "parts"... Ten above "生産(高)", one below. ALL of the 3V3 will be lost in the whole path. 3.3 divided by 11 is 0.3. SO... between "out" and GROUND, in the bit where 1/11th of the total 抵抗 存在するs, there will be 0.3 V lost. Between "the 最高の,を越す" and "out", all of the 残り/休憩(する)... 3.0 volts... will be lost.
Remember that a voltage is ALWAYS 手段d BETWEEN two points. It is "how hard" the 電子s "are 押し進めるing" to flow between those points. Hook up a 回路・連盟 like the one 述べるd, and 手段 the voltage between "out" and "the 最高の,を越す", and between "out" and "the 底(に届く)", ground. You should get values of about 3.0v and of 0.3v. USUALLY, when we say, for instance, "the voltage AT point x" is, say, 2.22 volts, we mean the voltage BETWEEN point x AND GROUND. But voltages are not ALWAYS 手段d that way.
Earlier, I said that one of the 制限s of the ESP8266 is that you must not 支配する the ADC pin to more than 1.0v. What I was 説 is that the voltage BETWEEN the ADC pin AND GROUND should not be greater than 1.0 volt.
井戸/弁護士席. 罰金. But. If we only ever connect up the 回路・連盟 we've seen, we don't need the Thing's cleverness to tell us the voltage... we can work it out!
Ah. Yes. But. There are things which CHANGE their 抵抗 in 確かな circumstances.
Such as a Light Dependant Resistor. (The 指名する pretty 井戸/弁護士席 gives the story away.
The one I have here has a 抵抗 of 400K when hidden from ordinary "indoor" lights in my 握りこぶし, and a 抵抗 of only 900 ohms when 50cm from a 60W incandescent (米)棚上げする/(英)提議する lamp.
If we JUST put the LDR into our 回路・連盟 IN PLACE of "R2", we light have a problem.
If the LDR were to become as conductive as a piece of wire, all would be 井戸/弁護士席... the voltage at "Out", called, not very imaginatively, Vout, would be nearly 無. The RATIO of the 抵抗 above and below "out" are what 事柄 to the VOLTAGE remember. (And a 10k R1 would keep the 現在の small enough.)
But what happens if the 抵抗 of the LDR becomes very high. Or even a little high... say 10k? NOT GOOD. The 割合 of the 抵抗s would be 1:1, half the total voltage would "減少(する)" ("disappear") across R1, and half across R2... making Vout 1.5 volts... half a volt higher than it should be. And, yes, half a volt IS TOO MUCH.
What to do.
Here's one answer:
It's "messy". It has its 欠陥s. But if R1 is 33k (a strange number in "the real world", but a "normal" resistor size in the electronics world), and R2 is 10k , then with no LDR, Vout is 0.7 volts. (That can be calculated, by some not very 複雑にするd mathematical 支配するs, or more 簡単に 決定するd just by hooking up some resistors and 3V3.
So... いっそう少なく than 1v. Good!
And what happens when we connect the LDR と一緒に ("in 平行の with", as in the diagram) R2?....
Think, before you read the answer. What we care MOST about is that we don't want Vout going above 1.0 volt. 33k and 10k on their own produced 0.7 volts between "Out" and Ground. What change will arise if we 供給する another path for the electricity, 平行の to R2? This about the extremes. We already know the answer when the LDR is "極端に 抵抗力のある". That gives 0.7v because an 極端に 抵抗力のある LDR is like an ABSENT LDR. And it the LDR becomes very CONDUCTIVE? (It becomes more conductive as light levels rise.) Remember the voltage 減少(する)s were 比例する to the 抵抗s. LESS 抵抗 負かす/撃墜する below, and there will be いっそう少なく voltage 減少(する) 負かす/撃墜する below. But ALL of the voltage must be "dropped", so いっそう少なく below, means more above.... sooo.....
Spoiler 警報!
I'm about to tell you if the new 回路・連盟 is okay!
========
Yes! It is okay! An LDR would never have NO 抵抗, but, consider the extreme. What if it did? Vout would 落ちる to ZERO!
Our little 回路・連盟 is 天然のまま.
But whatever you may say about it, even people with a 限られた/立憲的な theoretical understanding of electronics can be helped to see that at least we won't be 損失ing our "Thing" with the 回路・連盟.
I've... used?... another day churning this out. Most of the light 落ちるing on the sensor is from the desk lamp here beside me as I type.
First 実験(する)s were an abject 失敗... analogRead() returned values between 750 and 770 with the LDR under a desk lamp, in the shade of my 手渡す... and even when the LDR was Just 行方不明の.
A bit of thinking made me realize I hadn't 麻薬中毒の it up によれば the 計画(する) we'd hatched.
As soon as I did... and remember: The resistor values were chosen "at 無作為の" (井戸/弁護士席, not やめる), to 控訴 the resistors in my junk box. The LDR was "chosen" in the same manner. It was what I had. NOW the ソフトウェア... the basic "web page server" example, using the "/read" 命令(する), 報告(する)/憶測s:
26: When lamp (60W) about 5cm from sensor (LDR) (Don't leave it like that for long. I don't think the sensor will do 井戸/弁護士席 at the heat which will arise.)
35: Lamp 15cm from sensor.
61: Lamp 30cm from sensor.
673: Sensor "hidden" from light by cupped 手渡す : 726: Sensor "hidden" from light by inverted tea 襲う,襲って強奪する. (Gak. The sacrifices I make for you. I really should have drunk that tea while it was at least warm.)
761: Sensor taken out of 回路・連盟.
Some may 軽蔑(する) those values! And a "fancier" 回路・連盟 would have its 長所s. BUT! Even with that CRUDE 回路・連盟, I think we have a very creditable light sensor, more than 適する for SOME 使用/適用s.
For instance: I (機の)カム to the ESP8266 "Thing" a long time after creating my "Arduserver", a simple demonstration of controlling 数字表示式の 生産(高)s, and reading analog and 数字表示式の sensors across the internet. With the little sensor we've built up in the course of this, we have a perfectly 適する Arduserver with (almost) nothing more than the "デモ" web-server that is in Sparkfun's excellent support 構成要素s for the Thing.
They've already 供給するd an LED, on board, which can be turned on and off 経由で a web browser, across the web. If you hook up an LDR, as 述べるd above, and bend it '一連の会議、交渉/完成する to "look" at the LED, even with the distraction of the nearby "力/強力にする" LED, you can "see" the 影響 of turning the on-board LED on and off:
Analog pin reading, LED off: 41-44, depending on where (米)棚上げする/(英)提議する lamp is 向こうずねing...
Analog pin reading, LED on: 34 or 35... WORKS!... and that's "first try", without 精製するing any of many things which could BE 精製するd, to give a more 強健な system... 外部の, bigger, 孤立するd LED in place of on-board LED. Sensor and LED 孤立するd together, 保護物,者d from extraneous light from 残り/休憩(する) of world... tin 失敗させる/負かす 作品 井戸/弁護士席, once all exposed metal 孤立するd with 電気の tape.
Please get in touch if you discover 欠陥s in this page. Ways you are using "the Thing" would be of 利益/興味, too. Please について言及する the page's URL. (www. thingie)
If you 設立する this of 利益/興味, please について言及する in fora, give it a Facebook "like", Google "加える", or whatever. I've almost given up 令状ing these pages, because it seems they are seldom read, and of course not every reader will use them... so... is there any point? If you want more of this stuff, help!?
Click here to visit my main homepage where you
can 調査する other areas, such as education, programming, 投資するing.
Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes. A few "bad せいにするs" 予定 to Google+ button, etc.
....... P a g e . . . E n d s .....