I am trying to send data from my MacBook via python to the USB port that my microbit is connected to. my python program transfers the data then by looking on the back of my microbit I see that right next to the USB port a little light is blinking when information is sent so the micro bit is receiving information but the program that I wrote for the microbit won't display the information that has been sent. I have followed a tutorial on how to do this too. something is going wrong I need help!
import serial
import Stock_Web as SW
import time
ser = serial.Serial()
ser.baudrate = 115200
ser.port = "/dev/cu.usbmodem14102"
ser.open()
while True:
i =+ 1
i = str(i)
print('this is time ' + i)
DowPerBytes = str(SW.DowPercent())
DowPerBytes = DowPerBytes.encode()
ser.write(DowPerBytes)
time.sleep(.5)
# data = microbitdata[2:]
# data = data.replace('')
this is my custom module SW:
import requests
from bs4 import BeautifulSoup as soup
def DowPercent():
url = 'https://money.cnn.com/data/markets/'
result = requests.get(url)
src = result.content
Soup = soup(src, 'html.parser')
stock_per_raw = Soup.find('span', class_="ticker-name-change", attrs={"stream": "changePct_599362", "data-ticker-name": "Dow"})
return soup.get_text(stock_per_raw)
and here is the micro bit code: