0

My led is not blinking, I have no idea why it's not working. I am running it on "generic esp8266 module" plate.

 /*Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

My scheme Scheme

Wifi module is working fine, but led is not working at all. enter image description here

Another sketch

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <Servo.h>
// Initialize Wifi connection to the router
char ssid[] = "---";     // your network SSID (name)
char password[] = "---"; // your network key
int tempsensorPin = 0;
int lightsensorPin = 1;
bool searchState = false;
bool starting = false;
bool lightState = false;
Servo servo_test;  
// Initialize Telegram BOT
#define BOTtoken "----"  // your Bot Token (Get from Botfather)

WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

int Bot_mtbs = 1000; //mean time between scan messages
long Bot_lasttime;   //last time messages' scan has been done

void setup() {
  //servo_test.attach(8); 
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  pinMode(13, OUTPUT);
}

void loop() {
 digitalWrite(13,lightState);
  if (millis() > Bot_lasttime + Bot_mtbs)  {
    int numNewMessages = bot.getUpdates(bot.last_message_received + 1);

    while(numNewMessages) {
      Serial.println("got response");
      for (int i=0; i<numNewMessages; i++) {
        String id = bot.messages[i].chat_id;
        String text = bot.messages[i].text;

       //bot.sendMessage(bot.messages[i].chat_id, bot.messages[i].text, "");
        if(searchState){
          searchState=false;
          bot.sendMessage(bot.messages[i].chat_id, "http://lmgtfy.com/?q="+text, "");
        }else{
          bot.sendMessage(bot.messages[i].chat_id, answerMe(text), "");  
        }
      }
      numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    }

    Bot_lasttime = millis();
  }
}
String answerMe(String request){
 int tempSensor = analogRead(tempsensorPin);
 int lightSensor = analogRead(lightsensorPin);
 float voltage = tempSensor * 5.0;
 voltage /= 1024.0; 
 Serial.print(voltage); Serial.println(" volts");
   float temperatureC = (voltage - 0.5) * 20 ;  
 Serial.print(temperatureC); Serial.println(" degrees C");
 float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
 Serial.print(temperatureF); Serial.println(" degrees F");
 if(starting){
  if (request=="/temperatureF"){
    return "Current temperature is " + String(temperatureF) + " F";
  }
  if (request=="/temperatureC"){
    return "Current temperature is " + String(temperatureC) +" C";  
  }
  if(request=="/lightIntensity"){
    return "Current light intensity is " + String(lightSensor);
  }
  if(request=="/lightON"){
    lightState=true;
    return "Current light state is true!";  
  }
  if(request=="/lightOFF"){
    lightState=false;
    return "Current light state is false!";
  }
  if(request=="/lightDepend"){
    analogWrite(13,lightSensor);
    return "Here we go!"; 
  }
  if(request=="/google"){
    searchState=true;
    return "What you want to google?"; 
  }
  if(request=="close"){
    starting=false;            
    servo_test.write(0);
    return "Bye bye!";
  }
}else if(request=="/open"){
    starting=true;
    servo_test.write(90);
    return "What's next?"; 
}else
    return "Open the box first!";



}
7
  • You are uploading ESP8266 code to the Arduino???
    – Majenko
    Commented May 15, 2018 at 13:15
  • or his uploading Blink with pin 13 to esp8266 and expects the led on Arduino to blink
    – Juraj
    Commented May 15, 2018 at 13:17
  • I think he's compiling for the ESP8266 (I am running it on "generic esp8266 module" plate.) but uploading it to the Arduino. Maybe. It's a common mistake that you select the ESP8266 as your target when it's a mere peripheral to the Arduino that you are actully programming.
    – Majenko
    Commented May 15, 2018 at 13:18
  • the upload would fail, or not? 250+ kb? if I see it right RX is to RX and TX to TX
    – Juraj
    Commented May 15, 2018 at 13:19
  • 2
    So you're running code on the ESP8266 and expecting it to magically blink the LED on the Arduino?
    – Majenko
    Commented May 15, 2018 at 13:24

2 Answers 2

1

The esp8266 will not blink the LED on pin 13 or any other pin of the Uno. It has no access to pins of Uno. And your analogRead calls return some random values.

The RX to RX, TX to TX connection reduces the Uno to an "USB to Serial" adapter for the esp8266. You upload the Blink to esp8266. If the Blink sketch would have the original LED_BUILTIN pin number, then the LED on the esp8266 module would perhaps blink.

After you changed the connection RX to TX and TX to RX, you can't upload to esp8266 because the esp8266 is not anymore connected to PC over USB.

If you want to read and write the pins of Uno from esp8266, use ConfigurableFirmata sketch in Uno and FirmataMaster library in esp8266.

Other option is to write your own sketch for Uno and handle the communication between esp8266 and Uno over Serial.

Or you can use the esp8266 as network adapter with some firmware (AT firmware or WiFi Link) and port your sketch to Uno.

7
  • So it's impossible to make this light blink even if i change pin to 11? sorry for being dumb
    – Aksultan
    Commented May 15, 2018 at 14:04
  • you can blink any pin on Uno with a sketch in Uno. but for what you want to use the esp8266 module?
    – Juraj
    Commented May 15, 2018 at 14:49
  • i am using it to connect to the telegram bot and by its commands getting different sensor outputs such as light sensor and temperature sensor, i also want to blink light but it's not working, i spent like 2 days to solve this problem but its not working at all
    – Aksultan
    Commented May 15, 2018 at 15:02
  • you plan to send commands or you have a working sketch?
    – Juraj
    Commented May 15, 2018 at 16:50
  • i have working sketch, but i can't make my led working on it other modules working well
    – Aksultan
    Commented May 15, 2018 at 18:49
-1

Probably you are not uploading the code to ESP8266. Instead the code is getting uploaded to the Arduino. You should Ground the GPIO1 and connect ESP8266 Reset to Arduino Reset. Then go to the Sketch and see if you have changed the Board from ARduino to ESP8266.

1
  • how could a 250kb big esp sketch be successful uploaded to Uno?
    – Juraj
    Commented May 17, 2018 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.