Yun and ESPnow project
-
This is my test code so far. more info to come.
StickC with YUNfrom 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()))
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