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

    Where did ADC go in V1.1.2?

    Bug Report
    3
    14
    20.4k
    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.
    • world101W
      world101
      last edited by

      After some trial and error, I figured it out. A few changes I made:

      • Removed the "Set pin" block. This allowed the flow to compile without error.
      • Connected the ADJ pin (black) to VCC instead of GND per the sensor datasheet.
      • Added an audible tone function to the flow so a song will play when the liquid is detected.
      • Updates to the UI interface

      0_1548511932915_Screen Shot 2019-01-26 at 8.39.26 AM.png

      I'm still not sure why the ADC causes an error when the Set pin block is inserted. @heybin or @watson, perhaps you can look into that.

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

        All I can tell you is that ADC only works through the ADC pins on the base plate,
        The Grove port on the Core and gray is a digital i2C port.
        I'm still experimenting with a home-made rotation sensor

        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!

        world101W 1 Reply Last reply Reply Quote 0
        • world101W
          world101
          last edited by

          Here is a video: https://youtu.be/zWNDvSm6klk

          1 Reply Last reply Reply Quote 0
          • world101W
            world101 @ajb2k3
            last edited by

            @ajb2k3 said in Where did ADC go in V1.1.2?:

            All I can tell you is that ADC only works through the ADC pins on the base plate,
            The Grove port on the Core and gray is a digital i2C port.
            I'm still experimenting with a home-made rotation sensor

            I'm using GPIO5 on the base (bottom) of the M5stack grey core. I haven't received my Grove cables yet, but once I do, I plan to test this on the M5stack fire as well.

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

              @world101 The M5Go and M5 fire use Port B for analog sensors but don't have the I/O base that the Core and Gray have.

              As a followup, the units will work on the core via the adc pins 35&36

              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!

              world101W 1 Reply Last reply Reply Quote 0
              • world101W
                world101 @ajb2k3
                last edited by world101

                @ajb2k3

                I'm not looking to use the ADC blockly functionality in my flow above. The sensor I have can be considered a digital sensor. It only reports low (0V) or high (VCC) when capacitance is detected from a liquid. So I'm using digital pin functions within uiFlow.

                I'm just pointing out the fact that uiFlow is missing a bunch of blockly functions that I think were there in v1.1.1, but are gone in v1.1.2. Looking at your manual I see these under the Advanced menu. The ones in bold are missing from v1.1.2 of uiFLow. This might be the cause of my errors with the Set pin blockly function I was using in my first post flow. Not sure???

                Advanced,
                Pin,
                Analog Pin Write,
                Analog Pin Read,
                Digital Pin Read,
                Digital Pin Write,
                Set Pin Mode,
                Map Pin,
                GPIO,
                Set Pin Out of Pin,
                Set Pin In,
                Set Pin Out,
                Set Val to Pin In Value
                PWM,
                Set PWM of Pin,
                Set PWM Frequency,
                Set PWM Duty Cycle,
                ADC,
                Set ADC Pin to Value,
                Set Item,
                Set ADC Pin Bit Width,
                Read ADC Pin,

                DAC,
                Set Dac,
                Write Value to Dac,
                UART,
                Set Uart,
                Read Uart,
                Read Uart (0) Characters,
                Read a Line of Uart,
                Read Uart and Write to Buffer,
                Read Uart Status?,
                Write Value to Uart,
                I2C,
                Set I2C in Port,
                I2C Scan Available,
                I2C Address (0) is Ready,
                I2C Read Address (0) count (0),
                I2C Read Address (0) Reg (0) Count (0),
                I2C Read Address (0) One Byte,
                I2C Read Address (0) Reg (0) One Byte,
                Execute,
                Execute Code,
                Network,
                WIFI Connect,
                MQTT,
                MQTT Setup,
                MQTT Subscribe,
                MQTT Start,
                Get Topic Data,
                Publish Topic,

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

                  Thank you for checking out my handbook, I'm glad to see that is proving useful so far.
                  And thank you for pointing out the missing code blocks.

                  Out of curiosity can you share any pics and information on your sensors?
                  0 or 1 values from a water sensor?
                  (don't shout at me because I know you said not blocky, however,)
                  According to the M5 Documentation, the Earth Sensor Unit is a water sensor that has a variable input and outputs both analog and digital values.
                  Would you mind testing the earth sensor blocks on your sensor and let me know the outcome for my handbook please?

                  Ok back to the subject of alternative code use, again using the earth sensor,
                  in mycropython you can try

                  from m5stack import *
                  from m5ui import *
                  import units
                  
                  clear_bg(0x111111)
                  adc0 = units.get(units.adc,units.PORTA)
                  earth0 = units.Earth(units.PORTA)
                  
                  
                  
                  btnA = M5Button(name="ButtonA", text="ButtonA", visibility=False)
                  btnB = M5Button(name="ButtonB", text="ButtonB", visibility=False)
                  btnC = M5Button(name="ButtonC", text="ButtonC", visibility=False)
                  label0 = M5TextBox(136, 127, "Text", lcd.FONT_Default, 0xFFFFFF)
                  
                  
                  while True:
                    label0.setText(str(earth0.a_read()))
                    wait(0.001)
                  

                  or

                  
                  from m5stack import *
                  from m5ui import *
                  import units
                  
                  clear_bg(0x111111)
                  adc0 = units.get(units.adc,units.PORTA)
                  earth0 = units.Earth(units.PORTA)
                  
                  
                  
                  btnA = M5Button(name="ButtonA", text="ButtonA", visibility=False)
                  btnB = M5Button(name="ButtonB", text="ButtonB", visibility=False)
                  btnC = M5Button(name="ButtonC", text="ButtonC", visibility=False)
                  label0 = M5TextBox(136, 127, "Text", lcd.FONT_Default, 0xFFFFFF)
                  
                  
                  while True:
                    label0.setText(str(earth0.d_read()))
                    wait(0.001)
                  

                  Please can you try this and let me know the outcome please?

                  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!

                  world101W 1 Reply Last reply Reply Quote 0
                  • world101W
                    world101 @ajb2k3
                    last edited by

                    @ajb2k3

                    I would try your tests, but unfortunately, I don't have the Earth sensor from M5stack. I have a few things on order (Relay unit, hexagon neopixel unit, etc.), but the Earth unit is not one of them. I only have the water sensor I linked in my first post, model XKC-Y25-V. It's not from m5stack. Here is a link to a better datasheet.

                    http://www.naylampmechatronics.com/img/cms/Datasheets/XKC Y25 T12V.pdf

                    I just wire it straight to my m5stack core using jumper wires. The yellow wire goes to GPIO5 on the bottom of my m5stack grey.
                    0_1548640690032_IMG_1314.JPG

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

                      Apparently those blocks have now all been moved into the pin section, you can set the pwm duty within the analog write block and there is a block for setting a pin to in or out etc.. I cant see the adc bit width equivalent block anywhere. As i'm not too familiar with the functions of those blocks I never used them so please let me know if these reassigned blocks give the same function or not.

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

                        @world101 Ah, sorry for the misunderstanding, I don't mean test the actual earth sensor, I mean can you test the code with your sensor, please?

                        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!

                        world101W 1 Reply Last reply Reply Quote 0
                        • world101W
                          world101 @lukasmaximus
                          last edited by

                          @lukasmaximus said in Where did ADC go in V1.1.2?:

                          Apparently those blocks have now all been moved into the pin section, you can set the pwm duty within the analog write block and there is a block for setting a pin to in or out etc.. I cant see the adc bit width equivalent block anywhere. As i'm not too familiar with the functions of those blocks I never used them so please let me know if these reassigned blocks give the same function or not.

                          The Set pin block seems to cause the issue I was seeing with "AttribueError("type object 'ADC' has no attirbute 'OUT'",)". Now that I removed it, the flow is working fine. You are correct though, it looks like the Pin menu (presumably for GPIO pin functions) now has the combined blocks from Pin and ADC, but missing some blocks like ADC bit width, as you said. I wonder if that is on purpose. The Unit ADC from m5stack has the ADS1100 chip that supports up to 16 bits. Maybe the blockly code assumes users will only want to use 16 bits of resolution and not less???

                          1 Reply Last reply Reply Quote 0
                          • world101W
                            world101 @ajb2k3
                            last edited by

                            @ajb2k3 said in Where did ADC go in V1.1.2?:

                            @world101 Ah, sorry for the misunderstanding, I don't mean test the actual earth sensor, I mean can you test the code with your sensor, please?

                            I tried to wire my breadboard jumpers to port A of the Fire, but they didn't fit too well (2.54mm vs. 2.00mm pin pitch). I will have to wait on my shipment of Grove cables from Aliexpress. Also, it looks like you have the ADC unit and the Earth unit both defined on port A. uiFlow didn't like that.

                            So instead of trying to use the Unit functionality within uiFlow, I wired up the m5stack Grey again and used the Micropython console. This code works with my liquid sensor:

                            from m5ui import *
                            
                            clear_bg(0x111111)
                            
                            pinin = machine.Pin(5, machine.Pin.IN)
                            
                            btnA = M5Button(name="ButtonA", text="ButtonA", visibility=False)
                            btnB = M5Button(name="ButtonB", text="ButtonB", visibility=False)
                            btnC = M5Button(name="ButtonC", text="ButtonC", visibility=False)
                            label0 = M5TextBox(136, 127, "Text", lcd.FONT_Default, 0xFFFFFF)
                            
                            
                            while True:
                                val = pinin.value()
                                label0.setText(str(val))
                                wait(0.1)
                            

                            It reports a 0 (no liquid) or 1 (liquid detected) on the m5stack LCD.

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

                              opps, port A is only for i2c, Port B is for I/O
                              Sorry again for the typo that I didn't catch.
                              Sorry 2 I was playing with code and didn't realise both the adc and earth sensor was there as I was working on my book.
                              Sorry again for the confusion.

                              Glad to hear that the senor works.

                              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!

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