esp8266
tip v Sylvain platformio d1_mini / d1_mini_pro
Voor 3M spiffs in je config toevoegen build_flags = -Wl,-Teagle.flash.4m.ld
upload_speed = 460800
of upload_speed = 921600
voor snellere uploads, bij mij lijkt 460800 sneller, denk dat de io wellicht blocked bij hogere snelheden
Async TCP Client
-
https://github.com/me-no-dev/ESPAsyncTCP/blob/master/src/AsyncPrinter.h
-
https://github.com/me-no-dev/ESPAsyncTCP/issues/36
Async is nothing like Sync :)
You do not have available(), instead you have onData callback to handle incoming data as it comes. Basically the whole thing is event based and you have callback for each different event. For example:
You start with connect(host, port, onConnectCallback) and attaching onError callback if connect fails. Once you have connected, you can attach the rest of the callbacks and start sending and receiving data. Once you get onDisconnect or you close the client, you will no longer get onData callbacks and you can not send data. That's about it.
```cpp
client = new AsyncClient();
if(!client)//could not allocate client
return;
client->onConnect([](void * arg, AsyncClient * client) {
///....
client->onData([](void *arg, AsyncClient *c, void *data, size_t len) {
Serial.print("async_recv(): onData len = %d\n", len);
lib_deps ESPAsyncTCP in platformio.ini
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
https://github.com/me-no-dev/ESPAsyncTCP.git
OTA (over the air update)
platformio run -t upload --upload-port 192.168.1.73
mkspiffs error when running 'pio run -t buildfs'
pio run -t buildfs # or uploadfs
[Tue Jan 30 21:33:25 2018] Processing d1_mini_pro (platform: espressif8266; board: d1_mini_pro; framework: arduino)
-----------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 26 compatible libraries
Scanning dependencies...
Library Dependency Graph ( http://bit.ly/configure-pio-ldf )
|-- <ArduinoOTA> v1.0
| |-- <ESP8266WiFi> v1.0
| |-- <ESP8266mDNS>
| | |-- <ESP8266WiFi> v1.0
|-- <Hash> v1.0
|-- <ESP8266WiFi> v1.0
|-- <ESP8266mDNS>
| |-- <ESP8266WiFi> v1.0
Building SPIFFS image from 'data' directory to .pioenvs/d1_mini_pro/spiffs.bin
libc++abi.dylib: terminating with uncaught exception of type std::length_error: vector
*** [.pioenvs/d1_mini_pro/spiffs.bin] Error -6
There could be an error in ~/.platformio/platforms/espressif8266/builder/main.py
. Somehow the size is negative (-s -1069056):
"mkspiffs" -c data -p 256 -b 8192 -s -1069056 .pioenvs/d1_mini_pro/spiffs.bin
Could line 212 in main.py be faulty? "-s", "${int(SPIFFS_END, 16) - int(SPIFFS_START, 16)}",
ESP D1 Mini Pro (wemos.cc)
ESP D1 mini
- geleend van Sy1vain
- In Arduino IDE in add this URL in preferences: http://arduino.esp8266.com/stable/package_esp8266com_index.json
- then open 'boards manager'
ESP D1 mini via PlatformIO
- https://github.com/me-no-dev/ESPAsyncWebServer/blob/master/examples/ESP_AsyncFSBrowser/ESP_AsyncFSBrowser.ino
- http://docs.platformio.org/en/latest/platforms/espressif8266.html
mkdir ESP2
cd ESP2
brew install platformio
pio boards esp8266
pio init -b d1_mini
ls
subl .
pio run
pio run -t upload
mkdir data
cd data
echo hallo > index.htm
cd ..
pio run -t uploadfs
ping esptje.local
Smart Config
-
https://tzapu.com/esp8266-smart-config-esp-touch-arduino-ide/
-
the ESP8266 is actually a 32-bit Tensilica Xtensa LX106 processor running at 80 MHz with a full WiFi stack.
-
[[http://www.electrodragon.com/w/Wi07c|ElectroDragon ESP8266 Wiki]]
-
[[http://zeflo.com/2014/esp8266-weather-display/|Zeflo's Arduino code + wiring example]]
-
[[https://nurdspace.nl/ESP8266|NURDspace on ESP8266]]
-
[[http://www.seeedstudio.com/depot/WiFi-Serial-Transceiver-Module-w-ESP8266-p-1994.html|ESP8266 at seeedstudio.com]]
-
[[http://www.instructables.com/howto/ESP8266/|ESP8266 projects on instructables]]
-
[[http://www.esp8266.com/|user forum]]
-
[[https://www.sparkfun.com/products/12009]] (of 3.3 voltage regulator van pc moederbord afsolderen bijv BA033)
-
http://www.esp8266.com/wiki/doku.php?id=getting-started-with-the-esp8266
>> AT
<< OK
>> AT+GMR
<< 00150900
Set Wifi mode to both Access Point and STAtion: AT+CWMODE=3 List Access Points: AT+CWLAP get the connection status AT+CIPSTATUS restart the module AT+RST check SSID of connected network AT+CWJAP? get IP address AT+CIFSR
send something to a UDP server running on your computer
- on your computer run a UDP server:
nc -lu 10.0.0.161 9999
- then connect to the UDP server and send 5 bytes:
AT+CIPSTART=4,"UDP","10.0.0.161",9999
AT+CIPSEND=4,5
12345 SEND OK
setup a tcp server
AT+CIPMUX=1 AT+CIPSERVER=1,9999 AT+CIFSR
NodeMCU firmware
Flashing
- GPIO0 needs to be connected to ground to flash the chip.
- Download NodeMCU firmware from: https://github.com/nodemcu/nodemcu-firmware/releases
sudo ./esptool.py --port /dev/tty.usbserial write_flash 0x00000 nodemcu.bin
- run examples from https://github.com/nodemcu/nodemcu-firmware
- download [[http://benlo.com/esp8266/LuaLoader.zip|LuaLoader]]
NodeMCU API documentation
- http://www.nodemcu.com/docs/
-
https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en
=wifi.sta.getip() 10.0.0.209 255.255.255.0 10.0.0.1 =wifi.ap.getip() 192.168.4.1 255.255.255.0 192.168.4.1
NodeMCU Lua ESP8266 ESP-12E WiFi Development Board
- [[http://www.bitsandparts.eu/NodeMCU_Lua_ESP8266_ESP-12E_WiFi_Development_Board_IoT_v2_(Arduinos_en_andere_microcontrollers)-p110565.html]]
- [[http://www.banggood.com/NodeMcu-Lua-ESP-12E-WIFI-Development-Board-p-985891.html|esp8266 development board on banggood.com]]
- When turning on, this board will create a wifi network (doitWifi). The password is 12345678 You can very easily upload your own LUA scripts with [[https://github.com/4refr0nt/ESPlorer|ESPlorer]].
dir
function dir()
l = file.list();
for k,v in pairs(l) do
print("name:"..k..", size:"..v)
end
end
dir()
# connect to your wifi network
wifi.setmode(wifi.STATION) wifi.sta.config("SSID","password") print(wifi.sta.getip()) --192.168.18.110
# create a http get function
function dns(domain,cb) sk=net.createConnection(net.TCP, 0) sk:dns(domain,function(conn,ip) cb(ip) end) end
function httpget(domain,file) dns(domain, function(ip) sk=net.createConnection(net.TCP, 0) sk:on("receive", function(sck, c) print(c) end ) sk:connect(80,ip) sk:send("GET " .. file .. " HTTP/1.1 Host: " .. domain .. " Connection: keep-alive Accept: /
") end) end
# Compile NodeMCU firmware yourself to disable certain modules=
* http://www.allaboutcircuits.com/projects/guts-of-the-iot-part-1-building-nodemcu-from-source-for-the-esp8266/