This chapter describes the IOT ITT controller module. The controller module is necessary for any other module to work.
General knowledge of MQTT protocol: topics, brokers, subscribe, publish. General knowledge on microcontrollers and Arduino IDE.
The ITT IoT controller module is based on the Wemos D1 Mini controller. Its pinout can be seen in the following schematic.
Modules are using following I/O ports
As this is the controller module, no actuators or sensors are installed to it.
To program the controller module ITTIoT library is used. This is a custom library made specifically for ITT IoT kits. It aims to make the board easier to use with simple but yet effective methods. A non-exclusive list of methods is presented below:
Method | Description |
---|---|
iot.setup() | Does the operations necessary for setting up the ITTIoT framework and MQTT communications. |
iot.printConfig() | Prints the module configuration to the serial port. |
iot.handle() | Does the background work necessary for the communications to work. For example, checks if the communication with the broker is still working and checks if any new messages have been received. This method has to be called periodically. |
iot.connected() | A method defined by the user that is called when the connection with the MQTT broker has been established. It is primarily used to subscribe to topics with the method iot.subscribe(). |
iot.subscribe(String topic) | Subscribes to the topic specified as the operand. For example iot.subscribe(“IoT/button”) subscribes to the topic “IoT/button”. |
iot.received(String topic, String msg) | User-defined method that is called when the controller receives a message from one of the subscribed topics. The topic from which the message is received is the string “topic” and the body of the message is the string “msg”. |
iot.publishMsgTo(String topic, String msg, bool retain) | Publishes the message “msg” to the topic “topic”. Boolean retain informs the broker if the message should be saved into the memory of the broker. |
The user can connect to and program this controller using the Distancelab environment.
At the same time, one user can program the controller. But all users connected to the Distancelab MQTT broker can subscribe to and publish messages to the topics.