-
• #2
Just because you have nothing at all connected to an input pin doesn't mean it is a logical zoro.
To ensure that inputs default to expected logic levels you need to use pullup or pulldown resistors. See this link for an explanation:
http://playground.arduino.cc/CommonTopics/PullUpDownResistor
-
• #3
Yep - pretty much everything has a bit of capacitance in it, and there could be very small resistances to other pins as well. It's totally normal.
For a really simple example, even if you just press your finger so it covers C0 and some other pins, I bet it will totally change the values you read.
-
• #4
Experience the very same issue with reading values from resistive touch screen. The internal pull-up/down resistors are about 30..40K which may need to be considered when measuring - because they can pose 'significant load' on the measured 'object' - depending on circuitry. In my case, I could not detect the 'OFF' state reliably... continuous reading/sampling without pull-up/down even triggered subsequent setWatch() on the open pin - something did not expect. The solution is to pull down - and if the the 30..40K are a significant factor - switch to open input before reading (see http://forum.espruino.com/comments/11892295/). It is anyway a good thing to have the input as much open as possible to not waste any power. On the other hand to avoid floating, you may consider to pull down externally with a resistor of much higher value - 470K...1M and keep it... (value all depends on your circuitry). In my case it did not really matter 30..40K vs 300..400 Ohms, and left it pulled down.
Hi all
I am new to Espruino and is just starting something what will hopefully be a lot of fun.
So to start simple I have mounted Espruino on a breadboard and measuring voltage by connecting + on the battery to C0 and - to GND and then execute:
setInterval(function(){console.log(analogRead(C0)*E.getAnalogVRef());},250);
... on a AA battery (1,2 V) I measure a value around 1,3 (, used in DK, maybe for you 1.3).
However, when I remove the battery there are still some measurements, should there be?
Example output without battery:
0.67295681063
0.89780730897
2.78936170212
0.87308970099
2.98164893617
0.65816733067
0.86613545816
2.80983388704
0.84438538205
2.89468085106
0.71665560716
0.85554817275
2.88558139534
0.80850498338
1.68605577689
0.77740863787
0.82604651162
2.93058510638
0.81727574750
1.13138297872
0.77023255813
0.84757475083
2.96489361702
0.83800664451
1.00624584717
2.55388704318
0.83720930232
2.93581395348
0.75109634551
0.89780730897
2.81700996677
Example output with battery, which suggest actual reading:
1.38510638297
1.38430851063
1.38498338870
1.38590425531
1.38351063829
1.38430851063
1.38430851063
1.38351063829
1.38590425531
1.38430851063
1.38430851063
1.38259136212
1.38326693227
1.38430851063
1.38430851063
1.40026595744
1.38430851063
1.38259136212
1.38259136212
1.38590425531
1.38430851063
1.38430851063
1.38510638297
1.38510638297
1.38430851063
How come?
Thanks