Giter VIP home page Giter VIP logo

esp-micropython's Introduction

esp-micropython's People

Contributors

ruisantosdotme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-micropython's Issues

Error in BME280.py library file

It seems that there is a typing error in BME280.py. In method read_pressure (see code lines below) the right-shift operator >>12 in line 9 should be replaced by a left-shift operator <<12. This can be easily seen when comparing the coding with the coding in the original Bosch data sheet on page 25 (Document number: BST-BME280-DS002-15, Revision_1.6_092018).

In my test case the error mentioned above and as shown below caused a pressure decay of about 1500 Pa when I increased the sensor temperature by about 8 K via touching the sensor with my finger. From a physical point of view the pressure decay observed seems to be unreasonable and fortunately it vanishes, when the left-shift operator is used.

def read_pressure(self):
"""Gets the compensated pressure in Pascals."""
adc = self.read_raw_pressure()
var1 = self.t_fine - 128000
var2 = var1 * var1 * self.dig_P6
var2 = var2 + ((var1 * self.dig_P5) << 17)
var2 = var2 + (self.dig_P4 << 35)
var1 = (((var1 * var1 * self.dig_P3) >> 8) +
((var1 * self.dig_P2) >> 12))
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var1 = (((1 << 47) + var1) * self.dig_P1) >> 33
if var1 == 0:
return 0
p = 1048576 - adc
p = (((p << 31) - var2) * 3125) // var1
var1 = (self.dig_P9 * (p >> 13) * (p >> 13)) >> 25
var2 = (self.dig_P8 * p) >> 19
return ((p + var1 + var2) >> 8) + (self.dig_P7 << 4)

Best regards
Ebi

PS:

Here is the Bosch coding:

// Returns pressure in Pa as unsigned 32 bit integer in Q24.8 format (24 integer bits and 8
fractional bits).
// Output value of “24674867” represents 24674867/256 = 96386.2 Pa = 963.862 hPa
BME280_U32_t BME280_compensate_P_int64(BME280_S32_t adc_P)
{
BME280_S64_t var1, var2, p;
var1 = ((BME280_S64_t)t_fine) – 128000;
var2 = var1 * var1 * (BME280_S64_t)dig_P6;
var2 = var2 + ((var1*(BME280_S64_t)dig_P5)<<17);
var2 = var2 + (((BME280_S64_t)dig_P4)<<35);
var1 = ((var1 * var1 * (BME280_S64_t)dig_P3)>>8) + ((var1 * (BME280_S64_t)dig_P2)<<12);
var1 = (((((BME280_S64_t)1)<<47)+var1))*((BME280_S64_t)dig_P1)>>33;
if (var1 == 0)
{
return 0; // avoid exception caused by division by zero
}
p = 1048576-adc_P;
p = (((p<<31)-var2)*3125)/var1;
var1 = (((BME280_S64_t)dig_P9) * (p>>13) * (p>>13)) >> 25;
var2 = (((BME280_S64_t)dig_P8) * p) >> 19;
p = ((p + var1 + var2) >> 8) + (((BME280_S64_t)dig_P7)<<4);
return (BME280_U32_t)p;

If MQTT server disconnects due to duplicate client ID then umqttsimple raises OSERROR(-1)

I am running umqttsimple.py with Micropython 1.17 on an ESP32 client. Everything was running perfectly and then, by accident, I used the same MQTT client ID on another device. MQTT responded by disconnecting the original device - it is designed to disconnect the "older" client. I did have a dummy callback in place but was not expecting any topic messages as I had not subscribed to any.

I assume that when MQTT disconnected it created a socket error. The code at line 175 says: "if res == b"": raise OSERROR(-1)". This is the error I got and the main program stopped right there. This may be a socket handling error elsewhere but, in order to make the code more robust I changed the logic to "if res is None or res == b"": return None"

This patch works. Even if the code is not going to be patched, I hope that, by raising the issue, others will see what is happening when it happens to them.

Maybe the real problem is with the socket code which should return "none" when disconnected?

umqttsimple - network hangs after send ping 4 times

code:
client = umqttsimple.MQTTClient(ubinascii.hexlify(machine.unique_id()), '192.168.2.254',keepalive=100, **{'user':'a','password':'ni'})
client.set_last_will('a/availability','offline',retain=True)
client.connect()
client.publish('a/availability','online',retain=True)
while True:
client.ping();print('ping');time.sleep(1)
ping
ping
ping
ping
Disconnected

when I try ping my esp from other computer I see that esp desapear

I work on esp8266-20200911-v1.13.bin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.