I'm exploring ESP8266 boards
currently using a nodeMCU board
I use Arduino 1.6.12 to program the board
Have installed ESP8266 through menu Tools>>Board>>Board Manager
Then selected board "NodeMCU 1.0 (ESP-12E Module)"
Wrote a simple test example
compiled and uploaded
and it worked
so what?
As an absolute beginner with the ESP8266 i had done some reading and knew well that
for programming you have to boot with GPIO0 on GND
but this time i forgot
so why does it work then?
I can repeat it,
take the blink example
WifiScan or others,
upload without pressing the flash button
and it does...
That board uses the DTR and RTS signaling to set the GPIO pins the same as pressing the button would. The upload program toggles the serial in order to properly trigger it.
I try to adapt some Arduino software to the ESP8266
working quite well
very interesting board, really
but I have some questions popping up
How can a program determine what mode a pin is switched to, INPUT or OUTPUT?
I am prepared to do some bit banging if I have a docu,
pointer welcome
Can I do Serial output in setup() ?
Serial output is working well in loop(), not so in setup().
while (!Serial) { ;} does not help, not even a delay...
I have a few sample NodeMCU/ESP8266 projects on my project page just to get you started with what can be done. No need for UserID to download source code.
so I see my error now:
I was expecting that the serial monitor would do the same magic like it did on many Arduinos
and restart the module when I open it, I was wrong.
Unplugging the chip and then restart the monitor was not fast enough to catch early serial output either.
toggling D2 does the job
or
leaving the serial monitor open while flashing next version (this used to close the monitor once) works fine too
next question:
Currently I am working with a NodeMCU board.
I want to adapt things like pin mapping based on the board type
How can my sketch determine the exact board type?
I use #ifdef ESP8266 but want to know more precisely.
OutOfLine:
<...>
Currently I am working with a NodeMCU board.
I want to adapt things like pin mapping based on the board type
How can my sketch determine the exact board type?
I use #ifdef ESP8266 but want to know more precisely.
thanks for your help
Ummmmm....
"lethe" from the ESP8266.com forum has these words to say:
You should be able to obtain the flash ID with "esptool.py flash_id" without removing the shield. That command will only give you a hex manufacturer & chip ID, but fortunately the flashrom project maintains an extensive list in their source code: http://code.coreboot.org/svn/flashrom/t ... ashchips.h
I only prototype on the NodeMCU and may then transfer the software to a 12-E for the final project; therefore I know physically in advance the flash size; to my knowledge, the external flash chip is essentially the only difference in the core ESP8266 device from model -01 through the various NodeMCU.
Usually you would want to use a unique macro for each board but apparently the esp8266 core developers have decided to use the same macro for some of the boards that use the same ESP8266 module. Hopefully those boards are similar enough that it won't be a problem.
So you can do things like:
#ifdef ARDUINO_ESP8266_NODEMCU
which will evaluate true if you compiled the sketch for the NodeMCU 0.9 (ESP-12 Module) or NodeMCU 1.0 (ESP-12E Module) boards.
@pert many thanks, exactly the information I was looking for.
works well
grepping through the source I was not able to find the magic that defines these macros
i have tried to find that before...
pointer very much appreciated
where/how are they defined?
adapting some of my programs I get the following test output:
Checking for some macros
digitalPinHasPWM YES
analogInputToDigitalPin YES
digitalPinToPort YES
digitalPinToBitMask YES
digitalPinToTimer YES
COMPLETELY UNTESTED ON THIS BOARD
pin 0 ~Â Â Â Â Â port 0Â 0000000000000001 PWMÂ
pin 1 ~ Â Â port 0Â 0000000000000010 PWMÂ
pin 2 ~Â Â Â Â Â port 0Â 0000000000000100 PWMÂ
pin 3 ~Â Â Â Â Â port 0Â 0000000000001000 PWMÂ
pin 4 ~Â SDAÂ port 0Â 0000000000010000 I2CÂ PWMÂ
pin 5 ~Â SCLÂ port 0Â 0000000000100000 I2CÂ PWMÂ
pin 6Â Â Â Â Â Â Â port 0Â 0000000001000000
pin 7 Â Â Â Â Â Â port 0Â 0000000010000000
pin 8Â Â Â Â Â Â Â port 0Â 0000000100000000
pin 9Â Â Â Â Â Â Â port 0Â 0000001000000000
pin 10Â Â Â Â Â Â port 0Â 0000010000000000
pin 11Â Â Â Â Â Â port 0Â 0000100000000000
pin 12 ~Â MISO port 0Â 0001000000000000 SPIÂ PWMÂ
pin 13 ~Â MOSI port 0Â 0010000000000000 SPIÂ PWMÂ
pin 14 ~Â SCKÂ Â port 0Â 0100000000000000 SPIÂ PWMÂ
pin 15 ~Â SSÂ Â Â port 0Â 1000000000000000 SPIÂ PWMÂ
pin 16 ~Â Â Â Â Â Â port 0Â 0000000000000000 PWM
does this look reasonable?
well the forum software ruins all my formatting, but
@mrburnette thank you for the reference
looks impressive
will dig deeper when I will work with WiFi
right now I am exploring processor and GPIO
adapting some programs from github.com/reppr/pulses
I have connected 4 piezzos to the ESP8266 and let them play funny sounds
3.3V gives very low level on piezzos, but maybe you can hear it in the attachment
OutOfLine:
I have connected 4 piezzos to the ESP8266 and let them play funny sounds
3.3V gives very low level on piezzos, but maybe you can hear it in the attachment
no, you can't
the forum software did not accept the format
OutOfLine:
grepping through the source I was not able to find the magic that defines these macros
i have tried to find that before...
pointer very much appreciated
Note that the esp8266 core even defines another macro, ARDUINO_BOARD with the value of {build.board} as a string so you could do something like:
Serial.println("The board name is: " ARDUINO_BOARD);
But that's an extra feature of the esp8266 core, not a standard convention like the ARDUINO_{build.board} macros, which should be defined in any core since it's part of the hardware specification.