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

    WIP ACSSR Guide

    PROJECTS
    2
    4
    4.2k
    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.
    • ajb2k3A
      ajb2k3
      last edited by

      I can't get RS485/Modbus working and so here is the Work in Progress ACSSR Guide.
      https://www.hackster.io/AJB2K3/get-started-with-the-m5stack-acssr-cf960b

      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 1
      • felmueF
        felmue
        last edited by felmue

        Hello @ajb2k3

        for your excellent ACSSR guide you'll find below the UIFlow Modbus blocks to switch the ACSSR on / off (together with the RGB LED) using an M5Stack Basic.

        Two things to note which were not obvious to me:

        • Baudrate needs to be 115200 (anything lower only resets the ACSSR)
        • to turn the ACSSR on the value needs to be 0xFF00 (See here)

        Button functions:

        • Button A: relay on / LED red
        • Button B: relay off / LED green
        • Button C: read version

        0_1659277536153_UIFlowACSSRModbus_20220731.png

        and the corresponding Python code:

        from m5stack import *
        from m5ui import *
        from uiflow import *
        from modbus.master.uModBusSerial import uModBusSerial
        
        setScreenColor(0x222222)
        
        label0 = M5TextBox(54, 58, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
        label1 = M5TextBox(54, 100, "label1", lcd.FONT_Default, 0xFFFFFF, rotate=0)
        label2 = M5TextBox(50, 140, "label2", lcd.FONT_Default, 0xFFFFFF, rotate=0)
        
        def buttonA_wasPressed():
          # global params
          label0.setText(str(modbus.write_single_coil(4, 0, 0xFF00)))
          label1.setText(str(modbus.write_single_register(4, 0, 0xF800, True)))
          pass
        btnA.wasPressed(buttonA_wasPressed)
        
        def buttonC_wasPressed():
          # global params
          label2.setText(str(modbus.read_holding_registers(4, 1, 1, True)))
          pass
        btnC.wasPressed(buttonC_wasPressed)
        
        def buttonB_wasPressed():
          # global params
          label0.setText(str(modbus.write_single_coil(4, 0, 0x00)))
          label1.setText(str(modbus.write_single_register(4, 0, 0x07E0, True)))
          pass
        btnB.wasPressed(buttonB_wasPressed)
        
        modbus = uModBusSerial(1, tx=17, rx=16, baudrate=115200, data_bits=8, stop_bits=1, parity=None, ctrl_pin=None)
        

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

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

          @felmue said in WIP ACSSR Guide:

          Hello @ajb2k3

          for your excellent ACSSR guide you'll find below the UIFlow Modbus blocks to switch the ACSSR on / off (together with the RGB LED) using an M5Stack Basic.

          Two things to note which were not obvious to me:

          • Baudrate needs to be 115200 (anything lower only resets the ACSSR)
          • to turn the ACSSR on the value needs to be 0xFF00 (See here)

          Button functions:

          • Button A: relay on / LED red
          • Button B: relay off / LED green
          • Button C: read version

          0_1659277536153_UIFlowACSSRModbus_20220731.png

          and the corresponding Python code:

          from m5stack import *
          from m5ui import *
          from uiflow import *
          from modbus.master.uModBusSerial import uModBusSerial
          
          setScreenColor(0x222222)
          
          label0 = M5TextBox(54, 58, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
          label1 = M5TextBox(54, 100, "label1", lcd.FONT_Default, 0xFFFFFF, rotate=0)
          label2 = M5TextBox(50, 140, "label2", lcd.FONT_Default, 0xFFFFFF, rotate=0)
          
          def buttonA_wasPressed():
            # global params
            label0.setText(str(modbus.write_single_coil(4, 0, 0xFF00)))
            label1.setText(str(modbus.write_single_register(4, 0, 0xF800, True)))
            pass
          btnA.wasPressed(buttonA_wasPressed)
          
          def buttonC_wasPressed():
            # global params
            label2.setText(str(modbus.read_holding_registers(4, 1, 1, True)))
            pass
          btnC.wasPressed(buttonC_wasPressed)
          
          def buttonB_wasPressed():
            # global params
            label0.setText(str(modbus.write_single_coil(4, 0, 0x00)))
            label1.setText(str(modbus.write_single_register(4, 0, 0x07E0, True)))
            pass
          btnB.wasPressed(buttonB_wasPressed)
          
          modbus = uModBusSerial(1, tx=17, rx=16, baudrate=115200, data_bits=8, stop_bits=1, parity=None, ctrl_pin=None)
          

          Thanks
          Felix

          Thanks but can't get it to work on a core2 using the RS485 unit

          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
          • felmueF
            felmue
            last edited by felmue

            Hello @ajb2k3

            I've just checked. Above blocks work for me with an M5Core2 as well. Instead of TX=17 / RX=16 I use TX=14 / RX=13. That said I do not have the RS485 unit so I am using the little RS485 board (which came with the LAN module) albeit outside the LAN module connected via a BUS module.

            The ACSSR is powered from an external 12 V power supply. The little RS485 board is powered with 5 V from the M5Core2. There are only two wires between the ACSSR and the little RS485 board: A <-> A and B <-> B. I also added an 120 Ohm resistor between A and B of the little RS485 board. The ACSSR already has that resistor in place internally.

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

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