Arduino Forum

Development => Other Hardware Development => Topic started by: Juraj on Jan 25, 2018, 07:55 pm

Title: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Jan 25, 2018, 07:55 pm
There is a gap on the market. I couldn't find a WiFi shield with SPI connected ESP8266. It would be connected the same way like Ethernet shields and WiFi shield.

I know two libraries with standard arduino networking API (Server and Client implementation) which support SPI connection. The arduino.org's WiFi Link as used in Primo would need only a small #define modification for AVR. And today I found this WiFiSpi library and firmware (https://github.com/JiriBilek).
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: pert on Jan 26, 2018, 01:20 am
That WiFiSpi system looks nice.

I really like that the firmware is an Arduino sketch. I think that will make it much easier for people to install the firmware using the Arduino IDE compared to the headaches of trying to flash the AT firmware.  And of course this makes it so easy to read the firmware source code and make modifications.

The availability of a shield with the firmware already installed would make it even easier. Using AT commands is attractive when the ESP8266 ships with the AT firmware already installed.

I wonder how AT vs SPI compares in terms of overhead and performance?
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Jan 26, 2018, 06:48 am
WiFi Link firmware (https://github.com/jandrassy/arduino-firmware-wifilink/blob/master/README.md) is a sketch too. It has IoT configuration AP concept similar to PersWiFiManager, If the firmware connects to network, the Atmega sketch doesn't need to contain WiFi credentials. And it has Atmega sketch OTA Upload support, but it is not solved for SPI yet.

Of course, both features could by easy added to Jiri Bilek's library with WiFiManager and AVRISP (after solving the slave/master switching of SPI).

The SPI connection requires more wiring then the Serial connection. And more level shifters. So a shield would make it easy for beginners. (And the WiFi Link system requires one more connection for it's slaveReady signal.)

I trusted the statements on stackexchange about esp8266 gpio 5 V tolerance and did leave out the level shifters in my test setup. It works. The Wemos is fine. I wouldn't do that for permanent use, so the shield should have level shifting.

(https://github.com/jandrassy/arduino-firmware-wifilink/wiki/images/wemos-nano-spi.jpg)

And reset pin of Atmega should be connected too for AVRISP.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Jan 28, 2018, 05:09 pm
I solved the OTA AVR ISP for WiFiSpiESP firmware and Jiri accepted the pull request into a branch (https://github.com/JiriBilek/WiFiSpiESP/tree/OTA_AVR_ISP_(optional)).
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Jan 28, 2018, 06:05 pm
Hi,
I am glad you like the library.
The main goal was to substitute the buggy-by-nature serial communication with something more reliable. I tried several serial libraries using original AT firmware and at the end I am convinced the AT firmware is not suitable to make a reliable communication when the traffic is not negligible.

If you have any questions or comments, just write.

And big thanks to Juraj for (now still mysterious for me) piece of code :)
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Feb 12, 2018, 09:52 am
SPI connection with level conversion and mutual reset control (the white wire is needed only for WiFi Link firmware)

(https://github.com/jandrassy/arduino-firmware-wifilink/wiki/images/wemos-nano-ls-spi.jpg)


more here (https://github.com/jandrassy/arduino-firmware-wifilink/wiki/Test-Setup#spi-connection)



Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Jan 11, 2019, 11:18 am
Hi,
I am glad you like the library.
The main goal was to substitute the buggy-by-nature serial communication with something more reliable. I tried several serial libraries using original AT firmware and at the end I am convinced the AT firmware is not suitable to make a reliable communication when the traffic is not negligible.

If you have any questions or comments, just write.

And big thanks to Juraj for (now still mysterious for me) piece of code :)
Hello Jiri. Juraj

I am trying to use WiFiSpi inan Arduino DUE connected to a WeMos D1 mini pro wifi module.

I cannot get it to work.

Is the SAM architecture that different?
What can I try to tweak to make it work? Data rate divisor? (sam clock is 84MHz and usual divisor constants from AVR maybe do not work)
How can I get to this low level details?

Thanks for your help and support.

Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Jan 11, 2019, 11:24 am
Hello Jiri. Juraj

I am trying to use WiFiSpi inan Arduino DUE connected to a WeMos D1 mini pro wifi module.

I cannot get it to work.

Is the SAM architecture that different?
What can I try to tweak to make it work? Data rate divisor? (sam clock is 84MHz and usual divisor constants from AVR maybe do not work)
How can I get to this low level details?

Thanks for your help and support.


first of all - wiring? did you wire MISO, MOSI and clock to the SPI header? do you power the Wemos from Due 3.3 V pin?
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Jan 11, 2019, 11:55 am
The SPI bus frequency is not critical at all. It works at 400 kHz as well as 9 MHz (tested on STM32F103).
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Jan 11, 2019, 12:30 pm
first of all - wiring? did you wire MISO, MOSI and clock to the SPI header? do you power the Wemos from Due 3.3 V pin?
Yes, and SS pin too. (can SS be not wired?)

Power from separate LM1117-33; 800mA available.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Jan 11, 2019, 01:20 pm
You could turn on SPI debugging on ESP8266 app. In file SPICalls.cpp uncomment #define _DEBUG_SPICALLS.
But! The option turns on printing in ISR, and it is quite dangerous and should be used only to ensure the data are being read and transmitted. It could cause ESP resets and whatever bad you could imagine :)
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Jan 11, 2019, 01:36 pm
Yes, and SS pin too. (can SS be not wired?)

Power from separate LM1117-33; 800mA available.
which pin did you choose for SS on Due? did you set it with WiFiSpi.init()?

there is a small problem with esp8266 SS pin. If esp is reset and the master holds the SS HIGH, then esp doesn't boot (io 15 must be LOW at boot). my recommended solution is here (https://github.com/JiriBilek/WiFiSpi/issues/6)
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Jan 11, 2019, 05:33 pm
which pin did you choose for SS on Due? did you set it with WiFiSpi.init()?
I relied on the default being pin 52, as found here (http://forum.arduino.cc/index.php?topic=167068.0) and here (http://21stdigitalhome.blogspot.com/2013/02/arduino-due-hardware-spi.html)

Putting 52 in begin() made it work!

Thanks!!!!!!!!!!!!!!!!


there is a small problem with esp8266 SS pin. If esp is reset and the master holds the SS HIGH, then esp doesn't boot (io 15 must be LOW at boot). my recommended solution is here (https://github.com/JiriBilek/WiFiSpi/issues/6)
I set SS to low first line in setup(); so far no issues.

.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Jan 12, 2019, 12:31 pm
Working like a charm!!!  ;D  ;D  ;D

Now, I also found WiFiManager and managed to test it. VERY practical for 'first time setup', without changing the code every time.

I will definitely useit, hence my question:
How do I reset the last SSID so to have the wifimanager go into ConnectionAP from my application on DUE?

If I understood correctly, if the last SSID is not found, manager goes into AP automatically. This is OK if I "move" my device from on place to another, with a different wifi network.

What if I simply want to connect to a different wifi?
I would like to have a push button on my arduino DUE that would force WiFiManager (included in WiFiSpiESP, who is running on my WeMos D1) to forget the last wifi and go into ConnectionAP.


Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Jan 31, 2019, 08:52 pm
Library version: 2019-01-27
Hardware: Arduino DUE + Nodemcu 1.0

a)
I tested a little program to Scan the Network.
void setup()
{
  WiFiSpi.init();
...
    status = WiFiSpi.begin(ssid, pass);
...
}
void loop()
{
  int numSsid = WiFiSpi.scanNetworks();
...
}

As you can see below if, the name of SSID is more long then the previous,
in the next scan we have the short name filled with the exceeding chars,
in this case "GB".

Opening port
Port open
-- Attempting to connect to WPA SSID: ARDITO21
-- You're connected to the network
IP Address:      192.168.0.180
MAC:         F4:F2:1A:7F:CF:5C
BSSID:         88:74:53:89:26:80
-- Scan Networks
-- number of available networks:   2
0: ARDITO21   Signal: -53 dBm   Encryption: 8
1: 3Cube-50GB   Signal: -57 dBm   Encryption: 4
-- Scan Networks
-- number of available networks:   2
0: ARDITO21GB   Signal: -65 dBm   Encryption: 8
1: 3Cube-50GB   Signal: -57 dBm   Encryption: 4
-- Scan Networks
-- number of available networks:   2
0: ARDITO21GB   Signal: -66 dBm   Encryption: 8
1: 3Cube-50GB   Signal: -52 dBm   Encryption: 4



b)
In my applications, all use UDP, I have the following sequence:


1- WiFi.mode(WIFI_STA);
2- WiFi.disconnect();
3- ApSsidFound = WiFi.scanNetworks();
         select the AP with best signal
4- ApSsidS = WiFi.SSID(ApSsidSelect);
         then connect the AP
5- WiFi.config(ApIp, ApGateway, ApSubnet, ApDns);
6- WiFi.begin(ApSsid, ApPassword);
        at the end connect UDP
7- UDP.begin(UdpLocalPort) 

I was not able to find how to build the same sequence with WiFiSpi.
Thanks.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Jan 31, 2019, 10:13 pm
Hi, it looks like unterminated string. I'll look at it tomorrow.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 01, 2019, 01:42 pm
Fixed in commit https://github.com/JiriBilek/WiFiSpi/tree/4d12b26c8c5e80786d972e845f90f7bb858427b0 (https://github.com/JiriBilek/WiFiSpi/tree/4d12b26c8c5e80786d972e845f90f7bb858427b0)
Please get new version of master library and try again.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Feb 01, 2019, 03:43 pm
I tested the new version and WiFiSpi.scanNetworks() goes fine.

Referring to the point b) of my previous submit, there is a need of
    status = WiFiSpi.begin();
without (ssid, pass) or something else, to enable
    int numSsid = WiFiSpi.scanNetworks();
since I do not even know the name of the AP.

Thank you.

PS:In my house 4 AP are installed, the sensors are in every room (14).
They connect to the nearest AP.
The application of the sensors does not have the coded SSID.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 01, 2019, 04:54 pm
I looked at it now and for calling WiFiSpi.scanNetworks() you don't need to be connected.

Thanks for testing my library.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Feb 01, 2019, 06:45 pm
It was a my mistake, all OK.
Bye.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 04, 2019, 08:52 am
Fixed in commit https://github.com/JiriBilek/WiFiSpi/tree/4d12b26c8c5e80786d972e845f90f7bb858427b0 (https://github.com/JiriBilek/WiFiSpi/tree/4d12b26c8c5e80786d972e845f90f7bb858427b0)
Please get new version of master library and try again.
I have it installed, Arduino IDE does not let me reinstall the new master.
Shall I just unzip from github and overwrite?
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 04, 2019, 09:23 am
I suppose so, there is no need to "install" libraries, you have to copy them to the correct place only in order to be found by the compiler.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 04, 2019, 09:27 am
Thanks.

I try to follow Arduino IDE built in functions, because upgrades in time should be compatible, as opposed to doing "by hand" and then find that after an upgrade our sw does not compile - which is bad, but not tragic - or stops working... and that is serious trouble.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: pert on Feb 04, 2019, 09:54 am
The Arduino IDE's Library Manager does provide a convenient way to update libraries (as well as to install them). If the feature is enabled in preferences, the Arduino IDE even shows a notification when a new version of any installed library is available.

You can find more information on the Arduino Library Manager index here:
https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ (https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ)

The library is already 100% compliant with the requirements so the only thing that would need to be done is open an issue report at:
https://github.com/arduino/Arduino/issues/new (https://github.com/arduino/Arduino/issues/new)
Requesting the library to be added.



Library Manager does only allow you to update to the release versions of a library, so it is not so useful for beta testing the library in non-release states.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 04, 2019, 09:57 am
Oh, ok. So that explains why I don't see this lib as updateable. (I use and always have used the library manager)

Thanks.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 04, 2019, 10:50 am
Issued a request for adding the library to library manager, thanks for hint.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: pert on Feb 04, 2019, 10:54 am
I'm glad if I was able to be assistance. Judging from what I've seen of the library and the quality of your support on this thread, I think it will be a very welcome addition!
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 04, 2019, 10:55 am
I'm glad if I was able to be assistance. Judging from what I've seen of the library and the quality of your support on this thread, I think it will be a very welcome addition!
Kudos on that!!!!!
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Feb 04, 2019, 11:19 am
the Library Manager will not help to get the latest fixes. to update from GitHub, use git
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 04, 2019, 11:52 am
the Library Manager will not help to get the latest fixes.
What do you mean?
Every so often the Arduino IDE warns me of library updates, so why not?



to update from GitHub, use git
Is there info on using git?
Or you mean downloading by hand?
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 04, 2019, 12:04 pm
On github you can download the whole repository (actually only a selected branch) using the green button "Clone or download". You will get a .zip file with the files.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Feb 04, 2019, 12:41 pm
What do you mean?
Every so often the Arduino IDE warns me of library updates, so why not?



Is there info on using git?
Or you mean downloading by hand?

Library Manager offers new releases,  not partial fixes

google about git
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 04, 2019, 01:50 pm
Thanks.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 06, 2019, 01:32 pm
Fixed in commit https://github.com/JiriBilek/WiFiSpi/tree/4d12b26c8c5e80786d972e845f90f7bb858427b0 (https://github.com/JiriBilek/WiFiSpi/tree/4d12b26c8c5e80786d972e845f90f7bb858427b0)
Please get new version of master library and try again.
I re-downloaded the entire lib from the root - not from this commit - and although it had a few misfires the first couple of tries, now it seems to work fine.

I added a "ticker" to WiFiSpiESP so that it blinks while connecting to the wifi network and it blinks slowly if wifimanager is enabled and gets called. After connecting, the led goes steady.
If you think this is interesting, I can send you the .ino file to publish.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 06, 2019, 06:14 pm
@gcampos: it would be great to add an example to the library. Especially an example for wifimanager that, I admit, haven't time to try yet.
The best way would be to visit the github page of the WifiSPIESP project and add the example as a pull request.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 06, 2019, 06:21 pm
Fixed in commit https://github.com/JiriBilek/WiFiSpi/tree/4d12b26c8c5e80786d972e845f90f7bb858427b0 (https://github.com/JiriBilek/WiFiSpi/tree/4d12b26c8c5e80786d972e845f90f7bb858427b0)
Please get new version of master library and try again.
I am trying it out.
On my DUE I set up a client which connects to a server (my PC).
The Due is just waiting for PC to send data.

After some time I got the following error, just once, but the system is still running:

Quote
[espspi_proxy.h:329] W: Slave tx is not ready, status 0
I was not trying for time endurance, so I don't know exactly how long after last data exchange this happened, maybe 2 to 3 hours.

Any thoughts?
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 06, 2019, 07:01 pm
Status 0 means SPISLAVE_TX_NODATA, i.e. master requested data but ESP8266 didn't have any prepared for it. A quick look in the code gives the thought:
It could mean:
a) loss of a message in SPI communication. Then after a timeout master repeats the message.
b) slow response from the internet that leads to a timeout. Hopefully master got the data later.

