Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Nick_W

Pages: 1 ... 3 4 [5] 6 7 ... 15
61
mc-Studio / Re: Crashing during debugging
« on: January 17, 2017, 01:13:38 am »
I will have to go back and check what I'm doing, the MQTT library is all shared as it's not intended to be instansiated (although it does instantiate its own class of MQTTmessage). I will have to look at that.

The accelerometer libraries are all public, as they are intended to be instantiated. The new Time library is a mixture, so I will have to check that, but I think it's OK as there public functions are calling shared functions, (using the class name). So the main class is the real question.

In the main class, I'm fairly sure that most of my functions/subs are Public, but being called from shared events. I'm not trying to access Public variables in the Main class, there aren't any, as you can't instansiate the main class, all the Main class variables are shared or constants.

Do I need to go back and change them to shared to "future proof" them? Or is the Main class a special case as you can't have Public variables?

62
MQTT / Re: Beacons & MQTT
« on: January 17, 2017, 12:49:36 am »
Kbrooking

If you haven't found my github yet https://github.com/NickWaterton/mcScript I have examples of exactly that, plus a python program (beacon_decode.py) for receiving the beacons and converting them back to regular mqtt messages.

I currently support 12 data types (I think), such as temperature, battery, Rssi, humidity, pressure, altitude, boolean etc.

The data is converted to 24 bits, so there are limits on the range of numbers that can be sent, and you are limited to 2 decimal places, but the range is +/-32k, so enough for environmental sensors.

63
mc-Demo205 / Get GPS data into 12 bytes
« on: January 17, 2017, 12:25:46 am »
Does anyone know the accuracy of the GPS module? It's giving 6 decimal places, but it's hard to believe anything more than 4 decimal places are accurate.

Anyone have any code for shoehorning the gps lat and long into 24 or 32 bits, so they will fit in a SigFox payload?

If the floats are IEEE 754 format it should be easy enough to add them plus a timestamp into 12 bytes. Can you just add them to a ListOfBytes? I have tried the add and extract methods for ListofBytes without much luck. I think it's the extract methods that don't work.

Can anyone confirm these assumptions?

Thanks,

64
mc-Module / Time zones and RTC updates
« on: January 17, 2017, 12:20:47 am »
Does anyone know how time zones work? And how does the RTC on modules get updated? Is there a way to force an update?

I've been playing with my Time library, and find that quit often modules do not get their RTC updated, and so report 1999 or 2000. I assume the gateway is getting the time via NTP, and sends it to the modules. Is this just on boot, or does it periodically update? Can you get a module to request an update?

There is a time zone setting on the gateway config setup. How does this work? I have tried entering various values -4:00 for instance, but I don't know how this is passed to the modules, on boot? Plus it seems to make random changes to the module time (unrelated to the actual number). For instance entering -4:00 made 10 hours difference to the time, 0 made -4 hours difference to the time.

Z time is 1 hour off (DST I assume), so -4 hours should be eastern, but no, it's 10 hours off. Bit confusing how this works.

Anyone know?

65
Batw, I pointed out the same thing in my post yesterday. Also if you connect once via USB, you can't disconnect and reconnect without restarting mcStudio (it crashes).

Makes life difficult until you figure it out.

66
mc-Module / Maximum Length of a String?
« on: January 16, 2017, 04:43:23 pm »
Is there a maximum length of a string?

I ask, because I have a json object, which I am publishing via MQTT, and I'm getting a run time error "arguments too long", which is where I convert the json to a string (prior to ListofByte).

Depending on how long the strings in the json are, I get the error, or not. The magic number seems to be around 280 characters.

I'm working around it by splitting the strings into two json objects, and publishing both of them (which works).

What are the limitations?

Thanks,

67
mc-Module / Lots of new things posted
« on: January 16, 2017, 01:08:23 pm »
Checkout my github https://github.com/NickWaterton/mcScript

Lots of new things,

New Time library, provides multiple instances of Device.GetTimeSpan(), in millis and micros, Unix style GetTimeStamp in multiple formats, GetUptimeString() to get uptime in human readable format, plus further enhancements to follow.

New 110 Module DoorSensor version (now uses Time Library)
New 120 module accelerometer library update.
New Demo 205 test program.

New python module mqtt logging program.

Hopefully I'll get a few more updates in over the next few days.

Hope the new versions work for you!

