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

    Yun and ESPnow project

    Scheduled Pinned Locked Moved PROJECTS
    1 Posts 1 Posters 2.8k Views 1 Watching
    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 Offline
      ajb2k3
      last edited by

      This is my test code so far. more info to come.
      StickC with YUN

      from m5stack import *
      from m5ui import *
      from uiflow import *
      import espnow
      import wifiCfg
      import hat
      
      setScreenColor(0x111111)
      
      hat_yun0 = hat.get(hat.YUN)
      
      
      wifiCfg.wlan_ap.active(True)
      espnow.init()
      label0 = M5TextBox(70, 16, "Text", lcd.FONT_Default,0xFFFFFF, rotate=90)
      label1 = M5TextBox(53, 17, "Text", lcd.FONT_Default,0xFFFFFF, rotate=90)
      label2 = M5TextBox(35, 17, "Text", lcd.FONT_Default,0xFFFFFF, rotate=90)
      label3 = M5TextBox(19, 17, "Text", lcd.FONT_Default,0xFFFFFF, rotate=90)
      label4 = M5TextBox(21, 117, "Text", lcd.FONT_Default,0xFFFFFF, rotate=90)
      
      
      espnow.add_peer('80:7d:3a:db:e2:19', id=1)
      label0.setText(str(espnow.get_mac_addr()))
      while True:
        label1.setText(str(hat_yun0.temperature))
        espnow.broadcast(data=str((hat_yun0.temperature)))
        label2.setText(str(hat_yun0.humidity))
        espnow.broadcast(data=str((hat_yun0.humidity)))
        label3.setText(str(hat_yun0.pressure))
        espnow.broadcast(data=str((hat_yun0.pressure)))
        label4.setText(str(hat_yun0.getLight()))
        espnow.broadcast(data=str((hat_yun0.getLight())))
        wait_ms(2)
      

      And on the core side

      from m5stack import *
      from m5ui import *
      from uiflow import *
      import espnow
      import wifiCfg
      
      setScreenColor(0x222222)
      
      
      
      wifiCfg.wlan_ap.active(True)
      espnow.init()
      label0 = M5TextBox(29, 6, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label1 = M5TextBox(23, 47, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label2 = M5TextBox(26, 95, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label3 = M5TextBox(17, 134, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label4 = M5TextBox(20, 172, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0)
      
      sentmp = None
      sen01 = None
      sunhum = None
      senpre = None
      
      
      
      def recv_cb(_):
        global sentmp,sen01,sunhum,senpre
        sen01, _, sentmp = espnow.recv_data(encoder='str')
        wait_ms(100)
        label1.setText(str(sen01))
        label2.setText(str(sentmp))
        label3.setText(str(sunhum))
        label4.setText(str(senpre))
      
        pass
      espnow.recv_cb(recv_cb)
      
      
      
      label0.setText(str(espnow.get_mac_addr()))
      

      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

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post