This is a question from a newbie so please bear with me if I did anything stupid. I am trying to collect sensor data from my pyboard. process it with PC and send controlling command to the pyboard. The two-way communication needs to be done real time.
Two simple things I tried to do was (1). write from PC to pyboard and use it to control LED brightness and (2) collect the voltage from a pyboard pin and write the voltage value. I had no difficulty with (1). For (2), pyboard could not write to the PC and writting to the SD card requires reset.
I also referred to this post: viewtopic.php?t=1130
With pyboard.py tool I could only have the values printed on REPL, but not written to a txt file in real time.
Here is another code I tried for (2):
Code: Select all
import time
import pyb
p1=pyb.ADC('X1')
while True:
vol=p1.read()/4095*3.3
f=open('log/data.txt','w')
f.write(vol)
f.close()
delay(500)
I wondered if there is any way to collect values from pyboard and make it accessible for PC without reset. Any help is much appreciated.