IMPOERTANT: For now this library supports up to ESP 8266 community version: 2.3.0
If you compile with 2.4.0
or greater version. This code will not work as expected.
MyControllerDevice is network driver for embedded devices to communicate with MyController. You can make your own sensors network on top of embedded hardwares. Currently this library supports for ESP8266 via MQTT protocol
When you compile you have to change the following settings on dependencies,
-
Change
MQTT_MAX_PACKET_SIZE
to 512 bytes on PubSubClient.h
-
Download dependencies to your arduino environment.
-
Download this library to your arduino library location
-
Have a look on example
-
Implement your code
#include <MyController.h>
MyController mc;
void before(){
//Your code before this library inialize
}
void presentation(){
//Presentation code, to send available sensors detail
}
void receiveTime(unsigned long mcTimestamp){
//Do something with received time
}
void receive(McMessage &message) {
//If MyController sends some data, you will receive here.
}
void setup() {
if(!isSystemConfigured()){
//You can check, does this node/device configured. If no you can display/blink some led from here.
}
}
void loop() {
mc.loop();
//You can add your logic here.
}
We have to create gateway entry on MyController server and we have supply those settings to node/esp8266 one time.
Please note, here I have used MyController inbuilt MQTT broker. Which will not allow anonymous
by defaylt. We have to enable anonymous
. We can use with user details also. In the following screenshot I have shown as anonymous
.
We can use any MQTT broker.
Once the firmware successfully uploaded to ESP8266, When you turn on the device. We can see a Access Point(AP) somthing like ESP_XXXXXX
(default password: mycontroller
) this is your device AP. You have to connect your mobile or computer to update MyController and actual AP settings for your ESP8266. Once you have connected to ESP device AP, you have to enter the following IP on your browser 192.168.4.1
. Annd follow these steps,