Go Down

Topic: ESP8266 SPI WiFi Shield ("nice to have") (Read 5860 times) previous topic - next topic

Juraj

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.

pert

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?

Juraj

#2
Jan 26, 2018, 06:48 am Last Edit: Jan 26, 2018, 09:58 am by Juraj
WiFi Link firmware 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.



And reset pin of Atmega should be connected too for AVRISP.

Juraj

I solved the OTA AVR ISP for WiFiSpiESP firmware and Jiri accepted the pull request into a branch.

bilekj

#4
Jan 28, 2018, 06:05 pm Last Edit: Jan 28, 2018, 06:18 pm by 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 :)

Juraj

#5
Feb 12, 2018, 09:52 am Last Edit: Feb 19, 2018, 07:14 pm by Juraj
SPI connection with level conversion and mutual reset control (the white wire is needed only for WiFi Link firmware)




more here




gcampos

#6
Jan 11, 2019, 11:18 am Last Edit: Jan 11, 2019, 11:19 am by gcampos
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.


Juraj

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?

bilekj

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

gcampos

#9
Jan 11, 2019, 12:30 pm Last Edit: Jan 11, 2019, 01:00 pm by gcampos
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.

bilekj

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

Juraj

#11
Jan 11, 2019, 01:36 pm Last Edit: Jan 11, 2019, 02:55 pm by Juraj
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

gcampos

#12
Jan 11, 2019, 05:33 pm Last Edit: Jan 11, 2019, 05:35 pm by gcampos
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!!!!!!!!!!!!!!!!


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.

.

gcampos

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.



ameliaamelia

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.

Go Up