Announcing the "ST_Anything" Arduino/ThingShield Project

Yep, the issue you’re now faced with is the fact that the Arduino MEGA and the ThingShield are not communicating to each other correctly. The sketch is running, as is evident from the Serial Monitor, however it waits until it can communicate with the ThingShield before proceeding.

In the picture you showed above, it almost looks like one of the jumpers is plugged into the empty space next to pin 14, and the jumper that should be in pin 15 is actually in pin 14. It is probably just the way the picture was taken however.

I believe you stated that you’ve tried using my sketches as-is, direct from my Github repository, correct? I just want to make sure that you didn’t change any pin assignments, possibly causing a conflict with pins 2/3 and pins 14/15.

If desired, you can also try using a different Hardware UART on the Arduino MEGA, to make sure pins 14/15 aren’t the problem. To do so, you’ll need to edit a file in the ST_Anything library called constants.h. Near the very bottom of the file, you’ll want to adjust the code to comment out the last line, and uncomment the second to last line.

Before
//static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL2; //MEGA - You MUST jumper Pin16 to Pin2 AND Pin17 to Pin3 - do not use Pin2 or Pin3 in your sketch!
static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL3; //MEGA - You MUST jumper Pin14 to Pin2 AND Pin15 to Pin3 - do not use Pin2 or Pin3 in your sketch!

After
static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL2; //MEGA - You MUST jumper Pin16 to Pin2 AND Pin17 to Pin3 - do not use Pin2 or Pin3 in your sketch!
//static const SmartThingsSerialType_t SERIAL_TYPE = HW_SERIAL3; //MEGA - You MUST jumper Pin14 to Pin2 AND Pin15 to Pin3 - do not use Pin2 or Pin3 in your sketch!

You’ll then need to change your jumper wires accordingly - You must jumper Pin16 to Pin2 AND Pin17 to Pin3.

If this doesn’t work, we’ll need to look elsewhere. By the way, what version of the Arduino IDE are you running? I have seen issues caused by IDE releases which required code changes to address. I am running version 1.6.5 and have not updated it in a long time. I may try the latest version to see if it works, or causes any issues.

BTW - Here is what the Serial Monitor display should look like when everything is working. Example from the ST_Anything.ino sketch:

Everything: init started
Everything: Free RAM = 6180
Everything: UNKNOWN
Everything: JOINED
Everything: init ended
Everything: Free RAM = 6180
Everything: adding sensor named illuminance
Everything: Free RAM = 6170
Everything: adding sensor named temphumid
Everything: Free RAM = 6170
Everything: adding sensor named water
Everything: Free RAM = 6170
Everything: adding sensor named motion
Everything: Free RAM = 6170
Everything: adding sensor named contact
Everything: Free RAM = 6170
Everything: adding executor named switch
Everything: Free RAM = 6170
Everything: adding executor named alarm
Everything: Free RAM = 6170
Everything: initDevices started
Everything: Free RAM = 6176
Everything: Sending: illuminance 391
Everything: Sending: temperature 78
Everything: Sending: humidity 50
PS_Water::Analog Pin value is 207 vs limit of 200
Everything: Sending: water wet
IS_Motion: 30 second Motion Sensor Calibration Started...
Everything: Sending: contact closed
Everything: Sending: switch off
Everything: Sending: alarm off
Everything: initDevices ended
Everything: Free RAM = 6176
IS_Motion: Motion Sensor Calibration Finished
Everything: Sending: motion active

Yes I am using your code as is unchanged I will try the suggested method you described above and let you know the out come. And again thank you for taking the time to try and correct my problem.

FYI - I just tried Arduino 1.6.12 with no success at all. 1.6.12 caused compiler errors. Not sure what is wrong.

I reverted back to Aruino IDE v1.6.5-r5 and all is well again.

What version of the Arduiono IDE are you running? On what platform (Windows, Linux, MAC OS)?

The latest IDE 1.6.12 on windows

I do not see version 1.6.5-r5 just v 1.6.5 are they the same?

I would guess they are the same. I am going to try going through each version, 1.6.6 - 1.6.12 to see if U can figure out where things break.

