Hi Todd, I fully understand this, Dan’s coding is very elegant, but in my case I started with
code from jodyalbritton’s JodyThing project, and from CHRISTOPHER SCORDINSKY’s programming.
My Arduino sketch, with three sensors, all I2C, with a local LCD compiles as follows
Sketch uses 19,826 bytes (69%) of program storage space. Maximum is 28,672 bytes.
Global variables use 1,319 bytes (44%) of dynamic memory, leaving 1,241 bytes for
local variables. Maximum is 2,560 bytes.
I donot think memory is the issue
I am able to send 3 pieces of data to Groovy Device Handler, and have it show up properly, sort of , on valueTiles on my smartphone.
For Android 2.14 I could not create multiline text on the valueTiles, or use lower case characters.
I just saw that 2.15 has just been released, but no mention of multiline text.
My problem is that I cannot send a command from the phone to the Arduino.
I confirmed that the Arduino’s hardware serial port is working properly,
I am not convinced that the shield is receiving data properly,
When powered up with the arduino code used by Christopher, as shown
//*****************************************************************************
void setNetworkStateLED()
{
SmartThingsNetworkState_t tempState = smartthing.shieldGetLastNetworkState();
if (tempState != stateNetwork)
{
switch (tempState)
{
case STATE_NO_NETWORK:
if (isDebugEnabled) Serial.println(“NO_NETWORK”);
smartthing.shieldSetLED(2, 0, 0); // red
break;
case STATE_JOINING:
if (isDebugEnabled) Serial.println(“JOINING”);
smartthing.shieldSetLED(2, 0, 0); // red
break;
case STATE_JOINED:
if (isDebugEnabled) Serial.println(“JOINED”);
smartthing.shieldSetLED(0, 0, 0); // off
break;
case STATE_JOINED_NOPARENT:
if (isDebugEnabled) Serial.println(“JOINED_NOPARENT”);
smartthing.shieldSetLED(2, 0, 2); // purple
break;
case STATE_LEAVING:
if (isDebugEnabled) Serial.println(“LEAVING”);
smartthing.shieldSetLED(2, 0, 0); // red
break;
default:
case STATE_UNKNOWN:
if (isDebugEnabled) Serial.println(“UNKNOWN”);
smartthing.shieldSetLED(0, 2, 0); // green
break;
}
stateNetwork = tempState;
}
}
the big LED on the Shield always turns to a Green color, indicating an :UNKNOWN" state
yet it still transmits correctly with a proper Smart Phone Valuetile display.
I put a pair of oscilloscope probes on the TXD, and RXD lines coming off the Arduino Shield
The Blue trace is the data being sent to the Shield from the Arduino, in this case the payload is “A37”
The red trace, I was surprised to see, is on the Arduino’s RXD line
I have looked at the Smartthings.h and .cpp files trying to determine the baudrate between the Arduino and the Smartthings Shield, I could not find and numbers. Anyone know the baudrate between the Arduino and the Shield?
I loaded the “stLEDwithNetworkStatus.ino” file and added
_#include <Wire.h>
_#include <LiquidCrystal.h>
_#include <TKLCD.h>
_#include “Adafruit_SHT31.h”
_#include <avr/pgmspace.h>
_Adafruit_SHT31 sht31 = Adafruit_SHT31();
_TKLCD_Local lcd = TKLCD_Local(); // when programming a TKLCD module itself
//*****************************************************************************
// Pin Definitions | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
// V V V V V V V V V V V V V V V V V V V V V V V V V V V V V
//*****************************************************************************
_#define PIN_LED 5
// this transmit to phone 05/31/16 4:53 pm
_#define PIN_THING_RX 0 // RX for Leonardo on TKLCD
_#define PIN_THING_TX 1 // TX for Leonardo on TKLCD
The underscores are to prevent this page from going bonkers with the Include # signs
The loop is
//*****************************************************************************
void loop()
{
// run smartthing logic
smartthing.run();
setNetworkStateLED();
Serial.println(“In the Loop”);
delay (5000);
}
The Arduino Debug Monitor shows a column of “In the Loop”
There is no Arduino data being transmitted, except what
smartthing.run(); and setNetworkStateLED(); create.
The oscilloscope waveform looks like this
Someting is being transmitted, and something is being received ( I have no idea as to what )
The last function looks like this, added some serial println for the Arduino Debug screen
//*****************************************************************************
void messageCallout(String message)
{
// if debug is enabled print out the received message
if (isDebugEnabled)
{
Serial.print(“Received message: '”);
Serial.print(message);
Serial.println("’ ");
}
// if message contents equals to ‘on’ then call on() function
// else if message contents equals to ‘off’ then call off() function
if (message.equals(“on”))
{
Serial.println(“on”);
on();
}
else if (message.equals(“off”))
{
Serial.println(“off”);
off();
}
}
The groovy code I have loaded has the ability to send the text “on” and “off”
While the above arduino code is running every 5 seconds, I get the oscilloscope wave form as above, but when I push the Test button Time on the Smart phone, to send a text message of “on” and “off” I get the following waveform
The added red I presume is the text being sent from the Groovy program, to the Shield, and into the Arduino.
So we are receiving something from the groovy program, whay is not showing up on the Arduino Debug screen?
Also, the Big LED on the Smart Things shield comes up Green.
If I knew the serial protocol used between the Arduino and the Shield, I may be able to use the scopes RS232 decoding to see what was being transmitted to the Arduino.
Any assistance would be appreciated
Ben