<?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[Initiate an action with Button A or B]]></title><description><![CDATA[<p dir="auto">I would like to have it so a get request with arguments gets run when an action is made, for example pressing button A or B. I'm new with M5stickC and don't know how to do that.<br />
This is the code for sending a SMS with a delay... but executing a API call with a button is unknown for me...</p>
<pre><code> #include &lt;M5StickC.h&gt;
 #include &lt;Arduino.h&gt;
 #include &lt;WiFi.h&gt;
 #include &lt;WiFiMulti.h&gt;
 #include &lt;HTTPClient.h&gt;
 #define USE_SERIAL Serial

WiFiMulti wifiMulti;

void setup() {

USE_SERIAL.begin(115200);

USE_SERIAL.println();
USE_SERIAL.println();
USE_SERIAL.println();

for(uint8_t t = 4; t &gt; 0; t--) {
    USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
    USE_SERIAL.flush();
    delay(1000);
}

wifiMulti.addAP("xxxxx", "xxxxxx");

}

void loop() {
// wait for WiFi connection
if((wifiMulti.run() == WL_CONNECTED)) {

    HTTPClient http;

    USE_SERIAL.print("[HTTP] begin...\n");
    // configure traged server and url

      http.begin("https://api.46elks.com/a1/sms");
      http.addHeader("Content-Type", "application/x-www-form-urlencoded"); 
      http.setAuthorization("xxxxx", "xxxxxx");
      int httpCode = http.POST("from=+xxxxx&amp;to=+xxxxxx&amp;message=Hej");


    USE_SERIAL.print("[HTTP] GET...\n");
    // start connection and send HTTP header
     httpCode = http.GET();

    // httpCode will be negative on error
    if(httpCode &gt; 0) {
        // HTTP header has been send and Server response header has been handled
        USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

        // file found at server
        if(httpCode == HTTP_CODE_OK) {
            String payload = http.getString();
            USE_SERIAL.println(payload);
        }
    } else {
        USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
    }

    http.end();
}

delay(10000);
}
</code></pre>
]]></description><link>https://community.m5stack.com/topic/1883/initiate-an-action-with-button-a-or-b</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 03:11:25 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/1883.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Apr 2020 23:20:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Initiate an action with Button A or B on Thu, 23 Apr 2020 15:38:06 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the reply<br />
Found the tutorial too!<br />
<a href="http://forum.m5stack.com/topic/42/lesson-2-buttons-menu" target="_blank" rel="noopener noreferrer nofollow ugc">http://forum.m5stack.com/topic/42/lesson-2-buttons-menu</a></p>
]]></description><link>https://community.m5stack.com/post/8325</link><guid isPermaLink="true">https://community.m5stack.com/post/8325</guid><dc:creator><![CDATA[rbrakus]]></dc:creator><pubDate>Thu, 23 Apr 2020 15:38:06 GMT</pubDate></item><item><title><![CDATA[Reply to Initiate an action with Button A or B on Thu, 23 Apr 2020 02:57:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rbrakus" aria-label="Profile: rbrakus">@<bdi>rbrakus</bdi></a></p>
<pre><code>  if (M5.BtnA.wasPressed()) {
           ......
  }
  M5.update();
</code></pre>
]]></description><link>https://community.m5stack.com/post/8322</link><guid isPermaLink="true">https://community.m5stack.com/post/8322</guid><dc:creator><![CDATA[m5stack]]></dc:creator><pubDate>Thu, 23 Apr 2020 02:57:02 GMT</pubDate></item></channel></rss>