This is the Android Remote Control for TheBox was on this repository with an attached relay. This allows us to remote turn on any electric device.
You can enter the IP-address of the local MQTT-Broker (e.g. Mosquitto), then hit Go! It automatically subscribes to all topics necessary by the actuators in "TheBox". It gives basic control functions to the following parts:
The general control scheme looks like this:
The code for the ESP32's in order to control the motors and LEDS can be found here.
ATTENTION: It is in an experimental stage!
Since the latest version of the Android APP, we fused the MQTT Broker and MQTT Client into one app. The steps are as follows:
- Allow installation from "Unknown Sources" following this link
- Start a Wifi Hotspot using Android with the following credentials:
- SSID: Blynk
- Password: 12345678
- Start the APP which can be downloaded here
- Start the Server by clicking the Start SERVER button
- Enter
0.0.0.0
as the IP in the IP-editor - Enter the Setup number (e.g. 4) in the settings
- Hit the GO button
- The app should show "Connected"
In order to let the ESP find the Server Automatically two things have to be kept in mind in the ESP32-code
- The SSID and password have to be set to Blynk and 12345678 respectively:
const char *ssid = "Blynk";
const char *password = "12345678";
- The Server-IP has to be the one of the "Gateway" which can ensured using this code in the setup_wifi():
void setup_wifi()
{
uc2wait(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Device-MAC: ");
Serial.println(WiFi.macAddress());
Serial.print("Connecting to ");
Serial.print(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
uc2wait(500);
Serial.print(".");
}
localIP = WiFi.localIP().toString();
gatewayIP = WiFi.gatewayIP().toString();
gatewayIP.toCharArray(MQTT_SERVER, BUFLEN);
Serial.println("");
Serial.print("WiFi connected with IP:");
Serial.println(localIP);
Serial.print("Default Gateway (MQTT-SERVER):\t");
Serial.println(MQTT_SERVER);
}
An example file which has been tested with the LED-Array can be found here.
The latest version of the signed APK of the app can be downloaded here
- Install the free App MQTT Broker App from the Play Store
- Install the UC2 controler APP using this link
- Setup the WiFi-Acces Point (AP) on your Android Phone (Sometimes called wifi-sharing or Hotspot) under Settings -> Tethering&mobile Hotspot -> WiFi Hotspot
- The settings should be the following:
- SSID: Blynk
- Password: 12345678
- Start the Hotspot
- Open the MQTT Broker App and hit start
- A message "mqtt>Broker URL - 0.0.0.0:1883" appears -> Great!
- Open the UC2 Controler APP and enter the IP-address as 0.0.0.0 and hit Go!
- A message which says Connected should appear
- All set!
- Close the app and restart it (really remove the panel from the task manager)
You can send the commands using 3rd party apps for debugging. The general topic-structure is:
-
/<S><INT3>/<DEV><INT2>/COMD
with S=Setup, DEV=Device, COMD=Command (delimited by "+" sign) and INT3=3 integers, INT2=2 integers. A COMD is built by a<COMMANDSEQUENCE>+<VAL1>+<VAL2>+...+<VALn>
. Here are some examples: -
Motor: Z-Stage:
/S013/MOT01/RECM DRVZ+-50
, -100..100 -
Motor: S-Stage:
/S013/MOT02/RECM DRVZ+-50
, -100..100 -
Fluo LED:
/S013/MOT01/RECM NA+10966
, 0..25600 -
LED-Array:
/S013/LAR01/RECM NA+1
, 0,1,2,3,4
The COMD STATS
or ANNO
are used for inter-device-communication and bug-fixing.