Getting started with Wemos D1 and AT&T M2X IoT platform

What IoT actually stands for? In order to analyze in more depth, the subject we need to define some basic concepts about this kind of young technology. IoT is the acronym of Internet of Things, a network of hardware, mainly used for automation and data logging in order to simplify every day tasks both in industry and in every day life. Usually these kind of equipment are connected together to form a network over the internet.

Example of simple GPS monitoring application

The first mentioning of IoT was made in 1999 by Kevin Ashton during one of his presentation. Todays IoT is all around us starting from simple smart gadgets mainly designed for home and office use till serious surveillance and security systems used by the military and airports.

As you can see on the first image a basic IoT network is made out of three components. The first, WeMos the starting point of the chain – takes care of collecting data and transmitting to the closest WiFi hotspot. The second is a common WiFi equipped router, links the WeMos to the internet. The third one is AT&Ts cloud service, called M2X. No, it is not full of vegetables as presented on the picture. It takes care of collecting and storing the data transmitted by the WeMos.

But how can we setup fast and for low price such a device? Actually it is more cheap and easy as it sounds. There are several online platforms available nowadays for IoT projects. One of the best is called M2X and it is developed by AT&T corporation. Its free version has some limitations of course, but comes with a lot of advantages:

  • Large and explicit documentation
  • Huge number of APIs for numerous environments like Arduino, Python, PHP, C, Java, JavaScript, .NET and many others
  • Easy to use
  • Ready made charts, maps and triggers


One of the cheapest hardware solution I could find for WiFi based applications is the so called WeMos D1 R2, which cost me around 7 euros from a local shop here in Košice. Which is a good price if we keep in mind what we get for that price, lets see the specifications:

  • 80 or 160MHz selectable operating frequency
  • 11 IO pins: one analog input, PWM/I2C/one-wire support (except D0 pin)
  • 3v3 voltage level
  • 4MB flash
  • ESP8266 chipset
  • Http host and client support
  • Wifi capability


There are two methods how you can easily flash the Wemos D1:

  1. Arduino IDE: it is possible to write and compile software directly in Arduino official IDE, with the necessary libraries installed, in C/C++ language, this article will deal with this method.
  2. NodeMCU: the original IDE for managing these boards, its language is Python


Hopefully you already have the latest Arduino IDE downloaded and installed on your PC, if not you can get it from this link: arduino-1.8.7-windows.exe

Step 1:

Fire it up, and go to File -> Preferences (or shortcut Ctrl + comma ) , than copy the following address into the Additional Boards Manager URLs:

Step 2: 

After this step, go to Tools -> Board: “current board” -> Boards Manager. In the search bar type ESP82666, and download the ESP8266 library developed by ESP8266 Community.

After installing the library select the corresponding board (in this case WeMos D1 R1), from Tools -> Board: “WeMos D1 R1”.

It is recommended to try flashing your board before getting into more serious things with a simple Blink code, to verify if the installed libraries are up and running fine. For this task you can find a lot of  examples under Files -> Examples.

Step 3:

If everything went as it was supposed to be it is time to download the library for Arduino from AT&T Github page  (link: ) and install it with the in-built *.zip installer,  (Sketch -> Include Library -> Add .ZIP library). 

Step 4:

For now we are finished with the necessary hardware and software preparation, it is time to create a new account or login into the existing one, at and create a new device.

The last step on the AT&Ts website is to Add a new stream to the device.

Step 5:

Everything is ready to test out the setup. For this paste this code into your IDE:

I would like to mention that I am not the author of this source code, I have just modified the original example code that was included in the examples library by AT&T.

After uploading the source code to the WeMos D1 and refreshing M2X you should see the incoming data from your device, something similar as mine on the right.

Wait! There are more possibilities with M2X! You can create custom dashboards, where you can add widgets like charts (bar, radial), stream activity, geographic maps. Also these widgets can be embedded into external websites, like the one below:


Basically this would be the main idea behind IoT, how you send data to a remote server and store it. Of course there is much more what could be done, like sending commands to the WeMos D1 R2 or storing and also analyzing the remotely received data. This will be an other article, how many other things you can do with these cheap equipment. Possibilities are unlimited.