Setting up the local broker

Now that the setup is in place, let's discuss what we want to achieve in this chapter. Later in this chapter, we will come back to the mobile application:

You have enough knowledge now to complete the entire system from ESP8266 code to your local broker and to the mobile application. To complete this chain we can start with the ESP8266. Let's create a simple plug code and let's use the PaaS service offered by iotcentral.eu as an authorization and cloud MQTT service:

  1. Create an account and validate your email address on iotcentral.eu:
  1. Get the bondar.bin binary image of a local MQTT broker and write it to a nodeMcu 4Mb board. Power off and then on the board:
  1. Use your mobile application to search for an Access Point named Bondar_XXXXXXX where XXXXXX are the latest six digits from the MAC address.
  2. Connect to it and use the password 12345678 if it is requested. Navigate with your phone browser to address 192.168.4.1 and in the web page enter the same credentials that you have used for the iotcentral.eu account. The local broker will connect to the iotcentral.eu platform and will register itself.

On your devices page on iotcentral.eu you should be able to see your newly registered local broker. Using the local broker on an ESP8266 is not mandatory, but it simplifies your code on ESP. If you choose not to use a local broker, you need to connect directly to the cloud MQTT broker on iotcentral.eu. In this case we need to get your allocated topic and add more logic in your code to handle this:

On https://github/bcatalin/demoapp is the code that we will use as the ESP8266 code. Get the code and write it to the ESP8266.

After the ESP8266 is rebooted, go to your phone and search for on Access Point named ESPap. Connect to it and navigate with your browser to the address http://192.168.4.1 like you did for the local EP8266 MQTT broker. In the page presented by the ESP8266, fill the Wi-Fi credentials, the username, and password used for iotcetral.eu, the Amazon Alexa name you want to call your module to turn something ON or OFF, and your time zone (this is not implemented, you can just do it as an exercise):

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.142.193