Provisioning your ESP8266 with our server


#1

After you have loaded the app on your smartphone and flashed the initial bin file firmware to your ESP8266 you need to complete the provisioning process.

This is all done from your smartphone and the process is as follows:

  • Create an account on the ESPproMon server

  • Scan one of the available QR code images.

  • Connect your ESP8266 to the server via a WiFi connection to your router.

Sounds simple eh? We will add screenshots and tips for a smooth provisioning process within this category.

PLEASE NOTE THE GUIDE BELOW IS FOR ANDROID AND THERE ARE SOME SUBTLE DIFFERENCES FOR IOS.


Release of ESPproMon 2.0
What if you move to other WiFi AP?
#2

#3

The first time you use the app you will need to create an account on the ESPproMon cloud based server as shown below. [Images 1 and 2]


Scan your chosen QR code image as shown in the What’s new in version 1.0 of ESPproMon? thread. Then you will be guided through connecting your ESP8266 to the server. First stage is to select your normal WiFi Access Point and enter the password. [Images 3 and 4]

Select the Wireless Access Point created by the ESP8266 called ESPproMon. [Images 5 and 6]

The rest of the process is automatic and will display the following screens. [Images 7 and 8]

[Images 9 and 10]


Step by step guide to setting up ESPproMon
Connecting a PeaceFair Pzem-004T to an Espressif ESP8266
#4

The Provisioning process is quite complex and I will provide some tips in the posts that follow which will ensure a smoother process for you.

You will notice I have added an image number pair to the previous post so [images 1 and 2] and [images 7 and 8] for example.

If you have any problems with the Provisioning process please indicate which images you saw or didn’t see etc and we will advise accordingly.


#5

Top tips for smoother provisioning of your ESP8266 with the ESPproMon cloud based server.

  1. Use this tip and you might not need any of the following tips. When you see image 7, put your phone to sleep i.e. press the power button on most smartphones and then press it again to wake it up. You should see that Provisioning has now moved on to image 8.

  2. It might seem obvious but ensure you enter the correct password for your WiFi router. With small phones it’s very easy to press the wrong key. Look closely at your phone to see that each key you press is what you intended to press.

  3. There are various timeouts used within the Provisioning process, but they are quite generous timeouts so don’t race through the process and fall foul of pressing the wrong key. Conversely don’t start provisioning and then wander off to make a cup of tea half way through.

  4. The time taken from image 6 to 7 and 7 to 8 should be less than about 20 seconds. Sometimes it can take a little longer but with experience it becomes clear that the provisioning process needs to be repeated. You can press the back arrow key towards top right of the screen rather than wait for the full timeout process to complete. We recommend you power cycle the ESP8266 if you need to repeat the provisioning process.

In our next post we will provide details regarding the status of the on boards LED(s) for the WeMos and NodeMCU during the provisioning stage and beyond.


#6

The WeMos has a single on board LED so there is no confusion when we refer to the ESPproMon status LED. The NodeMCU has 2 LED’s as shown in the image below.
ESPproMon NodeMCU LEDS
The LED on the left (connected to GPIO 2, D4) is the status LED for ESPproMon and the LED on the right (connected to GPIO 16, D0) will normally just indicate if the board is powered up (see note 1).

Once you have flashed our firmware to your ESP8266 the LED will blink, very faintly, at 1 second intervals. You need to look closely to see the LED blink but it should be there. This is to tell you that the firmware has loaded correctly and the ESP is ready to be provisioned to our server.

After you have completed the provisioning process the LED will blink, again very faintly, at 5 second intervals and this is the normal status for the LED.

If the status LED is not blinking at all then you should power cycle your ESP and it will blink at 1 or 5 second intervals as indicated above.

This is probably a good place to mention the ESP’s EEPROM. A small flag is set in your EEPROM when it has been provisioned with our server and it disables the ESP’s WiFi Access Point. If you need to enable the Access Point you can manually clear this flag in EEPROM by shorting a wire (or resistor) between ground and GPIO 5 (D1) for a few seconds.

The status LED should then change from the 5 second blink frequency to 1 second, indicating the Access Point is now available and the ESP can be re-provisioned. Please note EEPROM is a special area of memory which is not overwritten when you flash a new bin file to the ESP.

Clearing EEPROM can also be done within the app by pressing the red, CLEAR EEPROM button at the bottom of the SETUP page. When you press the button the label will change to “Press Again” to ensure the button wasn’t pressed by mistake. The terminal in the TARIFF page will confirm the EEPROM was cleared and you can then re-provision your ESP.


Note 1: As GPIO 16 (D0) is used for the RF transmitter, if you are using one, then the second LED on the NodeMCU will go on and off as you use the RF transmitter,


#7

At present this tip has a 100% success rate at provisioning.


#8

Just adding an EEPROM clearing sketch that also has OTA functionality.
You should only need this sketch if you need to bring up the Access Point and you can’t use the other methods that we recommend (shorting D1 GPIO 5 to ground for a few seconds or the EEPROM clearing options in the ESPproMon app).

Ensure you enter your WiFi credentials in the sketch before flashing this sketch via OTA or a serial connection. If you use serial ensure you manually reset the ESP after flashing. Once you have the sketch on your ESP you should see a device connected to your router called EEPROMcleared. With the IP allocated to this device you can then do an OTA update with our latest firmware and proceed with provisioning to our server etc.

/********************************************************************************************
  Clean512bytesV2
  EEPROM-Cleaner v1.2.0 from http://www.esp8266.com/viewtopic.php?f=24&t=14710

 Copyright (c) 2017 Helmut Stult (schinfo) OTA added by Costas the coder

 ********************************************************************************************/

