ESP8266 with Arduino IDE


This post will show how to connect the ESP8266 to the IoT server. This how-to will use the ESP8266 library for the Arduino IDE.

Install the Arduino IDE

Download the Arduino IDE (1.6.4, or 1.6.5. Currently the 1.6.6 version is not compatible)

Install the ESP8266 Board Package

Enter into Additional Board Manager URLs field in the Arduino v1.6.4+ preferences. If this url is not working, maybe you may need to check the Github project that supports the library:

Next, go to the Boards manager Tools > Boards > Board manager… to install the ESP8266 package. Search for the esp8266 and install the package esp8266 by ESP8266 Community

Now you can program almost any ESP8266 directly from the Arduino IDE. From the Tools > Boards you should see now the new ESP8266 boards installed. Select your board to be able to compile code for the ESP8266.

You can find additional information for the ESP8266 package in the ESP8266 Github repository. The easiest board to program is the Node MCU, that do not require pressing Flash + Reset buttons for uploading the sketch. Anyway, at this step you should be able to compile and update some ESP8266 example provided in the ESP8266 library to continue with the integration of the thinger platform.

Install Arduino Libraries

This part is also so easy and its covered in more detail in this additional post. But it is as simple as going to Sketch > Include Library > Manage Libraries… and search for thinger and install the library.

Running the example project

Now your IDE is ready for compiling code for the ESP8266 boards and working with the thinger platform. So we are going to load the default example for the ESP8266 from File > Examples > > ESP8266. The example code looks like following (for the 1.1.0 library version):

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ThingerWifi.h>

#define USERNAME "your_user_name"
#define DEVICE_ID "your_device_id"
#define DEVICE_CREDENTIAL "your_device_credential"

#define SSID "your_wifi_ssid"
#define SSID_PASSWORD "your_wifi_ssid_password"