I wasn't able to understand if the communication was broken from the point the "Slave not ready" message was written or if it continued to run. Changes in version 0.2.0 were made especially to increase robustness of message exchange.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Feb 06, 2019, 07:22 pm
@gcampos: it would be great to add an example to the library. Especially an example for wifimanager that, I admit, haven't time to try yet.
The best way would be to visit the github page of the WifiSPIESP project and add the example as a pull request.
Jiri, treti odstavec v https://github.com/JiriBilek/WiFiSpiESP/tree/OTA_AVR_ISP_(optional)#optional-ota-avr-isp
:-)
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 06, 2019, 09:45 pm
Jiri, treti odstavec v https://github.com/JiriBilek/WiFiSpiESP/tree/OTA_AVR_ISP_(optional)#optional-ota-avr-isp
:-)
Sorry, my linguistic skills are not enough1 :) :) :)
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 06, 2019, 09:57 pm
Status 0 means SPISLAVE_TX_NODATA, i.e. master requested data but ESP8266 didn't have any prepared for it. A quick look in the code gives the thought:
It could mean:
a) loss of a message in SPI communication. Then after a timeout master repeats the message.
b) slow response from the internet that leads to a timeout. Hopefully master got the data later.

I wasn't able to understand if the communication was broken from the point the "Slave not ready" message was written or if it continued to run. Changes in version 0.2.0 were made especially to increase robustness of message exchange.
When I saw the error message, I tried to send data from the server to Arduino and it received and displayed correctly.
That's why I think that the code on the DUE continued to run waiting for data, and communication was not broken, otherwise I would have other messages about reconnecting.

