Home › Forums › The libraries hosted on the site › EByte LoRa e22 UART devices sx1262/sx1268 › E220 LoRa Receive-Intervall and MycroPython and Arduino Env communication (UnicodeError:)
- This topic has 24 replies, 3 voices, and was last updated 10 months, 3 weeks ago by
g0730n.
-
AuthorPosts
-
-
14 January 2024 at 16:15 #29230
Hello,
I use the following to receive data:while True: if lora.available() > 0: code, value = lora.receive_message() print(ResponseStatusCode.get_description(code)) print(value) time.sleep(2)
My question is, what is the time.sleep(2) for?
I have noticed that if I send data within 2sec, then I get an error message in the Thonny IDE or the data is lost.
And what happens if several transmitters send data at the same time?
Kind regards,
woto-
This topic was modified 1 year, 4 months ago by
Renzo Mischianti.
-
This topic was modified 1 year, 4 months ago by
Renzo Mischianti.
-
This topic was modified 1 year, 3 months ago by
Renzo Mischianti.
-
This topic was modified 1 year, 4 months ago by
-
14 January 2024 at 19:29 #29232
Hi Woto,
if you don’t add the sleep time, the processor gets 100% of usage and can freeze.If you receive more than one message, the messages are stored in the buffer of E220, and when you read them, you receive the two messages at once.
Bye Renzo
-
15 January 2024 at 12:16 #29268
Hi Renzo,
if the transmitter sends within 2sec, then the Micropython programme as receiver is terminated with the error unicode-error at line 636 in lora_e220.py.
What could be the reason for this? The message is only a few bytes long:
“Hello World! 1”. The next message is then “Hello World! 2” and so on.best regards
Woto -
15 January 2024 at 14:17 #29272
Please, paste the complete error stack trace..
Bye Renzo -
16 January 2024 at 13:25 #29289
Hi Renzo,
excuse me for the late answer.I will do it today in the evening.
best regards,
woto -
17 January 2024 at 19:16 #29291
Hi Renzo,
I have now found a little time to reproduce the error.When I send a message every second I get the following message in the Thonny editor:
Traceback (most recent call last): File "<stdin>", line 127, in <module> File "/lib/LoraWanE220/lora_e220.py", line 636, in receive_message UnicodeError:
Maybe you can help me.
best regards
Woto -
18 January 2024 at 15:12 #29294
Hi Woto,
It seems that there is a character that’s not encoded correctly, which kind of message do you send?
Bye Renzo -
18 January 2024 at 16:25 #29297
Hi Renzo,
I send with the following command:
e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 18, DateTimeStr + " ,Hello, world?" + String (i));
The variable DateTimeStr is:
DateTime nowTime = MCP7940.now(); // get the current time String DateTimeStr = String(nowTime.year()) + "." + String(nowTime.month()) + "." + String(nowTime.day()) + " " + String(nowTime.hour()) + ":" + String(nowTime.minute()) + ":" + String(nowTime.second());
OWN_ADDH = 0x00 OWN_ADDL = 0x01 i is an integer
If I send all 6s, everything is fine. Only if I send every second does this message appear and the programme stops.
-
19 January 2024 at 08:58 #29303
But you send from Arduino env and receive in MicroPython env?
Bye Renzo -
20 January 2024 at 12:40 #29308
Hi Renzo,
yes, that’s right.best regards
Woto -
20 January 2024 at 12:41 #29309
-
22 January 2024 at 21:54 #29351
Do you have FEC on or off?
-
23 January 2024 at 15:51 #29361
Hi g0730n,
I do not know “FEC”. What does it mean? -
23 January 2024 at 16:34 #29366
I’ve been experimenting some with data corruption on my setup sending between arduino and pi pico(micropython).
Factors to consider:
1. Timing
2. Forward Error Correction
3. “ReceiveMessageUntil()”, i have experimented with this setting as i was receiving two messages packed into one… eg. “Msg0Msg1”, using this setting seems to help??If both devices are powered up at same time, and one LoRa begins receiving half way through the senders transmission, it will only receive half the message, hence corrupted data. I have only noticed this happening with FEC off, but more testing needed.
Once I’m able to log into forum here on my computer I will post my code for the working setup I’m putting together.
I am using bare ATMEGA328P chip on arduino side, and pi pico on the other side.
-
23 January 2024 at 17:02 #29363
ok, I read
https://mischianti.org/ebyte-lora-e32-micropython-exploring-library-2/
now.I think it is on, because the Default-Value is ON.
-
25 January 2024 at 13:36 #29415
Hi g0730n,
thanks for answer.
I will test the function “ReceiveMessageUntil()”. Maybe it could help me. -
26 January 2024 at 09:00 #29468
I also pin this discussion, and if I find some time, I retrieve all devices and do some tests.
Give me feedback on your test.
Thanks, Renzo -
2 February 2024 at 16:07 #29612
Hello,
I would now like to switch off the FEC in the Python programm.
How can I do this?Thanks Woto
-
2 February 2024 at 17:06 #29615
Hello,
I now have data issued to me.
In lora_e220.py, I insert on line 636 (before data = data.decode(‘utf-8’):
print (data)
If I receive all 4s, I get the following output:
b’0212024.2.2 15:14:25 5cm’
After 4s the next output:
b’0212024.2.2 15:14:29 19cm’If I receive every second, Data looks like this:
b’0212024.2.2 16:59:58 7cm\xf00212024.2.2 16:59:59 19cm’After “7cm” it says \xf0. What does that mean?
-
3 February 2024 at 11:24 #29619
Hello,
When I enter the following in the Thonny IDE, I get an error message:
>>> b'\xf0'.decode() Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeError: >>>
I think the problem is the character \xf0.
This does not seem to be a Unicode character. Unfortunately, µPython does not allow you to specify a second parameter in the decode() function, e.g.data.decode('UTF-8','ignore')
.This does not work.
But how can this be solved?-
This reply was modified 1 year, 3 months ago by
woto.
-
This reply was modified 1 year, 3 months ago by
-
4 February 2024 at 10:56 #29622
Hi woto,
I must do some check, but someone uses this approach to clean the strx.encode('utf-8','ignore').decode("utf-8")
But I must check It.
Bye Renzo -
4 February 2024 at 16:06 #29623
Hi Renzo,
I tried it, but it does not work. I get the following error in der Thonny-IDE:>>> b'0212024.2.2 15:26:34 3cm\xf60212024.2.2 15:26:35 22cm'.encode('utf-8','ignore').decode("utf-8") Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'bytes' object has no attribute 'encode' >>>
-
4 February 2024 at 17:22 #29624
Hi renzo,
I think I have a solution for myself, maybe for others too.
I have created a new static method in the class LoraE220:@staticmethod def _cleanData(_data): data = bytes(_data) ret_values = [] ret_arr = bytearray(ret_values) for i in range(len(_data)): if _data[i] <= 127 : ret_arr.append(_data[i]) return ret_arr
This methode is called before the decode function:
str_ret = LoRaE220._cleanData(data) data = str_ret.decode('utf-8') msg = data
Now the decoding function works and if I define a separator for the sender, I can separate the messages from each other.
-
This reply was modified 1 year, 3 months ago by
woto.
-
30 June 2024 at 21:09 #30876
I will keep this in mind.
-
This reply was modified 1 year, 3 months ago by
-
6 February 2024 at 08:23 #29644
Hi Woto,
thanks. It’s very interesting and helpful.
I’m going to examine the situation, but with your help, I think It will become simpler.
Thanks again, Renzo.
-
-
AuthorPosts
- You must be logged in to reply to this topic.