Hello
I have a problem with UART0 communication with my PC from ESP8266.
My main.py code looks like (it should send magnetometer data throw UART)
from machine import Pin, I2C
from lsm303e import LSM303
import time
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)
lsm303 = LSM303(i2c)
p2 = Pin(2, Pin.OUT)
#and send the data
from machine import UART
uart = UART(0, 9600)
uart.init(9600, bits=8, parity=None, stop=1)
while 1:
time.sleep(0.001)
uart.write(str(lsm303.mag_read())+'\n')
And when I want to read this data in my PC (I am using cp2100), none of the data had come. UART REPL mode in boot.py is running without problem with this usb to uart converter.
My python code in my PC for reading uart data is:
import serial
import time
ser = serial.Serial('/dev/ttyUSB0', 9600)
while 1:
print(str(ser.readline()))
time.sleep(0.5)
Where is problem? I have not see any
THX Mike
Uart communication
Re: Uart communication
Since UART0 ist used for REPL, you can on the ESP8266 simple print() what you want to send. No need to use the UART API.