Arduino+ESP8266

※ Note: The ESP8266 has a 3.3V operating voltage. In this guide, 5V is applied to the RX and TX pins of the ESP8266, so the ESP8266 board may be broken. ※ Due to a bug in the WiFiEsp library, sensor data transmission is possible, but actuator commands can not be received at arduino side.

Arrangements: Arduino, Arduino AC power, ESP8266

Please apply AC power to Arduino.

1. ESP8266 F/W update

1.1 Circuit configuration

FlashCircuit
Esp8266 Arduino
Rx Rx
Tx Tx
CH_PD 3.3V
VCC 3.3V
GND GND
GPIO0 GND
Arduino Arduino
RESET GND

1.2 ESP8266 Flash Tool, SDK Download

1.3 Flash ESP8266 Firmware

1.4 Verify flashing and Baudrate set

command response description
AT OK Verify normal operation of AT command
AT+GMR AT version:1.3.0.0(Jul 14 2016 18:54:01)
SDK version:2.0.0(656edbf)
compile time:Jul 19 2016 18:44:22
OK
Check to firmware version
AT+UART_DEF=9600,8,1,0,0 OK setting of Baudrate

2. Thing+ Guide for Arduino with ESP8266

2.1 Circuit configuration

RunningCircuit
Esp8266 Arduino
Rx GPIO7
Tx GPIO6
CH_PD 3.3V
VCC 3.3V
GND GND

2.2 Install libraries

Reference : Install arduino firmware

2.2.1 Modifying the PubSubClient’s Header File

2.2.2 config setting

void ThingplusClass::begin(Client& client, byte mac[], const char *apikey) {
	const char *server = "mqtt.sandbox.thingplus.net";
	const int port = 1883;

	this->mac = mac;
	snprintf(this->gatewayId, sizeof(this->gatewayId), PSTR("%02x%02x%02x%02x%02x%02x"),
			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
	this->apikey = apikey;

	this->mqtt.setCallback(mqttSubscribeCallback);
	this->mqtt.setServer(server, port);
	this->mqtt.setClient(client);
}

3. Register gateway

Reference : Register Gateway