M5Module-LAN-13.2
M5Module-LAN-13.2
0
Project description
README for HTTP.ino
File Description:
- File Name: HTTP.ino
- Author: SeanKwok (shaoxiang@m5stack.com)
- Date: 2023-10-26
- Version: 0.1
- Description: This is an example demonstrating how to make HTTP requests using the M5Stack board and LAN Module 13.2.
Supported Hardware:
- M5Core/Core2/CoreS3 + LAN Module 13.2
Platform Version:
- Arduino M5Stack Board Manager v2.0.7
Dependencies:
- M5_Ethernet: Github Repository
- ArduinoHttpClient: Github Repository
- M5Unified: Github Repository
- M5GFX: Github Repository
Functionality Overview:
- The code initializes the M5 display and sets up the LAN module.
- It continuously checks for a valid Ethernet connection and initializes the Ethernet client.
- Performs an HTTP GET request to
httpbin.org/getand displays the status code and response on the M5 display. - Waits for five seconds.
- Performs an HTTP POST request to
httpbin.org/postwith sample data and displays the status code and response on the M5 display. - Waits for five seconds before repeating the loop.
README for LinkStatus.ino
File Description:
- File Name: LinkStatus.ino
- Author: SeanKwok (shaoxiang@m5stack.com)
- Date: 2023-10-26
- Version: 0.1
- Description: This code is designed to periodically check the Ethernet link status on an M5Stack board equipped with a LAN Module 13.2. It displays the status on the M5Stack's screen.
Supported Hardware:
- M5Core/Core2/CoreS3 + LAN Module 13.2
Platform Version:
- Arduino M5Stack Board Manager v2.0.7
Dependencies:
- M5_Ethernet: Github Repository
- M5Unified: Github Repository
- M5GFX: Github Repository
Functionality Overview:
- Initializes the M5 display with relevant configurations and displays "Wait For Ethernet".
- Identifies the specific M5 board type and sets the appropriate pins.
- Initializes the LAN module and attempts to retrieve an IP address via DHCP.
- The loop function then checks the Ethernet link status every 500ms:
- If the link status is unknown, it displays "Wait For Ethernet".
- If the link is on, it displays the assigned IP address.
- If the link is off, it displays "OFF".
README for MQTT.ino
Include Necessary Libraries:
- The necessary libraries for M5Stack display and graphics are included.
- Libraries for SPI and Ethernet (for the LAN Module) are included.
- PubSubClient library is included for MQTT functionalities.
Predefined Values:
- The MAC address, theme color, publish interval, publish and subscribe topics are defined.
Global Variable Declarations:
- Pins for Chip Select (CS), Reset (RST), and Interrupt (INT) are defined.
- Screen dimensions are initialized.
- Instances for the LAN module, M5Canvas, and MQTT client are created.
MQTT Callback Function:
- Whenever a message is received on the subscribed topic, the callback function is triggered. It prints the received message on both the Serial monitor and the M5Stack's display.
MQTT Reconnect Function:
- If the client gets disconnected from the MQTT server, this function attempts to reconnect. Once connected, it sends a "hello world" message and subscribes to the designated topic.
Setup Function:
- Initializes the M5Stack display settings.
- Initializes the LAN module and connects to the network via DHCP.
- Checks for the presence of Ethernet hardware and link status.
- Sets up the MQTT client to connect to the server and designates the callback function.
Loop Function:
- Constantly checks the MQTT connection and reconnects if disconnected.
- Publishes a message at a predefined interval.
- Displays published data on the M5Stack's screen.
Overall, this code demonstrates a simple MQTT client implementation on the M5Stack device using the LAN module for network connectivity. The device publishes messages at regular intervals and listens for incoming messages on a particular topic, displaying all messages on its screen.
README for WebServer.ino.ino
Overview
This example demonstrates how to set up a web server using the M5Stack platform and LAN Module 13.2. Users can access the M5Stack through a web browser and will be greeted with a "Hello M5Stack LAN Module!" message.
Required Hardware
- M5Core/Core2/CoreS3
- LAN Module 13.2
Platform Version
- Arduino M5Stack Board Manager v2.0.7
Required Libraries
- M5_Ethernet: GitHub Link
- M5Unified: GitHub Link
- M5GFX: GitHub Link
Installation & Usage
- Install the libraries mentioned above.
- Set up your M5Stack platform and the LAN module.
- Upload the provided code to the Arduino IDE.
- Once uploaded, the IP address will be displayed on the M5Stack screen.
- Access the displayed IP address using a web browser.
Notes
- If Ethernet hardware is not found or the Ethernet cable isn't connected, error messages will be displayed.