Here's the code:
Code: [Select]

void loop()
{
 
  if(!client.connected())
  {
       // if you get a connection, report back via serial:
      Serial.print(++count) ;
      Serial.print(" - Connecting to server: "); Serial.print(TARGET_ADDR);
      if(client.connect(TARGET_ADDR, TARGET_PORT))
      {
        Serial.println("... Connected!");
      }
      else
      {
        Serial.println("... Not connected!!!!");
        client.flush();
        client.stop();
        delay(2000);
        if(count>1000)
        {
          count=0;
          do
          {
            WiFiSpi.disconnect();
            Serial.print("\r\nAttempting to REconnect to network: "); Serial.println(ssid);
            // Connect to WPA/WPA2 network:
            status = WiFiSpi.begin(ssid, pass); // connect to specific network
            //status = WiFiSpi.begin("", ""); // connect to last succeffull connected network
            // wait 5 seconds for connection:
            delay(6000);
          }
          while(status != WL_CONNECTED);
        }
        // you're connected now, so print out the data:
        Serial.println("Connected to the network!");
      }
  }
 
  if(client.connected())
  {
    if(client.available())
    {
      Serial.println("\rFromServer---");
      while(client.available())
      {
        char c = client.read();
        Serial.write(c);
        delay(5);
      }
      Serial.println("\r\n--------------");
    }
    else
    {
       delay(20);
    }
  }
}
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 06, 2019, 10:03 pm
So then everything is as expected. An error in communication, either between master and ESP or between ESP and the internet. And the new protocol managed to sort it out :)
FYI, I added checksum to data messages and a trivial handshaking mechanism that can resubmit the message in case it had not been delivered properly.

