Нужна помощь help with nodemcu32s

spiderus2014

New member
hi guys
i'm working on a project to control leds with remotexy by millis function
the problem is that when i upload the code to nodemcu, my phone can't find it's wifi network
i'll attach my project
tanks a lot.
 

Вложения

tretyakov_sa

Moderator
Команда форума
Your code is written to connect ESP in the mode of connecting to a router.
The esp32 module does not create its own access point.
 

spiderus2014

New member
[QUOTE = "tretyakov_sa, post: 67180, member: 1240"] Your code is written to connect ESP in the mode of connecting to a router.
The esp32 module does not create its own access point. [/ QUOTE]

it's working very well, but without some lines that i add
i don't know if it's right.

Код:
 // RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP32CORE_WIFI_POINT
#include <WiFi.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377


// RemoteXY configurate 
#pragma pack (push, 1)
uint8_t RemoteXY_CONF [] =
  {255,7,0,27,0,172,1,8,24,5,
  130,1,21,71,21,29,2,0,130,1,
  3,21,21,79,2,0,130,1,39,21,
  21.79,2,0,130,1,0,0,63,7,
  0,0,131,1,52,1,10,5,1,2,
  31,216,167,217,132,216,168,216,175,216,
  167,217,138,216,169,0,130,1,1,1,
  50,5,0,16,131,0,32,1,9,5,
  2,2,31,49,0,131,0,22,1,9,
  5,3,2,31,50,0,131,0,12,1,
  9,5,4,2,31,51,0,131,0,2,
  1,9,5,5,2,31,52,0,129,0,
  42,2,8,3,0,24,216,167,217,132,
  216,170,217,133,216,167,216,177,217,138,
  217,134,0,130,1,0,7,63,14,2,
  0,2,0,1,8,11,5,2,2,26,
  31,31,79,78,0,79,70,70,0,2,
  0,13,8,11,5,2,2,2,26,31,31,
  79,78,0,79,70,70,0,2,0,25,
  8,11,5,2,2,26,31,31,79,78,
  0.79,70,70,0,2,0,37,8,11,
  5,2,2,26,31,31,79,78,0,79,
  70,70,0,65,4,3,13,7,7,2,
  129,0,5,14,3,6,2,17,52,0,
  65,4,39,13,7,7,2,65,4,27,
  13,7,7,2,65,4,15,13,7,7,
  2,129,0,17,14,3,6,2,17,51,
  0,129,0,29,14,3,6,2,17,50,
  0,129,0,41,14,3,6,2,17,49,
  0,129,0,49,13,10,4,2,24,216,
  167,217,132,216,163,217,135,216,175,216,
  167,217,129,0,2,1,25,74,13,14,
  2,2,26,31,31,79,78,0,79,70,
  70,0,4,0,9,27,9,65,2,2,
  26,67,5,6,22,15,5,2,2,26,
  11.67.5,42,22,15,5,2,2,26,
  11,4,0,45,27,9,65,2,2,26,
  129,0,41,94,16,4,2,31,216,178,
  217,133,217,134,32,216,167,217,132,216,
  170,216,180,216,186,217,138,217,132,0,
  129,0,5,94,16,4,2,31,216,178,
  217,133,217,134,32,216,167,217,132,216,
  170,217,136,217,130,217,129,0,65,2,
  27.89,9,9,2};
 
// this structure defines all the variables of your control interface
struct {

    // input variable
  uint8_t sw1_4; // = 1 if switch ON and = 0 if OFF
  uint8_t sw1_3; // = 1 if switch ON and = 0 if OFF
  uint8_t sw1_2; // = 1 if switch ON and = 0 if OFF
  uint8_t sw1_1; // = 1 if switch ON and = 0 if OFF
  uint8_t switch_1; // = 1 if switch ON and = 0 if OFF
  int8_t s1_2; // = 0..100 slider position
  int8_t s1_1; // = 0..100 slider position

