Ui Flow support for onewire and ds18x20



  • onewire and ds18x20 seem not being supported in Ui Flow Micropython. Does anyone know how to integrate onewire and ds18x20 libraries?
    Thanks!


  • M5Stack

    @fb24 UIFlow don't provide third-party Unit or sensor block yet. if your sensor is use I2C protocol , you could use the I2C block to communication.


  • M5Stack

    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



  • 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



  • @m5stack Thanks a lot for your advice



  • @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.



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



  • @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



  • @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.



  • @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?


  • M5Stack

    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



  • @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!



  • @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.



  • @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



  • @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!



  • 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.



  • @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)
    :)



  • @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)
    
    


  • @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!



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

    Thanks a million for the help! :))