Send Data from PC to ESP32 via onboard USB - Micropython

PyPat2021
Posts: 4
Joined: Sun Jun 12, 2022 12:27 pm

Send Data from PC to ESP32 via onboard USB - Micropython

Postby PyPat2021 » Sun Jun 12, 2022 12:40 pm

Hello,

I've been fighting with this problem for about 4 days now...
I have a Python program on my Computer that is working absolutely fine and calculating some relevant numbers...
I now bought an ESP32 Devkit V1 and connected a LCD 16x2 Display to it.
I would really like to use the onboard USB port (the one you use for programming Micropython [COM3]) to send my calculated results from my PC to the ESP32 and then show them on the LCD display. I am using Micropython

This is my code in Python on my PC:

Code: Select all

import serial, time

ser = serial.Serial(port='COM3', baudrate=115200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1)
time.sleep(1)

ser.write(b'Some Data\r'.encode()) 
print(ser.readline()) 
time.sleep(1)
print("done")
This is my Micropython ESP32 code:

Code: Select all

import machine
import _thread
from machine import Pin, I2C, UART
import time
from I2C_LCD import I2cLcd

uart = UART(2,115200)
uart.init(115200, bits=8, parity=None, stop=1)

DEFAULT_I2C_ADDR = 0x27
i2c_lcd = I2C(scl=Pin(14), sda=Pin(13), freq=400000)
lcd = I2cLcd(i2c_lcd, DEFAULT_I2C_ADDR, 2, 16)

while True:
    if uart.any():
        msg = uart.readline()
        uart.write(msg)
        try:
            lcd.clear()
            lcd.move_to(0, 0)
            lcd.putstr("DATA")
            lcd.move_to(0, 1)
            lcd.putstr("RECEIVED!")
        except:
            pass
I first of all want to detect wether there is any data received at all...but nothing happens!
I am relatively new to all of this and just want to know wether it this would be possible at all?
My wiring is OK...

How could I solve my problem?

Thank you very much in advance!

PyPat2021
Posts: 4
Joined: Sun Jun 12, 2022 12:27 pm

Re: Send Data from PC to ESP32 via onboard USB - Micropython

Postby PyPat2021 » Mon Jun 13, 2022 2:10 pm

Anybody? :cry:

premmirth
Posts: 1
Joined: Fri Aug 05, 2022 6:05 pm

Re: Send Data from PC to ESP32 via onboard USB - Micropython

Postby premmirth » Fri Aug 05, 2022 6:27 pm

Hey did you find an answer to this query ? I am stuck on this too . Please help if you got that

Who is online

Users browsing this forum: Basalt, PepeTheGreat and 59 guests