BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

WEMOS connection to laptop vs only power


#1

Hi all,

I have a question regarding my WEMOS D1 connection to the blynk server to run the app. So far, it is able to work as long as it is connected to my laptop. However, I want to run it without wires so basically:

Flash the code on the arduino IDE for the WEMOS D1 to run the BLYNK app,
unplug the connection from the computer and then connect it to a power source.

But when I do this, I lose all connection to the blynk app. I thought that the WEMOS D1 supports wifi connection and it should work without a connection to my laptop. Does anyone know why this isn’t working?


#2

Sooo many possibilities here… First and foremost would be… how are you powering it away for the laptop?

Details please…

  • Via USB socket - AC adapter or battery bank

  • Via pins - 5v pin or 3.3v pin

  • Tesla’s (the person not the car) wireless power transmission

  • Happy thoughts… :stuck_out_tongue:


#3

Secondly… define “connection to my laptop”… With any ESP based device, the laptop or PCs only purpose is to supply programming and power via the USB socket. Any properly configured Blynk sketch you install should use WiFi for the server connection… regardless of other physical connections.

Perhaps show us the sketch you used

Please paste then format it as per the directions…

Blynk - FTFC


#4

I’m using an AC adapter


#5

… with a USB plug? 5V? I use some (both 5v and 3.3v) for various direct pin use myself.

It will need to be a quality 1A supply… might get away with a quality 700mA


#6

I excluded the token and wifi credentials on purpose, but when I upload the code it is actually there.

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <BH1750.h>  // https://github.com/claws/BH1750
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN D6

#define ON_PIN D5

#define ultraEntered D0
#define nightOrDay_Pin D3

int ON_or_OFF_ultra;
int ON_or_OFF_app;
int man_auto = 0;
int Entered = 0; 
int nightOrDay = 0;
int manual_auto_switch = 1;
int blynk_notify = 0;

int lux[]={0,0,0}; // Get lux value 


int LED_Brightness = 127;


double sum = 0; 
double avg = 0; 
int sampsetting = 0; 
int setting = 0; 
int brightReturn = 0;
int sumLight = 0; 



Adafruit_NeoPixel strip = Adafruit_NeoPixel(64, PIN, NEO_RGBW + NEO_KHZ800);

BH1750 lightMeter;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

BlynkTimer timer;

int red, green, blue, brightness; 

BLYNK_WRITE(V0){  
  red = param.asInt(); 
}

BLYNK_WRITE(V1){ 

  green = param.asInt(); 

}

BLYNK_WRITE(V2){ 
  blue = param.asInt(); 
}

BLYNK_WRITE(V3){ 
  brightness = param.asInt(); 
}

BLYNK_WRITE(V4){ 
  man_auto = param.asInt();
}

BLYNK_WRITE(V6){
  ON_or_OFF_app = param.asInt(); 
  
}

BLYNK_WRITE(V7){
    setting = param.asInt();
}

void sendUptime()
{

   uint16_t lux = lightMeter.readLightLevel();
  // Serial.println(lux);
   Blynk.virtualWrite(5, lux);
  
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
   //Read the Temp and Humidity from DHT

}



//---------------------------------------------------------------------------------------------------Brightness Code-----------------------------------------------------------------

double Average(){
  int i;  
  sumLight=0;
  avg=0;
  for(i=0; i<3; i++){
    lux[i] = lightMeter.readLightLevel(); 
    sumLight+=lux[i]; 
    delay(200);
  }

  avg=sumLight/3; 
  return avg; 
}

int Samplevel(double average){
  if(avg<=0){
    sampsetting = 0;  
  }

  else if (avg>1){

    if (avg<=200){
      sampsetting = 1; 
    }

    else if (avg>=201 && avg <= 400){
      sampsetting = 2; 
    }

    else if (avg>=401 && avg<=600){
      sampsetting = 3;   
    }

    else if (avg>=601 && avg<=800){
      sampsetting = 4;
    }

    else if (avg>=801 && avg<=1000){
      sampsetting = 5; 
    }

    else { 
      sampsetting = 6; 
    }

    
  }

  Serial.print("Sample Setting: ");
  Serial.println(sampsetting);
  return sampsetting; 
}

