Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad readings every 16th reading #8

Open
OndrejBakan opened this issue Oct 5, 2017 · 1 comment
Open

Bad readings every 16th reading #8

OndrejBakan opened this issue Oct 5, 2017 · 1 comment

Comments

@OndrejBakan
Copy link

OndrejBakan commented Oct 5, 2017

Hi! First of all thanks for your work!

I was measuring temperature with one minute interval and I noticed that every +- 16 minutes I got false readings. Temperature is 20.5°C and than it suddenly drops to 16 - 18°C for one reading. Same goes for pressure, 975 hPa and then drop to about 967. False values are not same everytime.

Here is my code:

import machine
import network
from lib import bme280
from lib import urequests as requests

i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
bmp = bme280.BME280(i2c=i2c)

def connect():
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        wlan.connect('*', '*')
        while not wlan.isconnected():
            pass

def get_data(timer=None):
    api_key = '*'
    temperature, pressure, humidity = bmp.read_compensated_data()

    temperature = (temperature / 100) - 2
    pressure = (pressure / 256) / 100

    url = 'https://api.thingspeak.com/update?api_key={}&field1={}&field2={}' . format(api_key, temperature, pressure)
    r = requests.get(url)


connect()

get_data()

timer = machine.Timer(-1)
timer.init(period=60000, mode=machine.Timer.PERIODIC, callback=get_data)
@OndrejBakan OndrejBakan changed the title Bad readings +- 16 minutes Bad readings every +- 16 minutes Oct 5, 2017
@OndrejBakan OndrejBakan changed the title Bad readings every +- 16 minutes Bad readings every 16th reading Oct 6, 2017
@OndrejBakan
Copy link
Author

I just noticed it's not every 16 minutes, but every 16th reading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant