jiribilek / wifispi Goto Github PK
View Code? Open in Web Editor NEWSPI library for Arduino AVR and STM32F1 to connect to ESP8266
License: GNU Lesser General Public License v3.0
SPI library for Arduino AVR and STM32F1 to connect to ESP8266
License: GNU Lesser General Public License v3.0
Is there a hardware reason why the number of sockets is limited to 4? Or could the code be adjusted to allow for a (slightly) larger number, say, 8?
If yes, could this be made configurable?
Most of the websites are switching to SSL, and that is VERY data hungry (crashing) for AT command set users, SPI should be plenty fast to keep up the buffer dequeuing
Is this library still in progress?
Hi!
I was just wondering if you could make an example for how you would implement the clientcode to support the ESP running wifiManager?
This appears to stop your code running on the ESP until a wifi connection is established? And therefor it does not respond to the client during this time?
Mortrn
This library looks like the perfect addition to our project, thanks for all the effort!
Is it possible to run the code on the Arduino Due as well? Has anyone figured out the wiring for it yet?
MISO, MOSI and SCK should be clear (SPI-4, SPI-1 and SPI-3 respectively), but for SS Master, there are three pins available (4, 10 and 52), which of the three should be used and how should I configure this?
If someone already has figured out the (best) way to wire it, maybe the Due could also be added to the list on the main README.md?
Thanks a lot again!
Hi!
I am having a problem that creates a 3000ms delay when calling WiFiSpiServer::avaliable() in my STM32 run loop.
Is this a known problem with the ESP? I have traced it all the way to ServerSpiDrv::getClientState and it is in the EspSpiDrv::waitResponseCmd the delay is created. I would guess the ESP does not respond before 3 seconds inside the function ServerSpiDrv::cmdGetClientStateTcp.
This creates a 3 second delay every time my loop is ran so the application gets a "bit" slow :-P
Hope to here from you as besides this the library is getting really good! :-D
Thank you,
Morten Lund
EDIT: The problem described here results from reaching the maximum limit of sockets (apparently 4). The question thus is how to manage or determine the current number of socket connections, see third post below.
The main page of my project on the Arduino Due side connects to my GitHub repository and downloads a file containing the current version and then informs the user if an update is available. This works great also with WiFiSpi.
However, the result of that query is only seen on the website the very first time I call the main page. Afterwards, the code still goes through, but no more text is sent to the browser.
To send text to the browser, I don't use client.write() or .print() directly but fill a buffer that is then sent to the browser once it's full or at the end of the website.
With the EthernetClient library, I use client.flush() for making sure that at the end of each call all characters are transmitted. I see that this function is not yet implemented in WiFiSpi, but I'm not really sure that this is the root cause of the problem because it does work the first time after each restart. I have also removed client.stop() and also added a delay to make sure that there is enough time for the Arduino to send away all reimaining data in the buffer, but no success.
Do you have any idea where the problem could lie?
Here's the code in question if that is of any relevance:
if(enable_version_check){
printlnToWebClient(PSTR("<BR><BR>Checking for newer version...<BR>"));
flushToWebClient();
httpclient.connect("bsb-lan.de", 80);
httpclient.println("GET /bsb-version.h");
httpclient.println();
unsigned long timeout = millis();
while (millis() - timeout < 3000 && !httpclient.available()) {
}
int major = -1;
int minor = -1;
int patch = -1;
char version_number[8] = { 0 };
while (httpclient.available()) {
char c = httpclient.read();
if (c == '\"') {
int index = 0;
do {
c = httpclient.read();
version_number[index] = c;
index++;
} while (c != '\"');
version_number[index-1] = '\0';
if (major < 0) {
major = atoi(version_number);
} else if (minor < 0) {
minor = atoi(version_number);
} else if (patch < 0) {
patch = atoi(version_number);
}
}
}
httpclient.stop();
if ((major > atoi(MAJOR)) || (major == atoi(MAJOR) && minor > atoi(MINOR)) || (major == atoi(MAJOR) && minor == atoi(MINOR) && patch > atoi(PATCH))) {
printToWebClient(PSTR("New version available: "));
printFmtToWebClient(PSTR("<A HREF=\"https://github.com/fredlcore/bsb_lan/archive/master.zip\">%d.%d.%d</A><BR>\r\n"), major, minor, patch);
} else {
printToWebClient(PSTR("Version up to date."));
}
}
Currently, the condition "Version up to date" is true and I can output the result to the serial port, but it is not printed to the web browser.
This is what printToWebClient() does:
int printToWebClient(const char *format){
int len = strlen(strcpy(bigBuff + bigBuffPos, format));
bigBuffPos += len;
if(bigBuffPos > OUTBUF_USEFUL_LEN){
flushToWebClient();
}
return len;
}
void flushToWebClient(){
if(bigBuffPos > 0){
client.write(bigBuff, bigBuffPos);
bigBuffPos = 0;
return;
}
client.flush();
}
The following code results in the warning below:
max_cul = new WiFiSpiClient();
[...]
delete max_cul;
max_cul = NULL;
warning: deleting object of polymorphic class type 'WiFiSpiClient' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]
delete max_cul;
Is there a way to prevent this warning?
Newer compilers, namely xpack-arm-none-eabi-gcc/9.2.1-1.1 issues warnings about deprecated boolean type.
warning: 'boolean' is deprecated [-Wdeprecated-declarations]
Change boolean to bool.
Hi,
I've tried wiring both a Mega2560 and Uno clones to a Wemos D1 mini according to the instructions but I'm getting WiFi shield not present
on both the AVR boards on startup. The wiring is done through a logic level converter like this https://www.aliexpress.com/store/product/IIC-I2C-Logic-Level-Converter-Bi-Directional-Module-5V-to-3-3V-For-Arduino/612195_1893394721.html
There was no issues building or flashing on any of the boards and the D1 serial console says SPI SLAVE ver. 0.1.1
. I've double checked the wirings and used all of the three boards to connect to miscellaneus SPI modules.
If I understood correctly from the code, WifiSpiESP has debug printing on by default. Is there a way to get more output on what the AVR side code is doing? I tried declaring #define DEBUG
and #define _DEBUG_
before #include <WifiSpi.h>
but I'm not getting any more output.
OT background:
I came across your post at https://community.thinger.io/t/esp8266-and-arduino-connected-by-spi-interface/405 while searching to see if someone has implemented something like this. I've tried various serial based solutions to make these devices communicate nicely (https://github.com/bportaluri/WiFiEsp, https://github.com/jeelabs/esp-link and https://github.com/tuanpmt/esp_bridge for example), but either they were not working at all or failed at a specific use case I needed the connectivity for (mainly just MQTT publish & subscribe).
The most reliable solution for my particular use case has been code I wrote myself to forward MQTT data through serial as JSON (https://github.com/ristomatti/esp8266-rxtx-mqtt/blob/master/src/esp8266-rxtx-mqtt.cpp) but it's cumbersome to use as it requires separately flashing the ESP for all changes.
Out of frustration I yesterday started writing a more general purpose serial RPC callback scheme relying on https://github.com/thijse/Arduino-CmdMessenger for communication. This morning before continuing on the code I decided to do one more round of googling to see if there's some library/method I haven't run across and I ended up here full of hope as WifiSpi/WifiSpiESP looked to have a fresh approach. Hopefully the issue I'm having can be fixed and I can continue with writing some other code that requires a solid link between the devices! :)
thank you sir for amazing work. I am using your library to send data to my https secure server, using POST method but it can not connect to https server.
Serial.println("Send weight to server :" + String(finalWeight));
Serial.print("Starting connection to server...");
Serial.println(centralServer);
// if you get a connection, report back via serial:
if (secureClient.connectSSL(centralServer, centralServerPort)) {
Serial.println("connected to server");
// Prepare the POST request
String path = "/api/iotdata.php";
String postData = "{\"device\":" + String(deviceID) + ",\"weight\":" + String(finalWeight, 2) + ",\"timestamp\":\"" + currentDateTime + "\"}";
//final https request
String request = String("POST ") + path + " HTTP/1.1\r\n" + "Host: " + String(centralServer) + "\r\n" + "User-Agent: Arduino/1.0\r\n" + "Connection: keep-alive\r\n" + "Content-Type: application/json\r\n" + "Content-Length: " + postData.length() + "\r\n" + "\r\n" + postData;
//Serial.print("Http post request :");
//Serial.println(request);
// Convert String to char array
char charRequest[request.length() + 1];
request.toCharArray(charRequest, request.length() + 1);
// Send the request
secureClient.write(charRequest);
}
while when i simply use
if (secureClient.connect(centralServer, centralServerPort)) {
Serial.println("connected to server"); }
i am able to connect to server and send data to serevr.
i an supply correct fingerprint and setting fingerprint too using
WiFiSpi.setSSLFingerprint(fingerprint);
please help me resolve this issue.
The AxTLS is now in https://github.com/esp8266/Arduino deprecated and should not be used. Change to BearSSL gives us more control over certificate validation but requires some changes on client side:
When flashing the ESP (built from master) it will be flashed with version 0.2.3 of the protocol. Installing the latest library for Arduino (Tools -> Library Manager) will get you version 0.2.0. This causes a "protocol version mismatch. Please upgrade the firmware" error.
Two issues
Is it possible, similar to the Ethernet library, to set a fixed MAC address for the WiFi connection? Or is the MAC address fixed as part of the ESP and not changeable?
Hello JiriBilek
I have that same issue all over again, as soon as Arduino studio told me of the availability of 0.3.0, I updated both the library and the WiFiSPIESP, but the following message showed up again.
"Protocol version mismatch. Please upgrade the firmware"
Thank you for all the time and effort you put into this software, more power to you.
I have copied the old issue that was fixed before here for your referance
Yours
Yazeed
Hi there
I hope this is not something that has been addressed elsewhere, but i am facing a little problem using this software
I have downloaded the software for the ESP8266 and the software for the Arduino, it seems that there is a version mismatch, >when i go to grab matching versions, I find that even when both are labeled as release 0.2.5, WiFiSpi contains version 0.2.3 and >WiFiSpiESP is at 0.2.4, and I can not seem to find matching versions in both projects (At least not recent ones)
I am presented with the error "Protocol version mismatch. Please upgrade the firmware"
Thank you in advance
Hi there
I hope this is not something that has been addressed elsewhere, but i am facing a little problem using this software
I have downloaded the software for the ESP8266 and the software for the Arduino, it seems that there is a version mismatch, when i go to grab matching versions, I find that even when both are labeled as release 0.2.5, WiFiSpi contains version 0.2.3 and WiFiSpiESP is at 0.2.4, and I can not seem to find matching versions in both projects (At least not recent ones)
I am presented with the error "Protocol version mismatch. Please upgrade the firmware"
Thank you in advance
I'm pretty happy to see this project and really like the idea (an ESP-01 with WifiESP creates a lot of trouble because of the serial communication).
For the WifiSpiESP lib I changed a little bit the setup and made some test runs with by using an Arduino M0 combined with a NodeMCU and D1 mini. For both, the ConnectWithWPA example works nicely, beside sporadic freezes after ~5-10 minutes.
But if I adapt the Wiifi NTP examples, always only once a repsonse with packet size 48 is received and properly converted into UTC time. All following responses report a size of 0.
I another test, I created a small MQTT client with the PubSub lib. The connection to the broker is established, a subscribe for 3 messages is confirmed, but never an update is received. After a while, the M0 frezzes completely.
Hi!
I am still testing this and I am still having some problems with instability and I am unable to figure out what is the cause of this problems.
When I enable debugging in espspi_drv.cpp I get this in my serial: Cmd exp:A0, got:91
.status() command also returns WL_IDLE_STATUS and WL_NO_BOARD at random times.
Mostly WL_IDLE_STATUS.
The board is still connected like described in the issue #5
Morten
I flashed WiFiSpiESP BearSSL branch to WeMos D1 Mini(ESP12).
And I opened https://github.com/JiriBilek/WiFiSpi/tree/BearSSL/examples/ConnectWithWPA, edit ssid & pass, flashed to Arduino Uno.
And I connected D1 and UNO, Reset Uno.
But connection fail.
Do you have any help.
Attempting to connect to WPA SSID: aterm-d5a4ee-g
[espspi_proxy.h:219] W: Bad CRC, retransmitting
Attempting to connect to WPA SSID: aterm-d5a4ee-g
Attempting to connect to WPA SSID: aterm-d5a4ee-g
Attempting to connect to WPA SSID: aterm-d5a4ee-g
[espspi_proxy.h:219] W: Bad CRC, retransmitting
Attempting to connect to WPA SSID: aterm-d5a4ee-g
Attempting to connect to WPA SSID: aterm-d5a4ee-g
Heap: 51784
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 50 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7e
>> df e0 d0 1 5 30 2e 32 2e 35 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 50 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7e
>> df e0 d0 1 5 30 2e 32 2e 35 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
Heap: 50656
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
Heap: 50656
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 1 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Invalid message header - message rejected.
df 34 66 32 ee 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fb
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 1 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
Heap: 50656
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
Heap: 50656
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
Heap: 50656
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
no aterm-d5a4ee-g found, reconnect after 1s
Heap: 50656
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Heap: 50656
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Heap: 50656
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Heap: 50656
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
scandone
no aterm-d5a4ee-g found, reconnect after 1s
reconnect
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
<< df 34 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 fb
Conn: aterm-d5a4ee-g scandone
del if0
usl
mode : null
mode : sta(cc:50:e3:08:1c:d6)
add if0
-> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Hi!
I have an ESP connected to my STM32 and I have two issues.
1: My ESP does not allways appear in my routers list of clients. The ESP reports back that has successfully connected to the AP but it is not reachable by its IP or in the routers clientlist.
Disconnect/Reconnect power to ESP usually makes it work again for some time/reconnects
2: This problem may be related to the above, but the server function «avaliable» does not return a client for most of the time when i try to Connect to the esp.
Also the few times i do get a connection the client data gets read very slow concidering this is a very fast spi connection? Couple of seconds for 100-200bytes.
Any ideas on where or how i can debug this?
Thank you,
Mortem
The WiFiSPIServer class allows only one incoming connection, although ESP8266 has no such limitation (in fact, there is obviously an limitation but is higher than one) . The limit is forced by the _sock
array that serves as binding information between master and slave.
Discussed in #13
Would it be possible to add the remoteIP() function that is available for WiFiSpiUDP already, also to WiFiSpiClient? It used to be the same case with the Ethernet Library until version 2.0 that remoteIP was only implemented for UDP, but nowadays in version 2.0, it is available also for generic clients. This would make it easier to port code to your library. Thanks!
I'm trying to get the ArduinoMDNS example for registering a service working with WiFiSpi. The original sketch can be found here:
https://github.com/arduino-libraries/ArduinoMDNS/blob/master/examples/Ethernet/RegisteringServices/RegisteringServices.ino
I have adapted it to work with WiFiSpi and WiFiSpiUdp and it compiles fine, but after the mdns.addServiceRecord("Arduino mDNS Webserver Example._http", 80, MDNSServiceTCP);
line, the debug output of the Arduino (Due) is filled with these lines:
[espspi_proxy.h:329] W: Slave tx is not ready, status 0
[srvspi_drv.cpp:262] W: Error waitResponse
[espspi_proxy.h:329] W: Slave tx is not ready, status 0
[srvspi_drv.cpp:262] W: Error waitResponse
[espspi_proxy.h:329] W: Slave tx is not ready, status 0
[srvspi_drv.cpp:262] W: Error waitResponse
The sketch seems to stay in some kind of infinite loop repeating these messages.
Is WiFiSpiUdp (significantly) different from EthernetUDP, so that the mDNS library cannot be used with WiFiSpi? Or is this (hopefully) just a misconfiguration or bug that can be fixed?
Here's the test case:
// Illustrates how to register a Bonjour service.
#include <SPI.h>
#include "src/WiFiSpi/src/WiFiSpi.h"
#include "src/WiFiSpi/src/WiFiSpiUdp.h"
#include "src/ArduinoMDNS/ArduinoMDNS.h"
WiFiSpiUdp udp;
MDNS mdns(udp);
// you can find this written on the board of some Arduino Ethernets or shields
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char ssid[] = "WiFiNetwork"; // your network SSID (name)
char pass[] = "Password"; // your network password (use for WPA)
int status = WL_IDLE_STATUS;
WiFiSpiServer server(80);
void setup()
{
Serial.begin(115200);
Serial.println("Go...");
WiFiSpi.init();
if (WiFiSpi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
if (!WiFiSpi.checkProtocolVersion()) {
Serial.println("Protocol version mismatch. Please upgrade the firmware");
// don't continue:
while (true);
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open network:
status = WiFiSpi.begin(ssid, pass);
Serial.println(status);
if (status != WL_CONNECTED)
Serial.println("Cannot connect to AP.");
// don't continue if connection failed
}
delay(3000);
Serial.println("Connected to wifi");
Serial.println(WiFiSpi.localIP());
server.begin();
// Initialize the mDNS library. You can now reach or ping this
// Arduino via the host name "arduino.local", provided that your operating
// system is mDNS/Bonjour-enabled (such as MacOS X).
// Always call this before any other method!
mdns.begin(WiFiSpi.localIP(), "arduino");
// Now let's register the service we're offering (a web service) via mDNS!
// To do so, we call the addServiceRecord() method. The first argument is the
// name of our service instance and its type, separated by a dot. In this
// case, the service type is _http. There are many other service types, use
// google to look up some common ones, but you can also invent your own
// service type, like _mycoolservice - As long as your clients know what to
// look for, you're good to go.
// The second argument is the port on which the service is running. This is
// port 80 here, the standard HTTP port.
// The last argument is the protocol type of the service, either TCP or UDP.
// Of course, our service is a TCP service.
// With the service registered, it will show up in a Bonjour-enabled web
// browser. As an example, if you are using Apple's Safari, you will now see
// the service under Bookmarks -> Bonjour (Provided that you have enabled
// Bonjour in the "Bookmarks" preferences in Safari).
mdns.addServiceRecord("Arduino mDNS Webserver Example._http", 80, MDNSServiceTCP);
}
void loop()
{
// This actually runs the mDNS module. YOU HAVE TO CALL THIS PERIODICALLY,
// OR NOTHING WILL WORK! Preferably, call it once per loop().
mdns.run();
// The code below is just taken from the "WebServer" example in the Ethernet
// library. The only difference here is that this web server gets announced
// over mDNS, but this happens in setup(). This just displays something
// in the browser when you connect.
WiFiSpiClient client = server.available();
if (client) {
// an http request ends with a blank line
bool current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("Hello from a mDNS-enabled web-server running ");
client.println("on your Arduino board!");
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}
Hello Jiri,
After spending an entire day to find out why I can't get the ip address passed from my Mega2560 to my ESP8266 I was about to give up. But then I made a last attempt: What I found out is that the ip address is passed when I set all of the 4 parameters at once.
I.e. WifiSpi.config(local_ip) doesn't work but WifiSpi.config(local_ip, dns, gateway, subnet) works well.
I had a look at the WiFiSpi.h / WiFiSpi.cpp but I couldn't find out what goes wrong here.
Can you please have a look at this issue?
Best regards from Duesseldorf (Germany)
Michael
Hi, I compiled WiFiSpiESP(WiFiSPIESP.ino) to my Nodemcu(LoLin) and also compiled WiFiSPI(MQTT_Publish.ino) to my Arduino Mega 2560.
I repetitively got "WiFi module not present" in output. Do you have any idea whats wrong?
my wiring is like this :
Name: Nodemcu - Arduino Mega
SS: D8 - 53
MOSI: D7 - 51
MISO: D6 - 50
SCK: D5 - 52
3V arduino: Vin NodeMCU
GND arduino: Gnd NodeMCU
I have connected my Wemos D1 mini to the ISP connector on the Zero, SS to D10 and D1 to D7. The SPI never starts on the M0. I added: #include <SPI.h> and SPI.begin(); to the client app and the SPI now connects to the ESP8266 with no issues. Could you point me in the right direction to add this to your library or could you check to see why the SPI isn't starting on the M0.
Using a Teensy 3.6 (STM32F4) I'm getting some random timeouts on SPI access. Using the changes in the Development branch severely reduces this effect, and fixes the random TCP disconnects. However, this still happens sometimes, making transmission of time sensitive information unreliable.
Also, I'm using an SPI connection of 10MHz, but I have also tried with 1MHz, and this still happens. What should be the maximum speed for the library ?
Hi,
Is there a way that I'm not seeing of using SPI1 or SPI2 interfaces instead of SPI without altering the library?
If not, could this be considered?
Best regards
If a new (version of) sketch is uploaded or Serial Monitor resets the Arduino, the esp doesn't know and holds the unused connections.
If esp is reset and the master holds the SS HIGH, the esp doesn't boot (we know why). It is sometimes hard to get out of this state.
I would recommend to WiFiSpi library users to connect the reset pin of esp8266 to some pin of Arduino (level shifted) and add this code to setup() of the sketch before WiFiSpi.init():
pinMode(SS, OUTPUT);
digitalWrite(SS, LOW); // required boot state of the SS pin on esp8266
pinMode(ESP_RESET_PIN, OUTPUT);
digitalWrite(ESP_RESET_PIN, LOW); // low for reset
delay(5);
pinMode(ESP_RESET_PIN, INPUT); // let it to reset's pull-up circuit
delay(1000); // wait for esp to boot
or support it in init() with optional espResetPin parameter
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.