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 9 months, 3 weeks ago by woto.
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 9 months, 3 weeks ago by woto.
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:
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.
I think, I have found the mistake.
The E220 module only works with 5 V (according to the data sheet) and my circuit only had 3.3 V. After I supplied the module with 5 V, it works without any problems.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.