You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-18
Original file line number
Diff line number
Diff line change
@@ -27,15 +27,18 @@ $ ant dist
27
27
28
28
#### Basic Wiring functions ####
29
29
30
-
```pinMode```, ```digitalRead```, ```digitalWrite``` work as usual.
30
+
```pinMode```, ```digitalRead```, ```digitalWrite```, ```analogWrite``` work as usual.
31
31
32
32
Pin numbers correspond directly to the esp8266 GPIO pin numbers. To read GPIO2,
33
33
call ```digitalRead(2);```
34
34
35
35
GPIO0-GPIO15 can be ```INPUT```, ```OUTPUT```, ```INPUT_PULLUP```, and ```OUTPUT_OPEN_DRAIN```.
36
36
GPIO16 can be ```INPUT``` or ```OUTPUT```.
37
37
38
-
```analogRead(0)``` reads the value of the ADC channel connected to the TOUT pin.
38
+
```analogRead(A0)``` reads the value of the ADC channel connected to the TOUT pin.
39
+
40
+
```analogWrite(pin, value)``` enables software PWM on the given pin. PWM may be used on pins 0 to 15.
41
+
Call ```analogWrite(pin, 0)``` to disable PWM on the pin.
39
42
40
43
Pin interrupts are supported through ```attachInterrupt```, ```detachInterrupt``` functions.
41
44
Interrupts may be attached to any GPIO pin, except GPIO16. Standard Arduino interrupt
@@ -62,7 +65,13 @@ more than 20 milliseconds is not recommended.
62
65
63
66
```Serial``` object works much the same way as on a regular Arduino. Apart from hardware FIFO (128 bytes for TX and RX) HardwareSerial has additional 256-byte TX and RX buffers. Both transmit and receive is interrupt-driven. Write and read functions only block the sketch execution when the respective FIFO/buffers are full/empty.
64
67
65
-
By default the diagnostic output from WiFi libraries is disabled when you call ```Serial.begin```. To enable debug output again, call ```Serial.setDebugOutput(true);```
68
+
```Serial``` uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3 (RX). Serial may be remapped to GPIO15 (TX) and GPIO13 (RX) by calling ```Serial.swap();``` after ```Serial.begin();```. Calling ```swap``` again maps UART0 back to GPIO1 and GPIO3.
69
+
70
+
```Serial1``` uses UART1 which is a transmit-only UART. UART1 TX pin is GPIO2. To use ```Serial1```, call ```Serial1.begin```.
71
+
72
+
By default the diagnostic output from WiFi libraries is disabled when you call ```Serial.begin```. To enable debug output again, call ```Serial.setDebugOutput(true);```. To redirect debug output to ```Serial1``` instead, call ```Serial1.setDebugOutput(true);```.
73
+
74
+
Both ```Serial``` and ```Serial1``` objects support 5, 6, 7, 8 data bits, odd (O), even (E), and no (N) parity, and 1 or 2 stop bits. To set the desired mode, call ```Serial.begin(baudrate, SERIAL_8N1);```, ```Serial.begin(baudrate, SERIAL_6E2);```, etc.
66
75
67
76
#### WiFi(ESP8266WiFi library) ####
68
77
@@ -91,6 +100,9 @@ Four samples are provided for this library.
91
100
92
101
Library for calling functions repeatedly with a certain period. Two examples included.
93
102
103
+
It is currently not recommended to do blocking IO operations (network, serial, file) from Ticker
104
+
callback functions. Instead, set a flag inside the ticker callback and check for that flag inside the loop function.
105
+
94
106
#### EEPROM ####
95
107
96
108
This is a bit different from standard EEPROM class. You need to call ```EEPROM.begin(size)```
@@ -101,29 +113,43 @@ Size can be anywhere between 4 and 4096 bytes.
101
113
whenever you wish to save changes to flash. ```EEPROM.end()``` will also commit, and will
102
114
release the RAM copy of EEPROM contents.
103
115
116
+
EEPROM library uses one sector of flash located at 0x7b000 for storage.
117
+
104
118
Three examples included.
105
119
106
120
#### I2C (Wire library) ####
107
121
108
-
Only master mode works, and ```Wire.setClock``` has not been verified to give exactly correct frequency.
122
+
Wire library currently supports master mode up to approximately 450KHz (at 80 MHz CPU clock).
109
123
Before using I2C, pins for SDA and SCL need to be set by calling
110
-
```Wire.pins(int sda, int scl)```, i.e. ```Wire.pins(0, 2);``` on ESP-01.
124
+
```Wire.begin(int sda, int scl)```, i.e. ```Wire.begin(0, 2);``` on ESP-01.
111
125
112
126
#### SPI ####
113
127
114
-
An initial SPI support for the HSPI interface (GPIO12-15) was implemented by [Sermus](https://github.com/Sermus).
115
-
The implementation supports the entire Arduino SPI API including transactions, except setting phase and polarity as it's unclear how to set them in ESP8266 yet.
128
+
SPI library supports the entire Arduino SPI API including transactions, including setting phase and polarity.
116
129
117
130
#### ESP-specific APIs ####
118
131
119
132
APIs related to deep sleep and watchdog timer are available in the ```ESP``` object.
120
133
121
-
```ESP.deepSleep(microseconds, mode)``` will put the chip into deep sleep. ```mode``` is one of ```WAKE_DEFAULT```, ```WAKE_RFCAL```, ```WAKE_NO_RFCAL```, ```WAKE_RF_DISABLED```. (GPIO16 needs to be tied to RST to wake from deepSleep.)
134
+
```ESP.deepSleep(microseconds, mode)``` will put the chip into deep sleep. ```mode``` is one of ```WAKE_RF_DEFAULT```, ```WAKE_RFCAL```, ```WAKE_NO_RFCAL```, ```WAKE_RF_DISABLED```. (GPIO16 needs to be tied to RST to wake from deepSleep.)
122
135
123
136
```ESP.wdtEnable()```, ```ESP.wdtDisable()```, and ```ESP.wdtFeed()``` provide some control over the watchdog timer.
124
137
125
138
```ESP.reset()``` resets the CPU.
126
139
140
+
```ESP.getFreeHeap()``` returns the free heap size.
141
+
142
+
```ESP.getChipId()``` returns the ESP8266 chip ID as a 32-bit integer.
143
+
144
+
Several APIs may be used to get flash chip info:
145
+
146
+
```ESP.getFlashChipId()``` returns the flash chip ID as a 32-bit integer.
147
+
148
+
```ESP.getFlashChipSize()``` returns the flash chip size, in bytes, as seen by the SDK (may be less than actual size).
149
+
150
+
```ESP.getFlashChipSpeed(void)``` returns the flash chip frequency, in Hz.
Library was adapted to work with ESP8266 by including register definitions into OneWire.h
@@ -133,6 +159,7 @@ instead of the one that comes with the Arduino IDE (this one).
133
159
#### mDNS responder (ESP8266mDNS library) ####
134
160
135
161
Allows the sketch to respond to multicast DNS queries for domain names like "foo.local".
162
+
Currently the library only works on STA interface, AP interface is not supported.
136
163
See attached example and library README file for details.
137
164
138
165
#### Other libraries (not included with the IDE)
@@ -150,16 +177,6 @@ Pick the correct serial port.
150
177
You need to put ESP8266 into bootloader mode before uploading code (pull GPIO0 low and
151
178
toggle power).
152
179
153
-
### Things not done yet ###
154
-
155
-
- analogWrite (PWM). ESP8266 has only one hardware PWM source. It is not yet clear how to use it with analogWrite API. Software PWM is also an option, but apparently it causes issues with WiFi connectivity.
156
-
- pulseIn
157
-
- I2C slave mode
158
-
- WiFi.RSSI. SDK doesn't seem to have an API to get RSSI for the current network. So far the only
159
-
way to obtain RSSI is to disconnect, perform a scan, and get the RSSI value from there.
160
-
- Upload sketches via WiFi. Conceptually and technically simple, but need to figure out how to provide the best UX for this feature.
0 commit comments