#include <EEPROM.h> 
#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>
// sizeBytes being the number of bytes you want to use.
// It's defined with "#define sizeBytes"
// Size can be anywhere between 4 and 4096 bytes (Default for ESP8266_deauther = 4096)
//#define sizeBytes 4096
#define sizeBytes 512 // 512 bytes is fine for ESPproMon

// change it for lower or higher endByte (Default for ESP8266_deauther = 4096)
// normaly it's the same as sizeBytes
//#define endByte 4096
#define endByte 512  // just clear first 512 bytes

// change it for lower or higher startByte (Default = 0)
#define startByte 0

unsigned long ok = 0;
unsigned long nok = 0;
unsigned long tok = 0;
char myhostname[] = "EEPROMcleared";
const char* ssid = "YOUR WIFI NETWORK NAME";
const char* password = "YOUR WIFI PASSWARD";


void setup()
{
  WiFi.hostname(myhostname);
  Serial.begin(115200);
  ArduinoOTA.setHostname(myhostname);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
     delay(500);
     Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println(WiFi.localIP());  // Print the IP address
  ArduinoOTA.begin();
  EEPROM.begin(sizeBytes);

  delay(100);

  Serial.println("**********************************************************************************************************");
  Serial.println("");
  Serial.print("    Write a char(255) / hex(FF) from byte ");
  Serial.print(startByte);
  Serial.print(" to ");
  Serial.print(endByte - 1);
  Serial.print(" into the EEPROM with a defined size of ");
  Serial.print("");
  Serial.print(sizeBytes);
  Serial.println(" Bytes");
  Serial.println("");
  Serial.println("**********************************************************************************************************");
  Serial.println("");

  Serial.println("             testing EEPROM for written bytes");
  Serial.println("");

  for (int i = startByte; i < endByte; ++i)
  {
    if (EEPROM.read(i) == 255) {
      ++ok;
    } else {
      ++nok;
    }
  }

  Serial.printf("               empty bytes: %6d\r\n", ok);
  Serial.printf("           not empty bytes: %6d\r\n", nok);
  Serial.println("");
  Serial.println("**********************************************************************************************************");
  Serial.println("");

  Serial.println("**********************************************************************************************************");
  Serial.println("");
  Serial.println("             Start clearing EEPROM... - Please wait!!!");
  Serial.println("");
  Serial.println("**********************************************************************************************************");

  delay(1000);

  // write a char(255) / hex(FF) from startByte until endByte into the EEPROM
  for (int i = startByte; i < endByte; ++i) {
    EEPROM.write(i, -1);
  }

  EEPROM.commit();

  delay(1000);

  Serial.println("");
  Serial.println("             testing EEPROM for clearing");
  Serial.println("");

  String test;
  for (int i = startByte; i < endByte; ++i)
  {
    if (EEPROM.read(i) == 255) {
      ++tok;
    }
  }
  Serial.println("**********************************************************************************************************");
  Serial.println("");
  if (tok = endByte - startByte) {
    Serial.println("             EEPROM killed correctly");
  } else
    Serial.println("             EEPROM not killed - ERROR !!!");

  Serial.println("");
  Serial.println("**********************************************************************************************************");
  Serial.println("");
  Serial.println("             Ready - You can remove your ESP8266 / LoLin");
  Serial.println("");
  Serial.println("**********************************************************************************************************");
}

void loop()
{
  ArduinoOTA.handle();  
}

Flashing Bin files to your ESP8266
#9

@karthi welcome to the ESPproMon community site. Are you using Android or iOS?

What problems are you having with the provisioning?

Please post screenshots of any error messages.


#10

hi Costas,
i successfully provisioned and log on to the APP. on the other side i have PZEM-004t module which is not responding when i tried with Arduino uno, MEGA 2560 and esp8266 12E. i used this library to communicate with PZEM, https://github.com/olehs/PZEM004T .
I need your help to make it work.


#11

@karthi

Have you worked through the guides that tell you which pins to connect from the Pzem to the ESP8266?

You can’t use an Uno or Mega with our app but the ESP8266 12E should be fine.

Do you know how to wire up the Pzem and where are you picking up the 5V input for it?


#12

yes i used uno for testing pzem. for powering 5v taken from NODE MCU’s Vin

pin which is 5V coming from from USB.


#13

@karthi please upload a photo showing your Pzem and ESP all wired up.


#14

ok. Now i’m in workplace, after 2hours i’ll reach my house will work on that.

thank you for your fastest response.


#15

here is the pic of NODE MCU to PZEM

PZEM 5V–> Node mcu Vin
RX --> TX
TX–> RX
GND—> GND


#16

@karthi thanks for the photo. The TX and RX on the Pzem don’t go to the RX and TX pins on the ESP8266.

We have allocated specific GPIO pins for the RX and TX connections on the ESP8266.

Please look through this thread Connecting a PeaceFair Pzem-004T to an Espressif ESP8266


#17

I made the changes accordingly. i Flashed Node MCU with the firmware. now i want to register my device right?


#18

You should be able to use the firmware without registering it. Once you know it all works then you can register it.


#19

ok, for flashing firmware i used nodemcu-flasher

this Settings ok or i need to use esp8266 download tool?


#20

That flasher should be fine but we have found some users don’t know what size their flash chip is and have wrongly used 1M when it’s a 4M.

Our firmware will run with an incorrect flash size but it will not store the required access credentials to interface with our server.