void BrightnessAdjust(){

  int difference = 0;  
  avg = Average(); 
  Serial.print("Average: ");
  Serial.println(avg);
  sampsetting = Samplevel(avg); 
  difference = setting - sampsetting; 
  if(difference == 0){
    //do nothing 
  }

  else if (difference<0){
    if (difference == -1){
      LED_Brightness = 106; 
    }

    else if(difference == -2){
      LED_Brightness = 85;  
    }
    else if(difference == -3){
      LED_Brightness = 64;  
    }
    else if(difference == -4){
      LED_Brightness = 43;  
    }
    else if(difference == -5){
      LED_Brightness = 22;  
    }
    else if(difference == -6){
      LED_Brightness = 1;  
    }
    else{
    }
  }

  else if (difference>0){
    if (difference == 1){
      LED_Brightness = 148; 
    }
    else if(difference == 2){
      LED_Brightness = 169;  
    }
    else if(difference == 3){
      LED_Brightness = 190;   
    }
    else if(difference == 4){
      LED_Brightness = 212; 
    }
    else if(difference == 5){
      LED_Brightness = 233;  
    }
    else if(difference == 6){
      LED_Brightness = 255;  
    }
    else{
    }
  }
}



//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




void setup()
{
  Serial.begin(115200); // See the connection status in Serial Monitor
   Blynk.begin(auth, ssid, pass); //insert here your SSID and password
   Wire.begin();

  lightMeter.begin();
 
  // Setup a function to be called every second
  timer.setInterval(1000L, sendUptime);
  #if defined (__AVR_ATtiny85__)  //Array
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif

    strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop()
{

  Blynk.run();
  timer.run();

   ON_or_OFF_ultra=digitalRead(ON_PIN);
   Entered = digitalRead(ultraEntered);
   nightOrDay = digitalRead(nightOrDay_Pin);

   if (Entered == HIGH ){ 
      Serial.println("Entered the room");
      if (blynk_notify == 0){
      Blynk.notify("Someone has entered your room or house");
      blynk_notify = 1;
      }
        if (man_auto == LOW){
          BrightnessAdjust();
          strip.setBrightness(LED_Brightness);
          strip.show();
            if (nightOrDay == HIGH){
              for(int i =0; i<64; i++){
                strip.setPixelColor(i,0,0,255);
                strip.show();
              }
            }
      
            else if (nightOrDay == LOW){
               for(int i = 0; i<64; i++){
                strip.setPixelColor(i,186,255,0);
                strip.show();
               }
            }
        }

        else if (man_auto == HIGH){
          if(ON_or_OFF_app == HIGH){
              Serial.print("ON or OFF : "); 
              Serial.println(ON_or_OFF_app);
            for(int i=0; i<64; i++){
              strip.setPixelColor(i,green,red,blue);
              strip.show();   
            }
              strip.setBrightness(brightness);
              strip.show();
          }

          else if (ON_or_OFF_app == LOW){
              Serial.print("ON or OFF : "); 
              Serial.println(ON_or_OFF_app);
            for(int i = 0; i<64; i++){ 
              strip.setPixelColor(i,0,0,0);
              strip.show();
            }
          }
        }
   }

   else{ 
        blynk_notify = 0;

        for(int i =0; i<64; i++){ 
            strip.setPixelColor(i,0,0,0);
            strip.show();
        }
   
   }
}
   
     


#7

Yes, I am connecting it with a USB plug and an AC adapter that is rated for 5.1 V and 2.1 A.


#8

Not enough… Since you are running NeoPixels, power is the primary suspect… as the LEDs draw fluctuating current (up to 60mA per pixel at full "white’), thus 64 LEDs * 60mA = 3840mA (3.8 A)

The Wemos will be browning out and disconnecting long before you even fully run the strip.

Also (just in case) never power the LEDs from the Wemos power pins…

You may need seperate power sources for the Wemos and the LEDs, but shared grounding, and a much bigger power supply, and possibly smoothing capacitors on the LED power rail.

Google for all that, as none of it is Blynk specific.