Привет. Нужна помощь. Я хочу подключить к плате Arduino NANO плату ESP8266 (ESP-01), и соединить эту конструкцию с сервером Blynk (желательно с локальным (он у меня есть)).
Вот мой код:
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "gdfdfbdfbfbbbdbdbfbb123"; //lokal token
char ssid[] = "wifiname";
char pass[] = "password12345678";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
BlynkTimer timer;
WidgetLCD lcd(V1);
#define ledPin 13
#define photo A7
#define magswitch 8
int photovalue;
byte magvalue;
byte button;
int timerNo;
void photosensor()
{
photovalue = analogRead(photo);
photovalue = map(photovalue,0,1023,0,100);
photovalue = constrain(photovalue,0,100);
Blynk.virtualWrite (V0, photovalue);
}
void jumpersensor()
{
magvalue = digitalRead(magswitch);
Blynk.virtualWrite (V3, magvalue);
}
BLYNK_WRITE(V2)
{
if(param.asInt()==1)
{
lcd.clear();
lcd.print(2,0,"Security ON");
timer.enable(timerNo);
}
else
{
lcd.clear();
lcd.print(2,0,"Security OFF");
timer.disable(timerNo);
}
}
void setup()
{
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
timer.setInterval(1000L, photosensor);
timerNo = timer.setInterval(1000L, jumpersensor);
timer.disable(timerNo);
pinMode(magswitch,INPUT);
pinMode(ledPin,OUTPUT);
pinMode(photo,INPUT);
}
void loop()
{
Blynk.run();
timer.run();
}
Тут идет считывание фоторезистора и геркона, отправка параметров на смартфон в приложение Blynk.
С USB передачей (устройство было подключено к пк и был запущен файл …\arduino-1.8.5\libraries\Blynk\scripts\blynk-ser - c измененными параметрами для локального сервера.) всё работает как часы.
Подключал ESP8266 (ESP-01) по картинке
Вот сама схема в реальности:
••• синий светодиод загорается на секунду после включение.
Питания хватает, ибо я подключал даже компьютерный блок питания к плате питания, всё тоже самое.
Вот что пишет Монитор порта:
Я смотрел другие темы, но увы ничего не нашел. Буду благодарен за помощь.
==============================ENG - google translate===========================
Hey. Help is needed. I want to connect the ESP8266 (ESP-01) board to the Arduino NANO board, and connect this design to the Blynk server (preferably with a local one (I have it)).
The code above.
…
There is a reading of the photoresistor and reed switch, sending parameters to the smartphone in the application Blynk.
With USB transfer (the device was connected to the PC and the file was started … \ arduino-1.8.5 \ libraries \ Blynk \ scripts \ blynk-ser - with the changed parameters for the local server.) Everything works like clock.
…
••• The blue LED lights up for a second after turning on.
Power is enough, because I have even connected a computer power supply to the power board, all the same.
…
I looked at other topics, but I did not find anything. I will be grateful for the help.