├── .gitattributes ├── Esp8266 └── sketch_esp8266_mqtt │ └── sketch_esp8266_mqtt.ino ├── README.md ├── mqtt_dashboard.aia └── mqtt_dashboard ├── assets ├── Untitleddesign.png ├── external_comps │ └── de.ullisroboterseite.ursai2pahomqtt │ │ ├── aiwebres │ │ └── icon.png │ │ ├── classes.jar │ │ ├── components.json │ │ ├── extension.properties │ │ └── files │ │ ├── AndroidRuntime.jar │ │ └── component_build_infos.json ├── humidity_wather_16790.png ├── off.png ├── on.png └── temperature_icon_175973.png ├── src └── appinventor │ └── ai_emmiasim67 │ └── mqtt_dashboard │ ├── Screen1.bky │ └── Screen1.scm └── youngandroidproject └── project.properties /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Esp8266/sketch_esp8266_mqtt/sketch_esp8266_mqtt.ino: -------------------------------------------------------------------------------- 1 | #include //Library for Adafruit sensors , we are using for DHT 2 | #include //DHT library which uses some func from Adafruit Sensor library 3 | #include //library for using ESP8266 WiFi 4 | #include //library for MQTT 5 | #include //library for Parsing JSON 6 | 7 | //defining Pins 8 | #define DHTPIN 5 9 | #define LED D2 10 | 11 | //DHT parameters 12 | #define DHTTYPE DHT11 // DHT 11 13 | DHT_Unified dht(DHTPIN, DHTTYPE); 14 | uint32_t delayMS; 15 | 16 | //MQTT Credentials 17 | const char* ssid = "Oneplus";//setting your ap ssid 18 | const char* password = "12345678";//setting your ap psk 19 | const char* mqttServer = "iot.reyax.com"; //MQTT URL 20 | const char* mqttUserName = "BCHgWchyFe"; // MQTT username 21 | const char* mqttPwd = "dnKbAMzWFx"; // MQTT password 22 | const char* clientID = "username0001"; // client id username+0001 23 | const char* topic = "Tempdata"; //publish topic 24 | 25 | //parameters for using non-blocking delay 26 | unsigned long previousMillis = 0; 27 | const long interval = 5000; 28 | 29 | String msgStr = ""; // MQTT message buffer 30 | 31 | float temp, hum; 32 | 33 | 34 | //setting up wifi and mqtt client 35 | WiFiClient espClient; 36 | PubSubClient client(espClient); 37 | 38 | void setup_wifi() { 39 | delay(10); 40 | 41 | WiFi.begin(ssid, password); 42 | 43 | while (WiFi.status() != WL_CONNECTED) { 44 | delay(500); 45 | Serial.print("."); 46 | } 47 | 48 | Serial.println(""); 49 | Serial.println("WiFi connected"); 50 | Serial.println("IP address: "); 51 | Serial.println(WiFi.localIP()); 52 | 53 | } 54 | 55 | void reconnect() { 56 | while (!client.connected()) { 57 | if (client.connect(clientID, mqttUserName, mqttPwd)) { 58 | Serial.println("MQTT connected"); 59 | // client.subscribe("api/command/37/#"); 60 | client.subscribe("lights"); 61 | Serial.println("Topic Subscribed"); 62 | } 63 | else { 64 | Serial.print("failed, rc="); 65 | Serial.print(client.state()); 66 | Serial.println(" try again in 5 seconds"); 67 | delay(5000); // wait 5sec and retry 68 | } 69 | 70 | } 71 | 72 | } 73 | 74 | //subscribe call back 75 | void callback(char*topic, byte* payload, unsigned int length) { 76 | Serial.print("Message arrived in topic: "); 77 | Serial.println(topic); 78 | Serial.print("Message:"); 79 | String data = ""; 80 | for (int i = 0; i < length; i++) { 81 | Serial.print((char)payload[i]); 82 | data += (char)payload[i]; 83 | } 84 | Serial.println(); 85 | Serial.print("Message size :"); 86 | Serial.println(length); 87 | Serial.println(); 88 | Serial.println("-----------------------"); 89 | Serial.println(data); 90 | // StaticJsonDocument<256> doc; //read JSON data 91 | // deserializeJson(doc, payload, length); //deserialise it 92 | // JsonObject command = doc["command"]; //get the values of command parameter 93 | 94 | // int command_parameters_led = command["parameters"]["led"]; //get value of led, which will be 1 or 0 95 | // 96 | // if (command_parameters_led == 1) { 97 | // Serial.println("LED"); 98 | // digitalWrite(LED, HIGH); 99 | // } 100 | // else { 101 | // digitalWrite(LED, LOW); 102 | // } 103 | if(data=="ON"){ 104 | Serial.println("LED"); 105 | digitalWrite(LED, HIGH); 106 | } 107 | else{ 108 | digitalWrite(LED, LOW); 109 | } 110 | } 111 | 112 | 113 | void setup() { 114 | Serial.begin(115200); 115 | // Initialize device. 116 | dht.begin(); 117 | // get temperature sensor details. 118 | sensor_t sensor; 119 | dht.temperature().getSensor(&sensor); 120 | dht.humidity().getSensor(&sensor); 121 | 122 | pinMode(LED, OUTPUT); 123 | digitalWrite(LED, LOW); 124 | 125 | setup_wifi(); 126 | 127 | client.setServer(mqttServer, 1883); //setting MQTT server 128 | client.setCallback(callback); //defining function which will be called when message is recieved. 129 | 130 | } 131 | 132 | void loop() { 133 | if (!client.connected()) { //if client is not connected 134 | reconnect(); //try to reconnect 135 | } 136 | client.loop(); 137 | 138 | unsigned long currentMillis = millis(); //read current time 139 | 140 | if (currentMillis - previousMillis >= interval) { //if current time - last time > 5 sec 141 | previousMillis = currentMillis; 142 | 143 | //read temp and humidity 144 | sensors_event_t event; 145 | dht.temperature().getEvent(&event); 146 | 147 | 148 | if (isnan(event.temperature)) { 149 | Serial.println(F("Error reading temperature!")); 150 | } 151 | else { 152 | Serial.print(F("Temperature: ")); 153 | temp = event.temperature; 154 | Serial.print(temp); 155 | Serial.println(F("°C")); 156 | } 157 | // Get humidity event and print its value. 158 | dht.humidity().getEvent(&event); 159 | if (isnan(event.relative_humidity)) { 160 | Serial.println(F("Error reading humidity!")); 161 | } 162 | else { 163 | Serial.print(F("Humidity: ")); 164 | hum = event.relative_humidity; 165 | Serial.print(hum); 166 | Serial.println(F("%")); 167 | } 168 | 169 | // msgStr = "{\"action\": \"notification/insert\",\"deviceId\": \"s3s9TFhT9WbDsA0CxlWeAKuZykjcmO6PoxK6\",\"notification\":{\"notification\": \"temperature\",\"parameters\":{\"temp\":" + String(temp) + ",\"humi\":" + String(hum) + "}}}"; 170 | msgStr = String(temp) +","+String(hum); 171 | byte arrSize = msgStr.length() + 1; 172 | char msg[arrSize]; 173 | 174 | Serial.print("PUBLISH DATA:"); 175 | Serial.println(msgStr); 176 | msgStr.toCharArray(msg, arrSize); 177 | client.publish(topic, msg); 178 | msgStr = ""; 179 | delay(50); 180 | 181 | } 182 | 183 | } 184 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mqtt-in-Android-app---mit-app-inventor 2 | In this tutorial we will implement MQTT in Android application using drag and drop programming blocks in MIT App inventor. 3 | [![MQTT in ANdroid](https://highvoltages.co/wp-content/uploads/2021/12/ESP8266-RASPBERRY-PI-WIRELESS-COMMUNICATION.png)](https://www.youtube.com/watch?v=WAimZhU5phs) 4 | 5 | Also if you want to read the steps , go to: 6 | https://highvoltages.co/iot-internet-of-things/how-to-mqtt/how-to-make-mqtt-android-application-using-mit-app-inventor/ 7 | -------------------------------------------------------------------------------- /mqtt_dashboard.aia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard.aia -------------------------------------------------------------------------------- /mqtt_dashboard/assets/Untitleddesign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard/assets/Untitleddesign.png -------------------------------------------------------------------------------- /mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/aiwebres/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/aiwebres/icon.png -------------------------------------------------------------------------------- /mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/classes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/classes.jar -------------------------------------------------------------------------------- /mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/components.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "categoryString": "EXTENSION", 3 | "dateBuilt": "2020-11-15", 4 | "nonVisible": "true", 5 | "iconName": "aiwebres/icon.png", 6 | "methods": [ 7 | { 8 | "deprecated": "false", 9 | "name": "Connect", 10 | "description": "Connect to a MQTT broker.", 11 | "params": [{ 12 | "name": "CleanSession", 13 | "type": "boolean" 14 | }] 15 | }, 16 | { 17 | "deprecated": "false", 18 | "name": "ConnectWithLastWill", 19 | "description": "Connect to a MQTT broker.", 20 | "params": [ 21 | { 22 | "name": "CleanSession", 23 | "type": "boolean" 24 | }, 25 | { 26 | "name": "Topic", 27 | "type": "text" 28 | }, 29 | { 30 | "name": "Message", 31 | "type": "text" 32 | }, 33 | { 34 | "name": "Retain", 35 | "type": "boolean" 36 | }, 37 | { 38 | "name": "QoS", 39 | "type": "number" 40 | } 41 | ] 42 | }, 43 | { 44 | "deprecated": "false", 45 | "name": "Disconnect", 46 | "description": "Disconnects from the broker.", 47 | "params": [] 48 | }, 49 | { 50 | "deprecated": "false", 51 | "name": "FromDictionary", 52 | "description": "Export conection parameters to a dictionary.", 53 | "params": [{ 54 | "name": "dict", 55 | "type": "dictionary" 56 | }] 57 | }, 58 | { 59 | "deprecated": "false", 60 | "name": "IsNull", 61 | "description": "Test whether an object is null.", 62 | "params": [{ 63 | "name": "Object", 64 | "type": "any" 65 | }], 66 | "returnType": "boolean" 67 | }, 68 | { 69 | "deprecated": "false", 70 | "name": "Publish", 71 | "description": "Publish a MQTT message. Retain flag is false, QoS is 0.", 72 | "params": [ 73 | { 74 | "name": "Topic", 75 | "type": "text" 76 | }, 77 | { 78 | "name": "Message", 79 | "type": "text" 80 | } 81 | ] 82 | }, 83 | { 84 | "deprecated": "false", 85 | "name": "PublishBinary", 86 | "description": "Publishes a binary coded MQTT message.", 87 | "params": [ 88 | { 89 | "name": "Topic", 90 | "type": "text" 91 | }, 92 | { 93 | "name": "BinaryMessage", 94 | "type": "text" 95 | }, 96 | { 97 | "name": "RetainFlag", 98 | "type": "boolean" 99 | }, 100 | { 101 | "name": "QoS", 102 | "type": "number" 103 | } 104 | ] 105 | }, 106 | { 107 | "deprecated": "false", 108 | "name": "PublishByteArray", 109 | "description": "Publishes a binary array.", 110 | "params": [ 111 | { 112 | "name": "Topic", 113 | "type": "text" 114 | }, 115 | { 116 | "name": "ByteArray", 117 | "type": "any" 118 | }, 119 | { 120 | "name": "RetainFlag", 121 | "type": "boolean" 122 | }, 123 | { 124 | "name": "QoS", 125 | "type": "number" 126 | } 127 | ] 128 | }, 129 | { 130 | "deprecated": "false", 131 | "name": "PublishEx", 132 | "description": "Publish a MQTT message.", 133 | "params": [ 134 | { 135 | "name": "Topic", 136 | "type": "text" 137 | }, 138 | { 139 | "name": "Message", 140 | "type": "text" 141 | }, 142 | { 143 | "name": "RetainFlag", 144 | "type": "boolean" 145 | }, 146 | { 147 | "name": "QoS", 148 | "type": "number" 149 | } 150 | ] 151 | }, 152 | { 153 | "deprecated": "false", 154 | "name": "Subscribe", 155 | "description": "Subscribe a topic.", 156 | "params": [ 157 | { 158 | "name": "Topic", 159 | "type": "text" 160 | }, 161 | { 162 | "name": "QoS", 163 | "type": "number" 164 | } 165 | ] 166 | }, 167 | { 168 | "deprecated": "false", 169 | "name": "SubscribeByteArray", 170 | "description": "Subscribe a topic for receiving byte arrays.", 171 | "params": [ 172 | { 173 | "name": "Topic", 174 | "type": "text" 175 | }, 176 | { 177 | "name": "QoS", 178 | "type": "number" 179 | } 180 | ] 181 | }, 182 | { 183 | "deprecated": "false", 184 | "name": "ToDictionary", 185 | "description": "Export conection parameters to a dictionary.", 186 | "params": [], 187 | "returnType": "dictionary" 188 | }, 189 | { 190 | "deprecated": "false", 191 | "name": "Unsubscribe", 192 | "description": "Unsubscribe a topic.", 193 | "params": [{ 194 | "name": "Topic", 195 | "type": "text" 196 | }] 197 | } 198 | ], 199 | "blockProperties": [ 200 | { 201 | "rw": "read-write", 202 | "deprecated": "false", 203 | "name": "Broker", 204 | "description": "The IP address or hostname of the server to connect to.", 205 | "type": "text" 206 | }, 207 | { 208 | "rw": "read-write", 209 | "deprecated": "false", 210 | "name": "ClientCertFile", 211 | "description": "The name of the client certificate file.", 212 | "type": "text" 213 | }, 214 | { 215 | "rw": "read-write", 216 | "deprecated": "false", 217 | "name": "ClientID", 218 | "description": "The unique client Id. If this field is blank a random GUID is used.", 219 | "type": "text" 220 | }, 221 | { 222 | "rw": "read-write", 223 | "deprecated": "false", 224 | "name": "ClientKeyFile", 225 | "description": "The name of the client key file.", 226 | "type": "text" 227 | }, 228 | { 229 | "rw": "read-write", 230 | "deprecated": "false", 231 | "name": "ClientKeyPassword", 232 | "description": "The client key password.", 233 | "type": "text" 234 | }, 235 | { 236 | "rw": "read-write", 237 | "deprecated": "false", 238 | "name": "ClientKeystoreFile", 239 | "description": "The name of the client keystore file.", 240 | "type": "text" 241 | }, 242 | { 243 | "rw": "read-write", 244 | "deprecated": "false", 245 | "name": "ClientKeystorePassword", 246 | "description": "The client keystore password.", 247 | "type": "text" 248 | }, 249 | { 250 | "rw": "read-write", 251 | "deprecated": "false", 252 | "name": "ClientPemFormatted", 253 | "description": "The client certifacte and key files are PEM formatted.", 254 | "type": "boolean" 255 | }, 256 | { 257 | "rw": "read-only", 258 | "deprecated": "false", 259 | "name": "ConnectionState", 260 | "description": "The connection state:\n0: Disconnected. The client is not connected to a broker.\n1: Connecting. The client is currently creating a connection to a MQTT broker.\n2: Connected. The client is connected to a MQTT broker.\n3: Disconnecting. The client is currently disconnecting from the MQTT broker.\n4: ConnectionAbortet. The connection could not be established or was interrupted.", 261 | "type": "number" 262 | }, 263 | { 264 | "rw": "read-write", 265 | "deprecated": "false", 266 | "name": "ConnectionTimeout", 267 | "description": "Connection timeout [seconds].", 268 | "type": "number" 269 | }, 270 | { 271 | "rw": "read-only", 272 | "deprecated": "false", 273 | "name": "IsConnected", 274 | "description": "true: Client is connected to a MQTT broker.", 275 | "type": "boolean" 276 | }, 277 | { 278 | "rw": "read-only", 279 | "deprecated": "false", 280 | "name": "IsDisconnected", 281 | "description": "true: Client is disconnected from the MQTT broker.", 282 | "type": "boolean" 283 | }, 284 | { 285 | "rw": "read-write", 286 | "deprecated": "false", 287 | "name": "KeepAlive", 288 | "description": "Keep alive interval [seconds].", 289 | "type": "number" 290 | }, 291 | { 292 | "rw": "read-only", 293 | "deprecated": "false", 294 | "name": "LastAction", 295 | "description": "Returns the last Action the error code belongs to.", 296 | "type": "text" 297 | }, 298 | { 299 | "rw": "read-only", 300 | "deprecated": "false", 301 | "name": "LastErrorCode", 302 | "description": "Returns the code of the last error.", 303 | "type": "number" 304 | }, 305 | { 306 | "rw": "read-only", 307 | "deprecated": "false", 308 | "name": "LastErrorMessage", 309 | "description": "Returns a text message about the last error.", 310 | "type": "text" 311 | }, 312 | { 313 | "rw": "read-only", 314 | "deprecated": "false", 315 | "name": "LastExecptionCause", 316 | "description": "Provides information on the last exception.", 317 | "type": "text" 318 | }, 319 | { 320 | "rw": "read-write", 321 | "deprecated": "false", 322 | "name": "MaxInflight", 323 | "description": "The max inflight limits to how many messages we can send without receiving acknowledgments.\nIncrease this value in a high traffic environment.", 324 | "type": "number" 325 | }, 326 | { 327 | "rw": "read-write", 328 | "deprecated": "false", 329 | "name": "Port", 330 | "description": "The port number of the server to connect to.", 331 | "type": "number" 332 | }, 333 | { 334 | "rw": "read-write", 335 | "deprecated": "false", 336 | "name": "Protocol", 337 | "description": "The protocol to use.", 338 | "type": "text" 339 | }, 340 | { 341 | "rw": "read-only", 342 | "deprecated": "false", 343 | "name": "StateConnected", 344 | "description": "Constant for connection state 'Connected'.", 345 | "type": "number" 346 | }, 347 | { 348 | "rw": "read-only", 349 | "deprecated": "false", 350 | "name": "StateConnecting", 351 | "description": "Constant for connection state 'Connecting'.", 352 | "type": "number" 353 | }, 354 | { 355 | "rw": "read-only", 356 | "deprecated": "false", 357 | "name": "StateConnectionAbortet", 358 | "description": "Constant for connection state 'ConnectionAbortet'.", 359 | "type": "number" 360 | }, 361 | { 362 | "rw": "read-only", 363 | "deprecated": "false", 364 | "name": "StateDisconnected", 365 | "description": "Constant for connection state 'Disconnected'.", 366 | "type": "number" 367 | }, 368 | { 369 | "rw": "read-only", 370 | "deprecated": "false", 371 | "name": "StateDisconnecting", 372 | "description": "Constant for connection state 'Disconnecting'.", 373 | "type": "number" 374 | }, 375 | { 376 | "rw": "read-write", 377 | "deprecated": "false", 378 | "name": "TimeToWait", 379 | "description": "Maximum time to wait for an action to complete [seconds].\n-1 means the action will not timeout.", 380 | "type": "number" 381 | }, 382 | { 383 | "rw": "read-write", 384 | "deprecated": "false", 385 | "name": "TrustedCertFile", 386 | "description": "The name of the trusted certificate file.", 387 | "type": "text" 388 | }, 389 | { 390 | "rw": "read-write", 391 | "deprecated": "false", 392 | "name": "TruststoreFile", 393 | "description": "The name of the truststore file.", 394 | "type": "text" 395 | }, 396 | { 397 | "rw": "read-write", 398 | "deprecated": "false", 399 | "name": "TruststorePassword", 400 | "description": "The password of the truststore file.", 401 | "type": "text" 402 | }, 403 | { 404 | "rw": "read-write", 405 | "deprecated": "false", 406 | "name": "UserName", 407 | "description": "The user name used authentication and authorization.", 408 | "type": "text" 409 | }, 410 | { 411 | "rw": "read-write", 412 | "deprecated": "false", 413 | "name": "UserPassword", 414 | "description": "The password used authentication and authorization.", 415 | "type": "text" 416 | } 417 | ], 418 | "helpUrl": "http://UllisRoboterSeite.de/android-AI2-PahoMQTT.html", 419 | "type": "de.ullisroboterseite.ursai2pahomqtt.UrsPahoMqttClient", 420 | "versionName": "1.0", 421 | "androidMinSdk": 7, 422 | "version": "1", 423 | "external": "true", 424 | "showOnPalette": "true", 425 | "name": "UrsPahoMqttClient", 426 | "helpString": "AI2 extension block for MQTT communication.", 427 | "properties": [ 428 | { 429 | "defaultValue": "", 430 | "name": "Broker", 431 | "editorArgs": [], 432 | "editorType": "string" 433 | }, 434 | { 435 | "defaultValue": "", 436 | "name": "ClientCertFile", 437 | "editorArgs": [], 438 | "editorType": "asset" 439 | }, 440 | { 441 | "defaultValue": "", 442 | "name": "ClientID", 443 | "editorArgs": [], 444 | "editorType": "string" 445 | }, 446 | { 447 | "defaultValue": "", 448 | "name": "ClientKeyFile", 449 | "editorArgs": [], 450 | "editorType": "asset" 451 | }, 452 | { 453 | "defaultValue": "", 454 | "name": "ClientKeyPassword", 455 | "editorArgs": [], 456 | "editorType": "string" 457 | }, 458 | { 459 | "defaultValue": "", 460 | "name": "ClientKeystoreFile", 461 | "editorArgs": [], 462 | "editorType": "asset" 463 | }, 464 | { 465 | "defaultValue": "", 466 | "name": "ClientKeystorePassword", 467 | "editorArgs": [], 468 | "editorType": "string" 469 | }, 470 | { 471 | "defaultValue": "", 472 | "name": "ClientPemFormatted", 473 | "editorArgs": [], 474 | "editorType": "boolean" 475 | }, 476 | { 477 | "defaultValue": "30", 478 | "name": "ConnectionTimeout", 479 | "editorArgs": [], 480 | "editorType": "non_negative_integer" 481 | }, 482 | { 483 | "defaultValue": "60", 484 | "name": "KeepAlive", 485 | "editorArgs": [], 486 | "editorType": "non_negative_integer" 487 | }, 488 | { 489 | "defaultValue": "10", 490 | "name": "MaxInflight", 491 | "editorArgs": [], 492 | "editorType": "non_negative_integer" 493 | }, 494 | { 495 | "defaultValue": "1883", 496 | "name": "Port", 497 | "editorArgs": [], 498 | "editorType": "non_negative_integer" 499 | }, 500 | { 501 | "defaultValue": "TCP", 502 | "name": "Protocol", 503 | "editorArgs": [ 504 | "TCP", 505 | "SSL", 506 | "TLS" 507 | ], 508 | "editorType": "choices" 509 | }, 510 | { 511 | "defaultValue": "-1", 512 | "name": "TimeToWait", 513 | "editorArgs": [], 514 | "editorType": "integer" 515 | }, 516 | { 517 | "defaultValue": "", 518 | "name": "TrustedCertFile", 519 | "editorArgs": [], 520 | "editorType": "asset" 521 | }, 522 | { 523 | "defaultValue": "", 524 | "name": "TruststoreFile", 525 | "editorArgs": [], 526 | "editorType": "asset" 527 | }, 528 | { 529 | "defaultValue": "", 530 | "name": "TruststorePassword", 531 | "editorArgs": [], 532 | "editorType": "text" 533 | }, 534 | { 535 | "defaultValue": "", 536 | "name": "UserName", 537 | "editorArgs": [], 538 | "editorType": "string" 539 | }, 540 | { 541 | "defaultValue": "", 542 | "name": "UserPassword", 543 | "editorArgs": [], 544 | "editorType": "string" 545 | } 546 | ], 547 | "events": [ 548 | { 549 | "deprecated": "false", 550 | "name": "ConnectionStateChanged", 551 | "description": "Connection state has changed.", 552 | "params": [ 553 | { 554 | "name": "NewState", 555 | "type": "number" 556 | }, 557 | { 558 | "name": "StateString", 559 | "type": "text" 560 | } 561 | ] 562 | }, 563 | { 564 | "deprecated": "false", 565 | "name": "ErrorOccurred", 566 | "description": "Error occurred.", 567 | "params": [ 568 | { 569 | "name": "ActionName", 570 | "type": "text" 571 | }, 572 | { 573 | "name": "ErrorCode", 574 | "type": "number" 575 | }, 576 | { 577 | "name": "ErrorMessage", 578 | "type": "text" 579 | } 580 | ] 581 | }, 582 | { 583 | "deprecated": "false", 584 | "name": "MessageReceived", 585 | "description": "Message received.", 586 | "params": [ 587 | { 588 | "name": "Topic", 589 | "type": "text" 590 | }, 591 | { 592 | "name": "Payload", 593 | "type": "text" 594 | }, 595 | { 596 | "name": "Message", 597 | "type": "text" 598 | }, 599 | { 600 | "name": "RetainFlag", 601 | "type": "boolean" 602 | }, 603 | { 604 | "name": "DupFlag", 605 | "type": "boolean" 606 | } 607 | ] 608 | }, 609 | { 610 | "deprecated": "false", 611 | "name": "PublishedByteArrayReceived", 612 | "description": "Message with byte array received.", 613 | "params": [ 614 | { 615 | "name": "Topic", 616 | "type": "text" 617 | }, 618 | { 619 | "name": "ByteArray", 620 | "type": "any" 621 | }, 622 | { 623 | "name": "RetainFlag", 624 | "type": "boolean" 625 | }, 626 | { 627 | "name": "DupFlag", 628 | "type": "boolean" 629 | } 630 | ] 631 | } 632 | ] 633 | }] -------------------------------------------------------------------------------- /mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/extension.properties: -------------------------------------------------------------------------------- 1 | type=external 2 | -------------------------------------------------------------------------------- /mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/files/AndroidRuntime.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/files/AndroidRuntime.jar -------------------------------------------------------------------------------- /mqtt_dashboard/assets/external_comps/de.ullisroboterseite.ursai2pahomqtt/files/component_build_infos.json: -------------------------------------------------------------------------------- 1 | [{"contentProviders":[],"metadata":[],"broadcastReceivers":[],"broadcastReceiver":[],"libraries":[],"services":[],"type":"de.ullisroboterseite.ursai2pahomqtt.UrsPahoMqttClient","androidMinSdk":["7"],"activityMetadata":[],"assets":[],"native":[],"permissions":["android.permission.INTERNET","android.permission.ACCESS_NETWORK_STATE"],"activities":[]}] -------------------------------------------------------------------------------- /mqtt_dashboard/assets/humidity_wather_16790.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard/assets/humidity_wather_16790.png -------------------------------------------------------------------------------- /mqtt_dashboard/assets/off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard/assets/off.png -------------------------------------------------------------------------------- /mqtt_dashboard/assets/on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard/assets/on.png -------------------------------------------------------------------------------- /mqtt_dashboard/assets/temperature_icon_175973.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HighVoltages/Mqtt-in-Android-app---mit-app-inventor/962bed0790450159092958540ee73256adffb7d7/mqtt_dashboard/assets/temperature_icon_175973.png -------------------------------------------------------------------------------- /mqtt_dashboard/src/appinventor/ai_emmiasim67/mqtt_dashboard/Screen1.bky: -------------------------------------------------------------------------------- 1 | dataButton1UrsPahoMqttClient1IsConnectedUrsPahoMqttClient1UrsPahoMqttClient1TRUEUrsPahoMqttClient1UrsPahoMqttClient1IsConnectedButton1TextDisconnectLabel5TextPress Disconnect to disconnect.UrsPahoMqttClient1Tempdata0Button1TextConnectLabel5TextPress Connect to Connect.Image1UrsPahoMqttClient1IsConnectedEQImage1Pictureoff.pngUrsPahoMqttClient1lightsONImage1Pictureon.pngLabel2TextONUrsPahoMqttClient1lightsOFFImage1Pictureoff.pngLabel2TextOFFNotifier1Not Connected to MQTT broker.UrsPahoMqttClient1EQTopicTempdataglobal dataSPLITMessage,Label3Textglobal data1°CLabel4Textglobal data2% -------------------------------------------------------------------------------- /mqtt_dashboard/src/appinventor/ai_emmiasim67/mqtt_dashboard/Screen1.scm: -------------------------------------------------------------------------------- 1 | #| 2 | $JSON 3 | {"authURL":["ai2.appinventor.mit.edu"],"YaVersion":"213","Source":"Form","Properties":{"$Name":"Screen1","$Type":"Form","$Version":"30","AppName":"mqtt_dashboard","Title":"Screen1","Uuid":"0","$Components":[{"$Name":"HorizontalArrangement1","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-1595314665","$Components":[{"$Name":"Label1","$Type":"Label","$Version":"5","BackgroundColor":"&HFFFFFFFF","FontSize":"20","Width":"-2","Text":"MQTT Dashboard","TextAlignment":"1","Uuid":"-636827044"}]},{"$Name":"VerticalArrangement1","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","AlignVertical":"2","BackgroundColor":"&HFFFFFFFF","Width":"-2","Uuid":"-202048395","$Components":[{"$Name":"HorizontalArrangement2","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","AlignVertical":"2","BackgroundColor":"&HFFFFFFFF","Width":"-2","Uuid":"1066387287","$Components":[{"$Name":"Image1","$Type":"Image","$Version":"6","Clickable":"True","Height":"50","Width":"50","Picture":"off.png","ScalePictureToFit":"True","Uuid":"710698234"},{"$Name":"Label2","$Type":"Label","$Version":"5","FontSize":"20","Text":"OFF","TextAlignment":"1","Uuid":"1144921090"}]},{"$Name":"HorizontalArrangement3","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","AlignVertical":"2","BackgroundColor":"&HFFFFFFFF","Width":"-2","Uuid":"-1218686152","$Components":[{"$Name":"Image2","$Type":"Image","$Version":"6","Clickable":"True","Height":"50","Width":"50","Picture":"temperature_icon_175973.png","ScalePictureToFit":"True","Uuid":"-1231561333"},{"$Name":"Label3","$Type":"Label","$Version":"5","FontSize":"20","Text":"...","TextAlignment":"1","Uuid":"2083819515"}]},{"$Name":"HorizontalArrangement4","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","AlignVertical":"2","BackgroundColor":"&HFFFFFFFF","Width":"-2","Uuid":"-1476904287","$Components":[{"$Name":"Image3","$Type":"Image","$Version":"6","Clickable":"True","Height":"50","Width":"50","Picture":"humidity_wather_16790.png","ScalePictureToFit":"True","Uuid":"-2024918385"},{"$Name":"Label4","$Type":"Label","$Version":"5","FontSize":"20","Text":"...","TextAlignment":"1","Uuid":"-12587841"}]},{"$Name":"HorizontalArrangement6","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","AlignVertical":"2","BackgroundColor":"&HFFFFFFFF","Width":"-2","Uuid":"-572261049","$Components":[{"$Name":"Button1","$Type":"Button","$Version":"7","FontSize":"20","Text":"Connect","Uuid":"2111880465"},{"$Name":"Label5","$Type":"Label","$Version":"5","FontSize":"18","Text":"Press Connect to connect.","TextAlignment":"1","Uuid":"-1539850788"}]}]},{"$Name":"HorizontalArrangement5","$Type":"HorizontalArrangement","$Version":"4","AlignVertical":"3","Width":"-2","Uuid":"1481222635","$Components":[{"$Name":"Image4","$Type":"Image","$Version":"6","Width":"-2","Picture":"Untitleddesign.png","ScalePictureToFit":"True","Uuid":"363448988"}]},{"$Name":"Notifier1","$Type":"Notifier","$Version":"6","Uuid":"-1336545786"},{"$Name":"UrsPahoMqttClient1","$Type":"UrsPahoMqttClient","$Version":"1","Broker":"iot.reyax.com","ClientID":"username0006","UserPassword":"dnKbAMzWFx\"","Uuid":"1624190364"}]}} 4 | |# -------------------------------------------------------------------------------- /mqtt_dashboard/youngandroidproject/project.properties: -------------------------------------------------------------------------------- 1 | # 2 | #Sat Dec 18 14:20:19 UTC 2021 3 | source=../src 4 | name=mqtt_dashboard 5 | defaultfilescope=App 6 | main=appinventor.ai_emmiasim67.mqtt_dashboard.Screen1 7 | color.accent=&HFFFF4081 8 | sizing=Responsive 9 | assets=../assets 10 | theme=Classic 11 | showlistsasjson=True 12 | useslocation=False 13 | aname=mqtt_dashboard 14 | actionbar=False 15 | color.primary=&HFF3F51B5 16 | build=../build 17 | versionname=1.0 18 | versioncode=1 19 | color.primary.dark=&HFF303F9F 20 | --------------------------------------------------------------------------------