Online community http://www.esp8266.com supporting all aspects of the ESP8266 and ESP8266EX
For more info see our wiki https://github.com/esp8266/esp8266-wiki/wiki
Check out the code examples in https://github.com/esp8266/source-code-examples
ESP8266 core for Arduino
License: GNU Lesser General Public License v2.1
Online community http://www.esp8266.com supporting all aspects of the ESP8266 and ESP8266EX
For more info see our wiki https://github.com/esp8266/esp8266-wiki/wiki
Check out the code examples in https://github.com/esp8266/source-code-examples
Sketch uses 196,284 bytes (37%) of program storage space. Maximum is 524,288 bytes.
java.lang.NullPointerException
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingProgrammer(SerialUploader.java:246)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:75)
at processing.app.debug.Compiler.upload(Compiler.java:157)
at processing.app.Sketch.upload(Sketch.java:1259)
at processing.app.Sketch.exportApplet(Sketch.java:1201)
at processing.app.Sketch.exportApplet(Sketch.java:1173)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2432)
at java.lang.Thread.run(Thread.java:745)
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
So far, the Servo library is not supported. 4b73026#commitcomment-10456654
It would be nice if the library could be expanded to support the esp8266 as well; this is probably dependent on the PWM code being implemented.
Hello, this I have, when I tried tools - burn bootloader. I have windows 7 64.
There seems to be some sort of compiler build issue in the latest windows zip.
You just get a message saving Error compiling
But if you look at the verbose output and cut and paste it into the Windows command line, and run it, the error is that the xtensia gcc compilor can't locate libiconv-2.dll
Used version is 0.9.5
Latest SDK version is esp_iot_sdk_v1.0.0_15_03_20 released
Fix bugs:
Full Changelog & Download:
http://bbs.espressif.com/viewtopic.php?f=5&t=286
add support for Arduino Eclipse Plugin (http://www.baeyens.it/eclipse/)
change the platform.txt, the Compiling is working.
the serial upload in current broken.
@@ -17,6 +17,9 @@ compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH "-I{compiler.sdk.path}/inc
compiler.c.cmd=xtensa-lx106-elf-gcc
compiler.c.flags=-c -Os -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -MMD -std=c99
+compiler.S.cmd=xtensa-lx106-elf-gcc
+compiler.S.flags=-c -g -x assembler-with-cpp -MMD
+
compiler.c.elf.ldscript=eagle.app.v6.ld
compiler.c.elf.flags=-nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{compiler.c.elf.ldscript}"
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
@@ -57,7 +60,7 @@ recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.fla
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
-recipe.S.o.pattern="{compiler.path}{compiler.as.cmd}" -o "{object_file}" "{source_file}"
+recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
hope this help.
I am the developer of the aREST library (http://arest.io) that implements a REST interface for Arduino & Raspberry Pi boards.
I am currently working on adapting the aREST Arduino library to your project, it nearly works but in the code I need to detect when an ESP8266 is used, and when a classical Arduino is used. For example to detect an Arduino Mega I use:
Is there something similar I could use to detect that the ESP8266 is selected? Thanks!
I was measured 4.81mbps for the following code:
void shiftOutFast(byte data)
{
byte i = 8;
do{
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, 1 << CLOCK);
if(data & 0x80)
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, 1 << DATA);
else
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, 1 << DATA);
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, 1 << CLOCK);
data <<= 1;
}while(--i);
return;
}
http://nerdralph.blogspot.ca/2015/04/a-4mbps-shiftout-for-esp8266arduino.html
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Need to update from SDK 0.9.5 to SDK 1.0.0
To visually match the Arduino IDE naming conventions and general ESP8266 naming here are my suggestions:
platform.txt:
As in ESP8266 world boards are called as modules, so name should include the word "Modules"
name=Arduino ESP8266 Modules
programmers.txt:
In Arduino IDE all programmer names start with capital letter so captalizing ESPTool should look good
esptool.name=ESPTool
boards.txt
As there are several modules esp01.xxx definitions should be converted to generic.xxx and esp01 in variants directory should be renamed accordingly.
Variant names should include Module as above and esp01's replaced by generic elsewhere
generic.name=Generic ESP8266 Module
generic.build.board=ESP8266_GENERIC
generic.build.variant=generic
wifio.name=WIFIO Module
I have an 1306 OLED diplsay and wanted to at least verify the i2c address so i thought running http://playground.arduino.cc/Main/I2cScanner might be a nice idea.
I wired up 2 external pullups and changed to code to include
Wire.pins(12, 14);
Wire.begin();
But I get the following for all i2c addresses which cant be right:
Scanning...<\r><\n>
I2C device found at address 0x01 !<\r><\n>
I2C device found at address 0x02 !<\r><\n>
I2C device found at address 0x03 !<\r><\n>
I2C device found at address 0x04 !<\r><\n>
I2C device found at address 0x05 !<\r><\n>
I2C device found at address 0x06 !<\r><\n>
Remember: Nothing connected
A logic sniffer seems to return nothing unusual too:
EDIT: Apparently the esp8266 i2c function does use a different return code. Its the number of successfully received bytes I guess
size_t i2c_master_write_to(int address, const uint8_t* data, size_t size, bool sendStop)
{
i2c_start();
i2c_write(address << 1);
int ack = i2c_get_ack();
const uint8_t* end = data + size;
for (;data != end; ++data )
{
i2c_write(*data);
ack = i2c_get_ack();
}
if (sendStop)
i2c_stop();
return size;
}
EDIT2: After connecting the 1306 oled to a separate arduino and check the i2c address to be 0x3C i meddled a little bit with the Adafruit_SSD1306master, removing conflicting code and adding the esp8266 i2c init I was able to at least draw some lines. Have still to look why the lib hangups, I guess its a wdt timeout issue
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi!
I would like to know if you plan to include SSL support in the libraries.
I've tryed to send some https requests with no sucess.
It would be cool if it the ESP could act as a secure server too.
I've checked the some examples from the sdk and they have a code to create a secure server with digital certificate.
Thanks!
I downloaded the windows.zip for release "1.6.1-esp8266-1"
When I compile a blank sketch:
void setup(){}
void loop(){}
I get "Error Compiling", any ideas what I could be doing wrong?
I'm running Windows 7 64bit.
Having trouble to convert string to float:
Using:
value = strValue.toFloat();
always result in 0.00
Tried workaround using
value = atof(buf);
but this results into compiler errors:
c:/tools/arduino-1.6.1/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\mari\AppData\Local\Temp\build3253580446183462334.tmp/ESPClient1.cpp.elf section .text' will not fit in region
iram1_0_seg'
c:/tools/arduino-1.6.1/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-mallocr.o):(.literal+0x2c): undefined reference to _sbrk_r' c:/tools/arduino-1.6.1/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-mallocr.o): In function
malloc_extend_top':
d:\ivan\projects\arduinoesp\toolchain\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:2165: undefined reference to _sbrk_r' d:\ivan\projects\arduinoesp\toolchain\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:2202: undefined reference to
_sbrk_r'
c:/tools/arduino-1.6.1/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-freer.o): In function _malloc_trim_r': d:\ivan\projects\arduinoesp\toolchain\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:3325: undefined reference to
_sbrk_r'
d:\ivan\projects\arduinoesp\toolchain\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:3332: undefined reference to _sbrk_r' c:/tools/arduino-1.6.1/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-freer.o):d:\ivan\projects\arduinoesp\toolchain\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:3340: more undefined references to
_sbrk_r' follow
collect2.exe: error: ld returned 1 exit status
is there a reason for starting in WIFI_AP_STA mode?
in the default config the AP is "open" (no WPA2, no password), this can be a big risk of the security for the application or the network.
int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase)
{
if (wifi_get_opmode() == WIFI_AP)
{
// turn on AP+STA mode
mode(WIFI_AP_STA);
}
i preferred to only open the AP if the user really need it.
mode(WIFI_STA);
Alse posted on ESP8266.com forumn.
I'm not entirely sure that this is a bug but I can't see any other explanation for the behavior. I am using the following code on which is connected to a python script which essentially acts as a terminal-esque way of sending and receiving data to the ESP. The code below works and I can have the light set on or off. The problem is that, after a message has been sent using sendMessage, the ESP will no longer receive packets. I can see from the serial output that the loop is still running and if I remove the call to sendMessage, it will continue turning the light on and off merrily. I wonder if I'm just missing something?
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
WiFiClient client;
WiFiUDP port;
char packetBuffer[255];
unsigned int localPort = 9999;
IPAddress serverIP(192, 168, 1, 117);
void setup() {
Serial.begin(9600);
WiFi.begin("******", "********");
port.begin(9999);
pinMode(2, OUTPUT);
digitalWrite(2,LOW);
}
void loop() {
int packetSize = port.parsePacket();
Serial.println(packetSize);
if (packetSize) {
int len = port.read(packetBuffer, 255);
if (len > 0) packetBuffer[len] = 0;
Serial.println(packetBuffer);
handleMessage(String(packetBuffer));
}
delay(500);
}
void handleMessage(String data) {
if(data=="on"){
digitalWrite(2,HIGH);
Serial.println("ON");
sendMessage("light on");
}
if(data=="off"){
digitalWrite(2,LOW);
Serial.write("OFF");
sendMessage("light off");
}
}
void sendMessage(char data[]) {
port.beginPacket(serverIP,localPort);
port.write(data);
port.endPacket();
}
From what I can see, it looks like the call to beginPacket in WiFiUDP.cpp resets everything when it calls: _ctx->unref();
In order to try and get around this I have tried calling stop and then begin again after a transmission to restart the listening but to no avail.
int WiFiUDP::beginPacket(IPAddress ip, uint16_t port)
{
ip_addr_t addr;
addr.addr = ip;
if (_ctx)
_ctx->unref();
_ctx = new UdpContext;
return (_ctx->connect(addr, port)) ? 1 : 0;
}
Any plans to update to SDK 1.0
I need to convert numbers entered in a browser (Strings) or sent by MQTT (char array) to a floating point number (double).
I've been trying and failing various ways, but I'm pretty new to C (only since i got hold of the beta for this) so i've failed.
Igrr has said that atof has not been implemented ... this is what is in core_esp8266_noniso.c
float atof_internal(const char* s)
{
float result = 0;
return result;
}
atol does work but I'd kinda like the decimals... ( i know i can just enter an integer and then divide...)
Does anyone have any ideas... or fancy giving me a quick patch for this.. I'd try.... infact i spent a few hours on it.. but I'm so new to arrays, pointers, and all this that i just fail....
Cheers
A
Hello, would it be possible to add a SimpleTimer? I am not sure, how it should work, but to be able to find e.g. SimpleTimer, I have to copy the .h and .cpp file to the arduino-1.6.1\hardware\esp8266com\esp8266\cores\esp8266. I have tried to copy is to the C:\RH\arduino-1.6.1\libraries\ but it didn't worked. BTW this library works well and could be used without any change.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
With the 1.6.2 IDE release, there is now a way to download new boards directly. Will this implementation be able to support the manager? It would be nice to be able to use a single IDE rather than a fork.
Hi,
does somebody know a infrared library which works with this esp8266 Arduino IDE ?
Id not found one, because they all dependt on avr interupts.
Arduino: 1.6.1 (Windows 8.1), Platine: "Generic ESP8266 board"
C:\Users####\Documents\Arduino\libraries\Arduino-IRremote\IRremote.cpp:25:27: fatal error: avr/interrupt.h: No such file or directory
#include < avr/interrupt.h >
compilation terminated.
Sorry for my English.
Thanks in advance.
I created a library, but I can't use os_print in my code, anything instead?
: error: 'os_printf_plus' was not declared in this scope
os_printf("\n\n");
^
here is my header
#include "ets_sys.h"
#include "c_types.h"
#include "osapi.h"
#include "user_interface.h"
Something seems to be wrong with the way how interrupts are handled.
I'm trying to record pulses of length 250-2000 micros. Example sketch:
volatile int lastTime = 0;
void setup()
{
Serial.begin(115200);
attachInterrupt(2, pinChanged, CHANGE);
}
void loop()
{
}
void pinChanged()
{
int time = micros();
int duration = time - lastTime;
Serial.print(duration);
Serial.print("\r\n");
lastTime = time;
}
But this outputs something like:
76131
3683
76143
3752
76146
3667
76128
3768
76141
3741
76148
3661
76114
3785
76130
3683
...
I exprected numbers around 250-2000. It's stange that its almost all time a longer dealy and then a shorter. I double checked the wiring and the interrupts only occure with connected sensor.
I did the same using nodemcu (using gpio.trig
) and got ver accurate timings.
Any ideas what is going wrong here?
Hello!
I just wanted to compile the arduino-modbus-slave library (https://code.google.com/p/arduino-modbus-slave/downloads/detail?name=MODBUS.zip&can=2&q=) which seems to be perfectly compatible with the ESP8266 Arduino SDK because it only uses the Serial library which is fully adopted.
When I try to compile my sketch which depends on the MODBUS library I get the following error:
Does anybody know where the issue is?
It seems to be an issue with the xtensa toolchain but I cannot find out what it is.
Kind Regards
Marvin
read() and peek() in cbuf.h hast return type char this is wrong!
need to be int
int read()
int peek()
if not readBytesUntil for example is not working.
I´m trying to build a wireless PIR sensor from a ESP-07.
I have the code already working but after a undefined time the firmware hangs up and logs some unusual stuff on the UART.
The IDE I´ve used is built by myself and is the most actual version fresh from the esp8266 branch.
The Sketch:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
const int pirPin = 2;
const char* ssid = "Home 7362";
const char* password = "mysecretpasswordwhichnobodyshouldknowxDD";
const char* host = "192.168.178.24";
const int port = 80;
int lastMillis;
bool lastState;
WiFiClient wifiClient;
void pirInterrupt();
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
Serial.println("");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
pinMode(2, INPUT);
//attachInterrupt(2, pirInterrupt, FALLING);
lastMillis = millis();
while(digitalRead(pirPin) == LOW){
Serial.println("Calibrating...");
delay(200);
}
}
void loop() {
if(digitalRead(pirPin) == HIGH && lastState == LOW && millis() - lastMillis >= 5000){
pirInterrupt();
lastMillis = millis();
}
lastState = digitalRead(pirPin);
delay(20);
}
void pirInterrupt() {
Serial.println("PIR: alarm triggered!");
if (!wifiClient.connect(host, 80)) {
Serial.println("Connection failed!");
return;
}
String url = "/pirpush/push.php";
url += "?message=Der+Postmann+ist+da!";
url+= "&id=1";
Serial.print("Requesting URL: ");
Serial.println(url);
wifiClient.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
/*
delay(50);
while(wifiClient.available()){
String line = wifiClient.readStringUntil('\r');
Serial.print(line);
}
*/
Serial.println();
Serial.println("Closing connection.");
}
What is the issue with it?
In the Eclipse environment, the DTR line drops momentarily (about half a second) before programming commenses - this allows third party hardware to pull down GPIO0 and reset automatically - to make programming similar to programming Arduinos - yet in this environment, that does not happen. Is there any way to add this in?
Describe all the basic APIs and the libraries by adding documentation to the repository or to the wiki.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
References to malloc and other functions that use malloc (like sprintf) pull in _sbrk, which isn't available.
Need to tweak libc build so that it would use os_malloc and os_free instead.
The examples use 115200 baud ratge - yet the compiler complains that it's an invalid baud rate - it still works of course. Can this be removed?
I have a sketch that uses the itoa() function, and I got the error when compiling:
'itoa' was not declared in this scope
Is this function already included in the project? Thanks!
TX is working RX is disabled (only posible on GPIO 8 but we have no access to it)
in HardwareSerial.cpp in uart0_interrupt_handler add:
status = READ_PERI_REG(UART_INT_ST(1));
if (status & UART_TXFIFO_EMPTY_INT_ST)
{
WRITE_PERI_REG(UART_INT_CLR(1), UART_TXFIFO_EMPTY_INT_CLR);
Serial1._tx_empty_irq();
}
HardwareSerial1.cpp
/*
HardwareSerial1.cpp - esp8266 UART support
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 30 March 2015 by Markus Sattler (esp8266 platform support for UART1)
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "Arduino.h"
#include "cbuf.h"
extern "C" {
#include "osapi.h"
#include "ets_sys.h"
#include "mem.h"
#include "uart_register.h"
#include "user_interface.h"
}
#include "HardwareSerial1.h"
HardwareSerial1 Serial1;
uart_t* uart1_init(int baud_rate);
void uart1_set_baudrate(uart_t* uart, int baud_rate);
int uart1_get_baudrate(uart_t* uart);
void uart1_uninit(uart_t* uart);
void uart1_transmit(uart_t* uart, const char* buf, size_t size); // may block on TX fifo
void uart1_wait_for_transmit(uart_t* uart);
void uart1_transmit_char(uart_t* uart, char c); // does not block, but character will be lost if FIFO is full
void uart1_set_debug(bool enabled);
bool uart1_get_debug();
struct uart_
{
int baud_rate;
};
#define UART_TX_FIFO_SIZE 0x80
/*
void ICACHE_FLASH_ATTR uart1_interrupt_handler(uart_t* uart)
{
uint32_t status = READ_PERI_REG(UART_INT_ST(1));
if (status & UART_RXFIFO_FULL_INT_ST)
{
while(true)
{
int rx_count = (READ_PERI_REG(UART_STATUS(1)) >> UART_RXFIFO_CNT_S) & UART_RXFIFO_CNT;
if (!rx_count)
break;
while(rx_count--)
{
char c = READ_PERI_REG(UART_FIFO(1)) & 0xFF;
Serial1._rx_complete_irq(c);
}
}
WRITE_PERI_REG(UART_INT_CLR(1), UART_RXFIFO_FULL_INT_CLR);
}
if (status & UART_TXFIFO_EMPTY_INT_ST)
{
WRITE_PERI_REG(UART_INT_CLR(1), UART_TXFIFO_EMPTY_INT_CLR);
Serial1._tx_empty_irq();
}
}
*/
void ICACHE_FLASH_ATTR uart1_wait_for_tx_fifo(size_t size_needed)
{
while (true)
{
size_t tx_count = (READ_PERI_REG(UART_STATUS(1)) >> UART_TXFIFO_CNT_S) & UART_TXFIFO_CNT;
if (tx_count <= (UART_TX_FIFO_SIZE - size_needed))
break;
}
}
size_t ICACHE_FLASH_ATTR uart1_get_tx_fifo_room()
{
return UART_TX_FIFO_SIZE - ((READ_PERI_REG(UART_STATUS(1)) >> UART_TXFIFO_CNT_S) & UART_TXFIFO_CNT);
}
void ICACHE_FLASH_ATTR uart1_wait_for_transmit(uart_t* uart)
{
uart1_wait_for_tx_fifo(UART_TX_FIFO_SIZE);
}
void ICACHE_FLASH_ATTR uart1_transmit_char(uart_t* uart, char c)
{
WRITE_PERI_REG(UART_FIFO(1), c);
}
void ICACHE_FLASH_ATTR uart1_transmit(uart_t* uart, const char* buf, size_t size)
{
while (size)
{
size_t part_size = (size > UART_TX_FIFO_SIZE) ? UART_TX_FIFO_SIZE : size;
size -= part_size;
uart1_wait_for_tx_fifo(part_size);
for(;part_size;--part_size, ++buf)
WRITE_PERI_REG(UART_FIFO(1), *buf);
}
}
void ICACHE_FLASH_ATTR uart1_flush(uart_t* uart)
{
SET_PERI_REG_MASK(UART_CONF0(1), UART_TXFIFO_RST); // UART_RXFIFO_RST |
CLEAR_PERI_REG_MASK(UART_CONF0(1), UART_TXFIFO_RST); // UART_RXFIFO_RST |
}
void ICACHE_FLASH_ATTR uart1_interrupt_enable(uart_t* uart)
{
// WRITE_PERI_REG(UART_INT_CLR(0), 0x1ff);
// ETS_UART_INTR_ATTACH(&uart1_interrupt_handler, uart);
// SET_PERI_REG_MASK(UART_INT_ENA(0), UART_RXFIFO_FULL_INT_ENA);
// ETS_UART_INTR_ENABLE();
}
void ICACHE_FLASH_ATTR uart1_interrupt_disable(uart_t* uart)
{
CLEAR_PERI_REG_MASK(UART_INT_ENA(1), UART_RXFIFO_FULL_INT_ENA);
ETS_UART_INTR_DISABLE();
}
void ICACHE_FLASH_ATTR uart1_arm_tx_interrupt()
{
SET_PERI_REG_MASK(UART_INT_ENA(1), UART_TXFIFO_EMPTY_INT_ENA);
}
void ICACHE_FLASH_ATTR uart1_disarm_tx_interrupt()
{
CLEAR_PERI_REG_MASK(UART_INT_ENA(1), UART_TXFIFO_EMPTY_INT_ENA);
}
void ICACHE_FLASH_ATTR uart1_set_baudrate(uart_t* uart, int baud_rate)
{
uart->baud_rate = baud_rate;
uart_div_modify(1, UART_CLK_FREQ / (uart->baud_rate));
}
int ICACHE_FLASH_ATTR uart1_get_baudrate(uart_t* uart)
{
return uart->baud_rate;
}
uart_t* ICACHE_FLASH_ATTR uart1_init(int baudrate)
{
uart_t* uart = (uart_t*) os_malloc(sizeof(uart_t));
PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO2_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK);
// NO RX PIN only possible GPIO8 but no access to it
// PIN_PULLUP_EN(PERIPHS_IO_MUX_U0RXD_U);
// PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD);
uart1_set_baudrate(uart, baudrate);
WRITE_PERI_REG(UART_CONF0(1), 0x3 << UART_BIT_NUM_S); // 8n1
uart1_flush(uart);
uart1_interrupt_enable(uart);
WRITE_PERI_REG(UART_CONF1(1), ((0x20 & UART_TXFIFO_EMPTY_THRHD) << UART_TXFIFO_EMPTY_THRHD_S));
//((0x01 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S) |
return uart;
}
void ICACHE_FLASH_ATTR uart1_uninit(uart_t* uart)
{
uart1_interrupt_disable(uart);
// TODO: revert pin functions
os_free(uart);
}
void ICACHE_FLASH_ATTR uart1_swap(uart_t* uart)
{
}
void ICACHE_FLASH_ATTR
uart1_ignore_char(char c)
{
}
void ICACHE_FLASH_ATTR
uart1_write_char(char c)
{
if (c == '\n')
WRITE_PERI_REG(UART_FIFO(1), '\r');
WRITE_PERI_REG(UART_FIFO(1), c);
}
static bool s_uart_debug_enabled = true;
void ICACHE_FLASH_ATTR uart1_set_debug(bool enabled)
{
s_uart_debug_enabled = enabled;
if (enabled)
{
system_set_os_print(1);
ets_install_putc1((void *)&uart1_write_char);
}
else
ets_install_putc1((void *)&uart1_ignore_char);
}
bool ICACHE_FLASH_ATTR uart1_get_debug()
{
return s_uart_debug_enabled;
}
ICACHE_FLASH_ATTR HardwareSerial1::HardwareSerial1() :
_uart(0), _tx_buffer(0)
//_rx_buffer(0),
{
}
void ICACHE_FLASH_ATTR HardwareSerial1::begin(unsigned long baud, byte config)
{
// _rx_buffer = new cbuf(SERIAL1_RX_BUFFER_SIZE);
_tx_buffer = new cbuf(SERIAL1_TX_BUFFER_SIZE);
uart1_set_debug(false);
_uart = uart1_init(baud);
_written = false;
delay(1);
}
void ICACHE_FLASH_ATTR HardwareSerial1::end()
{
uart1_uninit(_uart);
// delete _rx_buffer;
delete _tx_buffer;
_uart = 0;
// _rx_buffer = 0;
_tx_buffer = 0;
}
void ICACHE_FLASH_ATTR HardwareSerial1::swap()
{
}
void ICACHE_FLASH_ATTR HardwareSerial1::setDebugOutput(bool en)
{
uart1_set_debug(en);
}
int ICACHE_FLASH_ATTR HardwareSerial1::available(void)
{
// return static_cast<int>(_rx_buffer->getSize());
return 0;
}
int ICACHE_FLASH_ATTR HardwareSerial1::peek(void)
{
return -1;
// return _rx_buffer->peek();
}
int ICACHE_FLASH_ATTR HardwareSerial1::read(void)
{
return -1;
// return _rx_buffer->read();
}
int ICACHE_FLASH_ATTR HardwareSerial1::availableForWrite(void)
{
return static_cast<int>(_tx_buffer->room());
}
void ICACHE_FLASH_ATTR HardwareSerial1::flush()
{
if (!_written)
return;
while (_tx_buffer->getSize() || uart1_get_tx_fifo_room() < UART_TX_FIFO_SIZE)
yield();
_written = false;
}
size_t ICACHE_FLASH_ATTR HardwareSerial1::write(uint8_t c)
{
_written = true;
size_t room = uart1_get_tx_fifo_room();
if (room > 0 && _tx_buffer->empty())
{
uart1_transmit_char(_uart, c);
if (room < 10)
{
uart1_arm_tx_interrupt();
}
return 1;
}
while (_tx_buffer->room() == 0)
{
yield();
}
_tx_buffer->write(c);
return 1;
}
ICACHE_FLASH_ATTR HardwareSerial1::operator bool() const
{
return _uart != 0;
}
void ICACHE_FLASH_ATTR HardwareSerial1::_rx_complete_irq(char c)
{
//_rx_buffer->write(c);
}
void ICACHE_FLASH_ATTR HardwareSerial1::_tx_empty_irq(void)
{
size_t queued = _tx_buffer->getSize();
if (!queued)
{
uart1_disarm_tx_interrupt();
return;
}
size_t room = uart1_get_tx_fifo_room();
int n = static_cast<int>((queued < room) ? queued : room);
while (n--)
{
uart1_transmit_char(_uart, _tx_buffer->read());
}
}
HardwareSerial1.h
/*
HardwareSerial.h - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 28 September 2010 by Mark Sproul
Modified 14 August 2012 by Alarus
Modified 3 December 2013 by Matthijs Kooijman
Modified 18 December 2014 by Ivan Grokhotkov (esp8266 platform support)
Modified 30 March 2015 by Markus Sattler (esp8266 platform support for UART1)
*/
#ifndef HardwareSerial1_h
#define HardwareSerial1_h
#include <inttypes.h>
#include "Stream.h"
#define SERIAL1_TX_BUFFER_SIZE 256
//#define SERIAL1_RX_BUFFER_SIZE 256
// // Define config for Serial.begin(baud, config);
// #define SERIAL_5N1 0x00
// #define SERIAL_6N1 0x02
// #define SERIAL_7N1 0x04
// #define SERIAL_8N1 0x06
// #define SERIAL_5N2 0x08
// #define SERIAL_6N2 0x0A
// #define SERIAL_7N2 0x0C
// #define SERIAL_8N2 0x0E
// #define SERIAL_5E1 0x20
// #define SERIAL_6E1 0x22
// #define SERIAL_7E1 0x24
// #define SERIAL_8E1 0x26
// #define SERIAL_5E2 0x28
// #define SERIAL_6E2 0x2A
// #define SERIAL_7E2 0x2C
// #define SERIAL_8E2 0x2E
// #define SERIAL_5O1 0x30
// #define SERIAL_6O1 0x32
// #define SERIAL_7O1 0x34
// #define SERIAL_8O1 0x36
// #define SERIAL_5O2 0x38
// #define SERIAL_6O2 0x3A
// #define SERIAL_7O2 0x3C
// #define SERIAL_8O2 0x3E
class cbuf;
typedef struct uart_ uart_t;
class HardwareSerial1 : public Stream
{
public:
HardwareSerial1();
void begin(unsigned long baud) { begin(baud, 0); }
void begin(unsigned long, uint8_t);
void end();
void swap(); //use GPIO13 and GPIO15 as RX and TX
int available(void) override;
int peek(void) override;
int read(void) override;
int availableForWrite(void);
void flush(void) override;
size_t write(uint8_t) override;
inline size_t write(unsigned long n) { return write((uint8_t)n); }
inline size_t write(long n) { return write((uint8_t)n); }
inline size_t write(unsigned int n) { return write((uint8_t)n); }
inline size_t write(int n) { return write((uint8_t)n); }
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool() const;
void setDebugOutput(bool);
void _tx_empty_irq(void);
protected:
friend void uart1_interrupt_handler(uart_t* uart);
void _rx_complete_irq(char c);
protected:
uart_t* _uart;
cbuf* _tx_buffer;
// cbuf* _rx_buffer;
bool _written;
};
extern HardwareSerial1 Serial1;
#endif
PubSub appears to be missing from the libraries and the original pubsub won't compile.
Firmata errors with
libraries/Firmata/src/Boards.h:337:2: error: #error "Please edit Boards.h with a hardware abstraction for this board"
#error "Please edit Boards.h with a hardware abstraction for this board"
^
Possibly https://github.com/esp8266/Arduino/blob/esp8266/libraries/Firmata/src/Boards.h could be changed to support the esp8266?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Should WDT be disabled during setup()?
It's quite common situation when setup() executes quite long time.
Any suggestions on what is going wrong here? Using the Arduino ESP8266 IDE to try and upload the HelloServer example.
ESP-01 is on COM4 on Windows via a FTDI TTL converter.
Board is set to Generic ESP8266. Programmer to ESPtool.
Any assistance gratefully received.
Cheers
Pete
esptool v0.4.2 - (c) 2014 Ch. Klippel <[email protected]>
setting board to none
setting baudrate from 115200 to 115200
setting port from COM1 to COM4
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
stat C:\Users\peter\AppData\Local\Temp\build4325786157015904206.tmp/HelloServer.cpp_00000.bin success
setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_cmd: sending command header
espcomm_cmd: sending command payload
serialport_receive_C0: 00 instead of C0
warning: espcomm_sync failed
error: espcomm_open failed
the
double sign = 1;
is set but never used?
change
esp01.upload.resetmethod=none
in esp8266/boards.txt to:
esp01.upload.resetmethod=ck
This is more a observation then issue report since you have already written in description that Wire.setClock gives weird frequency. I played with it a while and found that at 400 it gives frequency around 1khz. At 300000 and more it doesnt work at all since the scl is all distorted and non consistent (more like some noise). Maximum frequency I got was ~307kHz with set values around 180000-200000.
When I tried to use the original PubSub I got a message to say _dso_handle isn't defined.
This time I've tried a simple web server page - using nothing special and the compilation has come back with the same error..
C:\Users\Peter\AppData\Local\Temp\build71807972327932918.tmp/WiFiWebServer.cpp.elf: hidden symbol `__dso_handle' isn't defined
I used the same startup code as the server example that comes with this package - but this main loop
void loop(){
// Create a client connection
WiFiClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
readString += c;
//Serial.print(c);
}
//if HTTP request has ended
if (c == '\n') {
///////////////
Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<TITLE>Arduino GET test page</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>Zoomkat's simple Arduino button</H1>");
// DIY buttons
client.println("<a href=\"/?on\"\">ON</a>");
client.println("<a href=\"/?off\"\">OFF</a><br />");
// mousedown buttons
client.println("<br><input type=\"button\" value=\"ON\" onmousedown=\"location.href ('/?on');\"/>");
client.println("<input type=\"button\" value=\"OFF\" onmousedown=\"location.href ('/?off');\"/>");
// mousedown radio buttons
client.println("<br><br><input type=\"radio\" value=\"ON\" onmousedown=\"location.href ('/?on');\"\">ON</>");
client.println("<input type=\"radio\" value=\"OFF\" onmousedown=\"location.href ('/?off');\"\">OFF</>");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
///////////////////// control arduino pin
if(readString.indexOf("on") >0)//checks for on
{
digitalWrite(0, HIGH); // set pin 5 high
Serial.println("Led On");
}
if(readString.indexOf("off") >0)//checks for off
{
digitalWrite(0, LOW); // set pin 5 low
Serial.println("Led Off");
}
//clearing string for next read
readString="";
}
}
}
}
}
Split the esp8266 core out into a core repository that can be downloaded into the Arduino/hardware folder in documents.
This allows for the development of the core not to be tied directly to the IDE.
I've created a core based on this here:
https://github.com/ricklon/esp8266-core
The only major issue is that the tools folder should be inside esp8266com
The calculations with floats doesnt work. It averages to integer.
float i;
i = 5/2;
I have hooked up oled display and when I print the value, it shows just 2.00. First, I thought it may be just problem with display, so I get it to send the value back over serial but I got 2.0000000000
too.
Hello, I tried to build the arduino-1.6.1-windows.zip from source on Windows 7, 64. I had two issues, which I have fixed by myselve however could be good to maybe improve the ant build process. The first problem was with missing unzip program and the second was with missing tar program. I belive, that most people are building under linux, so this is by default there, but not under windows. I've just copied the unzip.exe and tar.exe to the build directory and everything was fine then.
I am trying to use https://github.com/cyborg5/IRLib/
IRLib/IRLib.h:74:7: error: '__FlashStringHelper' does not name a type
const __FlashStringHelper *Pnames(IRTYPES Type); //Returns a character string that is name of protocol.
How would I have to change https://github.com/cyborg5/IRLib/blob/master/IRLib.h to make it work on the esp8266?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I would like to use mDNS in order to advertise the web server running on the ESP8266 to the network, so that it is easily found by guests and other devices on the network. How can this be done?
Hello, great work on this project! I tested it and it works fine with the simple 8-pin ESP8266 module (the $5 one).
However, I've been trying with this module:
https://www.olimex.com/Products/IoT/MOD-WIFI-ESP8266-DEV/
And it doesn't work. I can upload the sketch but after that it fails and only return strange characters in the Serial monitor. I guess this is either because the flash memory is different from the other module, and because the clock is also different. Do you think that might be the cause? If yes, do you have plans to support different ESP8266 flash sizes/clocks in the future? Thanks
Until we get listed in the boards manager (#13), we should build a downloadable .zip file that can be installed into the user's Arduino/hardware directory.
Probably need to move files around in a batch or a shell script that will be run on one of the CI servers.
The included gcc wasn't built with the linker plugin, so enabling link-time optimization (-flto) fails.
dlopen:'.../arduino-1.6.1/hardware/tools/esp8266/xtensa-lx106-elf/bin/../libexec/gcc/xtensa-lx106-elf/4.8.2/liblto_plugin-0.dll': The specified module could not be found.
Lto not only reduces code size, it can significantly improve performance by doing constant folding for function calls like digitalWrite.
http://nerdralph.blogspot.ca/2014/04/gcc-link-time-optimization-can-fix-bad.html
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.