arduino-ESP8266 | An Arduino library to manage the ESP8266
kandi X-RAY | arduino-ESP8266 Summary
kandi X-RAY | arduino-ESP8266 Summary
An Arduino library to manage the ESP8266.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of arduino-ESP8266
arduino-ESP8266 Key Features
arduino-ESP8266 Examples and Code Snippets
Community Discussions
Trending Discussions on arduino-ESP8266
QUESTION
I read that I need to add the ICACHE_RAM_ATTR macro to interrup service routines (ISRs) and to every function that is called from there in my Arduino code for ESP8266 to prevent random crashes. I also found an explanation of what the macro ICACHE_RAM_ATTR does, although I'm not sure if the explanation, which is for the Espressif ESP8266 SDK, is also true for Arduino on ESP8266. And I did not understand why I need to add the macro to ISRs.
First question: Why do I need to add the ICACHE_RAM_ATTR macro to ISRs and all functions called from there?
Next question is, what happens if I force inlining a function that is called from an ISR:
...ANSWER
Answered 2019-Sep-27 at 09:30The ICACHE_RAM_ATTR and ICACHE_FLASH_ATTR are linker attributes. Once you compile your sketch, you can say if the function should be stored in the RAM or FLASH (normally you do not set anything: no cache).
ESP8266 is multitasking and the ESP32 has 2 cores. So you can execute your code as multithreading - since it use the RTOS.
And now the problem: The entire flash is used for the program and storage. Reading and writing to the flash can be done only over 1 thread. If you try to access the flash simultaneously over 2 different threads, your ESP will probably crash.
This is because you can put your function in the RAM instead of the flash. So even if you are writing something in the EEPROM or flash, this function can be called without accessing the flash.
With ICACHE_RAM_ATTR
you put the function on the RAM.
With ICACHE_FLASH_ATTR
you put the function on the FLASH (to save RAM).
Interrupt functions should use the ICACHE_RAM_ATTR. Function that are called often, should not use any cache attribute.
Important: NEVER access your flash inside an interrupt! The interrupt can occur during a flash access, so if you try to access the flash at the same time, you will get a crash (and sometimes this happens after 1-2 hours after you use your device).
Since you have only 32kb of IRAM (Instruction RAM), you should try to put only interrupt functions in the RAM, not all your functions, even if it is possible to do so.
Second question: NO, absolutely no! inline is another compiler flag, so that the compiler will try to put your entire function inside the caller function => convert a function call to c++ code inside your main. This doesn't mean that the compiler will do it, just try it. You can't ask to put the function inside the RAM, if the function does not exist anymore once you compile your sketch.
QUESTION
The problem testing my mood for the past few days is that although my ESP8266 chip is perfectly capable of fetching packets with parsePacket in a while loop, it completely misses these when I want BOTH to listen to incoming packets, but also allow my ESP8266 to read out sensors and send these over wifi.
So I cut out everything that has to do with the sensors and pasted the code below, but here is what's happening.
- In Setup(), the ESP sets up the wifi, SoftAP node, UDP and configures it.
- It then gets to a while loop where it listens for an incoming package over wifi; this tells the ESP to start spitting out data.
- When the ESP receives a packet (this is the "A. <<<" comment in my code and works fine), the code moves to the Loop() part and the sensors start spitting out data which is send over wifi
MY PROBLEM IS THIS STEP:
- During reading out the sensors and sending data over wifi I want the ESP8266 also to be able to receive incoming packets over wifi (this is the "B. <<<" comment in my code and does not work), the ESP keeps sending sensor data over wifi, but it does not receive any packets
My guess is that A. works fine because the 'while' condition will allow parsePacket to always catch an incoming packet. And because B. is inside the void loop I cannot use a 'while' condition but instead an 'if' statement, the parsePacket command is not requesting for an incoming package on the right moment. I have not been able to implement something that solves this. Quite a bit of searching is not really helping out and I cannot imagine I am alone having this problem.
Some things I found related:
- The WifiEventHandler unfortunately does not list an event that is related to receiving a packet: https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/generic-class.html
- I also found this topic, but I am unable to get this to work and the answer to this question somehow does not seem complete: Making a UDP class which doesn't block an ESP8266 / Arduino
I greatly appreciate your help and feedback!
Here is my code:
...ANSWER
Answered 2020-Jan-29 at 04:41The WiFi events in "Generic Class" are for OSI levels below transport layer. TCP and UDP are transport layer.
To receive UDP packets you must call UDP.parsePacket();
in loop()
(or in a function called from loop()
) like with every other Arduino networking library implementing the Arduino UDP
base class.
If packet is available call to parsePacket
reads the packet into internal buffer and returns the size of the packet. Next call to parsePacket
clears the buffer and fills it with new packet if it is available. You call parsePacket
twice and the second always returns nothing.
QUESTION
I am using https://github.com/Schm1tz1/aws-sdk-arduino-esp8266 default repository inside arduino sdk.
But It's sample code wont update shadow thing on AWS IOT. I configured everything correctly, Can some one help me on it?
...ANSWER
Answered 2018-Mar-30 at 14:23I am able to develop code using ARDUINO IDE that connects ESP8266 with AWS IOT by using this repo:http://github.com/odelot/aws-mqtt-websockets
QUESTION
I am using Arduino type device RobotDyn WiFi D1 R2 with builtin ESP8266 WiFi module. There are two photos: I want to create WiFi access point using official library taken from there:
https://arduino-esp8266.readthedocs.io/en/2.5.0-beta2/installing.html
Please, look at my sketch (code):
...ANSWER
Answered 2019-Jan-27 at 13:03Seems like your TCP IP settings don't get initialized, with this code, but they get set when you connect it to external wifi via the DHCP server.
I have this function which works for me. You might want to try it.
QUESTION
I have a UDP Server listening on my local network on IP:192.168.0.53 port 1337.
I have a UDP client also on the same subnet of my local network setup to send a packet to 255.255.255.255 port 1337 and it never arrives on my server. This happens repeatedly, and I am using the broadcast address as you can see.
I try from my client to send a packet to 192.168.0.53 port 1337 and it arrives fine. Showing a simpler non broadcast route works nicely.
I have tried 2 clients, as I believe some special flags need to be set for broadcast. Both PacketSender and this specific broadcast application are not received by my client.
My server is written using the ESP8266WiFi UDP class.
Am I missing something here? The broadcast should be received by my server but isn't. Do I need a special flag on my server perhaps?
The server code (based off of the Udp class linked above) simply is:
...ANSWER
Answered 2018-Feb-04 at 18:31The solution was to use multicast instead.
My server code was changed to join a multicast group and listen on a particular port:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install arduino-ESP8266
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page