Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Balta
    3. Posts
    B
    • Continue chat with Balta
    • Start new chat with Balta
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Balta

    • RE: Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite

      Thanks for all the great responses.

      I actually figure it out. I knew that my sensors were working because I could get the same code to work when using a ESP8266. I'm currently using GPIO25 for my 5 DS18B20 temperature sensors and I'm also using a 4.7 Ohm resistor as suggested by Dallas. At first, I could not see any sensor. After some thinkering, I was able to get the mac addresses of all 5 sensors with the Atom Lite but the temperature was ALWAYS 85. Googling for 85, someone said that we have to wait 750 ms after calling sensors.requestTemperatures();

        sensors.requestTemperatures();
        delay(750);  // This seems critical to get the sensors to work with AtomLite
      

      Then I can proceed to get the temperatures like so. Note that this only illustrates the spirit of what needs to be done and I haven't tested the exact code that follows.

      #include <M5Atom.h>
      #include <OneWire.h>
      #include <DallasTemperature.h>
      
      // GPIO where the DS18B20 is connected to
      const uint8_t oneWireBus = GPIO_NUM_25;
      
      // Setup a oneWire instance to communicate with any OneWire devices
      OneWire oneWire(oneWireBus);
      
      // Pass our oneWire reference to Dallas Temperature sensor
      DallasTemperature sensors(&oneWire);
      
      void setup() {
        M5.begin(true, false, true);  // But I need to test without this line.
        sensors.begin();
      }
      
      
      void loop() {
        sensors.requestTemperatures();
        delay(750);  // This seems critical to get the sensors to work with AtomLite
      
        const unsigned int num_DS18B20 = sensors.getDeviceCount();
      
        for (unsigned int i=0; i<num_DS18B20; ++i) {
          DeviceAddress mac;
          sensors.getAddress(mac, i);
          delay(10);
          const float temperature = sensors.getTempCByIndex(i);
          send_MQTT(mac, temperature);
          }
        }
        delay(10000);
      }
      

      I hope that this information will be useful for someone else trying to hookup some DS18B20 to an Atom Lite.

      posted in Atom
      B
      Balta
    • RE: Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite

      @felmue Thanks for your help.
      I've tried your suggestion of adding

      #include <M5Atom.h>
      ...
      M5.begin(true, false, true);
      

      And I was getting 85 which, according to a google search, means there is an error but I can see the mac addresses of all my 5 probes. What bothers me is that looking at the code of M5.begin(true, false, true); and according to your previous comment, I skip the I2C initialization which I was already doing before adding that line since I wasn't calling Wire.begin(25,21,10000);. I really don't see what would help my I2C problem. By adding M5.begin(true, false, true);, the only thing I add is initializing the display which I don't have on my atom lite.

      I've tried essentially the same code with my nodemcu, the same DS18B20 sensors and I can read the mac addresses and all 5 temperature no problem.

      I also have a Feather Huzzah esp8266 and a Feather Huzzah 32 esp32 that I will try out later.

      Could it be that the atom lite is not providing enough mA to the sensors?

      posted in Atom
      B
      Balta
    • Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite

      Hi,
      I'm trying to attach a DS18B20 (5 pcs, 3 meter), temperature sensors working with oneWire. I can't seem to get any reading on an Atom Matrix.

      Here's a short version of my code.

      #include <Arduino.h>
      #include <OneWire.h>
      #include <DallasTemperature.h>
      
      // GPIO where the DS18B20 is connected to
      const uint8_t oneWireBus = ONEWIREBUS;
      
      // Setup a oneWire instance to communicate with any OneWire devices
      OneWire oneWire(oneWireBus);
      
      // Pass our oneWire reference to Dallas Temperature sensor
      DallasTemperature sensors(&oneWire);
      
      float DS18B20_temperature = -100.0;
      
      void setup() {
        sensors.begin();
      }
      
      void loop() {
        sensors.requestTemperatures();
        const float temperature = sensors.getTempCByIndex(0);
        Serial.println(temperature);
        const unsigned int num_DS18B20 = sensors.getDeviceCount();
        Serial.printf("Number of DS18B20: %d\n", num_DS18B20);
        for (unsigned int i=0; i<num_DS18B20; ++i) {
          DeviceAddress mac;
          sensors.getAddress(mac, i);
          const float temperature = sensors.getTempCByIndex(i);
          Serial.println(temperature);
        }
      }
      

      I have tested my breadboard setup and the code with a NodeMCU and using a NodeMCU I can get the temperatures. When using my NodeMCU, I make sure to use the default SDA pin for it to work.

      I googled around and I can find multiple posts that claim that we can use almost any pin as SDA so I wonder how I can change GPIO25 to be SDA on an Atom Lite?

      In this post, EXT.IO Unit and UIFlow 1.4.5.1, there is comment hinting that 3 meter long wires could be too long and that 100cm is the longest at most.

      posted in Atom
      B
      Balta