Sorry about my english. I try to connect my ESP32 to wifi and it's resets. I post text in the Micropython interpreter of ESP32 (only erase ">>>"promt from every line) :
MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32
Type "help()" for more information.
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
True
wlan.connect('Dpto', '03755422170')
ets Jun 8 2016 00:22:57
rst:0x8 (TG1WDT_SYS_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:2
etc...
It's happends with an older firmware too.
In google there are a lots topics about it, but I don't find any usefull.
I try to find why the Timer Group 1 of the Whach Dog Timer send Resets, but donĀ“t find answers.
I erase the Firmware and write again, but the error continue.
Thanks in advance..
Related
I was recantly experimenting with espnow in micropython. Sudenly I rann Into A Problem wenn trying to run this code:
import network, espnow, time
wlan_sta = network.WLAN(network.STA_IF)
wlan_sta.active(True)
e = espnow.ESPNow()
e.active(True)
peer = b'\xff\xff\xff\xff\xff\xff' # MAC
e.add_peer(peer)
while True:
e.send(peer, "ESP")
time.sleep(1.1) # Sekunden
i get the Error OSError: -3
The Code worked on my Esp32 but not on the 8266 no clue why.
I tried reflashing my esp but that did not help either.
According to the documentation you need to call wla_sta.disconnect() after setting wlan_sta.active(True). This is the example from the docs:
import network
import espnow
# A WLAN interface must be active to send()/recv()
sta = network.WLAN(network.STA_IF) # Or network.AP_IF
sta.active(True)
sta.disconnect() # For ESP8266
e = espnow.ESPNow()
e.active(True)
peer = b'\xbb\xbb\xbb\xbb\xbb\xbb' # MAC address of peer's wifi interface
e.add_peer(peer)
e.send("Starting...") # Send to all peers
for i in range(100):
e.send(peer, str(i)*20, True)
e.send(peer, b'end') # The example in the docs is missing the `peer` argument.
If I run that example as written (well, correcting the second call to e.send as shown in the above code) and the corresponding receiver code, it all works just fine on a pair of esp8266's running v1.19.1-espnow-6-g44f65965b.
Update I think your problem is that the esp8266 may not support the broadcast address. While the documentation suggests that the esp8266 should be able to send to the broadcast address:
All active ESP-Now clients will receive messages sent to their MAC address
and all devices (except ESP8266 devices) will also receive messages sent to
the broadcast MAC address (b'\xff\xff\xff\xff\xff\xff') or any multicast MAC
address.
All ESP-Now devices (including ESP8266 devices) can also send messages to the
broadcast MAC address or any multicast MAC address.
It appears that this isn't the case. I'm able to use the example code from the docs when operating in unicast mode, but attempting to call e.add_peer with the broadcast address results in the same error you've reported.
I've opened issue #11 with this problem.
In Conclusion you can say that It IS posibille to use ESPnow on the esp 8266 in SingelCasting Mode but not in MultiCasting
I have an ESP32 microcontroller with MicroPython 1.19.1 that I'm setting up as a wifi access point. But, when I attempt to print the IP address with print(f'{wlan.ifconfig()}') it gets stuck in a reboot loop.
Here's the code in my boot.py:
from network import WLAN, AP_IF
from config import AP_NAME, AP_PASS
print('Starting in wifi access point mode...')
wlan = WLAN(AP_IF)
wlan.config(authmode=3, essid=AP_NAME, password=AP_PASS)
wlan.active(True)
while (wlan.active() == False):
print('.')
print(f'SSID: {AP_NAME}')
print(f'Password: {AP_PASS}')
print(f'{wlan.ifconfig()}')
Commenting out the print(f'{wlan.ifconfig()}') fixes the reboot loop, as does inserting a delay just before the statement.
This leads me to believe the access point is not fully ready by the time I'm calling ifconfig(). But, I'm working under the assumption the while (wlan.active() == False) is supposed to take care of that. Though in the serial output, there's not a single dot printed to indicate it looped even once.
Serial output looks like this (after inserting a delay to mitigate the reboot loop):
Starting in wifi access point mode...
SSID: Lab
Password: ********
('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
If the while loop were actually waiting for the access point to come up, I would expect a few lines with dots between the 'Starting' message and the printing of SSID. So I'm thinking wlan.active() is just telling me what I set in the line above: wlan.active(True) and is not a true reflection of the access point's readiness.
I tried help(wlan) to see what methods might be available to determine the state of the access point. Some of the more promising ones and their results are shown below.
>>> wlan.active()
True
>>> wlan.isconnected()
False
>>> wlan.status()
>>>
I'm not surprised by isconnected() returning false since it's probably just for wifi station mode. I had high hopes for status(), but it only returns None
Every tutorial I've found so far uses the while loop to check active(), but obviously that's not working. Sticking a random delay in seems like a bad solution.
Is there a reliable way to ensure the access point is fully ready before asking for its IP address?
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 had this working fine a few months ago but can't seem figure out what's changed. I have several ESP-01 and I can upload using Arduino IDE with Generic 8266 board profile but I can't get anything to run. Nothing shows on the Serial Monitor. I've tried simple code like:
void setup() {
// put your setup code here, to run once:
delay(1000);
Serial.begin(115200);
delay(1000);
Serial.println("Hello, you've entered setup()...");
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Good day, you're in loop()...");
delay(2000);
}
I've tried using a jumper to 3.3v on the ENable pin and a 10k resister. I've removed the GPIO0 after programming. Nothing seems to work. I have 4 chips so I know I'm not doing something.
I have 3.3v on VCC (measured), nothing on RST, EN to VCC (tried 10k to VCC), TX - RX, RX - TX, 0 - Gnd for programming, nothing on 2, Gnd - Gnd
I found the answer for this problem. It seems that the ESP-01 chip must have 10k resisters on GPIO 0, GPIO 2, and reset to VCC in order function properly. Although the chip seemed to accept the flash, the floating pins were causing problems. Once I added the pullup resisters, it was like magic, everything started working.
Just switch to boards version 2.4. It will work then