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

MLX90614 support #35

Open
jdavid opened this issue Jan 22, 2019 · 3 comments
Open

MLX90614 support #35

jdavid opened this issue Jan 22, 2019 · 3 comments

Comments

@jdavid
Copy link

jdavid commented Jan 22, 2019

In v032 to support MLX90614 it was enough to add the sendStop parameter to the endTransmission and requestFrom functions, as it's done in Arduino. See https://www.libelium.com/forum/viewtopic.php?f=27&t=13616&start=10#p56594

However since v033 the twi and Wire/I2C code has changed very much, the endTransmission and requestFrom functions don't exist anymore, and MLX90614 doesn't work.

How to implement this feature with the new code?

@jdavid
Copy link
Author

jdavid commented Jan 24, 2019

After further testing, actually it works fine except for scanning, I2C.scan(0x5A) returns an error.

Scanning with the old Wire library would be implemented like this:

Wire.beginTransmission(0x5A);
error = Wire.endTransmission();

And it works correctly.

@jdavid
Copy link
Author

jdavid commented Jan 24, 2019

I've fixed it with this change:

diff --git a/waspmote-api/WaspI2C.cpp b/waspmote-api/WaspI2C.cpp
index 87949f7..a972926 100644
--- a/waspmote-api/WaspI2C.cpp
+++ b/waspmote-api/WaspI2C.cpp
@@ -330,11 +330,11 @@ uint8_t WaspI2C::scan(uint8_t devAddr)
        packet_received.addr_length  = TWI_SLAVE_NO_INTERNAL_ADDRESS;   /* TWI slave memory address data size */
        packet_received.chip         = (devAddr << 1);          /* TWI slave bus address */
        packet_received.buffer       = buffer;  /* transfer data destination buffer */
-       packet_received.length       = 1;               /* transfer data size (bytes) */
+       packet_received.length       = 0;               /* transfer data size (bytes) */
 
        /* Perform a multi-byte read access then check the result. */
        I2C.secureBegin();
-       error = twi_master_read(&TWBR,&packet_received);
+       error = twi_master_write(&TWBR,&packet_received);
        
        return error;

@jdavid
Copy link
Author

jdavid commented Jan 24, 2019

By the way, why there're 2 calls to RTC.ON() here?
https://github.com/Libelium/waspmoteapi/blob/master/waspmote-api/main.cpp#L77

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