Author Topic: Where I'm keeping my Code  (Read 992 times)

Nick_W

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Where I'm keeping my Code
« on: September 19, 2016, 09:54:24 am »
Quote
In the below code snippet from the MMA8652 library, the whoAmI() function call is returning 0x00 and so the Accelerometer is never enabled.
Any suggestions as to why it is not returning 0x4a?

It works fine for me. I have just loaded the code into a new 110 module running 7.370 F/W

Here is the MQTT output

Code: [Select]
MCThings/000111B4/Status Booted: V1.02
MCThings/000111B4/Status Accel Sensor Online
MCThings/000111B4/KnockEnable True
MCThings/000111B4/Status OnLine

In order to read/write the I2C to the module, the read and write routines in the library are very specific. The MMA8562 needs a "repeated start" before you can read it. It is possible that I have a bug in here, as I'm not sure how to do a "repeated start", with the code tools we have. I do a write (without a stop) then a read - which is required for a repeated start - ie you can't have a stop before a read.

Can you post your code somewhere (I appreciate it's probably quite long) so that I can try it, or download from my github again? I did fix some small typo's in the last day or so. Not that they should effect anything, but it's working as is on my two 110 test modules.

If you put a magnet against the reedswitch, wait 5 seconds, then tap the module several times quickly (like a knock...), this is what you should see:

Quote
MCThings/000111B4/Door False
MCThings/000111B4/Doorknock True

Door False is the door detected as closed.
Doorknock True is what you get when two taps less than 0.75 seconds apart are detected (and the door remains closed for more than 1 second afterward).
« Last Edit: September 19, 2016, 09:59:33 am by Nick_W »