-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Using ADC #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, I found in the file 'core_esp8266_wiring_analog.c' the code used for the analogRead method. extern int __analogRead(uint8_t pin) { Does anyone can explain me this part of code ? Thanks a lot. |
This seems to be related to having or not having esp_init_default_data.bin flashed. We'll add proper esp_init_default_data.bin to this environment at some point in the future. |
Thanks for your reponse. I don't know how it is possible to "remove" this file during the flash step. Could you please help me on this point ? |
Having this exact same issue, is there anything we can do to work around this? |
Hello, I have the same issue like friends before. I am using voltage divider 10k / 33k so on TOUT (ADC pin) I have 850mV. The result of analogRead(A0) is about 20. I have flashed ESP12 with firmware v0.9.5.2 AT Firmware.bin. |
|
This esp_flasher has a bug which causes the first few sectors of flash to On Tue, Jun 2, 2015 at 5:12 PM, bluewalk [email protected] wrote:
|
Yes, too bad indeed. Do you have any other idea's that might help us finding a solution? |
Sure. |
Reverting the change provided fixes the issue I have with my boards! |
Do you have any external resistors connected to the TOUT pin? Resistor divider? |
Great news :) Where should I change core_esp8266_wiring_analog.c in my arduino folder ? |
You should change this file: C:\Users<>\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266\core_esp8266_wiring_analog.c |
So we have two groups of users, and two versions. One version works for one group, another works for the rest. Have to figure out what the difference is. |
It's no working for me :( When I pull down ADC pin to ground and use Where is a problem ? |
I've just tried a ESP-12 besides my NodeMCU dev board and with ADC grounded I get readings around 380-430 and sometimes a 0. It seems that on an ESP that is not integrated on a dev-board the readings are sometimes off. Whilst in NodeMCU this same setup gives me a constant reading. Grounded:
To VCC:
I've currently solved this by polling the ADC value twice with a three second delay, compare those, and if they are the same it's a good reading... not as it should, but kinda works atm. |
I made the changes in the file core_esp8266_wiring_analog.c and the issue is fixed on my NodeMCU 0.9.5 build 20150318. To ground: To VCC: to VCC/2 (resistor divider): |
Ok I will try this on NodeMCU firmware (not v0.9.5.2 AT Firmware.bin) but I remember I had a problem with programming from Arduino IDE when I flashed NodeMCU firmware :( There was a problem with communication. |
I used the NodeMCU flasher (https://github.com/nodemcu/nodemcu-flasher) with the internal binary file (INTERNAL://NODEMCU). This config uses nodemcu_integer_0.9.5_20150318.bin. |
Doesn't the Arduino IDE overwrite parts of the firmware anyway? Address 0x0 and 0x1? So if I understand correctly, you've flashed NodeMCU first and then flashed your generated bins from Arduino IDE through the upload button itself and that makes a difference? |
yes you are right. |
I'll give that a try later when I get home. See if I can replicate it. [edit] |
On what speed you upload your sketch from Arduino IDE after flashing NodeMCU ? I have "error: espcomm_open failed" :( |
Upload Speed : 115200 [edit] |
It must be my ESP-12 that is broken somehow, tried an ESP-07 with the above fix and that one works like a charm! Or is it because it had the AI-thinker firmware on at first? Will try to flash the ESP-12 with AI-thinker firmware and report back. [edit] |
i have same rpoblem on nodemcu dev board whit the original resistor divider. If I put gnd directly on chip, whithout divider, i read correctly 0V |
Any new solution for this problem ? I still have various values from ADC even if I flash ESP_8266_BIN0.92.bin before uploading sketch. |
Arduino Ide completely rewrite the flash, so there is no difference if you upload a .bin before Arduino upload. |
Yes I know, but someone wrote this resolve problem. I have no idea how to fix my issue :( |
If the context here is the Arduino environment, placing that file in the SDK directory will not make Arduino upload esp_ini_data_default.bin to the chip. This is not currently handled in this core... Edit: you can upload this file manually using esptool.py or esptool-ck. The address should be the size of your flash (as you set it in the IDE) minus 0x4000 (which is 0x7c000 for 512k sized flash). |
ok thanks, so we must manually upload the file i think this is an important feature to add to this core, because this byte is used also on the new function that adjust the RF power reading powersupply value on this pin, so actually, whit the original esp_ini_data_default.bin, that have Zero on 107th Byte, this function do not work. From Documentation: |
ok, i tested many times today,
so i Think that from factory we have the 33value in the init .bin file that it is burned. So for now untill in this core there is no init bin file uploading we can use only the analog read. |
5b00eba adds a way to select ADC mode for the sketch — either TOUT or VDD. |
Thanks bluewalk i modified that file and it is working for me now. We shall see what other pitfalls it will have once i start the wifi communication part of my code. |
I have been assembling an environment monitor within the Arduino IDE to email various parameters and used the LDR on the ADC(TOUT) on the ESP8266-201, this resulted in the device regularly crashing....after some tinkering with the circuit with no success I used the advice above indicated by Testato and made no other changes and this has been stable for more than 24 hours... •if i use the offical "system_adc_read()" the ADC value is correct.
I use Vcc<--[22K]---< This is the output without the MQ or PIR they are triggers for the email.... Logging Temperature: 19.30 deg Celsius - Humidity: 56.40% - Time: 10:55:31 - 28/7/2015 - Distance = 1cm - Light Value = 99% Saturation The ADC Line in the Arduino IDE... int LightV = map((system_adc_read()), 40, 900, 0, 100) ; Hope this is of help....... |
@genguskahn are you using the latest stable build? ADC should work there without further changes. |
Arduino IDE 1.64 with the board manager addition only....... |
It is the use of analogRead(A0) that results in the device crashing the only change was the line of code and this has been put back to check........I tried delays, smoothing caps, high value dividers feeding the LDR nothing changed until the line in the post above..... |
Could you please clarify which version you are using (version number is shown in the boards manager) and which line you are referring to? This one? |
I have just updated with the board manager and when I attempt to compile this error occurs? Build options changed, rebuilding all |
Version 1.6.5-947 sorry there was a file protection error....this now compiles successfully will try the analogRead(A0)..... |
The update has corrected this as there have been enough that it would have crashed by now...... Allocated storage for 1268 data points. Many thanks......... |
Can someone post recommended circuit for connecting light dependent resistor on ESP8266? Especially looking for which pin to pull up to. I'm using an adafruit huzzah. Thanks in advance! |
Vcc to 22K ----> ADC Pin (tout) <-------LDR & 10K(LDR Resistance dependant) in parallel to GND (very stable), then use Map to set the final value... |
Adc pin accept only a max value of 1V, so it is important chose a partitor value that at it' maximum value do not break this limit |
ADC or RF - choose yourself: http://www.esp8266.com/viewtopic.php?f=32&t=3905 |
@eta-sys what is the point of your comment? The referenced discussion is over 2 years old, the relevant SDKs mentioned were superseded ages ago, and this issue is closed. My own app does adc reads with wifi up, without issues. |
I personally found this discussion because I have a few ESP8266 modules with 8Mb of memory and wanted to use them. I couldn't use SDK above 10.1 as my program simply doesn't fit into mem. I'm sorry if I made someone angry but the topic I quoted was very helpful for me. |
@eta-sys not angry, I asked seriously. I've seen several issues about the adc, but most reference old discussions or issues or code that is no longer relevant to the current state of the core, or were due to a bad power supply. At this point, I'm wondering why. |
Hi,
I made some tests on the ADC using a NodeMCU 0.9.5 build 20150318.
My code just reads the value on the pin every 500ms.
Using a Arduino program :
I am surprised to have the value 700 when voltage on pin A0 is GND. Should be near 0.
I made the same test with a LUA program using ESPlorer.
The result is the following :
These last results sound good.
Does anyone have the same problem ?
Need something special to use the ADC pin ?
Thanks.
The text was updated successfully, but these errors were encountered: