Search found 13 matches

by microBoa
Thu Apr 29, 2021 2:54 am
Forum: ESP8266 boards
Topic: Get current UART settings
Replies: 3
Views: 2779

Re: Get current UART settings

Here's a one liner for my previous post in case anyone wants to retrieve UART settings in the future:

Code: Select all

_baud, _databits, _parity, _stopbits = tuple([x.split('=')[1] for x in str(UART(0))[8:-1].split(",")[:4]])
You can change the ':4' to ':7' if you want to also get the buffer/timeout settings.
by microBoa
Sat Apr 17, 2021 8:54 pm
Forum: ESP8266 boards
Topic: Trying to read MBUS data through UART
Replies: 4
Views: 3782

Re: Trying to read MBUS data through UART

Update: This is what I suspect is going on. You're using uart0 for the REPL, and uart1 to read your sensor. I don't know the pinout for the Wemos, or the default setup, so you'll have to verify. You probably don't need to detach the REPL and reattach, try commenting out those lines and just reading ...
by microBoa
Sat Apr 17, 2021 8:36 pm
Forum: ESP8266 boards
Topic: Trying to read MBUS data through UART
Replies: 4
Views: 3782

Re: Trying to read MBUS data through UART

write() is functioning like print(). When the uart is detached from dupterm, at least in my case, print() doesn't display anything, you need to use write() to see your output. I'm using an ESP01 (8266) which just has the 1 set of uart pins, read() gets the input from your sensor or whatever, and wri...
by microBoa
Fri Apr 16, 2021 5:18 am
Forum: ESP8266 boards
Topic: Difference between print() and uart.write()
Replies: 4
Views: 3734

Re: Difference between print() and uart.write()

I realize its not gibberish, but since it wasn't what I was I wanted... Anyway, I figured it out. I think near the beginning of my attempts I tried this but still got the same error, now I know why. uart.write('SEQ/Len(): '+str(sequence).encode('ascii')+'\r\n') The error I got was something like can...
by microBoa
Thu Apr 15, 2021 7:50 am
Forum: ESP8266 boards
Topic: Difference between print() and uart.write()
Replies: 4
Views: 3734

Re: Difference between print() and uart.write()

Currently I'm using print(), but I want to do uos.dupterm(None, 1) and still see the output I was getting from print() for debugging. When I use print() the output I see is b'\xff\xfd\x18' (actually this is just sample output from a variable), this is what I'd like to see when I do uart.write(). pri...
by microBoa
Thu Apr 15, 2021 7:19 am
Forum: ESP8266 boards
Topic: Difference between print() and uart.write()
Replies: 4
Views: 3734

Difference between print() and uart.write()

If I print this byte string I get the output I want, but if I try to send it with uart.write() I get gibberish. >>> print(b'\xff\xfd\x18') b'\xff\xfd\x18' >>> uart.write(b'\xff\xfd\x18') ÿý3 I've tried various things from googling, but some of the functions aren't available in Micropython, and other...
by microBoa
Mon Apr 12, 2021 1:43 am
Forum: ESP8266 boards
Topic: Trying to read MBUS data through UART
Replies: 4
Views: 3782

Re: Trying to read MBUS data through UART

I've had some difficulty reading from the uart myself lately on an ESP8266. I think this should work for the Wemos. I'm a beginner with Micropython, so I hope I don't lead your astray. EDIT: when you do uos.dupterm(None, 1) you won't see any output from print() or REPL until you change it back again...
by microBoa
Sun Apr 11, 2021 6:15 am
Forum: ESP8266 boards
Topic: ValueError: syntax error in JSON
Replies: 2
Views: 3521

Re: ValueError: syntax error in JSON

Thanks, you're right. I needed to add the dict name:

conf.value

Code: Select all

ujson.dump(conf.value, f)
Thanks for taking a look and spotting that!
by microBoa
Sat Apr 10, 2021 10:54 pm
Forum: ESP8266 boards
Topic: ValueError: syntax error in JSON
Replies: 2
Views: 3521

ValueError: syntax error in JSON

I'm trying to read/write a dict{} containing settings. I've read the docs, but I'm getting ValueError: syntax error in JSON when I try to read the settings. I'm not sure how to confirm they were written correctly. What am I missing? (sorry don't know why formatting is off, using CODE tags). There's ...
by microBoa
Thu Apr 08, 2021 7:39 am
Forum: ESP8266 boards
Topic: Get current UART settings
Replies: 3
Views: 2779

Re: Get current UART settings

I still don't know if there's a more 'pythonic' way to do this, but in case anyone else wants to do it, this is what I whipped up for now. import ure from machine import UART def uart_cfg(device): cfg = ure.search('.*\((.*)\)', str(UART(device))).group(1).split(',') return cfg[1].split('=')[1], cfg[...