Skip to content

Part 2. Example. ESP8266

jrbail01 edited this page Nov 25, 2015 · 4 revisions

The ESP8266 is an incredibly cheap WiFi chip that has become an increasingly popular way to give microcontrollers internet connectivity.

ESP8266-based boards are great examples of powerful, cheap boards that can't handle TLS encryption.

Communication with the ESP8266 is typically done through AT commands. Here is an example of establishing a TCP connection and sending a POST:

// Enable multiple connections
AT+CIPMUX=1
	 
// Connect to the hub at Hub_IP and port 8080
AT+CIPSTART="TCP","Hub_IP",8080

// Tell is how long your POST is
AT+CIPSEND=Length_of_Data_You_Want_to_Send
	  
// Send the raw HTTP request
// POST
POST http://hubIP/bucketKey/signalName\r\n Content-Type: text/plain\r\n Content-Length: POST_length\r\n \r\n signalData

Note: \r\n represents a return and allows you to construct the entire request before sending it

If you'd like a complete example of sending to the hub through a microcontroller attached to an ESP8266, check out our Cactus Micro tutorial.

<< Part 2: Basic HTTP POST - Part 2: Example: Cactus Micro >>