Author Topic: Tilting Trigger on the Accelerometer  (Read 3984 times)

Nick_W

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Tilting Trigger on the Accelerometer
« on: January 15, 2017, 08:59:34 pm »
Update:

Checkout my github https://github.com/NickWaterton/mcScript for a new Demo 205 test program!

This program publishes the GPS location on motion start, or end of motion (selectable). Currently publishing via MQTT as we don't have a SigFox network in Canada, but good for proof of concept.

Also new: updated LIS2DH12 (accelerometer) library, with easy to configure options, and capability of reading the event name that triggered an interrupt (double_click, x_axis etc) (see demo 205 program for usage, and source for details).

Updated MQTT library (only one change as mcStudio 906 didn't like checking the count of Nothing) minor, but needed, still backwards compatible.

New mcthings_log.py Python program for logging (and displaying) MQTT data from your modules (actually should work with any mqtt data), features pretty printing of json, decoding of timestamps (at least my implementation of them), calculation of transmission delay, etc. Command line configurable, probably full of bugs, but works for me.

NOTE: mcStudio 906 and the demo 205 have some serious gremlins in them. The following is the only way I have been able to load a program into my 205:

  • Start mcStudio (this usually takes two tries), and load project. Do not connect 205 yet!
  • Click on build (hammer, icon). This will fail don't worry! This is just a test from the demons of debugging hell
  • Click on build again (wait.. wait) success! Demons begone. MCThings people you owe me 4 hours of my life back for figuring this out
  • Remove tiny power jumper from 205, and try not to loose it again...
  • Connect 205 via USB (I have never had OTA update working, so go with this)
  • Open "devices" screen, and connect "testboardGateway"
  • Insert tiny power jumper in USB position (assuming you haven't lost it again)
  • Wait for device to appear, and click on connect
  • Back on the main screen, click on "download to device" (or upload if you think that way), anyway, send program to 205. Do not try run, to debug, mcStudio will crash!
  • Wait for success message box, click OK. Then disconnect USB (device will not publish when connected to USB, so you can't see any messages)
  • Move tiny power jumper to battery position, and watch mqtt/logging program for data. Shake 205 to activate GPS, gasp as data appears (OK there is some waiting, a lot of waiting)

If you want to change anything, you can't reconnect the 205 (go ahead and try, mcStudio will crash when you click on "connect"). You have to make your changes, save them, then close mcStudio, and start from step 1 above. If you think this takes a long time to write/debug a program this way, you would be right.

If anyone has found a faster/easier way to do this, please let me know and I will be eternally grateful.

I am certain that there are some bugs in my test program, but the debug cycle was so exhausting, when it was working reasonably well, I decided to release it into the wild.

Things to note!

The push buttons do not work the way the way you think (at least if you are a positive logic person like me), they work on negative inside out logic. To be fair the clues are in the documentation, but the example is bonzo (if that is a word). The logic is active low (clue!), so false is button pressed. The example actually works because it ignores the button press interrupt, and detects the button release interrupt (SW1 = true = not pressed). So if you think the example detects button presses, it doesn't, it detects button unpresses by testing to see if the SW1/2 variable is unchanged from the normal state (true). As I say bonzo to me until you figure it out (but it is important if you want to detect long vs short presses).

Devices (all of them) do not publish when connected to USB testboard gateway. As you don't seem to be able to disconnect the gateway once it's connected. You will see nothing published after loading the program.

You can't debug a program with an MQTT.Subscription in it (also any type of module)

If you have a run time error in your program, Led 2 will flash every 5 seconds or so as the modules reboots. If you are using LED 2 to indicate activity, this may confuse you for some time.

It is really hard to tell which LED is flashing as they are all red, and right next to each other. Obviously given the cost of different coloured LEDs, this is understandable, so you have to look really closely to see what is being indicated. Or just turn an LED on and leave it on to make things easier.

With the current scarcity of switches, a tiny jumper was needed to select USB or battery power. I suggest attaching it with a large chain, to prevent loosing it.

Try it out!, let me know what you think, and feel free to improve it.

All I need now is a SigFox network, and a gateway that doesn't loose WiFi at crucial moments.

And yes, the wife is away visiting family this weekend.
« Last Edit: January 15, 2017, 09:47:20 pm by Nick_W »
Winner Winner x 1 Love Love x 1 View List