<?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[Core2 + Lan Module 13.2 + ENV IV help!]]></title><description><![CDATA[<p dir="auto">Hey guys,</p>
<p dir="auto">I have a Core2 with Lan module attached and an ENV IV unit plugged in.</p>
<p dir="auto">I'm trying to send the recorded data from the ENV IV sensors to a server by POST request</p>
<p dir="auto">I have succesfully ran an arduino example that collects data from both sensors and displays to the screen and to the serial monitor.<br />
<a href="https://github.com/m5stack/M5Unit-ENV/blob/master/examples/Unit_ENVIV_M5Core2/Unit_ENVIV_M5Core2.ino" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Unit-ENV/blob/master/examples/Unit_ENVIV_M5Core2/Unit_ENVIV_M5Core2.ino</a></p>
<p dir="auto">I have also successfully ran the following example that performs a GET and a POST request and displays the results.<br />
<a href="https://github.com/m5stack/M5Module-LAN-13.2/blob/main/examples/HTTP/HTTP.ino" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Module-LAN-13.2/blob/main/examples/HTTP/HTTP.ino</a></p>
<p dir="auto">Now I've attempted to combine the two and the below is what I've ended up with. The problem I'm facing is that it compiles ok, but only the bmp280 sensor gives any data, the SHT40 gives 'Error writing to I2C bus'. Can anyone see what I'm doing wrong or does the LAN module just block the SHT40 somehow?</p>
<p dir="auto">Serial:</p>
<pre><code>making GET request
Status code: 200
Response: {
  "args": {}, 
  "headers": {
    "Host": "httpbin.org", 
    "User-Agent": "Arduino/2.2.0", 
    "X-Amzn-Trace-Id": "Root=1-66574f8b-19e46aa01976708f76ff6811"
  }, 
  "origin": "81.96.198.248", 
  "url": "http://httpbin.org/get"
}

making POST request
Error trying to execute measureHighPrecision(): Error writing to I2C bus
,,99983.526679
</code></pre>
<p dir="auto">Code:</p>
<pre><code>#include &lt;M5Unified.h&gt;
#include &lt;Wire.h&gt;
#include &lt;M5GFX.h&gt;
#include &lt;SPI.h&gt;
#include &lt;M5Module_LAN.h&gt;
#include &lt;ArduinoHttpClient.h&gt;
#include &lt;SensirionI2cSht4x.h&gt;
#include &lt;Adafruit_BMP280.h&gt;
#include "Adafruit_Sensor.h"

#define THEME_COLOR 0x0760
#define SERVER "httpbin.org"
#define POST_INTERVAL 5000

Adafruit_BMP280 bmp;

SensirionI2cSht4x sht;

float temp, pressure, humd;
long lastTime = 0;

uint8_t cs_pin;
uint8_t rst_pin;
uint8_t int_pin;

int screen_height;
int screen_width;

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x89};

M5Module_LAN LAN;

M5Canvas canvas(&amp;M5.Display);

EthernetClient ethClient;

HttpClient client = HttpClient(ethClient, SERVER);

void setup() {
    M5.begin();
    M5.Display.begin();
    M5.Display.setTextColor(WHITE);
    M5.Display.setTextDatum(middle_center);
    M5.Display.setTextFont(&amp;fonts::FreeSansBoldOblique18pt7b);
    screen_height = M5.Display.height();
    screen_width  = M5.Display.width();
    while (!bmp.begin(0x76))
    { // Init this sensor,True if the init was successful, otherwise
      // false.
        M5.Lcd.println("Could not find a valid BMP280 sensor, check wiring!");
        Serial.println(F("BMP280 fail"));
    }
    uint16_t error;
    char errorMessage[256];
    Wire.begin();
    sht.begin(Wire, 0x44);

    uint32_t serialNumber;
    error = sht.serialNumber(serialNumber);
    if (error)
    {
        Serial.print("Error trying to execute serialNumber(): ");
        errorToString(error, errorMessage, 256);
        Serial.println(errorMessage);
    }
    else
    {
        Serial.print("Serial Number: ");
        Serial.println(serialNumber);
    }

    bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                    Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                    Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                    Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                    Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
    
    Serial.print("Serial initialized...");
    M5.Lcd.clear();

    M5.Display.fillSmoothRoundRect(2, 2, screen_width - 4, 36, 4, THEME_COLOR);
    M5.Display.drawString("Wait For Ethernet", screen_width / 2, 22);

    M5.Display.drawRoundRect(2, 40, screen_width - 4, 192, 4, THEME_COLOR);

    canvas.createSprite(280, 160);
    canvas.setTextColor(WHITE);
    canvas.setTextFont(&amp;fonts::FreeSansBoldOblique9pt7b);
    canvas.setTextScroll(true);
    canvas.setTextSize(0.5);

    cs_pin  = 33;
    rst_pin = 0;
    int_pin = 35;

    SPI.begin(SCK, MISO, MOSI, -1);

    LAN.setResetPin(rst_pin);
    LAN.reset();
    LAN.init(cs_pin);

    while (LAN.begin(mac) != 1) {
        Serial.println("Error getting IP address via DHCP, trying again...");
        delay(2000);
    }

    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
        Serial.println(
            "Ethernet shield was not found.  Sorry, can't run without "
            "hardware. :(");
        while (true) {
            delay(1);  // do nothing, no point running without Ethernet hardware
        }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
        Serial.println("Ethernet cable is not connected.");
    }
}

