[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

Its an Arduino Mega with an esp01 attached. Haven’t gotten around to getting an ESP8266 running yet but I hope to for some smaller devices around the house.


All done, I created a device handler and I’m seeing the button presses on the arduino serial. Used the timedrelay class to create the child and have it post the button presses as smartstrings for the callback() function to pick up and act on.
Sounds like not the way you would have made it but it works and required the least editing.
I’m away till monday but I’ll start looking into sound integration then.

3 Likes

Dear
When compiling the solution for the esp8266 I only get an error the arduino compiler.
This is the error:

Opciones de compilación cambiadas, reconstruyendo todo
Archiving built core (caching) in: C:\Users\FLIACA~1\AppData\Local\Temp\arduino_cache_396682\core\core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_512K64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____249db45d60b27e52e966680d93691659.a
libraries\SmartThings\SmartThingsESP8266WiFi.cpp.o: In function `st::SmartThingsESP8266WiFi::SmartThingsESP8266WiFi(String, String, IPAddress, IPAddress, IPAddress, IPAddress, unsigned short, IPAddress, unsigned short, void (*)(String), String, bool, int)':

C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings/SmartThingsESP8266WiFi.cpp:40: multiple definition of `st::SmartThingsESP8266WiFi::init()'

libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp.o:C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi/SmartThingsESP8266WiFi.cpp:59: first defined here

libraries\SmartThings\SmartThingsESP8266WiFi.cpp.o: In function `st::SmartThingsESP8266WiFi::run()':

C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings/SmartThingsESP8266WiFi.cpp:19: multiple definition of `st::SmartThingsESP8266WiFi::SmartThingsESP8266WiFi(String, String, IPAddress, IPAddress, IPAddress, IPAddress, unsigned short, IPAddress, unsigned short, void (*)(String), String, bool, int)'

libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp.o:C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi/SmartThingsESP8266WiFi.cpp:18: first defined here

libraries\SmartThings\SmartThingsESP8266WiFi.cpp.o: In function `st::SmartThingsESP8266WiFi::run()':

C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings/SmartThingsESP8266WiFi.cpp:19: multiple definition of `st::SmartThingsESP8266WiFi::SmartThingsESP8266WiFi(String, String, IPAddress, IPAddress, IPAddress, IPAddress, unsigned short, IPAddress, unsigned short, void (*)(String), String, bool, int)'

libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp.o:C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi/SmartThingsESP8266WiFi.cpp:18: first defined here

libraries\SmartThings\SmartThingsESP8266WiFi.cpp.o: In function `st::SmartThingsESP8266WiFi::~SmartThingsESP8266WiFi()':

Se encontraron múltiples librerías para "SmartThingsESP8266WiFi.h"
C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings/SmartThingsESP8266WiFi.cpp:31: multiple definition of `st::SmartThingsESP8266WiFi::~SmartThingsESP8266WiFi()'

Usado: C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi
 No usado: C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings
libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp.o:C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi/SmartThingsESP8266WiFi.cpp:50: first defined here

libraries\SmartThings\SmartThingsESP8266WiFi.cpp.o: In function `st::SmartThingsESP8266WiFi::~SmartThingsESP8266WiFi()':

C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings/SmartThingsESP8266WiFi.cpp:31: multiple definition of `st::SmartThingsESP8266WiFi::~SmartThingsESP8266WiFi()'

libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp.o:C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi/SmartThingsESP8266WiFi.cpp:50: first defined here

libraries\SmartThings\SmartThingsESP8266WiFi.cpp.o: In function `st::SmartThingsESP8266WiFi::~SmartThingsESP8266WiFi()':

C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings/SmartThingsESP8266WiFi.cpp:31: multiple definition of `st::SmartThingsESP8266WiFi::~SmartThingsESP8266WiFi()'

libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp.o:C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi/SmartThingsESP8266WiFi.cpp:50: first defined here

libraries\SmartThings\SmartThingsESP8266WiFi.cpp.o: In function `st::SmartThingsESP8266WiFi::run()':

C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings/SmartThingsESP8266WiFi.cpp:83: multiple definition of `st::SmartThingsESP8266WiFi::run()'

libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp.o:C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi/SmartThingsESP8266WiFi.cpp:110: first defined here

libraries\SmartThings\SmartThingsESP8266WiFi.cpp.o: In function `st::SmartThingsESP8266WiFi::send(String)':

C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThings/SmartThingsESP8266WiFi.cpp:144: multiple definition of `st::SmartThingsESP8266WiFi::send(String)'

libraries\SmartThingsESP8266WiFi\SmartThingsESP8266WiFi.cpp.o:C:\Users\Flia Caicedo-Aparici\Documents\Arduino\libraries\SmartThingsESP8266WiFi/SmartThingsESP8266WiFi.cpp:203: first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compilando para la tarjeta Generic ESP8266 Module.

Arduino is configured as follows

Can you successfully compile one of the standard Arduino examples, like Blink, for the ESP8266?

Actually, it appears you have an older version of my Smartthings libarary, as well as the newer one. I split the Smartthings library into multiple folders. Please remove all of your current ‘SmartThings’ Arduino libraries. Then download the latest version of all of the SmartThings library folders from my github repository and copy them to your Arduino\lubraries folder.

1 Like

Hi Dan,
I will am writing a smart app that subscribes to events and sends them to st_anything for sound effects. As I’m essentially making this up as I go along I dont suppose you know how the line of code that could call the sendEthernet() command in your device handler Parent_ST_Anything_Ethernet from a smartapp would be written?
I will just send event strings to the arduino and trigger sounds/states in response.
Thank you

@Alex_Payne

You may want to read up on the ST Documentation regarding a SmartApp calling a “command” in a Device Handler at http://docs.smartthings.com/en/latest/smartapp-developers-guide/devices.html#sending-commands.

This provides a good, high-level overview. To expose the “sendEthernet()” command to a SmartApp, you’ll need to modify the Parent Device Handler to add the custom command at the bottom of the definition section as shown below. This exposes the custom command to be used by SmartApps. I am not sure how easily arguments can be passed from the SmartApp to this custom command in the Device Handler as I have never tried to do this. The documentation that I linked above seems to indicate that it can be done.

	definition (name: "Parent_ST_Anything_Ethernet", namespace: "ogiewon", author: "Dan Ogorchock") {
		capability "Configuration"
            capability "Refresh"
            capability "Button"
            capability "Holdable Button"

            command "sendEthernet" 
	}

Thank you. I look forward to solving it and I’ll let you know

So I made a smart app that monitors events and sends the ones you want to the arduino. Added the command line to the parent device handler like you said.
Events appear on the callback sniffer as “Bathroom light On” “Pantry door Open” etc
I already have a working arduino set up that plays sound effects nice and loud and now this works I just have to put the 2 circuits and .ino programs together and it will work.

Smart App is here if anyone wants or has need of such a thing:

definition(
name: “WOPBOX Event Monitor”,
namespace: “Alex Payne”,
author: “Alex Payne”,
description: “Monitors hub events and informs WOPBOX”,
category: “Mode Magic”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/App-LightUpMyWorld.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/App-LightUpMyWorld@2x.png
)

preferences {

section(“Select WOPBOX”) {
input “WOPBOX”, “capability.configuration”, required: true
}
section(“Select events to be sent to WOPBOX”){
input “mySwitch”, “capability.switch”, title: “Switches”, required: false, multiple: true
input “myButton”, “capability.button”, title: “Buttons”, required: false, multiple: true
input “myMomentaryContact”, “capability.momentary”, title: “Momentary Contacts”, required: false, multiple: true
input “myMotion”, “capability.motionSensor”, title: “Motion Sensors”, required: false, multiple: true
input “myContact”, “capability.contactSensor”, title: “Contact Sensors”, required: false, multiple: true
input “myLock”, “capability.lock”, title: “Locks”, required: false, multiple: true
input “myThermostat”, “capability.thermostat”, title: “Thermostats”, required: false, multiple: true
input “myTemperature”, “capability.temperatureMeasurement”, title: “Temperature Sensors”, required: false, multiple: true
input “myBrightness”, “capability.illuminanceMeasurement”, title: “Light Sensors”, required: false, multiple: true
input “myHumidty”, “capability.relativeHumidityMeasurement”, title: “Humidty Sensors”, required: false, multiple: true
input “myEnergy”, “capability.energyMeter”, title: “Energy Sensors”, required: false, multiple: true
input “myPower”, “capability.powerMeter”, title: “Power Sensors”, required: false, multiple: true
input “myAcceleration”, “capability.accelerationSensor”, title: “Acceleration Sensors”, required: false, multiple: true
input “myPresence”, “capability.presenceSensor”, title: “Presence Sensors”, required: false, multiple: true
input “mySmoke”, “capability.smokeDetector”, title: “Smoke Sensors”, required: false, multiple: true
input “myWater”, “capability.waterSensor”, title: “Water Sensors”, required: false, multiple: true
input “myCO”, “capability.carbonMonoxideDetector”, title: “Carbon Monoxide Detectors”, required: false, multiple: true
}

}

def installed() {
log.debug “Installed with settings: ${settings}”
subscribeToEvents()
}

def updated() {
log.debug “Updated with settings: ${settings}”
unsubscribe()
subscribeToEvents()
}

def subscribeToEvents() {
subscribe(mySwitch, “switch”, eventHandler)
subscribe(myButton, “button”, eventHandler)
subscribe(myMomentaryContact, “momentary”, eventHandler)
subscribe(myMotion, “motion”, eventHandler)
subscribe(myContact, “contact”, eventHandler)
subscribe(myLock, “lock”, eventHandler)
subscribe(myThermostat, “thermostat.thermostatMode”, eventHandler)
subscribe(myThermostat, “thermostat.thermostatFanMode”, eventHandler)
subscribe(myThermostat, “thermostat.thermostatOperatingState”, eventHandler)
subscribe(myThermostat, “thermostat.temperature”, eventHandler)
subscribe(myThermostat, “thermostat.heatingSetpoint”, eventHandler)
subscribe(myThermostat, “thermostat.coolingSetpoint”, eventHandler)
subscribe(myThermostat, “thermostat.thermostatSetpoint”, eventHandler)
subscribe(myTemperature, “temperature”, eventHandler)
subscribe(myBrightness, “illuminance”, eventHandler)
subscribe(myHumidty, “humidity”, eventHandler)
subscribe(myEnergy, “energy”, eventHandler)
subscribe(myPower, “power”, eventHandler)
subscribe(myAcceleration, “acceleration”, eventHandler)
subscribe(myPresence, “presence”, eventHandler)
subscribe(mySmoke, “smoke”, eventHandler)
subscribe(myWater, “water”, eventHandler)
subscribe(myCO, “carbonMonoxide”, eventHandler)
}

def eventHandler(evt) {
log.debug “${evt.displayName} ${evt.stringValue}”
WOPBOX.sendEthernet(“${evt.displayName} ${evt.stringValue}”)
}

3 Likes

You’re right, apparently the libraries were outdated, and I was able to reprogram the ESP8266, but now smartthings can not create the devices.

Note: I am working with a Sonoff switch

Paste Log Smartthings Ide

error grails.validation.ValidationException: Validation Error(s) occurred during save():

  • Field error in object ‘physicalgraph.device.Device’ on field ‘deviceNetworkId’: rejected value [6001940770A3]; codes [physicalgraph.device.Device.deviceNetworkId.unique.error.physicalgraph.device.Device.deviceNetworkId,physicalgraph.device.Device.deviceNetworkId.unique.error.deviceNetworkId,physicalgraph.device.Device.deviceNetworkId.unique.error.java.lang.String,physicalgraph.device.Device.deviceNetworkId.unique.error,device.deviceNetworkId.unique.error.physicalgraph.device.Device.deviceNetworkId,device.deviceNetworkId.unique.error.deviceNetworkId,device.deviceNetworkId.unique.error.java.lang.String,device.deviceNetworkId.unique.error,physicalgraph.device.Device.deviceNetworkId.unique.physicalgraph.device.Device.deviceNetworkId,physicalgraph.device.Device.deviceNetworkId.unique.deviceNetworkId,physicalgraph.device.Device.deviceNetworkId.unique.java.lang.String,physicalgraph.device.Device.deviceNetworkId.unique,device.deviceNetworkId.unique.physicalgraph.device.Device.deviceNetworkId,device.deviceNetworkId.unique.deviceNetworkId,device.deviceNetworkId.unique.java.lang.String,device.deviceNetworkId.unique,unique.physicalgraph.device.Device.deviceNetworkId,unique.deviceNetworkId,unique.java.lang.String,unique]; arguments [deviceNetworkId,class physicalgraph.device.Device,6001940770A3]; default message [La propiedad [{0}] de la clase [{1}] con valor [{2}] debe ser única]
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:33: debug Executing ‘sendEthernet’ refresh
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:33: debug Using ip: 192.168.10.152 and port: 8090 for device: 9d5fbd70-c9c2-40e2-9d66-efc14585b993
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:33: debug Executing ‘refresh()’
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:33: debug setting deviceNetworkID = 6001940770A3
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:33: debug Executing ‘updateDeviceNetworkID’
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:33: debug Executing ‘configure()’
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:32: debug Executing ‘sendEthernet’ refresh
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:32: debug Executing ‘refresh()’
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:32: debug setting deviceNetworkID = 6001940770A3
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:32: debug Executing ‘configure()’
    9d5fbd70-c9c2-40e2-9d66-efc14585b993 09:15:32: debug Executing ‘updateDeviceNetworkID’

It appears you already have a Parent Device using the same MAC address. Delete any extra parent devices you may have and try saving your settings again. That will cause a refresh and the children should be created.

I have a really weird thing happening with an HC-SR505 PIR and my Arduino + thingshield.

I first set up 3 humidity/temp sensors in 3 bathrooms to use as triggers for the bathroom vent when someone is in the shower. That part is working great! I found the above PIR’s for less than $3 and bought a bunch. I bench tested them on an UNO R3 and they all tested out working perfectly.

I have two thingshields, the one in “production” for my temp/humidity sensors and one I am using to Develop with.

I hooked up the PIR to Pin 9 and defined it as the only sensor in Dan’s multi anything project. While connected via USB and debugging I am noticing the sensor is triggering properly. I see “Active” and “Inactive” appropriately on my child device on my phone. However, when I connect to power (yes I have tried 2 different supplies, one 12v and one 5 v) the sensor is always triggering high (active).

When I first observed this I thought it was the power supply and got another one. Then I moved the PIR to pin 13 so when it was High it would light the board LED so I could see what it was doing without the USB connection. Sure enough the LED pretty much stays lit all the time when on wall power.

So it gets weird when I remove power and unplug the thingshield. Same code loaded etc… just no thingshield attached to the arduino and the PIR works perfectly fine on wall power. I can tell because of the pin 13 LED status. lights when movement is in front of it, goes out when there is none. So it seems the presence of the thingshield is interfering?!

I am going to try a Mega and if that doesn’t do anything I will try a Tiny with the PIR running to it and then when it detect motion setting another pin on the Tiny to high momentarily and connecting that pin to the PIR in pin (13) that is on the thingshield to act as an intermediary device. I may also try to bend the pin 13 leg out on the thingshield keeping it from going in to the Uno so I am not at all going through the thingshield but connected directly to the arduino with the PIR wire. I realize those should just pass through but it works without the shield so why not?

Anyone have similar experiences or issues or thoughts?

So the Mega was no different and bending out Pin 13 on the thingshield so I can connect directly to the UNO and mega made no difference :confused:

Hi Dan,

I’m building a new NodeMCU for the garage, 4 sensors, DHT, SR501, Relay Switch and magnectic reed swtich to act as a door sensor.

I’m a bit confused by this part…

The name assigned to each device (1st argument below) must match the Groovy
  //           Device Handler names.  (Note: "temphumid" below is the exception to this rule
  //           as the DHT sensors produce both "temperature" and "humidity".  Data from that
  //           particular sensor is sent to the ST Hub in two separate updates, one for 
  //           "temperature" and one for "humidity")

static st::PS_DS18B20_Temperature sensor2(F("temperature1"), 15, 0, PIN_TEMPERATURE_1, false, 10, 1); 

How do switch from the DS18B20 to the DHT11?

Thanks in advance.

Yes!!, I am getting the same thing using an ESP8266. I am using my it in the garage. I noticed that while plugged into the power supply I bought (5V) every 4-5 minutes it triggers the pir sensor. Mine is the HC-SR501 that Dan had listed in the arduino sketch. I also noticed every 30 seconds that the contact sensors for my door flickers to the open state. Wondering if it is a floating ground issue.

Interestingly, I was going to hook up a Tiny to trigger the main arduino off of the PIR but decided to connect to the power supply directly (its 5V 2A) instead of the 5V pin on the arduino and it all works?! All the PIR’s are working now. I installed 3 of them and plan on adding at least 4 or 5 more.

Not sure what project you are looking at but this is my definition line in the ST_Anything_Multiples:

static st::PS_TemperatureHumidity sensor1(F(“temphumid1”), 60, 40, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT21,“temperature1”,“humidity1”);

Note the DHT21 try that with DHT11

I think the default sensor in the project is a DHT11

1 Like

Great work. I have successfully built NodeMCU devices - but am having trouble with basic ESP8266. Code compiles, uploads, device is on my network everything looks good - but no magic discovery of child devices (I’ve tried contact sensor and DS18B20). Any ideas?

The DS18B20 Temp sensor only works with a Dallas Semiconductor DS18B20 device.

Use the PS_TemperatureHumidity class instead. Take a look inside one of the Arduino Mega Multiples sketches for an example of using a DHT sensor.

1 Like

Sounds like the MAC address of your ESP8266 is not configured properly in your ST Parent Device.

Glad to hear it. The PIR sensors seem to require a decent 5v power supply to function reliably.