So i downloaded v1.6.5 now I am seeing some action in in the Serial Monitor. Now it looks identical to what you posted above. I will continue through the process and let you know how it goes.

That is excellent news! I will take a look and try to get the more recent versions of Arduino IDE working with my project.

My 1st test was with v1.6.6 and it is already broken… :frowning:

So, I believe part of my particular problem with the newer versions of the Arduino IDE had to do with how I had my PC configured to use Symbolic Links within the Arduino Libraries folder in my c:\users\username\documents\arduino\libraries folder.

I have removed those sym-links and copied all of the source code for the libraries to that local folder. Afterwards, I am able to use all versions (1.6.5 through 1.6.12) of the Arduino IDE EXCEPT v1.6.6. I am currently running v1.6.12 and it compiles, downloads, and runs the ST_Anything.ino sketch without any issues so far. I did clear out some other libraries that were not needed which may need to be updated to avoid other issues. The Arduino IDE is a little weird, as it has to compile everything in the libraries folder, even if the sketch you’re building does not include the library.

Hope this helps.

It does thank you i will try that after I get all this going. I am having some issues with my motion sensor it only reports motion every so often. Why might that be?

If you’re using the “typical Arduino PIR motion sensor”, it has two small potentiometers on it, as well as a jumper (usually).

The potentiometers are used to 1) adjust sensitivity & 2) to adjust how long to keep the output HIGH after motion STOPS. The delay is user selectable by twisting the potentiometer to suit your needs, but it is advised that you don’t set it to zero. I like mine at at least 30 seconds, as you don’t want a constant stream of “motion” - “no motion” events being sent to the SmartThings cloud.

The jumper is usually used to determine whether the output signal toggles on/of continuously when motion is detected, or just held HIGH when motion is detected. My software assumes the latter. Make sure your jumper is set correctly.
See detailed info here https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/testing-a-pir

Ok I will double check it. It is a Bosch motion sensor but I believe it does have adjustment I will verify. Thanks

Has anyone seen this error when trying to upload to the board

Arduino: 1.6.12 (Windows 10), Board: “Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)”

Sketch uses 22,998 bytes (9%) of program storage space. Maximum is 253,952 bytes.
Global variables use 1,665 bytes (20%) of dynamic memory, leaving 6,527 bytes for local variables. Maximum is 8,192 bytes.
java.io.IOException: Cannot run program “REMOVE/bin/avrdude”: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:26)
at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:129)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:206)
at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78)
at processing.app.SketchController.upload(SketchController.java:707)
at processing.app.SketchController.exportApplet(SketchController.java:680)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2176)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
… 8 more
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I can’t get 1.6.12 to upload. It compiles fine but will not upload

Never Mind…Got it to load after going to /user/name/appdata/ and delete Arduino15 directory and insuring that I updates all libraries then getting out and back in

1 Like

For the most part I believe I got things up and running. Still have a few sensors that don’t report in the app but i will tinker some more see if I can figure that out. I do have a question about adding multiple motion sensors. What exactly has to be changed in the code to accomplish this. I know I read somewhere above but really didn’t see a clear description. I have tried a few different things but cant get them to work. Any advice would be greatly appreciated, Thank you.

I think I may have found the answer in your ST_Anything_Alarm_Panel.device.groovy. I am assuming I just need to copy the motion part of this code and add it into what I am using maybe? Somehow? I know it needs to be changed in three places correct Arduino, Device Handler and smart app? I will give it a shot.

David,

Yes, that is a good example that show multiple motion detectors on one Arduino. You will need to modify your Arduino sketch, the Device Type Handler, the Multiplexer SmartApp, and create, using the ST IDE, the corresponding Virtual Motion Sensor devices found below.

https://github.com/DanielOgorchock/ST_Anything/blob/master/Groovy/VirtualDevices/VirtualMotionSensor.device.groovy

In the Multiplexer SmartApp would I add a new section for Motion or can I just put it under the contact sensors?

would something like this work for Multiplex

//-----Motion 1 ------

def motion1active(evt)
{
if (motion1.currentValue(“motion”) != “active”) {
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)"
motion1.active()
}

def motion1inactive(evt)
{
if (motion1.currentValue(“motion”) != “inactive”) {
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)"
motion1.inactive()
}