String t,h,p;

void loop() {
    Serial.println("making GET request");
    canvas.println("making GET request");
    canvas.pushSprite(20, 55);

    client.get("/get");
    // read the status code and body of the response
    int statusCode  = client.responseStatusCode();
    String response = client.responseBody();

    Serial.print("Status code: ");
    Serial.println(statusCode);
    Serial.print("Response: ");
    Serial.println(response);

    M5.Display.fillSmoothRoundRect(2, 2, screen_width - 4, 36, 4, THEME_COLOR);
    M5.Display.drawString("HTTP POST", screen_width / 2, 22);

    uint16_t error;
    char errorMessage[256];

    error = sht.measureHighPrecision(temp, humd);
    if (error)
    {
        Serial.print("Error trying to execute measureHighPrecision(): ");
        errorToString(error, errorMessage, 256);
        Serial.println(errorMessage);
    }
    else
    {
        t = String(temp);
        h = String(humd);
    }

    pressure = bmp.readPressure();
    p = String(pressure);

    Serial.print(t+","+h+","+p);
    
    String contentType = "text/plain";
    String postData    = String("ServerRoom,temp="+t+",humidity="+h);
    Serial.println(millis() - lastTime);
    if (millis() - lastTime &gt; POST_INTERVAL) {
        lastTime = millis();

        Serial.println("making POST request");
        canvas.println("making POST request");
        canvas.pushSprite(20, 55);
        delay(1000);
        
        error = client.post("/post", contentType, postData);
        if (error){
          Serial.print("error during POST:");
          Serial.println(error);
        }

        // read the status code and body of the response
        statusCode = client.responseStatusCode();
        response   = client.responseBody();

        Serial.print("Status code: ");
        Serial.println(statusCode);
        Serial.print("Response: ");
        Serial.println(response);

        canvas.print("Status code: ");
        canvas.println(statusCode);
        canvas.print("Response: ");
        canvas.println(response);
        canvas.pushSprite(20, 55);
        Serial.println("Wait five seconds");

    }
    delay(1000);
}

</code></pre>
]]></description><link>https://community.m5stack.com/topic/6512/core2-lan-module-13-2-env-iv-help</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Mar 2026 05:19:57 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6512.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 May 2024 16:08:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Core2 + Lan Module 13.2 + ENV IV help! on Fri, 31 May 2024 10:25:38 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/118308">@FlooidOps</a></p>
<p dir="auto">I am glad to hear you figured it out. And sorry for not being more specific about how to switch to the alternate GPIO.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/25432</link><guid isPermaLink="true">https://community.m5stack.com/post/25432</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 31 May 2024 10:25:38 GMT</pubDate></item><item><title><![CDATA[Reply to Core2 + Lan Module 13.2 + ENV IV help! on Fri, 31 May 2024 08:33:26 GMT]]></title><description><![CDATA[<p dir="auto">thanks <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a>,<br />
I made the change in the code which didnt work. Then I happened to glance over the docs page for the LAN module and spot that there is a little piece of plastic that you can move in order to change which pin the module is using!<br />
<img src="/assets/uploads/files/1717143066660-978c2dd2-2128-476b-9541-03a249a0fa01-image.png" alt="978c2dd2-2128-476b-9541-03a249a0fa01-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">This probably isnt new to some of you but I cant see anywhere that details this feature other than this small image at the top of the page for the LAN module<br />
<a href="https://docs.m5stack.com/en/module/LAN%20Module%2013.2" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/module/LAN Module 13.2</a></p>
<p dir="auto">I've successfully made a POST request with data from both sensors now, what a relief!</p>
]]></description><link>https://community.m5stack.com/post/25430</link><guid isPermaLink="true">https://community.m5stack.com/post/25430</guid><dc:creator><![CDATA[FlooidOps]]></dc:creator><pubDate>Fri, 31 May 2024 08:33:26 GMT</pubDate></item><item><title><![CDATA[Reply to Core2 + Lan Module 13.2 + ENV IV help! on Thu, 30 May 2024 19:12:17 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/118308">@FlooidOps</a></p>
<p dir="auto">yes, that pretty sure is your issue. Have you tried to switch to the alternate GPIO for Ethernet CS, e.g. GPIO2 (instead of GPIO 33)?</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/25429</link><guid isPermaLink="true">https://community.m5stack.com/post/25429</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Thu, 30 May 2024 19:12:17 GMT</pubDate></item><item><title><![CDATA[Reply to Core2 + Lan Module 13.2 + ENV IV help! on Wed, 29 May 2024 19:08:48 GMT]]></title><description><![CDATA[<p dir="auto">I think it may be because the I2C port uses GPIO 33 for SCL, and the Lan module also uses it for 'CS'. Can anyone comment on this?</p>
]]></description><link>https://community.m5stack.com/post/25426</link><guid isPermaLink="true">https://community.m5stack.com/post/25426</guid><dc:creator><![CDATA[FlooidOps]]></dc:creator><pubDate>Wed, 29 May 2024 19:08:48 GMT</pubDate></item></channel></rss>