Jump to content

Component: WLAN (ESP32) (Comms: Networking): Difference between revisions

From Flowcode Help
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(8 intermediate revisions by 3 users not shown)
Line 36: Line 36:


==Examples==
==Examples==
===Weather Predictor===


Here is an example of a next-day weather predictor that also shows the current-day weather for a ESP32 embedded device  
Here is an example of a next-day weather predictor that also shows the current-day weather for a ESP32 embedded device  
Line 42: Line 44:


{{Fcfile|ESP32_TTGO_Weather_Forecast_Predictor.fcfx|ESP32 weather predictor}}
{{Fcfile|ESP32_TTGO_Weather_Forecast_Predictor.fcfx|ESP32 weather predictor}}
===User Configurable Network Details===
When creating a product using an ESP32 device it is important that it can connect to the network of the person buying the product.
This is complicated as the ESP32 requires that the network SSID and password be defined by the user and this requires a means of getting the data into the ESP32 device.
Luckily as the ESP32 features the ability to host it's own network we can use this to create a simple web interface where the user can enter their network details.
{{Fcfile|ESP32_Config_Wifi.fcfx|ESP32 Config WIFI}}
More info on this available here [https://www.flowcode.co.uk/forums/viewtopic.php?f=10&t=634 Flowcode Forums - User Configurable Network Details]


==Macro reference==
==Macro reference==


===AcceptClose===
===AcceptClose===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AcceptClose'''
| width="90%" class="mtx-class-macrohead" | '''AcceptClose'''
|-
|-
| colspan="2" | Close the socket associated with the Accepted incoming connection 
| colspan="2" | Close the socket associated with the Accepted incoming connection 
Line 60: Line 77:


===AcceptOpen===
===AcceptOpen===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AcceptOpen'''
| width="90%" class="mtx-class-macrohead" | '''AcceptOpen'''
|-
|-
| colspan="2" | Returns 1 if there is an incoming connection on the listening port 
| colspan="2" | Returns 1 if there is an incoming connection on the listening port 
Line 74: Line 91:


===ConnectToSSID===
===ConnectToSSID===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ConnectToSSID'''
| width="90%" class="mtx-class-macrohead" | '''ConnectToSSID'''
|-
|-
| colspan="2" | Attempts to connect to the given SSID and Key values.  Returns 1 if the SSID has been connected.  
| colspan="2" | Attempts to connect to the given SSID and Key values.  Returns 1 if the SSID has been connected.  
Line 103: Line 120:


===CreateAccessPoint===
===CreateAccessPoint===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateAccessPoint'''
| width="90%" class="mtx-class-macrohead" | '''CreateAccessPoint'''
|-
|-
| colspan="2" | Sets up the wireless LAN module into AP mode to host a wireless network. Other WIFI enabled devices can then connect to the module. Returns 1 for success. 
| colspan="2" | Sets up the wireless LAN module into AP mode to host a wireless network. Other WIFI enabled devices can then connect to the module. Returns 1 for success. 
Line 137: Line 154:


===Disconnect===
===Disconnect===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Disconnect'''
| width="90%" class="mtx-class-macrohead" | '''Disconnect'''
|-
|-
| colspan="2" | Attempts to disconnect from the SSID.  
| colspan="2" | Attempts to disconnect from the SSID.  
Line 151: Line 168:


===Initialise===
===Initialise===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" | Initialise the WiFi system Returns 1 if successful Returns 0 if not 
| colspan="2" | Initialise the WiFi system Returns 1 if successful Returns 0 if not 
Line 165: Line 182:


===ReadEncryptionModeFromScan===
===ReadEncryptionModeFromScan===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadEncryptionModeFromScan'''
| width="90%" class="mtx-class-macrohead" | '''ReadEncryptionModeFromScan'''
|-
|-
| colspan="2" | Collects one of the encryption modes from the last SSID Scan. The ScanForSSID macro must be called first. 0=Open, 1=WEP, 2=WPA_PSK, 3=WPA2_PSK, 4=WPA_WPA2_PSK 
| colspan="2" | Collects one of the encryption modes from the last SSID Scan. The ScanForSSID macro must be called first. 0=Open, 1=WEP, 2=WPA_PSK, 3=WPA2_PSK, 4=WPA_WPA2_PSK 
Line 184: Line 201:


===ReadIP===
===ReadIP===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadIP'''
| width="90%" class="mtx-class-macrohead" | '''ReadIP'''
|-
|-
| colspan="2" | Collects a single byte from the local IP address. For example 192.168.0.1 Index = 3 : Return = 192 / Index = 0 : Return = 1 
| colspan="2" | Collects a single byte from the local IP address. For example 192.168.0.1 Index = 3 : Return = 192 / Index = 0 : Return = 1 
Line 203: Line 220:


===ReadIPString===
===ReadIPString===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadIPString'''
| width="90%" class="mtx-class-macrohead" | '''ReadIPString'''
|-
|-
| colspan="2" | Collects the local IP address and returns it as an ASCII string. e.g. "192.168.0.1" 
| colspan="2" | Collects the local IP address and returns it as an ASCII string. e.g. "192.168.0.1" 
Line 217: Line 234:


===ReadSSIDFromScan===
===ReadSSIDFromScan===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadSSIDFromScan'''
| width="90%" class="mtx-class-macrohead" | '''ReadSSIDFromScan'''
|-
|-
| colspan="2" | Collects one of the SSID name strings from the last SSID Scan. The ScanForSSID macro must be called first. 
| colspan="2" | Collects one of the SSID name strings from the last SSID Scan. The ScanForSSID macro must be called first. 
Line 236: Line 253:


===ReadSignalStrengthFromScan===
===ReadSignalStrengthFromScan===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadSignalStrengthFromScan'''
| width="90%" class="mtx-class-macrohead" | '''ReadSignalStrengthFromScan'''
|-
|-
| colspan="2" | Collects the signal strength from the last SSID Scan. The ScanForSSID macro must be called first. Value returned is in negative dB, smaller value = better signal 
| colspan="2" | Collects the signal strength from the last SSID Scan. The ScanForSSID macro must be called first. Value returned is in negative dB, smaller value = better signal 
Line 255: Line 272:


===ScanForSSID===
===ScanForSSID===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ScanForSSID'''
| width="90%" class="mtx-class-macrohead" | '''ScanForSSID'''
|-
|-
| colspan="2" | Checks for wireless networks in the local area which are broadcasting their SSID. Must not be connected to a network to allow this to function. Returns the number of wireless networks found, max 8. 
| colspan="2" | Checks for wireless networks in the local area which are broadcasting their SSID. Must not be connected to a network to allow this to function. Returns the number of wireless networks found, max 8. 
Line 269: Line 286:


===SocketClose===
===SocketClose===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SocketClose'''
| width="90%" class="mtx-class-macrohead" | '''SocketClose'''
|-
|-
| colspan="2" |  
| colspan="2" |  
Line 283: Line 300:


===SocketConnect===
===SocketConnect===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SocketConnect'''
| width="90%" class="mtx-class-macrohead" | '''SocketConnect'''
|-
|-
| colspan="2" |  
| colspan="2" |  
Line 307: Line 324:


===SocketListen===
===SocketListen===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SocketListen'''
| width="90%" class="mtx-class-macrohead" | '''SocketListen'''
|-
|-
| colspan="2" | Listen on, or bind, local port to already opened socket. Returns 1 if OK, 0 if fail 
| colspan="2" | Listen on, or bind, local port to already opened socket. Returns 1 if OK, 0 if fail 
Line 326: Line 343:


===SocketOpen===
===SocketOpen===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SocketOpen'''
| width="90%" class="mtx-class-macrohead" | '''SocketOpen'''
|-
|-
| colspan="2" | Returns 1 if socket sucessfully opened 
| colspan="2" | Returns 1 if socket sucessfully opened 
Line 340: Line 357:


===SocketRead===
===SocketRead===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SocketRead'''
| width="90%" class="mtx-class-macrohead" | '''SocketRead'''
|-
|-
| colspan="2" |  
| colspan="2" |  
Line 364: Line 381:


===SocketWrite===
===SocketWrite===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SocketWrite'''
| width="90%" class="mtx-class-macrohead" | '''SocketWrite'''
|-
|-
| colspan="2" |  
| colspan="2" |  
Line 388: Line 405:


===Uninitialise===
===Uninitialise===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Uninitialise'''
| width="90%" class="mtx-class-macrohead" | '''Uninitialise'''
|-
|-
| colspan="2" | Shuts down the WiFi system  for low power operation. Returns 1 if successful  Returns 0 if not 
| colspan="2" | Shuts down the WiFi system  for low power operation. Returns 1 if successful  Returns 0 if not 
Line 403: Line 420:
==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-
Line 412: Line 429:
| width="90%" | Verbose Debug
| width="90%" | Verbose Debug
|-
|-
| colspan="2" |  
| colspan="2" | Provides verbose debugging output via hardware UART channel 1 which is often connected to a UART to USB bridge.  
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | SSID Scan Size
|-
| colspan="2" | Maximum number of SSIDs that can be detailed from a single SSID network scan. Default 8 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
|-
|-

Latest revision as of 14:37, 13 July 2026

Author Matrix Ltd.
Version 2.4
Category Comms: Networking


WLAN (ESP32) component

Wireless LAN component designed to work with ESP32 modules

Component Source Code

Please click here to download the component source project: FC_Comp_Source_WLAN_ESP32.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_WLAN_ESP32.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Weather Predictor

Here is an example of a next-day weather predictor that also shows the current-day weather for a ESP32 embedded device

It uses the BBC weather component via Netwoekcomms and WLAN ESP32 components to connect to the BBC server and retrieve the weather forecast for the specified area code.

ESP32 weather predictor


User Configurable Network Details

When creating a product using an ESP32 device it is important that it can connect to the network of the person buying the product.

This is complicated as the ESP32 requires that the network SSID and password be defined by the user and this requires a means of getting the data into the ESP32 device.

Luckily as the ESP32 features the ability to host it's own network we can use this to create a simple web interface where the user can enter their network details.

ESP32 Config WIFI


More info on this available here Flowcode Forums - User Configurable Network Details

Macro reference

AcceptClose

AcceptClose
Close the socket associated with the Accepted incoming connection 
- VOID Return


AcceptOpen

AcceptOpen
Returns 1 if there is an incoming connection on the listening port 
- BYTE Return


ConnectToSSID

ConnectToSSID
Attempts to connect to the given SSID and Key values. Returns 1 if the SSID has been connected.  
- STRING SSID
 
- STRING Key
 
- BYTE Timeout
Number of seconds to wait for the connection, default 20 
- BYTE Return


CreateAccessPoint

CreateAccessPoint
Sets up the wireless LAN module into AP mode to host a wireless network. Other WIFI enabled devices can then connect to the module. Returns 1 for success. 
- STRING SSID
Name of the wireless network to create 
- STRING Password
Password used to gain access to the network 
- BYTE Channel
802.11 Channel Range 1-14 
- BYTE Encryption
0=Open, 1=WEP, 2=WPA_PSK, 3=WPA2_PSK, 4=WPA_WPA2_PSK 
- BYTE Return


Disconnect

Disconnect
Attempts to disconnect from the SSID.  
- BYTE Return


Initialise

Initialise
Initialise the WiFi system Returns 1 if successful Returns 0 if not 
- BYTE Return


ReadEncryptionModeFromScan

ReadEncryptionModeFromScan
Collects one of the encryption modes from the last SSID Scan. The ScanForSSID macro must be called first. 0=Open, 1=WEP, 2=WPA_PSK, 3=WPA2_PSK, 4=WPA_WPA2_PSK 
- BYTE Index
SSID Index 
- BYTE Return


ReadIP

ReadIP
Collects a single byte from the local IP address. For example 192.168.0.1 Index = 3 : Return = 192 / Index = 0 : Return = 1 
- BYTE Index
Range: 0 to 3 Where 3 = the first number and 0 = the last number 
- BYTE Return


ReadIPString

ReadIPString
Collects the local IP address and returns it as an ASCII string. e.g. "192.168.0.1" 
- STRING Return


ReadSSIDFromScan

ReadSSIDFromScan
Collects one of the SSID name strings from the last SSID Scan. The ScanForSSID macro must be called first. 
- BYTE Index
SSID Index 
- STRING Return


ReadSignalStrengthFromScan

ReadSignalStrengthFromScan
Collects the signal strength from the last SSID Scan. The ScanForSSID macro must be called first. Value returned is in negative dB, smaller value = better signal 
- BYTE Index
SSID Index 
- INT Return


ScanForSSID

ScanForSSID
Checks for wireless networks in the local area which are broadcasting their SSID. Must not be connected to a network to allow this to function. Returns the number of wireless networks found, max 8. 
- BYTE Return


SocketClose

SocketClose
 
- VOID Return


SocketConnect

SocketConnect
 
- STRING Address
 
- UINT Port
 
- BYTE Return


SocketListen

SocketListen
Listen on, or bind, local port to already opened socket. Returns 1 if OK, 0 if fail 
- UINT Port
 
- BYTE Return


SocketOpen

SocketOpen
Returns 1 if socket sucessfully opened 
- BYTE Return


SocketRead

SocketRead
 
- STRING Buffer
 
- UINT Size
 
- UINT Return


SocketWrite

SocketWrite
 
- STRING Buffer
 
- UINT Size
 
- UINT Return


Uninitialise

Uninitialise
Shuts down the WiFi system for low power operation. Returns 1 if successful Returns 0 if not 
- BYTE Return


Property reference

Properties
Verbose Debug
Provides verbose debugging output via hardware UART channel 1 which is often connected to a UART to USB bridge.  
SSID Scan Size
Maximum number of SSIDs that can be detailed from a single SSID network scan. Default 8 
Simulation
Network Interface
List of network interfaces connected to the PC. Sets which interface we are communicating via. 
Console Data
Generate Console Data