ArduinoNano Shield+ Esp8266-01 AT 1.7

my connection is ok. my code is correct.
But I can’t send data.
After a while, the board goes offline.

I tried USB Serial connection with “Arduino Uno”, no problem.
I’m using SoftwareSerial.
SoftwareSerial EspSerial(2, 3); // 2-RX, 3-TX
ESP8266 wifi(&EspSerial);

18:47:02.987 -> [7698] Connected to WiFi
18:47:02.987 -> [7698] Connecting to mqtt.mydevices.com:1883
18:47:04.309 -> [9014] Connected
18:47:05.121 -> [9828] Publish: topic 4, channel 65534, vaa

meanwhile it gives mux error.

*/

//#define CAYENNE_DEBUG // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial1 // Comment this out to disable prints and save space. Do not use the same serial at ESP-01.
#include <CayenneMQTTESP8266Shield.h>

// WiFi network info.
char ssid = “ssid”;
char wifiPassword = “Password”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “xxxxx”;
char password = “xxxx”;
char clientID = “xxxx”;

// The following two lines will allow a light switch connection via pushbutton.
// Channel 1 on the Dashboard servers and Pin 10 as the corresponding digital output on the Arduino board.
#define VIRTUAL_CHANNEL 1
#define ACTUATOR_PIN 10 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.

// Set ESP8266 Serial object. If using Arduino boards such as MEGA with two serial ports, use “Serial1” if you like.
// If using UNO or NANO with single serial ports, leave as “Serial”.
#define EspSerial Serial
ESP8266 wifi(&EspSerial);

void setup()
{
// Uncomment the following “/ *…* /” if debugging on a seperate serial port.
/* //Debug console
Monitor.begin(9600);
delay(2000);
while (!Serial)
{
; // wait for serial port to connect. Needed for Native USB only
}
Monitor.println(“Monitor connected.”);
*/

pinMode(ACTUATOR_PIN, OUTPUT);

// Set ESP8266 baud rate
EspSerial.begin(115200);
delay(10);

Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);
}

void loop()
{
Cayenne.loop();
}

// This function is called when data is sent from Cayenne.
CAYENNE_IN(VIRTUAL_CHANNEL)
{
int value = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
// Write the value received to the digital pin.
digitalWrite(ACTUATOR_PIN, value);
}

try this code

continuous?

01:36:40.225 -> AT
01:36:42.738 -> AT
01:36:45.251 -> AT
01:36:47.765 -> AT
01:36:50.280 -> AT
01:36:52.795 -> AT
01:36:55.306 -> AT
01:36:57.822 -> AT
01:37:00.337 -> AT
01:37:02.851 -> AT
01:37:05.332 -> AT
01:37:07.848 -> AT
01:37:10.361 -> AT
01:37:12.874 -> AT
01:37:15.387 -> AT
01:37:17.900 -> AT
01:37:20.413 -> AT
01:37:22.925 -> AT
01:37:25.439 -> AT
01:37:27.955 -> AT
01:37:30.469 -> AT
01:37:32.982 -> AT
01:37:35.493 -> AT
01:37:37.974 -> AT
01:37:40.484 -> AT
01:37:42.996 -> AT
01:37:45.505 -> AT
01:37:48.020 -> AT

Above code is not for using usb to print on serial monitor. Serial pin are used for communicating with the esp. That is the reason for this code is not suited for single hardware serial pins boards.

sorry, i tried the code below, 15sec. then goes offline.

#define VIRTUAL_CHANNEL 1
#define ACTUATOR_PIN 10
// Set ESP8266 Serial object.
//SoftwareSerial mySerial(9, 10); // RX, TX
#define EspSerial Serial

ESP8266 wifi(&EspSerial);

void setup()
{
// Serial.begin(9600);
// delay(10);
pinMode(ACTUATOR_PIN, OUTPUT);
// Set ESP8266 baud rate
EspSerial.begin(9600);
delay(10);

Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);

// Serial.println(WiFi.localIP());
}

void loop()
{
Cayenne.loop();
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_IN(VIRTUAL_CHANNEL)
{
int value = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
// Write the value received to the digital pin.
digitalWrite(ACTUATOR_PIN, value);
}

add this in the code:

CAYENNE_OUT_DEFAULT()
{
	// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
	Cayenne.virtualWrite(0, millis());
	// Some examples of other functions you can use to send data.
	//Cayenne.celsiusWrite(1, 22.0);
	//Cayenne.luxWrite(2, 700);
	//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}

nothing changed?

serial monitor shows it is publishing data. but there is a disconnect message.

yes somehow my connection is broken, this connection is not caused by esp8266, esp8266 alone is working properly with rx, tx empty code,?

Do you have two devices connecting with same client id?

no not.

can you try powering the esp with an external power supply and i hope you are using a voltage divider at the RX pin.