Well the program is now reading the data correctly. Taking the variables from secrets.py instead of using config.py to get variables and use myvar = b'secrets.MQTTSERVER'. Which obviously was not working. The connection to the server is working properly now, no longer getting errors and my BME280 is passing data onto the server. Still learning python here, thanks for your explanation and help.I am unsure what you mean by "have it pass as binary."
The code lineretrieves the string defined by myserver and then converts that to a binary string.Code:
server = b'secrets.myserver'
If that is your intent, then the answer to your question is yes.
Are you sure?
I'd expect that to return the literal bytes string (8 bit ASCII encoded) 'secrets.myserver'.
The b prefix to a string tells python to treat it as a byte string. It does not mean "binary".
To convert between byte and unicode string use bytes.decode() and str.encode() (or is it the other way around).
Statistics: Posted by eflwi — Sun Feb 09, 2025 11:40 pm