1

Topic: input

Hi I have a small project to open my garage door, this is up and running. Now I wish to add a reed switch to show on the APP whether the door is open or closed. When I added the switch, there was a field called "snap to pin" that allowed me to assign a pin to the relay module to open the gate.

I cannot find any such thing for the indication elements, I have worked my way through all of them, none can be allocated to a pin. Is this something that is possible or are these indication elements just for stuff happening on your phone, for example: showing which way your phone is pointing?

thanks

2

Re: input

I can just earth a pin with a limit switch if that is simpler / possible.

3

Re: input

You can do it in a sketch
https://remotexy.com/en/help/indications/led/

4

Re: input

thank you for the reply,

so I assume i add the LED with remoteXY, then edit the code in IDE to get it to do something?
does this need to be in its own function?
or does it go in the void loop()?
does anything extra need to be declared?

5

Re: input

cue340 wrote:

thank you for the reply,

so I assume i add the LED with remoteXY, then edit the code in IDE to get it to do something?
does this need to be in its own function?
or does it go in the void loop()?
does anything extra need to be declared?

The "snap to pin" feature of RemoteXY only applies to outputs of the RemoteXY application, such as a pushbutton or switch, and cannot be implemented for inputs to the RemoteXY application such as LEDs etc. You can directly use "snap to pin" for a RemoteXY pushbutton, for example, by delaring the controller output pin it chould be mapped to.

For a physical input to your mcu application, you are always going to have to map the input to the RemoteXY element that drives the visual display, it can't be mapped directly with "snap to pin".

In declaring a "snap to pin" number for a pushbutton or switch, it simply inserts the code to drive the controller output directly from the RemoteXY data state.

In your case, you want to drive an LED on the app screen from the state of a physical input to the controller, so you will have to include the code to do it, as explained in the sketch quoted in RemoteXY's answer https://remotexy.com/en/help/indications/led/.

I personally never use the "snap to pin" assignments in the RemoteXY build, because I can then do it in code, and change it, without having to rebuild the RemoteXY interface.  It's quite a cool feature for beginners, but I feel it puts "coding" in the wrong place.

2B, or not 2B, that is the pencil ...

6 (edited by cue340 2024-03-21 13:52:17)

Re: input

<quote>You can directly use "snap to pin" for a RemoteXY pushbutton, for example, by delaring the controller output pin it chould be mapped to.</quote>
Are you saying that the button I assigned to open the door can also change colour/text depending on an input i assign?

thank you for taking the time to respond and for all the info, ill see if i can get this working with some coding.

7

Re: input

the instructions say:
RemoteXY.led_1_r = 255;  // turn on red color

is the r in the code for red?
does this mean the name of the LED on the page is led_1 or led_1_    ?

8

Re: input

so no luck with the onscreen LED's, I was not able to get anything on the screen after a couple of hours.
So I tried text instead, surprisingly I was able to actually get something on the screen.

I have a limit switch connected to pins D7 and ground.

on booting up the nodeMCU I get "open" state, which is great, then I press the limit switch to simulate the gate being in the closed position, on the screen i get "closed" state, perfect!

but that is it, it wont change anymore, on releasing the switch it should go back to "open" state

i tried D6 too same results.

code:

/*
   -- gatekeeper --
   
   This source code of graphical user interface 
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 3.1.10 or later version 
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                   
     - for ANDROID 4.13.1 or later version;
     - for iOS 1.10.1 or later version;
    
   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.    
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG    

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>


// RemoteXY connection settings 
#define REMOTEXY_WIFI_SSID "iot"
#define REMOTEXY_WIFI_PASSWORD "sh6d0wh6t"
#define REMOTEXY_SERVER_PORT 6377


#include <RemoteXY.h>

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =   // 41 bytes
  { 255,1,0,11,0,34,0,17,0,0,0,230,1,126,200,1,1,2,0,1,
  51,37,24,24,9,8,31,103,97,116,101,0,67,42,91,40,10,5,93,24,
  11 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t button_01; // =1 if button pressed, else =0

    // output variables
  char text_01[11]; // string UTF8 end zero

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)
 
/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_BUTTON_01 D5


void setup() 
{
  RemoteXY_Init (); 
  
  pinMode (PIN_BUTTON_01, OUTPUT);
  
  // TODO you setup code
  
}

void loop() 
{ 
  RemoteXY_Handler ();
  
  digitalWrite(PIN_BUTTON_01, (RemoteXY.button_01==0)?LOW:HIGH);
  
  if (digitalRead(D7)==HIGH) strcpy (RemoteXY.text_01, "open");
  else strcpy (RemoteXY.text_01, "closed");


  // TODO you loop code
  // use the RemoteXY structure for data transfer
  // do not call delay(), use instead RemoteXY_delay() 


}

9

Re: input

cue340 wrote:

the instructions say:
RemoteXY.led_1_r = 255;  // turn on red color

is the r in the code for red?
does this mean the name of the LED on the page is led_1 or led_1_    ?

The fact that you have a variable from 0-255 called {something}_r means that you have an RGB LED on your page.

In the RemoteXY Include (copied form the online generator), you will also see that you have {something}_g, and {something}_b.

Those 3 values together define the colour of the RGB LED in terms of the RGB element brightnesses. In total that can produce 255*255*255 different colours - over 16 million of them !

Now if you only want a single LED, of one colour, replace the RGB LED on your layout with a single LED object, and configure the colour you want it to be when ON. The RemoteXY variable LED_1 will display the configured colour when 1, and OFF (background colour), when 0

2B, or not 2B, that is the pencil ...

10

Re: input

Quote:
you will also see that you have {something}_g, and {something}_b.

no, as i said I got the code from the indications LED page, all examples on the page are for the colour red, if there was one for green or blue it would have been self explanatory.

The page makes no distinction between the types of led's available at all. I added a normal led and was working with instructions for the rgb led, this was never going to work.

So I swapped to text, can anyone see why this only works once?
Do I need something in setup?
is it the pin I am using?
should I pull up rather than down?

11

Re: input

cue340 wrote:

on booting up the nodeMCU I get "open" state, which is great, then I press the limit switch to simulate the gate being in the closed position, on the screen i get "closed" state, perfect!

but that is it, it wont change anymore, on releasing the switch it should go back to "open" state

Possibly an electronic problem. If, when the switch is opened, the pin remains suspended, then there may be an undefined value at the input. You must pull the pin to positive or negative using a 1-10 kOhm resistor.

12

Re: input

Thank you everyone for your help, it is now working.

the code above is the code I am using

the wiring for the resistor is
3v to limit switch
other side of limit switch to input pin and also to the resistor (in my case D7)
other side of resistor to ground

13

Re: input

cue340 wrote:

Quote:
you will also see that you have {something}_g, and {something}_b.

no, as i said I got the code from the indications LED page, all examples on the page are for the colour red, if there was one for green or blue it would have been self explanatory.

The page makes no distinction between the types of led's available at all. I added a normal led and was working with instructions for the rgb led, this was never going to work.

Ok, so I can see what has occurred here, and yes, I agree, the examples should have made this clear.

For an RGB LED, there are 3 configurable (by check-boxes) components. You can enable 1 2, or 3 of those components for Red, Grn, and Blu.  In the example it is likely that the Grn and Blu components were NOT selected, so the code-builder only included the Red component variable for you to drive 0-255, and that would be the brightness of the red colour.

For a standard LED, you can have up to 8 "states" (9 if you count the OFF state), each state defining another, or the same, colour to be displayed for the LED.  So sending a value of 255 to a standard LED would not be a valid state number, so it does nothing.

2B, or not 2B, that is the pencil ...