I've been like two days looking for an android app which is wifi based and lets me read and write gpios, but not mqtt based as I don't have a raspberry.
Out of many, I've finally found this great app called Homotica which really stands out : https://github.com/davidevertuani/homotica and I've finally switched from cayenne (it keeps crashing).
There is one problem: the library has this one function called "homotica.attachCallback(myCallback);".
The description in /examples says " //if you need a callback when a pin state is changed, use attachCallback(myCallback) //myCallback must accept int arguments as the example below"
So technically, when one (specified) gpio changes state, a function is called and the code does something.
What happens instead, is that ANY gpio that changes state triggers the function.
This is what the library looks like, maybe you can help me (i've contacted the creator already- but no luck)
/*
Created by Davide Vertuani, April 28, 2018.
Released into the public domain.
Version 2.1
READ HERE! -------------------------------------
To ensure compatibility with th ESP8266,
BEFORE compiling open \libraries\Homotica\Homotica.h
and make sure the line
#define ESP
is NOT commented out.
If you're using an ethernet shield which needs
EthernetUDP and SPI, be sure that
#define ESP
IS commented out.
Then compile, you're good to go!
READ HERE! -------------------------------------
*/
#include <Homotica.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
//MODIFY THESE PARAMETERS
const char* ssid = "yourssid"; //your wifi ssid
const char* password = "yourpassword"; //your wifi password
IPAddress ip(192, 168, 1, 20); //your arduino IP
IPAddress gateway(192, 168, 1, 1); //your network gateway
IPAddress subnet(255, 255, 255, 0); //your network subnet mask
unsigned int mUdpPort = 5858; //modify here your arduino port
static String code = "xxxxxxxx"; //modify here your 8-digits auth code
Homotica homotica;
void setup() {
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
homotica.addUsedPinOutput(D1);
homotica.addUsedPinOutput(D2);
//for each pin you'se using as output (i.e. to control devices),
//call addUsedPinOutput(pin) on it, so that homotica knows it's being used
//and can configure it high or low depending on your configuration
//ALWAYS call homotica.addUsedPinOutput(pin) BEFORE calling homotica.set(port, code)
homotica.addUsedPinInput(D3);
homotica.addUsedPinInput(A0);
//for each pin you'se using as input (i.e. to read pin state),
//call addUsedPinInput(pin) on it, so that homotica knows it's being used
//and can configure it as input
//ALWAYS call homotica.addUsedPinInput(pin) BEFORE calling homotica.set(port, code)
homotica.attachInputFunction(myCustomInputFunction, 'M');
//if you need to precess some data before feeding it to the homotica app
//(like if you're reading a sensor via I2C) attach an Input Function and
//identify it with a char (now available: )
//in the app select "Custom channel", will call the fuction instead of radind
//directly from the GPIO
homotica.setActiveLow();
//delete the line if you're using active_high setup
//ALWAYS call homotica.setActiveLow() BEFORE calling homotica.set(port, code)
homotica.set(mUdpPort, code);
//homotica.set(mUdpPort, code) sets up the udp connection, MUST be called in setup()
//if you need to turn on/off your devices without worring about HIGH and LOW
//in Active High or low application, use the following fuctions
homotica.push(D1, 1000);
//pushes pin D1 for 1000 milliseconds
//i.e. turns it on, waits 1 second, then turns it off
homotica.turnOn(D2);
//turns on pin D2
homotica.turnOff(D2);
//turns off pin D2
homotica.toggle(D2);
//toggles pin D2 i.e. changes it state
homotica.attachCallback(myCallback);
//if you need a callback when a pin state is changed, use attachCallback(myCallback)
//myCallback must accept int arguments as the example below
}
void loop() {
homotica.refresh();
}
void myCallback(int usedPin){
//do stuff
}
int16_t myCustomInputFunction(){
//read sensors or do stuff
int16_t returnValue = 1234;
return returnValue;
//if an error has occurred - like the sensor didn't respond - you could
//refuse to return a valid value; in this case use:
//return homotica.SENSOR_ERROR;
//which will generate a negative response to the app.
//NOTE: the method does not accept negative values
}