Edit: I meant current v0.2.0
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 07, 2019, 05:37 pm
@gcampos: it would be great to add an example to the library. Especially an example for wifimanager that, I admit, haven't time to try yet.
The best way would be to visit the github page of the WifiSPIESP project and add the example as a pull request.
Done!
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 07, 2019, 05:46 pm
1)

Although I am using WiFiManager, it seems I must always connect with specific SSID and PASSWD in WiFiSpi.begin(ssid, pass).

I tried WiFiSpi.begin() and WiFiSpi.begin("", "") and this will give error.


This defeats the very purpose of WiFiManager itself.

How can start WiFiSpi when WiFiManager has already connected to the last network?


----


2)
WiFiManager will go into AP mode only if it does not find last connected SSID.

Is there a way to programmatically force it into AP mode, even if last SSID is available?

Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Feb 07, 2019, 05:47 pm
1)

Although I am using WiFiManager, it seems I must always connect with specific SSID and PASSWD in WiFiSpi.begin(ssid, pass).

I tried WiFiSpi.begin() and WiFiSpi.begin("", "") and this will give error.


This defeats the very purpose of WiFiManager itself.

How can start WiFiSpi when WiFiManager has already connected to the last network?
about that was the link 
"With WiFi Manager active, do not use WiFiSpi.begin() in the sketch. Only wait while WiFiSpi.status() != WL_CONNECTED."

