Error writing to I2C bus



  • @surya As @felmue says, they cannot both run from the Grove port.
    The DS18B20 is completely different and incompatible with I2C.
    It only needs 1 wire, so you may use the Power and Ground from the Grove and connect the DS18B20 signal pin to any-other-pin on the bottom of the AtomS3.



  • @teastain Thanks for the clarification!

    Yeah, I understood that these sensors likely use different communication protocols. Also, I attempted to use a different GPIO pin for the DS18B20, and it worked perfectly for me.

    Now, my only concern is my second script. Here, I'm using different ports for the ENV sensor and AtomPoE base in AtomS3. However, when I connect with the MQTT client, it breaks the ENV sensor's communication. Any advice is greatly appreciated!

    0_1708666315261_d62524c3-fdf8-4e9f-bec5-8de0ac674050-image.png



  • Have you check out my example in the Project zone as the MQTT has to be in a specific place in the code.



  • @ajb2k3

    I appreciate your input! Could you please share the link or specify the topic name related to the example you mentioned in the Project zone? I'm interested in diving deeper.



  • @surya https://uiflow2.m5stack.com/?pkey=c1c7d2ca888b497aab31505e1091adc6

    Another member on the forum was having difficulties so I shared the code I use for sending data over MQTT to my private server hosted on a CM4Stack.



  • @ajb2k3

    Thank you so much for sharing your work!

    Earlier, I successfully sent data over MQTT to AWS IoT Core in UIFlow2. However, in UIFlow2, I couldn't find a way to establish a (DHCP) Ethernet connection to AtomS3 using AtomPoE Base. That's why I decide to develop the code using PlatformIO. Do you have any reference Micropython script for an Ethernet connection?



  • Alas no as I don’t have one of those



  • Hello @Surya

    looking at your Arduino code I think a possible issue is the long delay of 10 seconds in loop() blocking client.loop(). You need to get rid of the long delay. How to periodically execute code without blocking is shown here.

    Thanks
    Felix



  • Hello @felmue

    I have already attempted a short delay, but unfortunately, that doesn't work for me. As for periodic code execution, I will give it a try.

    Thanks
    Surya



  • Oops, I forgot to share the error message. Here it is
    0_1708690342175_ed5ae410-5ec1-4881-a73d-af18d629b2f6-image.png



  • Hello @Surya

    after long hours of searching and debugging I found the reason why I2C would fail. It starts to fail as soon as SSL is invoked. The SSL library uses an analog GPIO as input for its random seed. And in your code you used GPIO2 which is one of M5AtomS3 Groove GPIOs.

    So to get rid of the I2C error try changing the GPIO used for random seed to GPIO10.

    //SSLClient ethClientSSL(ethClient, TAs, (size_t)TAs_NUM, 2);
    SSLClient ethClientSSL(ethClient, TAs, (size_t)TAs_NUM, GPIO_NUM_10);
    

    Thanks
    Felix



  • @felmue Laughed out loud, in brotherhood.
    Great job!



  • Hello @felmue

    I implemented the change using GPIO10 for the random seed, and the I2C issue seems to be resolved. Your help is greatly appreciated!

    Thank you for your fix!
    Surya