Just a FYI for anyone interested. After some experimenting I found the _thread works with micro python, which I wasn't aware of.
So threading works just how you think.
cheers
Just a FYI for anyone interested. After some experimenting I found the _thread works with micro python, which I wasn't aware of.
So threading works just how you think.
cheers
I'm using the same Unit with M5Paper and its working very well. I did get a similar error when I was first starting my project.
I did eventually get it working with the following set up.
uhf_rfid_0.set_region(uhf_rfid_0.REGIN_US)
uhf_rfid_0.automatic_freq_hopping(0xFF)
uhf_rfid_0.set_channel_freq(924.25)
epc_bool = 0
uhf_rfid_0.set_select_mode(0x01)
and then start waiting for tags with
def reader():
temp = None
count = None
clean = None
while True:
count += 1
# while not temp:
temp = uhf_rfid_0.single_polling()
if temp:
# label10.setText(str(temp))
print("-----")
print(temp[0])
print(temp[1])
print("-----")
this is on a separate thread and works quite well for my requirements.
The other issue I had and not sure if it was because I did not read correctly however. it works with the following tags (UHF RFID Tag ISO18000-6C)
Not sure if it helps, but I hope it offers some info thats of use.
reagrds
Kyle
Sure, this is running on a M5Paper, though I have had something very similar running on a M5Core, This is the small segment of an app written for long rang tag reading at a workshop to track keys and other equipment. I have kept in the tag reading portion. I hope this helps. Some of it is not needed for the reading, just too lazy to remove from the snippet.
from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
import time
import unit
import _thread
import os
import random
import urequests
from m5stack import touch
setScreenColor(15)
buzzer_1 = unit.get(unit.BUZZER, unit.PORTB)
uhf_rfid_0 = unit.get(unit.UHF_RFID, unit.PORTC)
version = 0.89
EPC = None
epc_bool = None
temp = None
tagList = []
TouchCordx = None
TouchCordy = None
rsense = 2
readerKey = None
businessKey = None
uhf_rfid_0.set_region(uhf_rfid_0.REGIN_US)
uhf_rfid_0.automatic_freq_hopping(0xFF)
uhf_rfid_0.set_channel_freq(924.25)
epc_bool = 0
uhf_rfid_0.set_select_mode(0x01)
print("Beapnow Reader : " + str(version))
print("---")
def genKey(length):
letters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str
def SetTouchCordenate():
global TouchCordx, TouchCordy
print("Setting Touch")
TouchCordx, TouchCordy, s, status = touch.read()
print(TouchCordx)
print(TouchCordy)
def uhf_rfid_cb(epc_no, dBm):
global EPC, epc_bool, temp
EPC = epc_no
_ = dBm
# label5.setText(str(EPC))
print("2")
print("---")
pass
# while not epc_bool:
# epc_bool = uhf_rfid_0.multiple_polling_read(uhf_rfid_cb, 100)
# while not (uhf_rfid_0.select_tag_param(EPC)):
# pass
ssid = None
pc = None
keyboard = None
sett = True
sim = True
bz = False
readerBool = True
touchBool = False
bzfreq = 500
la = []
ba = []
alphabet = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
tu = False
ltime = 0
dsc = 0
rr0 = None
rr1 = None
rr2 = None
rr3 = None
rr4 = None
rr5 = None
rr6 = None
rr7 = None
label0 = M5TextBox(502, 25, "Beapnow Tag Reader", lcd.FONT_DejaVu40, 0, rotate=90)
labelVersion = M5TextBox(
460, 30, "version: " + str(version), lcd.FONT_Default, 0, rotate=90
)
circle0 = M5Circle(492, 904, 30, 12, 0)
rectangle0 = M5Rect(290, 875, 60, 60, 12, 0)
rectangle1 = M5Rect(380, 875, 60, 60, 12, 0)
label1 = M5TextBox(334, 815, "Wifi", lcd.FONT_DejaVu24, 0, rotate=90)
label2 = M5TextBox(420, 663, "Read Sensitivity", lcd.FONT_DejaVu24, 0, rotate=90)
rs2 = M5TextBox(420, 882, "High", lcd.FONT_DejaVu18, 0, rotate=90)
label3 = M5TextBox(501, 770, "Wifi off", lcd.FONT_DejaVu24, 0, rotate=90)
label9 = M5TextBox(501, 620, "Waiting...", lcd.FONT_DejaVu24, 0, rotate=90)
label7 = M5TextBox(512, 892, "", lcd.FONT_DejaVu40, 0, rotate=90)
rectangle7 = M5Rect(170, 307, 200, 410, 14, 0)
label12 = M5TextBox(334, 322, "Tag #", lcd.FONT_DejaVu40, 0, rotate=90)
label13 = M5TextBox(331, 446, "1234567890", lcd.FONT_DejaVu40, 0, rotate=90)
label14 = M5TextBox(276, 431, "READ Success", lcd.FONT_DejaVu24, 0, rotate=90)
label15 = M5TextBox(227, 461, "Date Time", lcd.FONT_DejaVu24, 0, rotate=90)
def touchScreen():
global touchBool, ssid, pc, tu
print("Waiting for touch")
btty = 6
while True:
if touch.status():
print(str(touch.read()))
wait_ms(5)
def reader():
global bz, dsc, ltime, readerBool,rsense
temp = 0
count = 0
clean = 0
print("Waiting for RFID")
print("sensitivity = "+str(rsense))
while True:
ltime += 1
# while not temp:
temp = uhf_rfid_0.single_polling()
if temp:
label13.setText(str(temp[0]))
print("-----")
print(temp[0])
print(temp[1])
print("-----")
count += 1
lcd.show()
wait_ms(2)
def file_exists(filename):
try:
return (os.stat(filename)[0] & 0x4000) == 0
except OSError:
return False
def readSense():
global rsense
print("changing rsense")
if rsense == 2:
rsense = 5
rs2.setText("Low")
else:
rsense = 2
rs2.setText("High")
lcd.partial_show(370, 875, 60, 60)
def checkConfig():
# some check here
return True
def startTime():
print("START TIME")
# time = 0
# loop = True
# while loop:
# if time > 29:
# logTags()
# loop = False
# time += 1
# print(time)
# wait(.95)
label13.setText("")
ssid = ""
pc = ""
lcd.show()
_thread.start_new_thread(touchScreen, ())
if checkConfig():
_thread.start_new_thread(reader, ())
print("Ready for tags")
else:
print("waiting for register")
Hello
I looking for the best unit options to do the following tasks.
if there are any other or better options I would like to hear them
thanks
I have been able to get it working with the correct wiring using the grove port in a Core Basic Gray unit.
No I will start to use the io pins in the bottom of the unit so I can use the grove port for other things.
thanks for all your assistance.
@ajb2k3 When the servo is attached and then plugged in, it does not start. When the servo is removed and then plugged in it starts..
@teastain Thanks for the info. I hope you got something out of this adventure :). The StickC does not have a battery. I'll try with the Core Grey I have, it has a battery and see I can get it to work with the pins and not the Grove.
It does seem odd though.
thanks again
cheers Kyle
@teastain Thanks, I tried what you mentioned and same shut down...
curious
Hi,
I'm trying to connect a Servo Kit 180 to a M5StickC. However when I try the Stick shuts down when I connect the red pin.
See images below.
Do I need a separate connector or are the pins mixed up.
Best method for sending large sets of data back to api as a file.
I have tried urequests and the post does not like the keyword files.
does anyone have a method they would like to share.
thanks
Kyle
Not sure if this will help.
I made a quick reader based on a [project I'm working on this also works on m5Paper as well it's nothing complex simple read and display, this is on a Basic Core unit
A quick video showing it working
https://youtu.be/qvtr6Vy-HwY
The Tags I use are these ones
make sure the port is correct otherwise the bytes out of range error pops up
I hope it helps
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
uhf_rfid_0 = unit.get(unit.UHF_RFID, unit.PORTA)
uhf_rfid_0.set_region(uhf_rfid_0.REGIN_US)
uhf_rfid_0.automatic_freq_hopping(0xFF)
uhf_rfid_0.set_channel_freq(924.25)
epc_bool = 0
uhf_rfid_0.set_select_mode(0x01)
label0 = M5TextBox(128, 59, "Tag #", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(22, 106, "waiting ... ", lcd.FONT_Default, 0xFFFFFF, rotate=0)
while True:
# while not temp:
temp = uhf_rfid_0.single_polling()
if temp:
# label10.setText(str(temp))
print("-----")
print(temp[0])
print(temp[1])
print("-----")
label1.setText(temp[0])
wait(.5)