2)
WiFiManager will go into AP mode only if it does not find last connected SSID.

Is there a way to programmatically force it into AP mode, even if last SSID is available?

from the sketch you could use WiFiSpi.disconnect() and then reset
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 07, 2019, 06:28 pm
about that was the link 
"With WiFi Manager active, do not use WiFiSpi.begin() in the sketch. Only wait while WiFiSpi.status() != WL_CONNECTED."
Thanks, it worked.
(you know engineers, they never RTFM... ;):):):) )



from the sketch you could use WiFiSpi.disconnect() and then reset
You mean soft reset the module (what is the command via WiFiSpi) or hard reset (I must wire one output from arduino to the reset pin of the ESP module)?

 
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: Juraj on Feb 07, 2019, 07:20 pm
You mean soft reset the module (what is the command via WiFiSpi) or hard reset (I must wire one output from arduino to the reset pin of the ESP module)?
reset is only to activate the WiFiManager in setup() of the firmware, so softReset() will do
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 08, 2019, 05:16 pm
@gcampos: thanks for your contribution, I have just merged a slightly reworked code. The main problem I found was the permanently lid LED after connecting. I think it is unnecessary.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Feb 08, 2019, 10:26 pm
I am trying the last release of WiFiESPSpi from GitHub with
//#define WIFIMANAGER_ENABLED
untouched.
The compiler shows same errors, not present in the previous release.
1-VisualMicro studio.
2-Arduino Due
3-Arduino IDE 1.8.9 2019/02/04


