Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. dollychun
    D
    • Continue chat with dollychun
    • Start new chat with dollychun
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    dollychun

    @dollychun

    0
    Reputation
    3
    Posts
    475
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    dollychun Follow

    Posts made by dollychun

    • RE: Using G33 analogRead while connected to Wi-Fi

      @felmue said in Using G33 analogRead while connected to Wi-Fi:

      Have you confirmed that reading GPIO33 works again if you comment out the WiFi code? Maybe adding that isn't the cause that made reading GPIO33 stop working?

      Yes. I have confirmed that it works when I remove the Wifi code...
      I will try this with another atom...

      posted in Atom
      D
      dollychun
    • RE: Using G33 analogRead while connected to Wi-Fi

      @felmue Heres my code

      #include "M5Atom.h"
      #include "WiFi.h"
      
      int analogIn = 33;
      
      const char* ssid       = "PatoWiFi";
      const char* password   = "PatoWifi_Password";
      
      WiFiClient client;
      
      void setup() {
        // put your setup code here, to run once:
        M5.begin(true, false, true);
        Serial.begin(115200);
        pinMode(analogIn, INPUT);
        WiFi.begin(ssid, password);
        Serial.print("Connecting to WiFi");
        while(WiFi.status()!=WL_CONNECTED) {
          delay(500);
          Serial.print(".");
        }
        Serial.print("OK");
        Serial.print("\r\nWiFi connected\r\nIP address: ");
        Serial.println(WiFi.localIP());
        client.connect("www.someurl.com", 80);
        Serial.println("sending data to server");
        client.println("POST / HTTP/1.1");
        client.println("Host: www.someurl.com");
        client.println("User-Agent: ESP32/M5Atom");
        client.println("Accept */*");
        client.println();
        
        unsigned long timeout = millis();
        while (client.available() == 0) {
          if (millis() - timeout > 5000) {
            Serial.println(">>> Client Timeout !");
            client.stop();
          }
        }
      
        Serial.println("receiving from remote server");
        // not testing 'client.connected()' since we do not need to send data here
        while (client.available()) {
          char ch = static_cast<char>(client.read());
          Serial.print(ch);
        }
      
        // Close the connection
        Serial.println();
        Serial.println("closing connection");
        client.stop();
        
        WiFi.disconnect();
      }
      
      void loop() {
        // put your main code here, to run repeatedly:
        int val = analogRead(analogIn); // Always return 4095
        Serial.printf("AnalogRead = %d\n", val);
        delay(100);
      }
      
      posted in Atom
      D
      dollychun
    • Using G33 analogRead while connected to Wi-Fi

      First of all, this is my first post so please let me know if there is problem


      So I thought I'd do an analog read with the G33 pin, but it worked fine at first, but when I added the code to do the wifi communication, the G33 analog read always returned 4098.

      I searched and found that using ADC2 with analogread during wifi communication always returns 4098, but the G33 pin is ADC1.

      I don't know what's wrong, please help!

      posted in Atom
      D
      dollychun