I am using a BME280 temp/humidity/pressure sensor with both ESP8266 (nodeMCU v3) and ESP32 lite boards. The setup is pretty basic...it takes a reading, creates a GET request string, and then makes the GET request. I have a google script setup to parse the GET request and add a row a google sheet.
This seemed simple, but I am having a LOT of trouble with it.
1. The program reliably takes readings from the BME280 sensor.
2. It will also reliably form the GET URL.
3. It will intermittently/regularly hard reboots when doing the GET request (https).
4. This happens on both the ESP8266 and ESP32
After much testing:
1. I've found that if I run the board with I2C and the BME280 sensor without importing the urequests module, it never crashes.
2. If I send test GET requests without I2C and without importing the BME280 module, it never crashes.
3. When they are both imported and GET requests are tried, the system crashes. (GET, POST, requests, etc...all cause the system to crash)
4. The google script side works fine and receives and processes the GET with no issue. If the system crashes, it is during the GET request and the google script does NOT process the request. (I'm not sure if it receives the request when a crash happens.)
I have tried deleting the BME module, deleting the BME object, and performing gc.collect() prior to performing the get request and still get the same intermittent crashes. It'll hard reboot and then just go into a hard reboot loop.
Do you have any suggestions or ideas on this issue?
BME280 temp, humidity, pressure sensor
nodeMCU v3 (ESP8266)
(I have 3x ESP8266, 2x ESP32, and 5x BME280 and it happens on all of them)
BME280.py library: https://github.com/catdog2/mpy_bme280_esp8266
Code: Select all
import machine import time import BME280 import urequests # board settings sample_interval = 60 device = 'mcu2' sensor = 'bme280' location = 'basement' i2c = machine.I2C(scl=machine.Pin(14), sda=machine.Pin(12), freq=10000) # ESP8266 while True: import BME280 bme = BME280.BME280(i2c=i2c) temperature = bme.temperature()*(9/5) + 32 # F humidity = bme.humidity() # % pressure = bme.pressure() # hPa url_head = 'https://script.google.com/a/macros/<google_script_URL>/exec' url_data = '?device=' + device + '&sensor=' + sensor + '&location=' + location url_data = url_data + '&temperature=' + str(temperature) + '&humidity=' + str(humidity) + '&pressure=' + str(pressure) url_text = url_head + url_data print(url_text) urequests.get(url_text) time.sleep(sample_interval)