Compiling 'WiFiSpiESP' for 'NodeMCU 1.0 (ESP-12E Module)'
 
WiFiSpiESP.ino: 65:25: error: variable or field 'configModeCallback' declared void
   const char* PROTOCOL_VERSION = "0.2.0"
 
WiFiSpiESP.ino: 65:25: error: 'WiFiManager' was not declared in this scope
 
WiFiSpiESP.ino: 65:38: error: 'myWiFiManager' was not declared in this scope
   const char* PROTOCOL_VERSION = "0.2.0"
Error compiling project sources
Build failed for project 'WiFiSpiESP'


ameliaamelia
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 09, 2019, 09:19 am
Please check once more the file WiFiSPIEsp.ino. If you commented out the WIFIMANAGER_ENABLED define, there should be no wifimanager code needed.
I have correctly compiled the actual github version (master) for ESP8266 now.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Feb 09, 2019, 10:04 am
Found.
Using the Arduino IDE directly, all goes fine.
It seems that Visual Micro does not manage
#ifdef
kindly.
I will continue to investigate.

ameliaamelia
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Feb 09, 2019, 11:05 am
... continue

The Visual Micro requires to have the WiFiManager installed and included;
it verifies the
configModeCallback (line 80)
anyway, not taking into account the presence of the negative directive
#ifdef WIFIMANAGER_ENABLED
...
#endif


With the
WifiManager.h
always included, OK.
It's an issue that concerns the Visual Micro Team.