For more info see the bottom of this post http://mcthings.createaforum.com/mc-demo205/tilting-trigger-on-the-accelerometer/.

68
mc-Demo205 / 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.

69
mc-Gateway / Re: Odd behavior of Gateway after last F/W update
« on: January 14, 2017, 10:49:21 am »
Update from Nick stuck in his time loop.

After monitoring this overnight (to see how frequent it is), I have a synopsis of my log files:
Note I cut out all the good data, this is just showing delays, so it's not as bad as it looks!

The first entry is example typical good data.

Code: [Select]
[I 2017-01-14 10:14:41,196] MCThings/000111C2/Data           : Decoded timestamp: 2017-01-14 10:14:38.556000
                                                               WARNING: Publishing Delay of : 2.640 s
--
[I 2017-01-14 10:14:59,743] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 10:14:29.870000
                                                               WARNING: Publishing Delay of : 29.873 s
--
[I 2017-01-14 10:14:59,860] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 10:14:59.919000
                                                               Publishing Delay of          : -0.059 s
--
[I 2017-01-14 10:15:40,380] MCThings/000111B4/Data           : Decoded timestamp: 2017-01-14 10:14:38.728000
                                                               WARNING: Publishing Delay of : 61.652 s
--
[I 2017-01-14 10:15:40,621] MCThings/000111B4/Data           : Decoded timestamp: 2017-01-14 10:15:38.777000
                                                               Publishing Delay of          : 1.844 s
--
[I 2017-01-14 10:16:59,822] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 10:15:29.968000
                                                               WARNING: Publishing Delay of : 89.854 s
--
[I 2017-01-14 10:17:00,074] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 10:15:59.017000
                                                               WARNING: Publishing Delay of : 61.057 s
--
[I 2017-01-14 10:17:00,184] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 10:16:30.074000
                                                               WARNING: Publishing Delay of : 30.110 s
--
[I 2017-01-14 10:17:00,318] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 10:17:00.123000
                                                               Publishing Delay of          : 0.195 s
--
.
.
. long period of the same good/delayed data
.
.
.
[I 2017-01-14 11:00:33,974] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 11:00:04.399000
                                                               WARNING: Publishing Delay of : 29.575 s
--
[I 2017-01-14 11:00:34,099] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 11:00:34.448000
                                                               Publishing Delay of          : -0.349 s
--
[I 2017-01-14 11:02:04,186] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 11:01:34.546000
                                                               WARNING: Publishing Delay of : 29.640 s
--
[I 2017-01-14 11:02:04,315] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-14 11:02:04.599000
                                                               Publishing Delay of          : -0.284 s
--
[I 2017-01-14 11:02:41,863] MCThings/000111B4/Data           : Decoded timestamp: 2017-01-14 11:01:40.128000
                                                               WARNING: Publishing Delay of : 61.735 s
--
[I 2017-01-14 11:02:41,987] MCThings/000111B4/Data           : Decoded timestamp: 2017-01-14 11:02:40.178000
                                                               Publishing Delay of          : 1.809 s
--
[I 2017-01-14 11:02:42,912] MCThings/000111C2/Data           : Decoded timestamp: 2017-01-14 11:01:40.924000
                                                               WARNING: Publishing Delay of : 61.988 s
--
[I 2017-01-14 11:02:43,046] MCThings/000111C2/Data           : Decoded timestamp: 2017-01-14 11:02:40.973000
                                                               WARNING: Publishing Delay of : 2.073 s

Module BC is a battery monitor, so delayed messages don't really matter, so much. C2 and B4 are door monitors (running the same code), delays here are a problem (but the beacons arrive immediately, so there is a sort of workaround).

It seems to me there are a couple of possibilities (OK more than a couple):
  • This is behavior that was always happening, but messages were being lost, not cached, so in fact this is an improvement, in that the messages do eventually arrive.
  • This is some sort of continuation of my Gateway WiFi issues, that have not been properly explained yet, and messages that can't be sent immediately (via WiFi) are cached for later retry. I really need a second gateway to see if this has the same problem.
  • A fix for the "stops publishing" problem has introduced another problem where messages are now delayed (instead of the module stopping publishing) which is better, but still something of an issue.
  • This is a QoS issue, which I could fix if I understood QoS better. So far QoS seems to make no difference to the delay problem.
  • This is a LP network issue, which is now showing up as I'm sending longer (json) messages, and the retry mechanism is "resend failed messages on the next connection".

