<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[controlling relay HELP!!!!!]]></title><description><![CDATA[<p dir="auto">im trying to control a relay using the m5stickc plus2 on g26</p>
<p dir="auto">This is my code:</p>
<p dir="auto">from M5 import *  # Correct import for M5StickC in UIFlow 2.0<br />
import time</p>
<h1>Set GPIO pin for relay control (changed to GPIO 26)</h1>
<p dir="auto">RELAY_PIN = 26  # GPIO 26 for relay control</p>
<h1>Initialize the relay pin as an output</h1>
<p dir="auto">relay_pin = M5.Pin(RELAY_PIN, M5.Pin.OUT)  # Correct way to initialize the pin</p>
<h1>Function to turn on relay</h1>
<p dir="auto">def turn_on_relay():<br />
relay_pin.value(1)  # Set relay pin to HIGH (turn on)</p>
<h1>Function to turn off relay</h1>
<p dir="auto">def turn_off_relay():<br />
relay_pin.value(0)  # Set relay pin to LOW (turn off)</p>
<h1>Main loop</h1>
<p dir="auto">while True:<br />
try:<br />
# Check if button A is pressed<br />
if buttonA.isPressed():<br />
turn_on_relay()  # Turn on relay when button A is pressed<br />
lcd.fill(0)  # Clear the screen<br />
lcd.text(50, 50, "Relay ON", color=lcd.WHITE, font=FONT_Default)<br />
else:<br />
turn_off_relay()  # Turn off relay when button A is not pressed<br />
lcd.fill(0)  # Clear the screen<br />
lcd.text(50, 50, "Relay OFF", color=lcd.WHITE, font=FONT_Default)</p>
<pre><code>    time.sleep(0.1)  # Small delay to avoid overwhelming the system
except Exception as e:
    lcd.fill(0)  # Clear the screen on error
    lcd.text(50, 50, f"Error: {e}", color=lcd.WHITE, font=FONT_Default)
    time.sleep(2)  # Wait for a moment before trying again
</code></pre>
<p dir="auto">this is the error im getting on uiflow2.0</p>
<p dir="auto">Connected to Serial Port!</p>
<p dir="auto">MicroPython v1.24.0-dirty on 2024-12-20; M5STACK StickC PLUS2 with ESP32(SPIRAM)<br />
Type "help()" for more information.</p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">E (287120) i2c: i2c driver install error<br />
E (287136) time: The current date/time in Shanghai is: Wed Jan  1 02:35:08 2025<br />
E (287246) wifi:NAN WiFi stop<br />
E (287248) transport_base: poll_read select error 113, errno = Software caused connection abort, fd = 54<br />
E (287249) mqtt_client: Poll read error: 119, aborting connection<br />
[INFO] Syncing resources...<br />
[INFO] WiFi connected!<br />
Traceback (most recent call last):<br />
File "<a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow ugc">main.py</a>", line 6, in &lt;module&gt;<br />
NameError: name 'M5' isn't defined<br />
MicroPython v1.24.0-dirty on 2024-12-20; M5STACK StickC PLUS2 with ESP32(SPIRAM)<br />
Type "help()" for more information.</p>
</blockquote>
</blockquote>
</blockquote>
]]></description><link>https://community.m5stack.com/topic/7139/controlling-relay-help</link><generator>RSS for Node</generator><lastBuildDate>Wed, 13 May 2026 04:15:37 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7139.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Jan 2025 02:39:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to controlling relay HELP!!!!! on Mon, 17 Feb 2025 08:08:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a><br />
Hello, I'm going to tell you everything I know and have tried so far.<br />
I'm experiencing an issue with my M5 Hard devices. A few months ago, I purchased a couple of M5 Hard units for an MQTT data transmission project. I developed it in UIFlow 2, and everything worked perfectly.</p>
<p dir="auto">Recently, I bought more M5 Hard devices to expand the project, but now I’m facing a problem: when I install the firmware and try to connect them to WiFi, they won’t connect. I have tried the following without success:</p>
<p dir="auto">Reinstalling the USB drivers on my computer.<br />
Resetting the device to factory settings.<br />
Reinstalling the firmware.<br />
Trying different WiFi networks.<br />
Temporarily disabling the firewall and antivirus.<br />
Using different firmware versions.<br />
Checking the router configuration and connection parameters.<br />
Despite all these attempts, I still cannot connect them to WiFi. I’m getting the following error:</p>
<p dir="auto">arduino<br />
Copiar<br />
Editar<br />
E (328401) wifi: sta is connecting, return error<br />
Traceback (most recent call last):<br />
File "&lt;stdin&gt;", line 19, in &lt;module&gt;<br />
File "&lt;stdin&gt;", line 12, in setup<br />
OSError: Wifi Internal Error<br />
Additionally, I’m also getting this error:</p>
<p dir="auto">nginx<br />
Copiar<br />
Editar<br />
E (328338) i2c: i2c driver install error<br />
I don’t believe this is a network issue (firewall, antivirus, etc.) because, as I mentioned earlier, I have successfully programmed and connected other devices without any issues.</p>
<p dir="auto">I would really appreciate any suggestions or help.</p>
]]></description><link>https://community.m5stack.com/post/28244</link><guid isPermaLink="true">https://community.m5stack.com/post/28244</guid><dc:creator><![CDATA[sat-informatica]]></dc:creator><pubDate>Mon, 17 Feb 2025 08:08:27 GMT</pubDate></item><item><title><![CDATA[Reply to controlling relay HELP!!!!! on Fri, 14 Feb 2025 12:55:18 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/sat-informatica" aria-label="Profile: sat-informatica">@<bdi>sat-informatica</bdi></a></p>
<p dir="auto">below code works for me:</p>
<pre><code>import network

