Here is my code,
read bme280 data
def get_temp():
from bme280 import readBME280All
temperature,pressure,humidity = readBME280All()
return “%sF” % str(((temperature)*9/5)+32)
def get_pressure():
from bme280 import readBME280All
temperature,pressure,humidity = readBME280All()
return “%s hPa” % str(pressure)
def get_humidity():
from bme280 import readBME280All
temperature,pressure,humidity = readBME280All()
image = Image.open(r /home/pi/lib_oled96/FreeSans.ttf)
draw = ImageDraw.Draw(image)
return “%s percent” % str(humidity)
from PIL import ImageFont, ImageDraw
font = ImageFont.truetype(‘/home/pi/lib_oled96/FreeSans.ttf’, 13)
draw.text((1, 1), ‘Ambient Conditions’, font=font, fill=1)
font = ImageFont.truetype(‘/home/pi/Downloads/ssd1306-master/FreeSans.ttf’, 11)
draw.text((1, 20), get_temp(), font=font, fill=1)
draw.text((1, 35), get_pressure(), font=font, fill=1)
draw.text((1, 50), get_humidity(), font=font, fill=1)
oled.display()
sleep(5)
oled.cls()
I keep getting this error Traceback (most recent call last):
File “/media/pi/rootfs/home/pi/weathertest1.py”, line 6
return “%sF” % str(((temperature)*9/5)+32)
^
SyntaxError: ‘return’ outside function
I keep fixing but then I get a diffrent error. Can some tell me what is worng with my code.