I'm using the bmp280 on ESP8266 to read temperature and barometric pressure.
Sometimes an unwanted dot is printed from the print command in front of the data line (see example below, for instance in front of 5.571).
My full program looks like this:
import utime
from machine import Pin, I2C
from bmp280 import *
datfil = open('espdata.txt', 'w')
def toggle(p):
p.value(not p.value())
i2c = I2C(scl=Pin(5), sda=Pin(4))
blue=Pin(2,Pin.OUT)
blue.on()
bmp = BME280(i2c=i2c)
utime.sleep(0.5)
tstartms=utime.ticks_ms()
print('time','temperature','pressure')
print()
for i in range(0,120):
toggle(blue)
bmpres=bmp.values
temp=eval(bmpres[0].rstrip('C'))
pres=eval(bmpres[1].rstrip('hPa'))
time_s=(utime.ticks_ms()-tstartms)/1000
print('%5.3f' % time_s,',','%6.2f' % temp,',','%8.2f' % pres)
datfil.write(str(time_s)+','+str(temp)+','+str(pres)+'\n')
utime.sleep(0.5)
datfil.close()
print('File closed.')
for i in range(0,20):
toggle(blue)
utime.sleep(0.2)
blue.on()
How can I get rid of the strange dot (which is not there when I write data to file)?
Poul Riis
0.047 , 26.12 , 1001.64
0.696 , 25.78 , 1001.58
1.257 , 25.78 , 1001.63
1.818 , 25.75 , 1001.56
2.381 , 25.73 , 1001.50
2.945 , 25.75 , 1001.56
3.506 , 25.76 , 1001.57
4.069 , 25.76 , 1001.62
4.629 , 25.76 , 1001.60
5.192 , 25.81 , 1001.62
.5.751 , 26.32 , 1001.61
6.314 , 26.56 , 1001.53
6.875 , 27.35 , 1001.55
7.435 , 28.12 , 1001.95
7.997 , 28.78 , 1002.40
8.558 , 29.15 , 1001.66
9.122 , 28.60 , 1001.67
9.684 , 27.72 , 1000.81
10.245 , 28.19 , 1001.61
10.806 , 28.65 , 1001.27
11.365 , 29.82 , 1001.63
11.928 , 30.32 , 1001.62
12.487 , 30.70 , 1001.65
13.051 , 31.03 , 1001.65
13.615 , 31.30 , 1001.64
.14.177 , 31.56 , 1001.66
14.737 , 31.81 , 1001.74
15.299 , 32.01 , 1001.69
15.859 , 32.20 , 1001.67
16.422 , 32.38 , 1001.64
16.981 , 32.51 , 1001.68
17.542 , 32.62 , 1001.67
18.104 , 32.51 , 1001.59
18.664 , 32.28 , 1001.68
19.225 , 32.14 , 1001.60
19.788 , 32.04 , 1001.64
20.350 , 31.93 , 1001.62
20.911 , 31.84 , 1001.66
21.473 , 31.75 , 1001.65
.22.033 , 31.66 , 1001.65
Unwanted dot from print command
Re: Unwanted dot from print command
....Sorry, I forgot to mention that I run the program from jupyter notebook.
I just discovered that the strange dot is not there when running from a terminal (webrepl).
So the unwanted dot has probably more to do with jupyter notebook than with micropython.
Poul Riis
I just discovered that the strange dot is not there when running from a terminal (webrepl).
So the unwanted dot has probably more to do with jupyter notebook than with micropython.
Poul Riis