wlan = network.WLAN(network.STA_IF)
wlan.connect('SSID', 'Password')
label0.setText(str('Connecting...'))
while not (wlan.isconnected()):
  pass
label0.setText(str('Connected'))
</code></pre>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/28223</link><guid isPermaLink="true">https://community.m5stack.com/post/28223</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 14 Feb 2025 12:55:18 GMT</pubDate></item><item><title><![CDATA[Reply to controlling relay HELP!!!!! on Fri, 14 Feb 2025 11:20:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a>  hola he visto  que ayuda mucho a la comunidad.<br />
¿Podria ayudarme a saber porque me sale este error?<br />
estoy intentando conectar mi m5 tough a mi wifi pero me sale el siguiente error<br />
E (328421) wifi:NAN WiFi stop<br />
este es mi codigo<br />
import network</p>
<p dir="auto">wlan = network.WLAN(network.STA_IF)<br />
wlan.active(True)</p>
<h1>Borra configuraciones anteriores</h1>
<p dir="auto">wlan.disconnect()<br />
wlan.active(False)<br />
wlan.active(True)<br />
wlan.connect("TRC2021", "UoU@%0r3t6QON6ua")<br />
if wlan.isconnected():<br />
print("Conectado a WiFi con IP:", wlan.ifconfig()[0])<br />
else:<br />
print("No se pudo conectar a WiFi")</p>
]]></description><link>https://community.m5stack.com/post/28222</link><guid isPermaLink="true">https://community.m5stack.com/post/28222</guid><dc:creator><![CDATA[sat-informatica]]></dc:creator><pubDate>Fri, 14 Feb 2025 11:20:17 GMT</pubDate></item><item><title><![CDATA[Reply to controlling relay HELP!!!!! on Wed, 01 Jan 2025 05:37:27 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/eaglefpv" aria-label="Profile: EagleFPV">@<bdi>EagleFPV</bdi></a></p>
<p dir="auto">please have a look at the example I've just created in UIFlow2 Project Zone called: <em>M5StickCPlus2_GPIO26_On_Off_UIFlow2.2.0</em></p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/27668</link><guid isPermaLink="true">https://community.m5stack.com/post/27668</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 01 Jan 2025 05:37:27 GMT</pubDate></item></channel></rss>