🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    ENV sensor calibration

    Modules
    4
    13
    21.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      charlestondance
      last edited by

      Well that is not much use then!

      Is the problem the supplier or the device or the code?

      If the offset is the same within a certain range surely you could just subtract a constant? the issue is i have no way to measure humidity and pressure independently.

      ajb2k3A 1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3 @charlestondance
        last edited by

        @charlestondance I suppose you can try using the maths blocks but I have to ask (don't take this personally) are you sure your how thermostat is calibrated?

        In UIFlow, the temperature is returned as a value and so you can add that to a maths block as a variable number.
        Below is a quick code test (sorry had to retrieve the kit from the office/studio.alt text

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        W 1 Reply Last reply Reply Quote 0
        • W
          Wolli01 @ajb2k3
          last edited by

          @ajb2k3 Yes, the humidity results are really bad.
          How can I e.g. connect my own sensor SHT series?
          On my Pycom Wipy I have something like this running successfully.
          I like to set the code to change it for M5Stack.

          1 Reply Last reply Reply Quote 0
          • ajb2k3A
            ajb2k3
            last edited by

            Connecting the sensor depends on many things like operating characteristics.
            Can you post a link to the sensor you are looking at?
            Sometime its just a case of plug and play, sometimes its a case of hacing some code.

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            W 1 Reply Last reply Reply Quote 0
            • W
              Wolli01 @ajb2k3
              last edited by

              @ajb2k3
              https://www.sensirion.com/en/environmental-sensors/humidity-sensors/digital-humidity-sensors-for-various-applications/

              Of these I have the SHT 20/21 and the SHT 30/31 on my
              Pycom Wipy/Lopy are doing well.

              1 Reply Last reply Reply Quote 0
              • lukasmaximusL
                lukasmaximus
                last edited by

                @Wolli01 The sensor you sent us a link to, is it on a breakout board with pinouts? and is it possible to communicate with it via i2c?

                W 1 Reply Last reply Reply Quote 0
                • W
                  Wolli01 @lukasmaximus
                  last edited by

                  @lukasmaximus Yeah, no problems.
                  Enclosed the code that runs in Wipy over Python.

                  SHT31.PY
                  from machine import I2C
                  import time

                  R_HIGH = const(1)
                  R_MEDIUM = const(2)
                  R_LOW = const(3)

                  class SHT31(object):
                  """
                  Diese Klasse implementiert eine Schnittstelle zur SHT31 Temperatur und Luftfeuchtigkeit.
                  Sensor von Sensirion.
                  """
                  # Diese statische Karte hilft, den Heap und die Programmlogik sauber zu halten.
                  _map_cs_r = {
                  True: {
                  R_HIGH : b'\x2c\x06',
                  R_MEDIUM : b'\x2c\x0d',
                  R_LOW: b'\x2c\x10'
                  },
                  False: {
                  R_HIGH : b'\x24\x00',
                  R_MEDIUM : b'\x24\x0b',
                  R_LOW: b'\x24\x16'
                  }
                  }

                  def __init__(self, i2c, addr=0x44):
                      """
                      Initialisiert ein Sensorobjekt auf dem angegebenen I2C-Bus, auf das von der
                      angegebene Adresse.
                      """
                      if i2c == None or i2c.__class__ != I2C:
                          raise ValueError('I2C-Objekt als Argument benötigt!')
                      self._i2c = i2c
                      self._addr = addr
                  
                  def _send(self, buf):
                      """
                      Sendet das angegebene Pufferobjekt über I2C an den Sensor.
                      """
                      self._i2c.writeto(self._addr, buf)
                  
                  def _recv(self, count):
                      """
                      Lesen von Bytes vom Sensor über I2C. Die Anzahl der Bytes kann angegeben werden.
                      als Argument.
                      Liefert ein Bytearray für das Ergebnis.
                      """
                      return self._i2c.readfrom(self._addr, count)
                  
                  def _raw_temp_humi(self, r=R_HIGH, cs=True):
                      """
                      Lesen Sie die Rohtemperatur und Luftfeuchtigkeit vom Sensor ab und überspringen Sie CRC. Überprüfung.
                      Liefert ein Tupel für beide Werte in dieser Reihenfolge.
                      """
                      if r not in (R_HIGH, R_MEDIUM, R_LOW):
                          raise ValueError('Falscher Wiederholbarkeitswert angegeben!')
                      self._send(self._map_cs_r[cs][r])
                      time.sleep_ms(50)
                      raw = self._recv(6)
                      return (raw[0] << 8) + raw[1], (raw[3] << 8) + raw[4]
                  
                  def get_temp_humi(self, resolution=R_HIGH, clock_stretch=True, celsius=True):
                      """
                      Lesen Sie die Temperatur in Grad Celsius oder Fahrenheit und relativ dazu ab.
                      Feuchtigkeit. Auflösung und Taktverlängerung können festgelegt werden.
                      Liefert ein Tupel für beide Werte in dieser Reihenfolge.
                      """
                      t, h = self._raw_temp_humi(resolution, clock_stretch)
                      if celsius:
                          temp = -45 + (175 * (t / 65535.0))
                      else:
                          temp = -49 + (315 * (t / 65535.0))
                      return temp, 100 * (h / 65535.0)
                  

                  Main.PY
                  #Sensor SHT31-----------------------------------------------------------
                  if (Sensorwahl) == 'sht31':

                  i2c = I2C(0, I2C.MASTER, baudrate=100000)
                  sensor = sht31.SHT31(i2c, addr=0x44)
                  temp_humi = sensor.get_temp_humi()
                  time.sleep(0.6)
                  
                  pycom.rgbled(0xff007f) # magenta
                  pycom.heartbeat(False) #Lampe ausschalten um Energie zu sparen
                  
                  Temp1 = round(temp_humi[0],2)
                  Feuchte1 = round(temp_humi[1],2)
                  time.sleep(1)
                  
                  print('----------------------------------------------------------------------')
                  print("Ohne Runden = Temperature: {} °C | Humidity: {} %".format(temp_humi[0], temp_humi[1]))
                  print('----------------------------------------------------------------------')
                  
                  #Übergabe der Sensorwerte---------------------------------------
                  Temp1 = (Temp1 + 0) #Übergabe und Differenzeingabe
                  Feuchte1 = (Feuchte1 + 0) #Übergabe und Differenzeingabe
                  #Übergabe der Sensorwerte---------------------------------------
                  

                  #Sensor SHT31-----------------------------------------------------------

                  1 Reply Last reply Reply Quote 0
                  • lukasmaximusL
                    lukasmaximus
                    last edited by

                    The I2c implementation in UIflow firmware is a little weird, I think if you were to flash the standard micropython firmware and put the necessary libraries on there this would work fine.

                    W 2 Replies Last reply Reply Quote 0
                    • W
                      Wolli01 @lukasmaximus
                      last edited by

                      @lukasmaximus Yes, I thought about that, but how do I get the display to work? I can't cope with that.

                      1 Reply Last reply Reply Quote 0
                      • W
                        Wolli01 @lukasmaximus
                        last edited by

                        @lukasmaximus
                        Where can I find instructions how to integrate the M5Stack libraries into the MicroPython standard software on a M5Stack Core Grey/Black.

                        1 Reply Last reply Reply Quote 0
                        • lukasmaximusL
                          lukasmaximus
                          last edited by

                          You need to use a command line program called ampy to move the libraries across. This guy wrote a guide in which he used the standard micropython firmware and added his own libraries https://www.hackster.io/andreas-motzek/execute-logo-on-m5stack-esp32-basic-with-micropython-3713fd

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post