    // output variable
  uint8_t l1_4_r; // = 0..255 LED Red brightness
  uint8_t l1_1_r; // = 0..255 LED Red brightness
  uint8_t l1_2_r; // = 0..255 LED Red brightness
  uint8_t l1_3_r; // = 0..255 LED Red brightness
  char t1_2 [11]; // string UTF8 end zero
  char t1_1 [11]; // string UTF8 end zero
  uint8_t led_1_g; // = 0..255 LED Green brightness

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

} RemoteXY;
#pragma pack (pop)

/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
float OnTime = 0;                                                                                     // i add this line
float OffTime = 0;                                                                                     // i add this line
int ledPin1 = 6;                                                                                          // i add this line
int ledPin2 = 7;                                                                                          // i add this line
int ledState1 = LOW;                                                                                // i add this line
int ledState2 = LOW;                                                                                // i add this line
unsigned long previousMillis2 = 0;                                                       // i add this line
unsigned long previousMillis1 = 0;                                                       // i add this line


   unsigned long currentMillis = millis ();                                            // i add this line

void setup ()
{
  RemoteXY_Init ();
  pinMode (6, OUTPUT);
    pinMode (7, OUTPUT);

 
  // TODO you setup code
 
}

void loop ()
{
  RemoteXY_Handler ();

   OnTime = map (RemoteXY. S1_1, 0, 100, 0, 5000);                       // i add this line
  float v1_1n = OnTime / 1000; // i add this line
  dtostrf (v1_1n, 0, 1, RemoteXY.t1_1);                                                  // i add this line

  OffTime = map (RemoteXY. S1_2, 0, 100, 0, 5000);                        // i add this line
  float v1_2n = OffTime / 1000;                                                                // i add this line
  dtostrf (v1_2n, 0, 1, RemoteXY.t1_2);                                                   // i add this line

    if (RemoteXY.switch_1 == 1) {                                                               // i add this line

   if ((ledState1 == HIGH) && (currentMillis - previousMillis1> = OnTime)) {ledState1 = LOW; previousMillis1 = currentMillis; digitalWrite (ledPin1, ledState1);}                 // i add this line
  else if ((ledState1 == LOW) && (currentMillis - previousMillis1> = OffTime)) {ledState1 = HIGH; previousMillis1 = currentMillis; digitalWrite (ledPin1, ledState1);}                   // i add this line
 
  if ((ledState2 == HIGH) && (currentMillis - previousMillis2> = OnTime)) {ledState2 = LOW; previousMillis2 = currentMillis; digitalWrite (ledPin2, ledState2);}                                       // i add this line
  else if ((ledState2 == LOW) && (currentMillis - previousMillis2> = OffTime)) {ledState2 = HIGH; previousMillis2 = currentMillis; digitalWrite (ledPin2, ledState2);}           // i add this line
   ; } // i add this line
   else {digitalWrite (6,0); digitalWrite (7,0);}                  // i add this line
  // TODO you loop code
  // use the RemoteXY structure for data transfer


} [/ code]
 

spiderus2014

New member
i found a class on the internet which can help me, but i don't know how make it work with remotexy app,cause i past it into my sketch and upload it, but the wifi disappear.
is there any way to make it work like add it to remotexy library ?
the class is :
Код:
class Flasher
{
    // Class Member Variables
    // These are initialized at startup
    int ledPin;      // the number of the LED pin
    long OnTime;     // milliseconds of on-time
    long OffTime;    // milliseconds of off-time

    // These maintain the current state
    int ledState;                     // ledState used to set the LED
    unsigned long previousMillis;      // will store last time LED was updated

  // Constructor - creates a Flasher
  // and initializes the member variables and state
  public:
  Flasher(int pin, long on, long off)
  {
    ledPin = pin;
    pinMode(ledPin, OUTPUT);    
     
    OnTime = on;
    OffTime = off;
   
    ledState = LOW;
    previousMillis = 0;
  }

  void Update()
  {
    // check to see if it's time to change the state of the LED
    unsigned long currentMillis = millis();
    
    if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
    {
        ledState = LOW;  // Turn it off
      previousMillis = currentMillis;  // Remember the time
      digitalWrite(ledPin, ledState);  // Update the actual LED
    }
    else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
    {
      ledState = HIGH;  // turn it on
      previousMillis = currentMillis;   // Remember the time
      digitalWrite(ledPin, ledState);      // Update the actual LED
    }
  }
};


