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

    Ui Flow support for onewire and ds18x20

    UIFlow
    8
    26
    82.1k
    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.
    • lukasmaximusL
      lukasmaximus
      last edited by

      hey @fb24 onewire and ds18x20 are only supported in micropython version 1.12 uiflow micropython is based on version 1.11 if you are familiar with micropython I suggest you flash your M5Stack device with the latest micropython, I did a short video series on how to use M5Atom with micropython 1.12 and I will be doing some videos shortly on how to use other M5Stack devices with micropython 1.12

      F liemphL 2 Replies Last reply Reply Quote 0
      • R
        robalstona
        last edited by

        here you have the library to support ds18b20. You would have to copy these files to your device and from UiFlow call the appropriate micropython commands using the blocks Advanced -> Execute -> Execute code:

        https://github.com/micropython/micropython/tree/master/drivers/onewire

        F liemphL 2 Replies Last reply Reply Quote 0
        • F
          fb24 @m5stack
          last edited by

          @m5stack Thanks a lot for your advice

          1 Reply Last reply Reply Quote 0
          • F
            fb24 @robalstona
            last edited by

            @robalstona Excellent hint you gave me. I could successfully transfer the files to my device and the coude is running well. Thank you very much for your assistance.

            1 Reply Last reply Reply Quote 0
            • F
              fb24 @lukasmaximus
              last edited by

              @lukasmaximus Thank you very much. Where can I find your video regarding updating to micropython 1.12?

              1 Reply Last reply Reply Quote 0
              • R
                robalstona
                last edited by

                @fb24 Hi. A few days ago I made a custom block for ds18b20 support. Maybe you're interested

                https://github.com/stonatm/UiFlow-custom-blocks/tree/master/ds18b20

                A 1 Reply Last reply Reply Quote 1
                • C
                  crami25
                  last edited by

                  @fb24
                  I'm working on using the DS2482 (I2C to onewire) as an interface to the ds18x20.

                  0_1586112359427_980316c7-0ec4-4835-acd6-3dc4a1efe99d-image.png

                  There are existing libraries using arduino. I want to use UIFlow/Blockly . Today I just made a commit using UIFlow/Blockly addressing different sensors/devices like the EXT.IO unit communicating with an M5Stack master as slaves on the I2C bus.

                  1 Reply Last reply Reply Quote 0
                  • liemphL
                    liemph @lukasmaximus
                    last edited by

                    @lukasmaximus said in Ui Flow support for onewire and ds18x20:

                    hey @fb24 onewire and ds18x20 are only supported in micropython version 1.12 uiflow micropython is based on version 1.11 if you are familiar with micropython I suggest you flash your M5Stack device with the latest micropython, I did a short video series on how to use M5Atom with micropython 1.12 and I will be doing some videos shortly on how to use other M5Stack devices with micropython 1.12

                    I am now using Micropython 1.12 BUT not on M5, but other ESP (bare) development boards. I managed to use the M5 Units and Hats connected to the ESP development board. My question is If I flash my M5Stack Fire or other M5 cores with the latest Micropython is there any python libraries for accessing the internal functionalities of the cores? For example the LCD, AXP? Another assumption is that we could not program the core with UIFLOW, isn't it?

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

                      Hey @liemph it is possible to use micropython on m5stack fire and core, once you've flashed the firmware you just use a program like upyloader to transfer all the libraries to the flash. Here is an example of M5Stack Fire using pure micropython https://www.hackster.io/andreas-motzek/execute-logo-on-m5stack-esp32-basic-with-micropython-3713fd core can be programmed no problem with the uiflow interface, when using units, you must attach the unit by jumper wires to the same pin numbers as the port you selected which can be found in the documentation

                      1 Reply Last reply Reply Quote 0
                      • A
                        akshaypatil @robalstona
                        last edited by akshaypatil

                        @robalstona
                        Hi! I was unable to get your uiflow blocks from github to work,
                        the m5b files would not load into uiflow. (nothing happens)
                        Are they compatible with uiflow 1.4.5?
                        Secondly, I uploaded ds18x20.py using uPyloader and used "import ds18x20" in custom execute command. What steps do I take after to get the data from the sensor?
                        If possible, could you paste the python code? Need it for my project.
                        Thanks a lot!

                        A 1 Reply Last reply Reply Quote 0
                        • A
                          akshaypatil @akshaypatil
                          last edited by

                          @akshaypatil
                          The code on github is shown as 1 line, hence the confusion in understanding it even a slight bit. I'm new to programming, have just figured out the basic functions in uiflow, therefore I might be pretty ignorant.

                          1 Reply Last reply Reply Quote 0
                          • R
                            robalstona
                            last edited by

                            @akshaypatil Hi, you must find in uiflow field named Custom (Beta) in a row with other groups of blocks. Click on it and on right side will appears three new blue color buttons. One of them was called *open .m5b file click it and select ds18b20.m5b. You see loading notification, after this operatiin you see new block group appears below Custom (Beta) when you click it

                            A 1 Reply Last reply Reply Quote 0
                            • A
                              akshaypatil @robalstona
                              last edited by akshaypatil

                              @robalstona Yes, that's exactly what I've been trying, without any success. :/
                              I had made my own blocks for toggling GPIO pins in blynk with uiflow that would show a loading screen as soon as I clicked it, but with your blocks, it didn't work. (there is no loading notification)

                              If possible, it would be really helpful to see the code in normal python format. So that I could make my own blocks and cross-check if it's not just my computer?

                              Cheers!

                              1 Reply Last reply Reply Quote 0
                              • R
                                robalstona
                                last edited by

                                its weird to me, i use online wersiin of uiflow, its shows 1.4.5. Newer mind.

                                I based custom block on this file:
                                https://github.com/stonatm/M5Atom_matrix_library/blob/master/lib/dallas.py

                                there in a two class which diffirents in one line near return temperature dependent of sensor type

                                usage:
                                #run once
                                import time
                                from dallas import ds18b20 as sensor
                                sensor.init( pin )

                                #reading procedure
                                sensor.convert ( pin )
                                time.sleep_ms(750)
                                print ( sensor.read( pin ) )

                                This library is simple and have small amount of code but its sacrified to using only one sensor by pin. I don't implemented search rom procedures.

                                A 1 Reply Last reply Reply Quote 1
                                • A
                                  akshaypatil @robalstona
                                  last edited by akshaypatil

                                  @robalstona

                                  from m5ui import *
                                  from uiflow import *
                                  
                                  setScreenColor(0x111111)
                                  
                                  
                                  import time
                                  import onewire
                                  from dallas import ds18b20 as sensor
                                  
                                  sensor.init( pin )
                                  
                                  
                                  
                                  while True:
                                    sensor.convert ( pin )
                                    time.sleep_ms(750)
                                    print ( sensor.read( pin ) )
                                    wait_ms(2)
                                  

                                  Is this the basic code to display the temperature?
                                  Don't hesitate from thinking of me as a complete newbie, I have only been able to figure out basic logic/programming in python.
                                  The plan is to make a battery-heated lunchbox (my design thesis) that will be activated through blynk (or the button mstickC) and use the temperature reading to create a closed looped-feedback and switch it off.
                                  As simple as that sounds in my head. (but not really, as I have learned with time)
                                  :)

                                  R 1 Reply Last reply Reply Quote 0
                                  • R
                                    robalstona @akshaypatil
                                    last edited by

                                    @akshaypatil yes it is simplest form, but in this loop you display temperature every 0.75s on the console via print function. A function sensor.read ( pin ) return a value of readed temperature. You could store this value in variable to use for compare or other things.

                                    for example:

                                    temperature = sensor.read( pin )
                                    if temperature > 25:
                                        lcd.print('Too Hoot', 0, 0, 0xffffff)
                                    
                                    
                                    A 1 Reply Last reply Reply Quote 0
                                    • A
                                      akshaypatil @robalstona
                                      last edited by

                                      @robalstona

                                      from m5stack import *
                                      from m5ui import *
                                      from uiflow import *
                                      
                                      import machine
                                      import time
                                      import onewire
                                      from dallas import ds18b20 as sensor
                                      
                                      setScreenColor(0x111111)
                                      
                                      sensor.init(26)
                                      
                                      
                                      while True:
                                        sensor.convert (26)
                                        time.sleep_ms(750)
                                        lcd.print((sensor.read(26)), 0, 0, 0xffffff)
                                        wait_ms(2)
                                      
                                      

                                      I'm getting "cannot import name ds18b20" error, how do I get around this?

                                      Thank you for helping me out!

                                      1 Reply Last reply Reply Quote 0
                                      • A
                                        akshaypatil
                                        last edited by

                                        Nevermind!
                                        I got it to work!! Yahoo!!!

                                        Thanks a million for the help! :))

                                        R 1 Reply Last reply Reply Quote 0
                                        • liemphL
                                          liemph @robalstona
                                          last edited by

                                          @robalstona said in Ui Flow support for onewire and ds18x20:

                                          here you have the library to support ds18b20. You would have to copy these files to your device and from UiFlow call the appropriate micropython commands using the blocks Advanced -> Execute -> Execute code:

                                          https://github.com/micropython/micropython/tree/master/drivers/onewire

                                          Dear Roblastona, I realized that the feature to make and implement our own piece of phyton code into the UiFlow can solve many problems at hand. Could you lead me to URL or documentation on how to make the m5b files and implement it into the UiFlow?

                                          R 1 Reply Last reply Reply Quote 0
                                          • R
                                            robalstona @akshaypatil
                                            last edited by

                                            @akshaypatil I probably made a mistake in the file location. I "manually" start my programs from the main.py file, but uiflow saves program files in the /apps folder by default and also automatically saves this file with the sent program in the / as the main.py file. The app selector on the device works on a similar principle. So you can try to save the dallas.py file in the same place as the main.py file. The second option is that you copy and paste all the code in the class section into your program. I have firmware version 1.4.2 in my stickc and I have a built-in _onewire module that I import in the dallas.py file. It is possible that in other versions it may have a different name

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