Hello guys I have my ESP8266 connected to my Arduino. Then I typed in AT in the serial monitor. It confirmed this command with OK. After that I typed in AT+UART=9600, 8, 1, 0, 0 which gave me the response ERROR. Then I googled what I could do, which told me that I should try change the baud rate permanently with the command AT+IPR=9600. I did this but I got no response. After that I wondered if everything was ok so I typed in AT. No response. Now I'm a little bit sad because everything started to be great but I don't know how I can fix the whole problem. I also tried to upgrade its firmware with XTCOM Utility but it says it can't connect.
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
void setup() {
Serial.begin(115200); // communication with the host computer
//while (!Serial) { ; }
// Start the software serial for communication with the ESP8266
ESPserial.begin(115200);
Serial.println("");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
Serial.println("");
}
void loop() {
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
// listen for user input and send it to the ESP8266
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}
This is my code. I tried it with both 9600 and 115200 but if I use 115200 the serial monitor just shows some garbage signs. It's kind of frustrating because I can't even interact with the serial monitor as my typed commands don't show up anymore. Do you have any idea how I could fix this problem?
EDIT:
I read that the command AT+IPR=9600 breaks the module and it can just be fixed by reflashing it. Sadly this doesn't work because it somehow can`t connect.
When reconnecting to WiFi after waking up from deep sleep, an error "Brownout detector was triggered" is thrown causing the partial restart of the ESP. The setup phase is then done again, but now WiFi succeed to connect.
How to properly reestablish a WiFi connection after a deep sleep?
#include <WiFi.h>
#include "esp_wifi.h"
#define SSID "myssid"
#define PASS "ssidpass"
#define uS_TO_S_FACTOR 1000000ULL /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 10 /* Time ESP32 will go to sleep (in seconds) */
RTC_DATA_ATTR int boot_count = 0;
void setup() {
Serial.begin(115200);
delay(200);
print_wakeup_reason();
Serial.print("Boot count: "); Serial.println(boot_count);
Serial.println("WiFi connection");
WiFi.begin(SSID, PASS);
int try_count = 0;
while (WiFi.status() != WL_CONNECTED && try_count < 10) {
try_count++;
delay(1000);
Serial.println("Connection...");
}
Serial.println("WiFi connected");
WiFi.disconnect();
esp_wifi_stop();
Serial.println("Sleeping in 1s ...");
delay(1000);
esp_deep_sleep(TIME_TO_SLEEP * uS_TO_S_FACTOR);
}
void loop() {
}
void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
}
}
Corresponding serial monitor message :
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Wakeup was not caused by deep sleep: 0
Boot count: 0
WiFi connection
Connection...
WiFi connected
Sleeping in 1s ...
ets Jun 8 2016 00:22:57
rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Wakeup caused by timer
Boot count: 0
WiFi connection
Brownout detector was triggered
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Wakeup was not caused by deep sleep: 0
Boot count: 0
WiFi connection
Connection...
WiFi connected
Sleeping in 1s ...
ets Jun 8 2016 00:22:57
rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Wakeup caused by timer
Boot count: 0
WiFi connection
Brownout detector was triggered
I'm using a ESP-WROOM-32 (Chip is ESP32D0WDQ6 (revision 1)), on GNU Linux, with Arduino IDE 1.8.13, card library : Espressif System 1.0.4
This is a power problem. You need a more capable power supply to feed the ESP32. If using a USB-powered dev board, try replacing the USB cable and connecting it directly to a USB port on your computer. A powered USB hub might also help.
As my cable is undoubtedly good, I persevered and found this solution on the Net. Does the fault come from the component which is a copy and not an genuine? Mystery.
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
void initialize() {
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
}
I was having the same problem, has it has been mentioned that it is a power related problem I changed my power source from 2.0 to 3.0 and the problem was sorted out.
So I'm seeing this problem too. "Brownout detector was triggered" on my ESP32-S2-WROOMD (DevKit). It happens when WiFi.Begin is called but only when my ESP32 DevKit is loaded: meaning I am using the 3.3V rail for powering some GPIOs and I'm also using a 5V sensor.
Thinking the USB(2 and 3) ports weren't driving enough voltage/current I moved from the USB source to a separate regulated 5V power supply. This seemed to drive both the MCU and the peripheral lines well but I was still getting intermittent brown-outs.
Then I added a polarized 220uF capacitor across the 5V positive/negative source and that all but eliminated the issue for me. BUT is still happens occasionally and unfortunately randomly.
My rig includes an EPROG/JTAG debugger board with PlatformIO. Thinking the board might also be contributing I disconnected the debug board and that seems to have solved my problem (I didn't want to try to disable the brownout detector btw).
So, my thinking candidly is that the ESP32-S2 is very sensitive and finicky to power fluctuations which don't normally occur when the MCU is standing alone or simply connected with a sensor or two, but when you "load" it and there are power fluctuations (even when powered externally and not via USB) the chip has issues. BTW, I even dialed up the regulated power source to 5.5V to see if additional juice would solve the problem and still didn't 100% cure.
Thinking of moving to the newer S3....
In the search for the lowest consumption, I finally proceeded to various optimizations. And I came to deep sleep the ESP after disabling WiFi, and I take the ESP out of deep sleep with the WiFi still disabled. I reactivate the WiFi before using it. The ESP wake-up time is not a problem, low consumption is my priority. And it works without a problem, without even using the first solution I posted.
Issue
-When using the ESP8266 wired up in this way it will randomly disconnect the USB interface when it powers the relay. It may then re-connect but is sporadic.
-The code can be viewed below, but essentially the relay is powered for 300ms then waits 10 seconds to loop.
Wiring Diagram https://i.stack.imgur.com/4mycx.png
Tests:
I have swapped out the relay, pump, ESP8266, aswell as re-wiring the circuit multiple times to check for a short. I also have a integer incrementing every loop cycle, when the ESP8266 is able to re-connect it will print this variable, which shows the board is not crashing:
Serial output
https://i.stack.imgur.com/ziM8g.png
I then modified the diagram so the 5v power was not in parallel, but where two different power sources, one for the ESP8266 and one for the pump circuit, however the same issue was observed:
Test Wiring Diagram https://i.stack.imgur.com/7S0aP.png
Question:
Why does the USB disconnect when sending the control signal to the relay?
Is there a way to mitigate this?
Code:
int relayInput = 5; // the input to the relay pin
int debug_test = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(relayInput, OUTPUT); // initialize pin as OUTPUT
}
void loop() {
// put your main code here, to run repeatedly:
debug_test ++ ;
Serial.println(debug_test);
digitalWrite(relayInput, HIGH); // turn relay on
Serial.println("Water on!");
delay(300);
digitalWrite(relayInput, LOW); // turn relay off
Serial.println("Water off!");
Serial.println("Waiting 10 seconds");
delay(10000);
}
Parts:
Pump - https://www.ebay.co.uk/itm/Mini-Water-Pump-DC-3V-4-5V-Fish-Tank-Fountain-Aquarium-Submersible-White-Parts/174211676084?hash=item288fd337b4:g:128AAOSwfQteYWF3
ESP8255 - https://www.amazon.co.uk/gp/product/B07F5FJSYZ/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
Relay - https://www.amazon.co.uk/gp/product/B07BVXT1ZK/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
Ok, so researching in to this, it seems when the pump is on it pulls more current (amps) than the PC can provide.
This will be used connected to a external power source which should supply enough current to it, however I also wanted the flexibility to connect it to a PC with a serial connection to troubleshoot.
So in the end something like this:
https://i.stack.imgur.com/MKD1h.png
You are driving a 5v relay module with 3.3v output, which works perfectly for some people but it depends on the relay module and the board, this might be the problem. or the relay draws more than 12mA which is the maximum current can the ESP8266's GPIO deliver.
so I suggest you use an external power source for the relay and control it through the pin (D1 in your case).
Or just use a generic 5v relay with an external 5v power source and control it using a transistor, here is a circuit.
Additional information: https://electronics.stackexchange.com/questions/213051/how-do-i-use-a-5v-relay-with-a-3-3v-arduino-pro-mini?
I'm trying to create a simple serial communication between my ESP8266 E12 and a Sony Spresense. I have connected the Spre.RX with ESP.TX, the Spre.TX with ESP.RX and Spre.GND with ESP.GND.
Receiver:
byte rcvByte;
void setup() {
Serial.begin(9600);
while (!Serial) {;}
Serial.println("Receiving");
}
void loop() {
if (Serial.available()) {
rcvByte = Serial.read();
if (rcvByte == 'H') {
Serial.println("High");
}
if (rcvByte == 'L') {
Serial.println("Low");
}
}
}
Sender:
void setup() {
Serial.begin(9600);
while (!Serial) {;}
Serial.println("Sending");
}
void loop() {
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
Serial.println();
}
Unfortunately, nothing happens. I tried both, ESP as Sender and Spresense as Receiver and vice versa.
It works like a charm when I connect my ESP and a Arudino Uno, in both ways.
Do I have to enable the RX/TX pins with the Spresense somehow? I have tried the pins on the developer board as well as the small board directly. Any suggestions?
I took a quick look into this and my best guess, or tip after checking the code is to try the following on the Spresense side:
Simply change Serial to Serial2.
void setup() {
Serial2.begin(9600);
while (!Serial2) {;}
Serial2.println("Sending");
}
void loop() {
Serial2.print('H');
delay(1000);
Serial2.print('L');
delay(1000);
Serial2.println();
}
I have not tested so please do if you can.
I noticed a small detail in the hardware datasheet provided at:
Spresense Hardware Documents
In the section labeled - 2. Differences between Spresense and Arduino Uno:
It has a small table showing the comparison with explanations.
Located at the bottom of the table one can see the boxes for UART Serial communication.
Note the existence of two serial outputs on the spresense board. The Spresense Main board (smaller nano like) has a serial UART rx/tx pair with syntax variable -> "serial" but in addition the Spresense expansion shield also has a second UART RX/TX pair with syntax -> "serial2"
"The Spresense main board and extension board have UART terminals.
It is not possible to use the UART on both the main board and the extension board at the same time.
The extension board is configured to have the UART enabled when it is shipped. To use the UART pins on the main board when attached to the extension board, a 2.54mm pitch jumper have to be connected to pin 1 and 2 on JP10 of the extension board to disable the extension board UART. No jumper is supplied with the Spresense boards so this has to be purchased separately.
When the extension board UART is activated, the UART pins (D00, D01, D27 and D28) of the main board cannot be used as GPIO."
I ended up spending about three days pulling my hair out before i realized looking at documentation provides all the answers one could need..
The killer is in the details on this one.
This should provide some clarity to others experimenting with UART communication between spresense products while attempting utilize the expansion board.
When I Serial.print() anything within the setup function using the Arduino library and IDE, I don't get anything. But when I move the Serial.print() lines to the loop function they appear normally. The code in setup() seems to be running. I just can't print anything to serial.
Add a delay of 1000ms before Serial.begin(115200).
Put these lines at the top of the setup :
Serial.begin(9600);
Serial.setDebugOutput(true);