void setup() {

  thing.add_wifi(SSID, SSID_PASSWORD);

  // resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
  thing["led"] << [](pson& in){ digitalWrite(BUILTIN_LED, in ? HIGH : LOW); };

  // resource output example (i.e. reading a sensor value)
  thing["millis"] >> [](pson& out){ out = millis(); };

  // resource input/output example (i.e. passing input values and do some calculations)
  thing["in_out"] = [](pson& in, pson& out){
      out["sum"] = (long)in["value1"] + (long)in["value2"];
      out["mult"] = (long)in["value1"] * (long)in["value2"];

void loop() {

As you can see there are some default constants called USERNAME, DEVICE_ID, and DEVICE_CREDENTIAL that you must fill with the information provided in the device registration process. Also there is config for the WiFi access point. You must change SSID with your Wifi name, and SSID_PASSWORD with your WPA2 Wifi password.

At this point you should be able to program your device and get it connected to the platform. You can check your devices list, enter in the device dashboard clicking in the device name, and accessing the API dashboard (by clicking in the button below) where you can interact with the defined resources (led, millis, in_out). You should see in the device API something like the following pictures:

In the led resource you can turn the led on and off. It is an example of how to send information to the device. In this case it is only required sending a boolean, but you can send any value or json data. Just configure the device for reading the parameters and you could fill them from this API view.

The millis resource is an example of reading values from the device, just a output resource that provides some data. In this case it is read the current milliseconds from the device.

And finally the in_out resource is an example of how the device can take some input parameters an generate an output. In this example the device takes two input values and provides the sum and the multiplication. You can try running the resource with different input values here.

All those resources are illustrative and you can delete them to add you own resources, like reading a sensor value, using a relay, and so on.

You can see also a video that illustrates some of this steps for reading temperature and humidity values from a DHT11 sensor:

Create Real-time IoT Dashboards!
Make your IoT things react to hundred of IFTTT Events
How connect arduino micro via esp8266
IFTTT Maker Channel: Tweet temperature and humidity

Thanks for the detailed description.
I tried this method, and BUILTIN_LED does’nt go on/off. Nor is any of the GPIO PIN’s (4 or 5)

Where as millis & in_out are working as expected. I am using esp8266 esp12F with Arduino. (NOT NODE MCU)

Am I missing something?
Any help is much appreciated.

Thanks in Advance,


If you are able to read millis, and work with the other function, you are almost there! I think that the BUILTIN_LED is only available for NodeMCU. Try adding a Led to a digital pin, and change BUILTIN_LED with your digital pin. Take into account that pin numbers in ESP8266 Arduino library are defined as D4, D5, etc., instead of 4, 5… Take a look to this reference for more details about the ESP8266 pinout.

Anyway, this is a simple example. You can try adding different sensors or actuators like servos or relays to control them from the Internet. :wink:

Let me know if you get it working!


Thanks for an Instant Reply, Much Appreciated.
As the other functions worked, I thought that Pin Mapping is the issue. I tried the same, I used a GPIO 4 & 5 to test the same. But did’nt work. Now I will try D4 & D5.

Thanks in Advance,


I got it working, the issue was not initializing the PinMode.

pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(A0, INPUT);

Fixed it.

Thanks for Help,


Good! It makes sense :grinning:

I see also that when selecting the ESP8266 Generic Module (like you should have selected), the pin definitions like D2, D4, etc are not available… Seems to be only for the NodeMCU… Good to know. I use always the NodeMCU, as it is the easiest way to program an ESP8266…


Thanks for your reply,
NodeMCU is always better, but 1 FTDI with multiple ESP-12’s is cheaper if we have multiple applications.:wink:

Looking forward to work more with

Thanks & Regards,


Yes! NodeMCU can be easier for prototyping, but a simple ESP8266 is much better for final integration. It is smaller and cheaper! If you make something interesting, please, share it with us! :smiley:


I couldn’t access in_out resource from my device API. Can someone help me with this?


Can you please post your resource definition?


Resource definition was the same as in library example. By the way after reloading the page for a couple of times, the problem got resolved. Please look into it.

ESP8266 analog read

Great to know it finally worked. If the resource does not appear in the api explorer it uses to be a symptom of a delay inside the loop or any resource, an unstable connection with the device, and so on. It is useful to enable DEBUG when having problems to see what is happening really:


Hey , I am quite new to
what if if the ESP resets itself for some reason and doesn’t remember previous GPIO state ? Is there any provision in the code/lib, that ESP can be setup to read user defined GPIO state from the server ? Any help is greatly appreciated.
Thank You.


Hy! Thinger doesn’t have any feature to allow that (even jet jejej), but you can create a file in your flash memory or use EEPROM.h to save the last GPIO status.


I guess maybe you can try to write the GPIO to a bucket every time it has a change, and in setup you can read this bucket, (I’ve never did this, just answering with the idea of where would I try to accomplish the task).

Or you can make a call to write from device A (the GPIO status you want to keep) to thinger device B (the device will keep you the GPIO status backup) to storage this kind of values, and in setup of device A make a call to read GPIO status from device B variables, and of course make a call to read from device B variable status from device A, in this way you warantee if any device reboots, will recover the GPIO status from the other one, its like a kind of redundancy, I see this solution more easy to accomplish, there are examples of calls to write and read between thingers devices in the same and differents thinger accounts.

I don´t like the EEPROM solution in this particular case, because the life of this memory is short, you can write it just around of 10.000 times,and if you have a process that changes a lot the GPIO states, you can finish your EEPROM life pretty fast, I recommend to storage at EEPROM the configuration, because when the micro is configured and working, the configuration doesn’t changes frequently.


Today I wanted to connect to with my ESP8266 to monitor my test project.

Unfortunately I was not successful. I have followed the steps of your online turotorial with no luck.
My ESP8266 is connected to my wifi and I have definitely entered correct username,
deviceID and credentials ( I have even tried 2 devices, if I accidentally misspell something).

The library was successfully installed automatically and I don’t get any errors when i compile the project.

What else can I do, to connect the device to the website and start using all of it functionality?


hi @kosi96, can you enable the debug output of the sketch to see what is happening?



I did and this is what I’ve got in Serial Monitor error

If I ping it from my PC I also lose all the packets.


I’ve been in your situation when using ESP8266.
My suggestion is try to use NodeMCU instead of ESP8266. It is more stable. Seriously.
Did you ever test thinger platform using another DevKit?


I have tried using NodeMCU 1.0 with no luck. Same error…
Is is normal that I don’t get any packets back if I ping it?

Nope, this is my first and only device for now…