ESP8266 SPI WiFi Shield ("nice to have")

bilekj:
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 :slight_smile:

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.

gcampos:
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?

The SPI bus frequency is not critical at all. It works at 400 kHz as well as 9 MHz (tested on STM32F103).

Juraj:
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.

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 :slight_smile:

gcampos:
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

Juraj:
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 and here

Putting 52 in begin() made it work!

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

Juraj:
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

I set SS to low first line in setup(); so far no issues.

.

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.

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.

Hi, it looks like unterminated string. I'll look at it tomorrow.

Fixed in commit GitHub - JiriBilek/WiFiSpi at 4d12b26c8c5e80786d972e845f90f7bb858427b0
Please get new version of master library and try again.

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.

I looked at it now and for calling WiFiSpi.scanNetworks() you don't need to be connected.

Thanks for testing my library.

It was a my mistake, all OK.
Bye.

bilekj:
Fixed in commit GitHub - JiriBilek/WiFiSpi at 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?

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.

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.

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:

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:

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.

Oh, ok. So that explains why I don't see this lib as updateable. (I use and always have used the library manager)

Thanks.

Issued a request for adding the library to library manager, thanks for hint.