Difference between revisions of "ESP8266"

From Hackerspace ACKspace
Jump to: navigation, search
(moved ESP8266 to ESP^2: ESP information will become more extensive, so moving the egg salad programmer to its own page)
 
(first layout of the 'big' ESPage)
Line 1: Line 1:
#REDIRECT [[ESP^2]]
+
{{InfoBox
 +
|Type=featured
 +
|Title=NOTE
 +
|Text=For the ESP Egg Salad programmer, see [[ESP^2]]
 +
|Clear=both
 +
|Background=#f7fff7
 +
}}
 +
 
 +
== programming the ESP8266 ==
 +
 
 +
=== hardware: using the [[ESP^2]] ===
 +
 
 +
TODO
 +
 
 +
=== hardware: using an FTDI cable ===
 +
 
 +
TODO
 +
 
 +
=== software: using Arduino 1.6.4 ===
 +
Taken from https://github.com/esp8266/arduino
 +
 
 +
* Install Arduino 1.6.4 from the [http://www.arduino.cc/en/main/software Arduino website].
 +
* Start Arduino and open Perferences window.
 +
* Enter ''http://arduino.esp8266.com/package_esp8266com_index.json'' into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
 +
* Open Boards Manager from Tools > Board menu and install ESP8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
 +
* For the ESP^2, the device name (under Linux) is /dev/ttyACM3
 +
* Change the programmer from ''AVRISP mkII'' to ''ArduinoISP''
 +
* poweroff ESP (either unplug the USB or pull the device from the socket
 +
* set the switch to ''prog''
 +
* poweron the ESP
 +
* You can now upload your sketch
 +
 
 +
=== software: using esptool.py to upload NodeMCU ===
 +
 
 +
TODO
 +
 
 +
==== loading scripts from a webserver  ====
 +
 
 +
I ([[User:Da Syntax|Da Syntax]]) got tired from typing the scripts line for line into the lua console of the nodeMCU firmware. I wrote a little function to load the scripts from a webserver running on my laptop. This way I can just save the script on my laptop and load it to my ESP8266 calling 2 functions ( netload() and dofile("netloaded.lua") )
 +
<pre>function netload()
 +
conn=net.createConnection(net.TCP, 0)
 +
conn:on("receive", function(conn, payload)
 +
print(payload)
 +
file.open("netloaded.lua", "w")
 +
file.write(payload)
 +
file.close()
 +
end)
 +
conn:connect(8080,"192.168.1.193")
 +
conn:send("GET /test.lua HTTP/1.1\r\nHost: www.example.com\r\n"        .."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
 +
end
 +
</pre>
 +
==== Future plans ====
 +
 
 +
*Send mac address of the wifi module in get so the web server can return device specific firmwares
 +
*Put the script between specific tags so there won't be any problems with headers that are added by the web server + gives the possibility to add meta data (e.g. version of script or a signature)
 +
*Create a nice php/mysql webapp to easily manage the scripts per module
 +
 
 +
 
 +
== sample projects ==
 +
 
 +
Here are some sample projects
 +
 
 +
=== Webserver serving JSON (Arduino) ===
 +
 
 +
This arduino sketch provides a webserver-like interface and provides a json file (somewhat compatible with [[SpaceAPI]])
 +
There is a version running in the space in a 'hot' zone, and accessible on [http://192.168.1.132 http://192.168.1.132]
 +
 
 +
You can find the code [[ESP8266-DS18S20|here]]
 +
 
 +
=== SpaceAPI (Arduino) ===
 +
 
 +
The new [[SpaceAPI]] is a combination of some PHP, MySQL, and some ESP modules updating the space state and sensor data.
 +
The ESP sketch sketch will have several features like space state switch, indicator, Dallas temperature and other sensors, which can be enabled compile-time.
 +
 
 +
=== SpaceState (Arduino) ===
 +
 
 +
This Arduino sketch is a web client and will update the SpaceState
 +
 
 +
You can find the code [[ESP8266-SpaceState|here]]

Revision as of 18:55, 23 July 2015

NOTE
For the ESP Egg Salad programmer, see ESP^2

programming the ESP8266

hardware: using the ESP^2

TODO

hardware: using an FTDI cable

TODO

software: using Arduino 1.6.4

Taken from https://github.com/esp8266/arduino

  • Install Arduino 1.6.4 from the Arduino website.
  • Start Arduino and open Perferences window.
  • Enter http://arduino.esp8266.com/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
  • Open Boards Manager from Tools > Board menu and install ESP8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
  • For the ESP^2, the device name (under Linux) is /dev/ttyACM3
  • Change the programmer from AVRISP mkII to ArduinoISP
  • poweroff ESP (either unplug the USB or pull the device from the socket
  • set the switch to prog
  • poweron the ESP
  • You can now upload your sketch

software: using esptool.py to upload NodeMCU

TODO

loading scripts from a webserver

I (Da Syntax) got tired from typing the scripts line for line into the lua console of the nodeMCU firmware. I wrote a little function to load the scripts from a webserver running on my laptop. This way I can just save the script on my laptop and load it to my ESP8266 calling 2 functions ( netload() and dofile("netloaded.lua") )

function netload()
	conn=net.createConnection(net.TCP, 0)
	conn:on("receive", function(conn, payload)
		print(payload)
		file.open("netloaded.lua", "w")
		file.write(payload)
		file.close()
	end)
	conn:connect(8080,"192.168.1.193")
	conn:send("GET /test.lua HTTP/1.1\r\nHost: www.example.com\r\n"        .."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
end

Future plans

  • Send mac address of the wifi module in get so the web server can return device specific firmwares
  • Put the script between specific tags so there won't be any problems with headers that are added by the web server + gives the possibility to add meta data (e.g. version of script or a signature)
  • Create a nice php/mysql webapp to easily manage the scripts per module


sample projects

Here are some sample projects

Webserver serving JSON (Arduino)

This arduino sketch provides a webserver-like interface and provides a json file (somewhat compatible with SpaceAPI) There is a version running in the space in a 'hot' zone, and accessible on http://192.168.1.132

You can find the code here

SpaceAPI (Arduino)

The new SpaceAPI is a combination of some PHP, MySQL, and some ESP modules updating the space state and sensor data. The ESP sketch sketch will have several features like space state switch, indicator, Dallas temperature and other sensors, which can be enabled compile-time.

SpaceState (Arduino)

This Arduino sketch is a web client and will update the SpaceState

You can find the code here