Feedback switches

Post Reply
FakeApp
Posts: 2
Joined: Sat Aug 13, 2022 7:33 pm

Need help!
I have 20 lighting points that are controlled by the arduino, I can trigger the points by the SUPLA app or by switch.
What I'm not getting is to make the application receive the information if the point was turned on or off through the switch.

How can I send this information to the server? I used virtualrelay in programming.
User avatar
pzygmunt
Posts: 18282
Joined: Tue Jan 19, 2016 9:26 am
Location: Paczków
Contact:

Insert your code here.
FakeApp
Posts: 2
Joined: Sat Aug 13, 2022 7:33 pm

Currently I use the Blynk server with the following code:

Code: Select all

if (digitalRead(bot1Pin) != button1) {               // Verifica se o botPin foi pressionado
  int state1 = digitalRead(saida1Pin);            // Armazena em state o estado do ledPin
  digitalWrite(saida1Pin, !state1);               // Modifica o estado da porta ledPin
  Blynk.virtualWrite (V1, state1);
  
  
  button1 = digitalRead(bot1Pin); 
  }
  
  if (digitalRead(bot2Pin) != button2) {               // Verifica se o botPin foi pressionado
  int state2 = digitalRead(saida2Pin);            // Armazena em state o estado do ledPin
  digitalWrite(saida2Pin, !state2);               // Modifica o estado da porta ledPin
  Blynk.virtualWrite (V2, state2);
  
  button2 = digitalRead(bot2Pin); 
  }
User avatar
klew
Posts: 8184
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław

The easiest way to do it on Supla is to create Relay classes on proper gpios and then Button classes on buttons (or you can use SimpleButton class instead, which has much lower memory usage, but also don't support more advanced features like multiclick detection).
If you'll encounter any problem with this setup, try to reduce application to i.e. 2 relays + 2 buttons and check if it works. Once you'll get working solution, increase amount of channels. This way it will be easier to catch if problem is releated to memory or something else.

Here is one example with Relay and SequenceButton:
https://github.com/SUPLA/supla-device/b ... Button.ino

You can replace SequenceButton with SimpleButton and remove lines 60-70.
Then you can link button with relay with:

Code: Select all

button->addAction(Supla::TOGGLE, relay1, Supla::ON_PRESS);
Widzimy się na Supla Offline Party vol. 2 :!:
Post Reply

Return to “Help”