Flasher led1(12, 100, 400);
Flasher led2(13, 350, 350);

void setup()
{
}

void loop()
{
    led1.Update();
    led2.Update();
}
 

spiderus2014

New member
Have you already found the answer to your first question?

What do you want to get as a result?
thank you so much for your replay, unfortunately i don't.
maybe it's my fault.
all i need from the project is to control leds time by using millis(), not delay().
i tried to use this class,
Код:
class Flasher
{
    // Class Member Variables
    // These are initialized at startup
    int ledPin;      // the number of the LED pin
    long OnTime;     // milliseconds of on-time
    long OffTime;    // milliseconds of off-time

    // These maintain the current state
    int ledState;                     // ledState used to set the LED
    unsigned long previousMillis;      // will store last time LED was updated

  // Constructor - creates a Flasher
  // and initializes the member variables and state
  public:
  Flasher(int pin, long on, long off)
  {
    ledPin = pin;
    pinMode(ledPin, OUTPUT);    
     
    OnTime = on;
    OffTime = off;
   
    ledState = LOW;
    previousMillis = 0;
  }

  void Update()
  {
    // check to see if it's time to change the state of the LED
    unsigned long currentMillis = millis();
    
    if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
    {
        ledState = LOW;  // Turn it off
      previousMillis = currentMillis;  // Remember the time
      digitalWrite(ledPin, ledState);  // Update the actual LED
    }
    else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
    {
      ledState = HIGH;  // turn it on
      previousMillis = currentMillis;   // Remember the time
      digitalWrite(ledPin, ledState);      // Update the actual LED
    }
  }
};


Flasher led1(12, 100, 400);
Flasher led2(13, 350, 350);

void setup()
{
}

void loop()
{
    led1.Update();
    led2.Update();
}
but it doesn't work
and i tried to put a code in my sketch
the code is
Код:
// These variables store the flash pattern
// and the current state of the LED

int ledPin1 =  12;      // the number of the LED pin
int ledState1 = LOW;             // ledState used to set the LED
unsigned long previousMillis1 = 0;        // will store last time LED was updated
long OnTime1 = 250;           // milliseconds of on-time
long OffTime1 = 750;          // milliseconds of off-time

int ledPin2 =  13;      // the number of the LED pin
int ledState2 = LOW;             // ledState used to set the LED
unsigned long previousMillis2 = 0;        // will store last time LED was updated
long OnTime2 = 330;           // milliseconds of on-time
long OffTime2 = 400;          // milliseconds of off-time

void setup()
{
  // set the digital pin as output:
  pinMode(ledPin1, OUTPUT);     
  pinMode(ledPin2, OUTPUT);     
}

void loop()
{
  // check to see if it's time to change the state of the LED
  unsigned long currentMillis = millis();
  if((ledState1 == HIGH) && (currentMillis - previousMillis1 >= OnTime1))
  {
    ledState1 = LOW;  // Turn it off
    previousMillis1 = currentMillis;  // Remember the time
    digitalWrite(ledPin1, ledState1);  // Update the actual LED
  }
  else if ((ledState1 == LOW) && (currentMillis - previousMillis1 >= OffTime1))
  {
    ledState1 = HIGH;  // turn it on
    previousMillis1 = currentMillis;   // Remember the time
    digitalWrite(ledPin1, ledState1);      // Update the actual LED
  }
 
  if((ledState2 == HIGH) && (currentMillis - previousMillis2 >= OnTime2))
  {
    ledState2 = LOW;  // Turn it off
    previousMillis2 = currentMillis;  // Remember the time
    digitalWrite(ledPin2, ledState2);  // Update the actual LED
  }
  else if ((ledState2 == LOW) && (currentMillis - previousMillis2 >= OffTime2))
  {
    ledState2 = HIGH;  // turn it on
    previousMillis2 = currentMillis;   // Remember the time
    digitalWrite(ledPin2, ledState2);      // Update the actual LED
  }
}
all these codes from this link
More Blink Without Delay | Chambo

thanks again for your help.
 
Сверху Снизу