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
}
Wifi module is working fine, but led is not working at all.
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!";
}
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.