I can no longer control the LED from my PC or laptop.

Hello,

I am writing a program to control an LED using the Lolin(wemos) d1 mini board and Arduino IDE, and testing it by turning it on and off with my smartphone(blynk IoT). Until recently, I was able to control the LED on or off from my PC or laptop, but for some reason, I can no longer control the LED from my PC or laptop. However, the LED is still working well with my smartphone.
My PC and laptop are using windows10.

What could be the reason for this malfunction?

What types of datastreams (digital, virtual) are these widgets connected to?

Does rebooting your device make any difference?

Is there any possibility that you have two hardware devices that are using the same auth token?

Pete.

Dear Sir,
I am using digital types for datastreams.
I have same result after rebooting.
I have several wemos modules but only one device on testing.

I am a teacher in South Korea.
Last semester, I successfully taught my students with the same parts and the same program.
But since last July, I can’t control it on my PC or laptop.
I have tested with several wemos modules before the class and they all give the same result.
So I thought that the ability to control it from a PC was gone.
Again, I can use the LEDs on the wemos module with the smartphone app without any problems.
What could be the problem?

Are you sure that you’re signed in to the same Blynk account on both your mobile and desktop devices?

Pete.

Of course, I’m using the same account.
However, while testing again today, I noticed something very unusual. I was able to turn off the LED on the Wemos module from my PC.
However, to turn on the LED, I had to use my smartphone. I can’t turn it on from the PC, but I can turn it off.
And every time I turned the “BlueLed” button on/off on the PC, the button would move a little bit to the left, but then return to its original position. At the same time, I can see that the LED on the wemos flashes every time I move the button on the PC. That means it’s responding.
However, even though I can turn it on/off on my smartphone, I can only turn it off on my PC.
Why is this behavior?
I set the BlueLed of wemos to digital type.

Thank you for reading
111

I’d suggest you post your sketch, and the datastream detail for the BlueLed datastream.

Pete.

Dear Pete

My sketch is below

[Unformatted code removed by moderator]

/***************************************************************************
  =======================================================================
  .......................................................................
  H/W
  -----------------------------------------------------------------------
   - 2022/8/8
   D1 : GPIO5 --> RED LED
   D4 : GPIO2 --> BLUE LED
  -----------------------------------------------------------------------
*/

#define BLYNK_FIRMWARE_VERSION "0.1.1"////////////////////////////////////////////
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings

#define BLYNK_TEMPLATE_ID "**********"
#define BLYNK_TEMPLATE_NAME "*************"
#define BLYNK_AUTH_TOKEN "*************************"

#define PIR_SEN D0 // for mom PIR sensor
#define BLYNK_PRINT Serial // BlynkDebug.h 파일에서 serial포트로 블링크 로고가 출력됨
#include <ESP8266WiFi.h>   // ESP8266 Core WiFi Library, wemos모듈 등록이 안되었다면 Go to www.wemos.cc
#include <BlynkSimpleEsp8266.h> // 블링크 라이브러리를 설치하세요--> 스케치-->라이브러리 매니저-->"blynk"입력,,,, 참조 :  www.blynk.io

#include <ESP8266WebServer.h> //Local WebServer used to serve the configuration portal
#include <WiFiManager.h> //스케치-->라이브러리 매니저-->"WiFiManager"입력(설치는 최신것으로할것),,,참조 -> https://github.com/tzapu/WiFiManager,내컴터저장위치-->C:\Users\mac\Documents\Arduino\libraries\WiFiManager

SimpleTimer mbktimer; //---> BlynkTimer mbktimer; 로 대체해도 됨, BlynkTimer.h를 참조하세요

int OldState = LOW; // PIR_SEN의 초기값 
WidgetLED led(V0); // for led.on() & led.off()

char auth[] = BLYNK_AUTH_TOKEN;

void setup()
{
  // Debug console
  Serial.begin(115200); // 1초 당 115200비트의 전송 속도로 시리얼 모니터로 출력 됨.
  Serial.println("");//for new line
  Serial.println("221207_Korea.kr_CareSystem");
  WiFiManager MBK_wifiManager; // Initialize library
  MBK_wifiManager.autoConnect("AutoConnectAP");

  pinMode(PIR_SEN, INPUT); // PIR_SEN센서를 입력으로 설정 
  pinMode(LED_BUILTIN, OUTPUT); // LED_BUILTIN is D4. D4는 파란색 LED
  pinMode(D1, OUTPUT); // D1 is for RED-LED
  digitalWrite(D4, 1); // 파란색 LED off
    
  Blynk.config(auth);
  mbktimer.setInterval(3000L, MovingCheck); // 3초마다 Call  
}

void loop()
{
  Blynk.run();
  mbktimer.run();
}

void MovingCheck()
{
  int state = digitalRead(PIR_SEN); //PIR은 인체를 감지하면 3.3볼트가 출력됨
  if (state == LOW) led.off();//사람이 없으면 블링크화면에 있는 Moving LED가 off 
  else led.on(); //사람이 감지되면 Moving LED가 on
  if (state == HIGH && OldState == LOW) //사람이 없었다가 나타나면 "Moving OK"
  {
    digitalWrite(D4, 0); // 파란색 LED on
    Blynk.logEvent("moved", "Moving OK");
    delay(1000);
    digitalWrite(D4, 1); // 파란색 LED off
  }
  OldState = state;
} 

@minbkwan Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

I didn’t ask you to re-post the code with triple backticks, I asked you to edit your previous post to add them.

I guess your issue is connected to this problem, maybe you should join in this conversation…

There’s quite a lot of bad practice in your sketch, it would be nice if you taught your students to write better code.

Pete.

This source code is in its early stages and in the next step I will introduce better code to students like interrupt code(attachInterrupt).
The current problem used to work well in the past, so I’ll study it a little more.
Thank you for helping me.

Thanks a lot Mr.Pete

But before you do that you should remove the blocking delays, use GPIO numbers exclusively rather than “D” designations, use log.event more sensibly, stop using legacy WidgetLED, use BlynkTimer rather than SimpleTimer, and use virtual datastreams rather than digital.

Pete.

The reason why D1 and D4 are used is because they use the wemos module, which tells students that D4 is the same as GPIO2. I think it is more educational to do so.
SimpleTimer is also more helpful to students when compared to BlynkTimer.
Anyway, thank you again for your help

It’s better to use GPIO numbers throughout, and adding comments regarding which NodeMCU pins these map to for a number of reasons.

  • The code is easier to port to different hardware
  • It’s far easier to spot pin conflicts if all pin references use the same naming conventions - GPIOs or “D” references
  • If you’re going to use Blynk digital datastreams (which I don’t recommend) then these use GPIOs rather than “D” numbers.

If a professional developer used “D” numbers over GPIOs then they wouldn’t last very long in a business environment. In my opinion you should teach your students to use best practice.

Pete.

I agree with you about the compatibility of the code.
However, I think it’s important to present that process to students and gradually introduce them to good examples of better code.
Thanks for your advice, as always.