ameliaamelia
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Feb 09, 2019, 12:20 pm
Try to change #ifdef xxxx to #if defined(xxxx), it may work.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Feb 09, 2019, 02:33 pm
The #if defined (...) does not work.
Please see the reply at:
https://www.visualmicro.com/forums/YaBB.pl?num=1549707860 (https://www.visualmicro.com/forums/YaBB.pl?num=1549707860)
The suggested temporary solution does work.
ameliaamelia
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 11, 2019, 08:41 am
reset is only to activate the WiFiManager in setup() of the firmware, so softReset() will do
Thanks!
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: gcampos on Feb 11, 2019, 08:48 am
@gcampos: thanks for your contribution, I have just merged a slightly reworked code. The main problem I found was the permanently lid LED after connecting. I think it is unnecessary.
Thanks.

Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Mar 30, 2019, 10:06 am
Currently I use the function:
...
     if (true == WiFi.SSID(i).startsWith("NETWORK-NAME-PREFIX"))
      {
...

to select the network.
It would be very nice if it were implemented.
Thank you in advance.

ameliaamelia.
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Mar 30, 2019, 02:23 pm
Hi, ameliaamelia,
I wonder, what is the test good for?
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Mar 30, 2019, 03:40 pm
Just a make-up:

A-In the WiFiSpi module, I modified the parameters to maintain compatibility.

1-bool WiFiSpiClass :: config (IPAddress local_ip, IPAddress gateway, IPAddress dns_server) [row149]

2-bool WiFiSpiClass :: config (IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns_server) [row 157]
I just put the dns_server parameter as the last one.

B- In your examples there is the sequence

   while (! Udp.parsePacket () && (millis () - startMs) <UDP_TIMEOUT) {}

   // when there should be a packet do not call parsePacket () once more, call available () instead
   if (Udp.available ()) {


but when Udp.parsePacket () gives the result > 0, Udp.available () always gives the result = 0.
I removed Udp.available ()).

I am still in the testing phase to convert the whole network(20). I am waiting for the empty WiFiSpi card (for simplicity I used a NodeMCU 1.0) to replace the Arduino-Ethernet board..
Thanks again.

ameliaamelia
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Mar 30, 2019, 05:26 pm
In reply to:
"I wonder, what is the test good for?"

In my house(very large), I have several WiFi repeaters. I am using this function to select the dedicated access points; some are on internal-private network,others only on external pubblic network.
I temporaly used a strncmp(ssid,xxxxx,5).
Es. APINT01 APINT02 APEXTERN

ameliaamelia
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Mar 31, 2019, 11:52 pm
My tests.

Sessions of 60 messages sent/receive:

4Mhz
[wifispi_drv.cpp:262] W: Error waitResponse
[srvspi_drv.cpp:360] W: Error waitResponse
8Mhz
[espspi_proxy.h:219] W: Bad CRC, retransmitting
[espspi_proxy.h:329] W: Slave tx is not ready, status 0
[wifispi_drv.cpp:262] W: Error waitResponse
[espspi_proxy.h:261] W: Bad CRC, request repeated
[srvspi_drv.cpp:236] W: Error waitResponse
10Mhz
[espspi_proxy.h:219] W: Bad CRC, retransmitting
12Mhz
[srvspi_drv.cpp:360] W: Error waitResponse
[espspi_proxy.h:261] W: Bad CRC, request repeated
13Mhz
[espspi_proxy.h:329] W: Slave tx is not ready, status 0
[srvspi_drv.cpp:360] W: Error waitResponse
13.5Mhz
[espspi_proxy.h:219] W: Bad CRC, retransmitting
14Mhz not working ...

Response time 10-12ms, some 50ms.

Arduino DUE+NodeMCU 1.0.

ameliaamelia
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: bilekj on Apr 01, 2019, 08:12 am
Unfortunately, such errors happen. And their probability increases with the bus speed.
There is no relevant documentation to SPI registers in ESP8266 so it is hard to find out the timing errors.
Nevertheless, the protocol implemented over the SPI layer should be robust enough to survive the faults. The bad thing is that ESP8266 may lose incoming SPI message in some cases, one hypothesis is that the inner SPI controller misses the beginning of the transmission. I added a delay between SS down and start of the CLK but it doesn't cover all cases. See also: https://github.com/esp8266/Arduino/issues/5921
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Apr 01, 2019, 11:01 am
New test.

espspi_proxy.h:     delayMicroseconds(20); -> delayMicroseconds(xx);

8Mhz
delayMicroseconds(30);
Start:   No errors
Traffic: No errors
10Mhz
delayMicroseconds(30);
Start:   No errors
Traffic: No errors
delayMicroseconds(40);
Start:   No errors
Traffic: No errors
12Mhz
delayMicroseconds(30);
Start:   Some errors
Traffic: No errors
delayMicroseconds(40);
Start:   Some errors
Traffic: No errors
delayMicroseconds(50);
Start:   No errors
Traffic: No errors

The measured response time variations are negligible, so I will use 10Mhz with 50us.

ameliaamelia
Title: Re: ESP8266 SPI WiFi Shield ("nice to have")
Post by: ameliaamelia on Apr 08, 2019, 11:57 am
There are messages:
[espspi_proxy.h: 329] W: Slave tx is not ready, status 0

module espspi_proxy.h:
the _status after line 327 is 0x10.
Temporarily I changed the value of line 72 from 3000 to 50 to avoid a 3s timeout, my applications have a 100ms timeout.

ameliaamelia