What I don't understand is whether the delayed message is cached on the module, or the gateway. If it was the gateway, it could resend immediately (and QoS would help). If it's cached on the module, does this indicate a LP network connectivity issue (in which case why do beacons arrive immediately, and mqtt messages don't?). Is this a new thing I'm seeing since I switched to sending json (with timestamps), because json is much longer to send than beacons/short data - ie just publishing a value works, but sending a long json string fails partway through and is queued for retry the next time the module sends? I'm tending to think this is what is happening (ie option 5 above).

Uptime continues to be fantastic, literally weeks without a reset (well done whoever figured that out).
Battery life on the 120 module is holding good for now at 2.881V after 3 days (I need a few weeks to be able to say for sure this problem is fixed), but so far so good.

I may actually be able to get my 120 module accelerator library finished, and unlimber my 205 device...

Keep up the good work guys, and sorry to be the reporter of "weird stuff".

70
mc-Gateway / Re: Odd behavior of Gateway after last F/W update
« on: January 13, 2017, 07:45:18 pm »
Update,

I can now confirm that all modules and all data types published by MQTT suffer from random delays of up to several minutes (not just json).

Sometimes they arrive immediately, sometimes delayed by seconds to minutes. Beacons always arrive immediately.

Please take a look at this, I have posed my code to github https://github.com/NickWaterton/mcScript The two projects that show this problem the easiest are DoorSensor (the 110 module version) and BatteryMonitor.

Please let me know I'm not living in a time warp...

71
mc-Gateway / Odd behavior of Gateway after last F/W update
« on: January 13, 2017, 02:38:21 pm »
I would like to report some strange thing I am seeing after the last couple of F/W updates:

First, after the last upgrade, my previous problems connecting to WiFI have disappeared! My gateway is now connecting to WiFi properly again. I think this confirms that something in one of the recent upgrades broke WiFi - probably something to do with the gateway registry, as that was erased in the last upgrade.

After reconnecting to each module, mqtt data started to flow again.

Now, since I have implemented my timestamping system, I can see the delays from module to gateway to broker to me. Usually in the range of 3 seconds (but some at 140s), which could just be clock synchronization offset (I'm looking at delivery variation, not absolute values). This compares the timestamp from my server (from NTP) with the module timestamp (from the onboard RTC, set via the gateway).

However, from time to time, there will be a period when no mqtt data arrives on schedule, but then later, 2 or more messages arrive at the same time. I can see from the timestamps that they were sent on time correctly, but the gateway seems to be caching the messages, then delivers 2 or sometimes 3 messages all at once.

See this example output from my logging program: The timestamp on the left is from my server receiving the data from the broker (running on the server), the decoded timestamp is from the module.

Code: [Select]
[I 2017-01-13 15:22:37,548] MCThings/000111BC/BatteryVoltage : 3596.0
[I 2017-01-13 15:22:37,548] MCThings/000111BC/Rssi           : -79
[I 2017-01-13 15:22:38,917] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-13 15:19:48.727000
                                                               WARNING: Publishing Delay of : 170.191 s
                                                               {
                                                                 "time": "1484338788727",
                                                                 "Uptime": 73684,
                                                                 "UptimeString": "0:20:28:4",
                                                                 "BatteryVoltage": 3596,
                                                                 "Temperature": 23.125,
                                                                 "LowBattery": false
                                                               }
[I 2017-01-13 15:22:39,048] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-13 15:20:18.776000
                                                               WARNING: Publishing Delay of : 140.273 s
                                                               {
                                                                 "time": "1484338818776",
                                                                 "Uptime": 73714,
                                                                 "UptimeString": "0:20:28:34",
                                                                 "BatteryVoltage": 3596,
                                                                 "Temperature": 23.125,
                                                                 "LowBattery": false
                                                               }
[I 2017-01-13 15:23:07,973] MCThings/000111BC/LowBattery     : 0.0
[I 2017-01-13 15:23:07,974] MCThings/000111BC/Rssi           : -79
[I 2017-01-13 15:23:13,294] MCThings/000111BC/LowBattery     : 0.0
[I 2017-01-13 15:23:13,294] MCThings/000111BC/Rssi           : -79
[I 2017-01-13 15:23:23,293] MCThings/000111BC/LowBattery     : 0.0
[I 2017-01-13 15:23:23,293] MCThings/000111BC/Rssi           : -79
[I 2017-01-13 15:23:37,898] MCThings/000111BC/LowBattery     : 0.0
[I 2017-01-13 15:23:37,898] MCThings/000111BC/Rssi           : -79
[I 2017-01-13 15:23:40,309] MCThings/000111BC/LowBattery     : 0.0
[I 2017-01-13 15:23:40,309] MCThings/000111BC/Rssi           : -79
[I 2017-01-13 15:23:41,114] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-13 15:20:48.825000
                                                               WARNING: Publishing Delay of : 172.290 s
                                                               {
                                                                 "time": "1484338848825",
                                                                 "Uptime": 73744,
                                                                 "UptimeString": "0:20:29:4",
                                                                 "BatteryVoltage": 3596,
                                                                 "Temperature": 23.125,
                                                                 "LowBattery": false
                                                               }
[I 2017-01-13 15:23:41,243] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-13 15:21:18.874000
                                                               WARNING: Publishing Delay of : 142.369 s
                                                               {
                                                                 "time": "1484338878874",
                                                                 "Uptime": 73774,
                                                                 "UptimeString": "0:20:29:34",
                                                                 "BatteryVoltage": 3596,
                                                                 "Temperature": 23.125,
                                                                 "LowBattery": false
                                                               }
[I 2017-01-13 15:24:07,943] MCThings/000111BC/BatteryVoltage : 3596.0
[I 2017-01-13 15:24:07,944] MCThings/000111BC/Rssi           : -79
[I 2017-01-13 15:24:09,936] MCThings/000111BC/Data           : Decoded timestamp: 2017-01-13 15:21:48.923000
                                                               WARNING: Publishing Delay of : 141.013 s
                                                               {
                                                                 "time": "1484338908923",
                                                                 "Uptime": 73804,
                                                                 "UptimeString": "0:20:30:4",
                                                                 "BatteryVoltage": 3596,
                                                                 "Temperature": 23.125,
                                                                 "LowBattery": false
                                                               }
[I 2017-01-13 15:24:23,292] MCThings/000111BC/BatteryVoltage : 3596.0
[I 2017-01-13 15:24:23,292] MCThings/000111BC/Rssi           : -77

This is from a module set to publish json data every 30 seconds (the other numbers are decoded beacons). I'm assuming that the 140s baseline is just clock offset (but another module gives a delay of 3 seconds - they were both uploaded today - so why the difference?).

Anyway, as you can see, the internal timestamps show that they are indeed sent 30s apart, but they are received in groups of 1,2 or sometimes 3.

My gateway is back in it's central location, and QoS is set to default (QoS.AtMostOnce I think.)

Is my gateway still messed up? it didn't use to do this before. All my modules are doing this, not just one. The only ones that seem to be OK, are the ones not sending json (but they don't have timestamps, so it's hard to tell).

Some modules mostly report correctly, with occasional "make up" publishing, others mostly publish in groups. They are all the same distance (with rssi in the -70 range) from the gateway.

I do seem to be missing some beacons also. This sort of thing was definitely not happening before the latest upgrades. For example, my door sensor would report door open/closed within 0.2 seconds of my other door sensors reporting. Now, I get a sequence of door open/close events minutes after to door has opened/closed.

This is a log from my door sensor (which has not updated it's RTC - not sure why...):

Code: [Select]
[I 2017-01-13 15:49:06,687] subscribing to MCThings/000111C2/#
[I 2017-01-13 15:49:08,820] MCThings/000111C2/Door : 0.0
[I 2017-01-13 15:49:08,820] MCThings/000111C2/Rssi : -72
[I 2017-01-13 15:49:10,075] MCThings/000111C2/Data : Decoded timestamp: 1999-12-31 17:20:07.264000
                                                     Date/time not updated on module
                                                     {
                                                       "time": "946678807264",
                                                       "Uptime": 8407,
                                                       "UptimeString": "0:2:20:7",
                                                       "BatteryVoltage": 2819,
                                                       "Temperature": 14.875,
                                                       "Door": false,
                                                       "KnockEnable": true,
                                                       "PublishEnable": true
                                                     }
[I 2017-01-13 15:49:20,132] MCThings/000111C2/Door : 1.0
[I 2017-01-13 15:49:20,132] MCThings/000111C2/Rssi : -81
[I 2017-01-13 15:49:23,778] MCThings/000111C2/Door : 0.0
[I 2017-01-13 15:49:23,778] MCThings/000111C2/Rssi : -72
[I 2017-01-13 15:50:01,183] MCThings/000111C2/Door : 0.0
[I 2017-01-13 15:50:01,183] MCThings/000111C2/Rssi : -72
[I 2017-01-13 15:50:08,991] MCThings/000111C2/Uptime : 8467.0
[I 2017-01-13 15:50:08,992] MCThings/000111C2/Rssi   : -72
[I 2017-01-13 15:50:09,898] MCThings/000111C2/Data   : Decoded timestamp: 1999-12-31 17:20:18.144000
                                                       Date/time not updated on module
                                                       {
                                                         "time": "946678818144",
                                                         "Doorknock": true
                                                       }
[I 2017-01-13 15:50:10,019] MCThings/000111C2/Data   : Decoded timestamp: 1999-12-31 17:20:18.259000
                                                       Date/time not updated on module
                                                       {
                                                         "time": "946678818259",
                                                         "Door": true
                                                       }
[I 2017-01-13 15:50:10,144] MCThings/000111C2/Data   : Decoded timestamp: 1999-12-31 17:20:20.850000
                                                       Date/time not updated on module
                                                       {
                                                         "time": "946678820850",
                                                         "Door": false
                                                       }
[I 2017-01-13 15:50:10,327] MCThings/000111C2/Data   : Decoded timestamp: 1999-12-31 17:21:07.311000
                                                       Date/time not updated on module
                                                       {
                                                         "time": "946678867311",
                                                         "Uptime": 8467,
                                                         "UptimeString": "0:2:21:7",
                                                         "BatteryVoltage": 2819,
                                                         "Temperature": 14.9375,
                                                         "Door": false,
                                                         "KnockEnable": true,
                                                         "PublishEnable": true
                                                       }

Note the "[I 2017-01-13 15:49:20,132] MCThings/000111C2/Door : 1.0" this is a beacon reporting the door open, then "[I 2017-01-13 15:49:23,778] MCThings/000111C2/Door : 0.0" (0.0 is closed). So the door opened at 15:49:20,132 and closed 3.5 seconds later. The MQTT doesn't show up until "[I 2017-01-13 15:50:10,019]" ie 50 seconds later, but the internal timestamps show the same 3.5 seconds difference, so they were sent correctly, at the correct time, but all arrive at once.

This is NOT what used to happen before the latest upgrades, and obviously makes a door sensor useless...

Any idea's what is going on? this is messing with my real-time data collection.

72
mc-Module / Re: Reed Switch Problems
« on: January 12, 2017, 11:58:18 pm »
The

Code: [Select]
Thread.Sleep(10000)
Thread.ClearHardwareEvent()

In inSync() won't do anything (except for a small delay), so you should remove that.

The second occurance in ReedSwitchChanged() should come first, ie before if ReedSwitch = True Then....

What this is doing is compensating for switch bounce. Because the reedswitch is a physical piece of metal, it can "bounce" so you get several interrupts while it is "bouncing". If you read the ReedSwitch while it is bouncing, you can get false readings. The idea behind Thread.sleep(10000) is to wait 10ms for it to stop bouncing, then read it, hence the delay has to come before you read the switch.

The Thread.ClearHardwareEvent() clears any waiting interrupts in the routine that called it, in this case probably caused by the switch bouncing (otherwise the interrupt may trigger twice - the queue is only 2 deep).

This means that you can't read events that happen faster than every 10ms, but given that this is a physical switch, that is probably not possible anyway.

Hope this explains!

73
mc-Demo205 / Re: Tilting Trigger on the Accelerometer
« on: January 12, 2017, 11:10:36 pm »
The library Bartw refers to is the only currently working library, and its "alpha" at best. I am in the process of making a full featured library for the accelerometer in the 120 module, but was waiting for the battery issue to be solved.

With that likely solved in the latest firmware, I will get back to making this library into a full "beta" release, but it may take a little while.

The accelerometer in the 120 module can do what you want, and there are "bare bones" hooks into the functions in the library - but they are mostly untested, and need a deep understanding of the device and how it works (ie deep dive into the data sheet) to make working code from the current library. This was just my first pass.

I also have a 205, and some 120's, so I'm interested in getting this library to a usable state. I'll let you know when I have something easier to use.

If you dive into it, you could get something working from what we currently have though.

Take a look at

Code: [Select]
    Public Sub SetInterruptEnable1Bits(mode As Byte)
        'Set Interrupt 1 Enable bits  bits 1,2,3,4,5,6,7 (bit 0 not used)
        '(0: disable; 1: enable)
        'I1_CLICK CLICK interrupt on INT1 pin. Default value 0. bit 7
        'I1_AOI1 AOI1 interrupt on INT1 pin. Default value 0. bit 6
        'I1_AOI2 AOI2 interrupt on INT1 pin. Default value 0. bit 5
        'I1_DRDY1 DRDY1 interrupt on INT1 pin. Default value 0. bit 4
        'I1_DRDY2 DRDY2 interrupt on INT1 pin. Default value 0. bit 3
        'I1_WTM FIFO watermark interrupt on INT1 pin. Default value 0. bit 2
        'I1_OVERRUN FIFO overrun interrupt on INT1 pin. Default value 0. bit 1
        write(CTRL_REG3, (read(CTRL_REG3) & ~INT1_ENABLE_MASK) | mode)
    End Sub

And

Code: [Select]
    Public Sub SetINT1ActiveInterrupt(interrupt As Byte)
        'AOI And/Or combination of interrupt events. Default value: 0. Refer to Table 51 bit 7
        '6D 6-direction detection function enabled. Default value: 0. Refer to Table 51 bit 6
        'AOI 6D Interrupt mode
        ' 0  0 OR combination of interrupt events
        ' 0  1 6-direction movement recognition
        ' 1  0 AND combination of interrupt events
        ' 1  1 6-direction position recognition
        'Default value: 0 (0: disable interrupt request;1: enable interrupt request)
        'ZHIE/ZUPE Enable interrupt generation on Z high event or on direction recognition. bit 5
        'ZLIE/ZDOWNE Enable interrupt generation on Z low event or on direction recognition. bit 4
        'YHIE/YUPE Enable interrupt generation on Y high event or on direction recognition. bit 3
        'YLIE/YDOWNE Enable interrupt generation on Y low event or on direction recognition. bit 2
        'XHIE/XUPE Enable interrupt generation on X high event or on direction recognition. bit 1
        'XLIE/XDOWNE Enable interrupt generation on X low event or on direction recognition. bit 0
        write(INT1_CFG, interrupt)
    End Sub

AOI is the Accelerator Orientation Interrupt, DRDY is Data Ready.. You need to configure things correctly first, and clear the interrupts after they fire though.

Read through the library and see what you can come up with.

74
mc-Studio / Re: Crashing during debugging
« on: January 12, 2017, 10:41:49 pm »
Is that correct? A shared event can't call a public function in the same class? I swear I'm doing this, and it works.

I'm not debugging though, I can't get debugging to work if I have an mqtt subscription in the code.

Would the code not work if you did this, or would it cause obscure bugs?

75
mc-Module / MQTT QoS How Does it Work?
« on: January 12, 2017, 10:06:40 am »
Can anyone explain how the MQTT QoS setting works?

The reason I ask is that I'm not sure if this is controlling the connection between the module and the gateway, or the gateway and the MQTT server.

My gateway is not connecting to WiFi properly (after the last firmware upgrade - but this may be co-incidence), so I have connected it via Ethernet to my switch, which is in the basement. Now, some modules that are far away are only communicating sporadically.

Beacons mostly get through, but most (not all) MQTT messages are missed. I was wondering if changing the QoS setting would help. ie, does the module resend the MQTT message, if it does not get acknowledgment from the gateway (if QoS was set to QoS.AtLeastOnce), or does the module just "fire and forget", and the QoS setting is more to do with the gateway caching the message until it can confirm that the server has received it (in which case this is not of much use to me as it's hard wired).

Not sure why beacons would get through, but not mqtt messages - other than the fact that beacons are small, and mqtt messages are long...

Everything seems to work OK with the gateway centrally located, but WiFi either won't connect, or drops out (when it does connect) after a few hours (and doesn't reconnect).

Is there a warranty on the gateways? I've had it less than a year...

Pages: 1 ... 3 4 [5] 6 7 ... 15