[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

Did you Publish (for self) all of the DTH code as well?

//Dimmer Switch Pins
#define PIN_DIMMERLEVEL_1         44  //SmartThings Capability "Switch Level"  NOTE: MUST BE A PWM CAPABLE PIN!
#define PIN_DIMMERSWITCH_1        45  //SmartThings Capability "Switch"
#define PIN_DIMMERLEVEL_2         46  //SmartThings Capability "Switch Level"  NOTE: MUST BE A PWM CAPABLE PIN!
#define PIN_DIMMERSWITCH_2        47  //SmartThings Capability "Switch"

then

static st::EX_Switch_Dim          executor5(F("dimmerSwitch1"), PIN_DIMMERSWITCH_1, PIN_DIMMERLEVEL_1, LOW, false);   
static st::EX_Switch_Dim          executor6(F("dimmerSwitch2"), PIN_DIMMERSWITCH_2, PIN_DIMMERLEVEL_2, LOW, false);    

and of course

 st::Everything::addExecutor(&executor5);
 st::Everything::addExecutor(&executor6);

Does that make sense?

Yes i did self publishing, i just reloaded everything from repo and published it. still no response from the child devices

The Parent DTH code you linked to above was definitely out of date. Are you 100% sure youā€™re using the correct DTH code and are selecting the correct DTH when creating the Parent Device?

Here is the code that just got loaded from Repo

/**
 *  Parent_ST_Anything_Ethernet.groovy
 *
 *  Copyright 2017 Dan G Ogorchock 
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 *  Change History:
 *
 *    Date        Who            What
 *    ----        ---            ----
 *    2017-02-08  Dan Ogorchock  Original Creation
 *    2017-02-12  Dan Ogorchock  Modified to work with Ethernet based devices instead of ThingShield
 *    2017-02-24  Dan Ogorchock  Created the new "Multiples" device handler as a new example
 *    2017-04-16  Dan Ogorchock  Updated to use the new Composite Device Handler feature
 *    2017-06-10  Dan Ogorchock  Added Dimmer Switch support
 *    2017-07-09  Dan Ogorchock  Added number of defined buttons tile
 *    2017-08-24  Allan (vseven) Change the way values are pushed to child devices to allow a event to be executed allowing future customization
 *    2007-09-24  Allan (vseven) Added RGB LED light support with a setColorRGB routine
 *    2017-10-07  Dan Ogorchock  Cleaned up formatting for readability
 *    2017-09-24  Allan (vseven) Added RGBW LED strip support with a setColorRGBW routine
 *    2017-12-29  Dan Ogorchock  Added WiFi RSSI value per request from ST user @stevesell
 *    2018-02-15  Dan Ogorchock  Added @saif76's Ultrasonic Sensor
 *    2018-02-25  Dan Ogorchock  Added Child Presence Sensor
 *    2018-03-03  Dan Ogorchock  Added Child Power Meter
 *    2018-06-05  Dan Ogorchock  Simplified Parent & Child Device Handlers
 *    2018-06-24  Dan Ogorchock  Added Child Servo
 *    2018-07-01  Dan Ogorchock  Added Pressure Measurement
 *    2018-08-06  Dan Ogorchock  Added MAC Address formatting before setting deviceNetworkID
 *    2019-02-05  Dan Ogorchock  Added Child Energy Meter
 *    2019-02-09  Dan Ogorchock  Attempt to prevent duplicate devices from being created
 *    2019-09-08  Dan Ogorchock  Minor tweak to Button logic due to changes in the the Arduino IS_Button.cpp code
 *	
 */
 
metadata {
	definition (name: "Parent_ST_Anything_Ethernet", namespace: "ogiewon", author: "Dan Ogorchock") {
        capability "Configuration"
        capability "Refresh"
        capability "Button"
        capability "Holdable Button"
        capability "Signal Strength"
        
        command "sendData", ["string"]
	}

    simulator {
    }

    // Preferences
	preferences {
		input "ip", "text", title: "Arduino IP Address", description: "IP Address in form 192.168.1.226", required: true, displayDuringSetup: true
		input "port", "text", title: "Arduino Port", description: "port in form of 8090", required: true, displayDuringSetup: true
		input "mac", "text", title: "Arduino MAC Addr", description: "MAC Address in form of 02A1B2C3D4E5", required: true, displayDuringSetup: true
		input "numButtons", "number", title: "Number of Buttons", description: "Number of Buttons, 0 to n", required: true, displayDuringSetup: true
	}

	// Tile Definitions
	tiles (scale: 2){
		standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
			state "default", label:'Refresh', action: "refresh.refresh", icon: "st.secondary.refresh-icon"
		}
        
		standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
			state "configure", label:'Configure', action:"configuration.configure", icon:"st.secondary.tools"
		}

        valueTile("numberOfButtons", "device.numberOfButtons", inactiveLabel: false, width: 2, height: 2) {
			state "numberOfButtons", label:'${currentValue} buttons', unit:""
		}

        valueTile("rssi", "device.rssi", width: 2, height: 2) {
			state("rssi", label:'RSSI ${currentValue}', unit:"",
				backgroundColors:[
					[value: -30, color: "#006600"],
					[value: -45, color: "#009900"],
					[value: -60, color: "#99cc00"],
					[value: -70, color: "#ff9900"],
					[value: -90, color: "#ff0000"]
				]
			)
		}

		childDeviceTiles("all")
	}
}

// parse events into attributes
def parse(String description) {
	//log.debug "Parsing '${description}'"
	def msg = parseLanMessage(description)
	def headerString = msg.header

	if (!headerString) {
		//log.debug "headerstring was null for some reason :("
    }

	def bodyString = msg.body

	if (bodyString) {
        log.debug "Parsing: $bodyString"
    	def parts = bodyString.split(" ")
    	def name  = parts.length>0?parts[0].trim():null
    	def value = parts.length>1?parts[1].trim():null
        
		def nameparts = name.split("\\d+", 2)
		def namebase = nameparts.length>0?nameparts[0].trim():null
        def namenum = name.substring(namebase.length()).trim()
		
        def results = []
        
		if (name.startsWith("button")) {
			//log.debug "In parse:  name = ${name}, value = ${value}, btnName = ${name}, btnNum = ${namemun}"
            if ((value == "pushed") || (value == "held")) {
                results = createEvent([name: namebase, value: value, data: [buttonNumber: namenum], descriptionText: "${namebase} ${namenum} was ${value} ", isStateChange: true, displayed: true])
                log.debug results
                return results
            }
        }

		if (name.startsWith("rssi")) {
			//log.debug "In parse: RSSI name = ${name}, value = ${value}"
           	results = createEvent(name: name, value: value, displayed: false)
            log.debug results
			return results
        }


        def isChild = containsDigit(name)
   		//log.debug "Name = ${name}, isChild = ${isChild}, namebase = ${namebase}, namenum = ${namenum}"      
        //log.debug "parse() childDevices.size() =  ${childDevices.size()}"

		def childDevice = null

		try {

            childDevices.each {
				try{
            		//log.debug "Looking for child with deviceNetworkID = ${device.deviceNetworkId}-${name} against ${it.deviceNetworkId}"
                	if (it.deviceNetworkId == "${device.deviceNetworkId}-${name}") {
                	childDevice = it
                    //log.debug "Found a match!!!"
                	}
            	}
            	catch (e) {
            	//log.debug e
            	}
        	}
            
            //If a child should exist, but doesn't yet, automatically add it!            
        	if (isChild && childDevice == null) {
        		log.debug "isChild = true, but no child found - Auto Add it!"
            	//log.debug "    Need a ${namebase} with id = ${namenum}"
            
            	createChildDevice(namebase, namenum)
            	//find child again, since it should now exist!
            	childDevices.each {
					try{
            			//log.debug "Looking for child with deviceNetworkID = ${device.deviceNetworkId}-${name} against ${it.deviceNetworkId}"
                		if (it.deviceNetworkId == "${device.deviceNetworkId}-${name}") {
                			childDevice = it
                    		//log.debug "Found a match!!!"
                		}
            		}
            		catch (e) {
            			//log.debug e
            		}
        		}
        	}
            
            if (childDevice != null) {
                //log.debug "parse() found child device ${childDevice.deviceNetworkId}"
                childDevice.parse("${namebase} ${value}")
				log.debug "${childDevice.deviceNetworkId} - name: ${namebase}, value: ${value}"
            }
            else  //must not be a child, perform normal update
            {
                results = createEvent(name: name, value: value)
                log.debug results
                return results
            }
		}
        catch (e) {
        	log.error "Error in parse() routine, error = ${e}"
        }

	}
}

private getHostAddress() {
    def ip = settings.ip
    def port = settings.port
    
    log.debug "Using ip: ${ip} and port: ${port} for device: ${device.id}"
    return ip + ":" + port
}

def sendData(message) {
    sendEthernet(message) 
}

def sendEthernet(message) {
	log.debug "Executing 'sendEthernet' ${message}"
	if (settings.ip != null && settings.port != null) {
        sendHubCommand(new physicalgraph.device.HubAction(
            method: "POST",
            path: "/${message}?",
            headers: [ HOST: "${getHostAddress()}" ]
        ))
    }
    else {
        state.alertMessage = "ST_Anything Parent Device has not yet been fully configured. Click the 'Gear' icon, enter data for all fields, and click 'Done'"
        runIn(2, "sendAlert")   
    }
}

// handle commands
def configure() {
	log.debug "Executing 'configure()'"
    updateDeviceNetworkID()
	sendEvent(name: "numberOfButtons", value: numButtons)
}

def refresh() {
	log.debug "Executing 'refresh()'"
	sendEthernet("refresh")
	sendEvent(name: "numberOfButtons", value: numButtons)
}

def installed() {
	log.debug "Executing 'installed()'"
    if ( device.deviceNetworkId =~ /^[A-Z0-9]{12}$/)
    {
    }
    else
    {
        state.alertMessage = "ST_Anything Parent Device has not yet been fully configured. Click the 'Gear' icon, enter data for all fields, and click 'Done'"
        runIn(2, "sendAlert")
    }
    state.lastChildCreated = "none"
}

def initialize() {
	log.debug "Executing 'initialize()'"
    sendEvent(name: "numberOfButtons", value: numButtons)
}

def updated() {
	if (!state.updatedLastRanAt || now() >= state.updatedLastRanAt + 5000) {
		state.updatedLastRanAt = now()
		log.debug "Executing 'updated()'"
    	runIn(3, "updateDeviceNetworkID")
		sendEvent(name: "numberOfButtons", value: numButtons)
        log.debug "Hub IP Address = ${device.hub.getDataValue("localIP")}"
        log.debug "Hub Port = ${device.hub.getDataValue("localSrvPortTCP")}"
	}
	else {
//		log.trace "updated(): Ran within last 5 seconds so aborting."
	}
}

def updateDeviceNetworkID() {
	log.debug "Executing 'updateDeviceNetworkID'"
    def formattedMac = mac.toUpperCase()
    formattedMac = formattedMac.replaceAll(":", "")
    if(device.deviceNetworkId!=formattedMac) {
        log.debug "setting deviceNetworkID = ${formattedMac}"
        device.setDeviceNetworkId("${formattedMac}")
	}
    //Need deviceNetworkID updated BEFORE we can create Child Devices
	//Have the Arduino send an updated value for every device attached.  This will auto-created child devices!
    state.lastChildCreated = "none"
	refresh()
}

private void createChildDevice(String deviceName, String deviceNumber) {
    if ( device.deviceNetworkId =~ /^[A-Z0-9]{12}$/) {
    
		log.trace "createChildDevice:  Creating Child Device '${device.displayName} (${deviceName}${deviceNumber})'"
        
		try {
        	def deviceHandlerName = ""
        	switch (deviceName) {
         		case "contact": 
                		deviceHandlerName = "Child Contact Sensor" 
                	break
         		case "switch": 
                		deviceHandlerName = "Child Switch" 
                	break
         		case "dimmerSwitch": 
                		deviceHandlerName = "Child Dimmer Switch" 
                	break
         		case "rgbSwitch": 
                		deviceHandlerName = "Child RGB Switch" 
                	break
         		case "generic": 
                		deviceHandlerName = "Child Generic Sensor" 
                	break
         		case "rgbwSwitch": 
                		deviceHandlerName = "Child RGBW Switch" 
                	break
         		case "relaySwitch": 
                		deviceHandlerName = "Child Relay Switch" 
                	break
         		case "temperature": 
                		deviceHandlerName = "Child Temperature Sensor" 
                	break
         		case "humidity": 
                		deviceHandlerName = "Child Humidity Sensor" 
                	break
         		case "motion": 
                		deviceHandlerName = "Child Motion Sensor" 
                	break
         		case "water": 
                		deviceHandlerName = "Child Water Sensor" 
                	break
         		case "illuminance": 
                		deviceHandlerName = "Child Illuminance Sensor" 
                	break
         		case "illuminancergb": 
                		deviceHandlerName = "Child IlluminanceRGB Sensor" 
                	break
         		case "voltage": 
                		deviceHandlerName = "Child Voltage Sensor" 
                	break
         		case "smoke": 
                		deviceHandlerName = "Child Smoke Detector" 
                	break    
         		case "carbonMonoxide": 
                		deviceHandlerName = "Child Carbon Monoxide Detector" 
                	break    
         		case "alarm": 
                		deviceHandlerName = "Child Alarm" 
                	break    
         		case "doorControl": 
                		deviceHandlerName = "Child Door Control" 
                	break
         		case "ultrasonic": 
                		deviceHandlerName = "Child Ultrasonic Sensor" 
                	break
         		case "presence": 
                		deviceHandlerName = "Child Presence Sensor" 
                	break
         		case "power": 
                		deviceHandlerName = "Child Power Meter" 
                	break
         		case "energy": 
                		deviceHandlerName = "Child Energy Meter" 
                	break
         		case "servo": 
                		deviceHandlerName = "Child Servo" 
                	break
         		case "pressure": 
                		deviceHandlerName = "Child Pressure Measurement" 
                	break
			default: 
                		log.error "No Child Device Handler case for ${deviceName}"
      		}
            if ((deviceHandlerName != "") && (state.lastChildCreated != "${device.deviceNetworkId}-${deviceName}${deviceNumber}")) {
                addChildDevice(deviceHandlerName, "${device.deviceNetworkId}-${deviceName}${deviceNumber}", null,
         			[completedSetup: true, label: "${device.displayName} (${deviceName}${deviceNumber})", 
                	isComponent: false, componentName: "${deviceName}${deviceNumber}", componentLabel: "${deviceName} ${deviceNumber}"])
                state.lastChildCreated = "${device.deviceNetworkId}-${deviceName}${deviceNumber}"
        	}   
    	} catch (e) {
        	log.error "Child device creation failed with error = ${e}"
        	state.alertMessage = "Child device creation failed. Please make sure that the '${deviceHandlerName}' is installed and published."
	    	runIn(2, "sendAlert")
    	}
	} else 
    {
        state.alertMessage = "ST_Anything Parent Device has not yet been fully configured. Click the 'Gear' icon, enter data for all fields, and click 'Done'"
        runIn(2, "sendAlert")
    }
}

private sendAlert() {
   sendEvent(
      descriptionText: state.alertMessage,
	  eventType: "ALERT",
	  name: "childDeviceCreation",
	  value: "failed",
	  displayed: true,
   )
}

private boolean containsDigit(String s) {
    boolean containsDigit = false;

    if (s != null && !s.isEmpty()) {
//		log.debug "containsDigit .matches = ${s.matches(".*\\d+.*")}"
		containsDigit = s.matches(".*\\d+.*")
    }
    return containsDigit
}

Yes, that is the current code. How about the Child DTHā€™s?

here is the Child DTHā€™s

/**
 *  Child Switch
 *
 *  Copyright 2017 Daniel Ogorchock
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 *  Change History:
 *
 *    Date        Who            What
 *    ----        ---            ----
 *    2017-04-10  Dan Ogorchock  Original Creation
 *    2017-08-23  Allan (vseven) Added a generateEvent routine that gets info from the parent device.  This routine runs each time the value is updated which can lead to other modifications of the device.
 *    2018-06-02  Dan Ogorchock  Revised/Simplified for Hubitat Composite Driver Model
 *
 * 
 */
metadata {
	definition (name: "Child Switch", namespace: "ogiewon", author: "Dan Ogorchock", mnmn: "SmartThings", vid: "generic-switch") {
		capability "Switch"
		capability "Relay Switch"
		capability "Actuator"
		capability "Sensor"

		attribute "lastUpdated", "String"
	}

	simulator {

	}

	tiles(scale: 2) {
		multiAttributeTile(name:"switch", type: "lighting", width: 3, height: 4, canChangeIcon: true){
			tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
				attributeState "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff", nextState:"turningOn"
				attributeState "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#00A0DC", nextState:"turningOff"
				attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#00A0DC", nextState:"turningOff"
				attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn"
			}
 			tileAttribute("device.lastUpdated", key: "SECONDARY_CONTROL") {
    				attributeState("default", label:'    Last updated ${currentValue}',icon: "st.Health & Wellness.health9")
            }
		}
	}
}

def on() {
    sendData("on")
}

def off() {
    sendData("off")
}

def sendData(String value) {
    def name = device.deviceNetworkId.split("-")[-1]
    parent.sendData("${name} ${value}")  
}

def parse(String description) {
    log.debug "parse(${description}) called"
	def parts = description.split(" ")
    def name  = parts.length>0?parts[0].trim():null
    def value = parts.length>1?parts[1].trim():null
    if (name && value) {
        // Update device
        sendEvent(name: name, value: value)
        // Update lastUpdated date and time
        def nowDay = new Date().format("MMM dd", location.timeZone)
        def nowTime = new Date().format("h:mm a", location.timeZone)
        sendEvent(name: "lastUpdated", value: nowDay + " at " + nowTime, displayed: false)
    }
    else {
    	log.debug "Missing either name or value.  Cannot parse!"
    }
}

def installed() {
}

Dan,
I just found the issue, Child DTH wasnā€™t published :frowning: :cry:

Thank you for all your help. I was close to throwing ST out of the window.

1 Like

Glad to hear you got it working!

@ogiewon, @vbogach1ā€¦ as usualā€¦ a simple problemā€¦ I had defined some ins/outs on pins that are reserved on the MEGA. Dumb. Itā€™s never something hard. Always something simple. I had to walk away from it to sort it out.

1 Like

That did the trick! Iā€™m now reading the dimmer level via callback and running rudimentary stepper actions in response!!!

A further question I thought Iā€™d ask as it would probably prove useful to many amateurs experimenting with your amazing project: any thoughts on how I could set a variable based on the callback text? My current rudimentary approach is to use 3 distinct values and hard code them [if msg == dimmerSwitch1 100 {set target steps blah}, if 50 set target steps half of blah] but if I could figure out how to write the value of a numeric variable based on that amount, I could math the distance I am, from the distance, expressed in that variable, that I want to be, and move to that place.

This is more of a standard C/C++ programming question, I believe. Lots of resources are available online. You should definitely check out the following official documentation on the String object. You should be able to easily parse and convert the ā€˜valueā€™ into an Integer.

You might be able to try something like the following within the Callback() routine. (Note: this has not been tested!)

int value = msg.substring(msg.indexOf(" ") + 1).toInt();
1 Like

Iā€™m not sure where my mistake is. Iā€™m trying to get the Everything sketch to populate child devices. My hubā€™s setup and connected in the IDE. My ESP8266 nodeMCU is connected to wifi, and in the monitor giving me sensor information and sending it. Iā€™ve created the device in the IDE, then changed the IP, Mac address, port and button count in the application. I have static IPā€™s assigned for the Hub and the nodeMCU. This is my monitor on power. I donā€™t know what information might be helpful to find the problem.

I have the 2018 Smartthings hub, Iā€™ve attempted with it connected via ethernet, and Iā€™ve removed and readded the hub via wifi as well. Itā€™s currently connected to the network via wifi.

9:20:02.435 -> 
19:20:02.435 -> Initializing ESP8266 WiFi network.  Please be patient...
19:20:02.469 -> Attempting to connect to WPA SSID: *****
19:20:02.469 -> .....................
19:20:12.965 -> 
19:20:12.965 -> Enter the following three lines of data into ST App on your phone!
19:20:12.965 -> localIP = 192.168.1.***
19:20:12.965 -> serverPort = 8090
19:20:12.965 -> MAC Address = CC5********
19:20:12.965 -> 
19:20:12.965 -> SSID = *****
19:20:12.965 -> PASSWORD = bigwillystyle
19:20:12.965 -> hubIP = 192.168.1.***
19:20:12.965 -> hubPort = 39500
19:20:12.965 -> RSSI = -52
19:20:12.965 -> hostName = ESP8266-CC5********
19:20:12.965 -> 
19:20:12.965 -> SmartThingsESP8266WiFI: Intialized
19:20:12.965 -> 
19:20:12.965 -> Disabling ESP8266 WiFi Access Point
19:20:12.965 -> 
19:20:12.965 -> ArduinoOTA Ready
19:20:12.965 -> IP address: 192.168.1.***
19:20:13.000 -> ArduionOTA Host Name: ESP8266-CC5********
19:20:13.000 -> 
19:20:13.000 -> Everything: init ended
19:20:13.000 -> Everything: Free RAM = 48784
19:20:13.000 -> Everything: adding sensor named temperature
19:20:13.000 -> Everything: Free RAM = 48784
19:20:13.000 -> Everything: adding sensor named temphumid1
19:20:13.000 -> Everything: Free RAM = 48784
19:20:13.000 -> Everything: adding executor named switch1
19:20:13.000 -> Everything: Free RAM = 48784
19:20:13.000 -> Everything: adding executor named switch2
19:20:13.000 -> Everything: Free RAM = 48784
19:20:13.035 -> Everything: initDevices started
19:20:13.035 -> Everything: Free RAM = 48784
19:20:13.523 -> PS_DS18B20_Temperature::Requesting temperatures...DONE
19:20:13.523 -> PS_DS18B20_Temperature:: Temperature for the device # 1 is: -196.60
19:20:13.523 -> PS_DS18B20_Temperature:: Temperature for the device # 2 is: -196.60
19:20:13.523 -> Everything: Sending: temperature1 -196.60
19:20:23.542 -> Everything: Sending: temperature2 -196.60
19:20:35.571 -> PS_TemperatureHumidity: DHT Time out error
19:20:35.571 -> Everything: Sending: temperature1 -1.00
19:20:45.570 -> Everything: Sending: humidity1 -1.00
19:20:56.051 -> Everything: Sending: switch1 off
19:21:06.564 -> Everything: Sending: switch2 off
19:21:17.063 -> Everything: initDevices ended
19:21:17.063 -> Everything: Free RAM = 47648
19:21:37.087 -> PS_DS18B20_Temperature::Requesting temperatures...DONE
19:21:37.295 -> PS_DS18B20_Temperature:: Temperature for the device # 1 is: 83.30
19:21:37.295 -> PS_DS18B20_Temperature:: Temperature for the device # 2 is: -196.60

The Arduino side appears to be working fine, assuming your ST Hubā€™s address really is:

hubIP = 192.168.1.***

Please post a screen shot of your Parent Device from the ST Web IDE.

Also, what, if anything, are you seeing in Live Logs?

Did you remember to SAVE and PUBLISH all of the ST_Anything Devices, Parent and Child Devices?

1 Like

Really appreciate the starting point, thatā€™s given me enough that I can start researching and working out how to do a few things with it.

Do you think I should be concerned about basing this whole project around Strings given arduino/memory issues? I donā€™t know enough about it to know if I should worry!

I went through to double check, I apparently forgot to check the publish checkbox. As soon as I redid it and hit publish it started to populate in live logs.

As long as youā€™re not trying to use an Arduino UNO, memory should not be an issue.

I didnā€™t do it earlier, and I just wanted to thank you for the quick help the other day, and for all the work you did to code this. I managed to get everything going exactly how I intended and it all seems to be rock solid.

1 Like

Hello, Iā€™m a relative newcomer - thanks for the awesome support for the ESP8266!

I have a Lolin ESP8266 board, with 2 DS18b20 sensors attached. Both are sharing the same data bus D7. I have a simple sketch which uses the Dallas Temperature library to detect number of sensors, and to display the temperature for each sensor. This sketch works when uploaded to my board.

Iā€™m now trying to get my Lolin board to work with ST. I am using ā€œST_Anything_Multiples_ESP8266WiFiā€ sketch as my template. I have gone through the README, and came across this line specifically for the DS18b20:

Special Case DS18B20 Temperature: ā€œtemperature1ā€ if only one sensor, ā€œtemperatureā€ if using multiples as the 1, 2, 3 will be auto added to the end of the name

So I modified the constructor as follows:
static st::PS_DS18B20_Temperature sensor2(F("temperature"), 15, 0, PIN_TEMPERATURE_1, false, 10, 1);

However, when I upload and run the sketch to my board, it only detects 1 sensor. Here is a sample output from the console:

SmartThingsESP8266WiFI: Intialized

Disabling ESP8266 WiFi Access Point

ArduinoOTA Ready
IP address: 192.168.1.192
ArduionOTA Host Name: ESP8266-XXXXXXXXX

Everything: init ended
Everything: Free RAM = 49136
Everything: adding sensor named temperature
Everything: Free RAM = 49136
Everything: initDevices started
Everything: Free RAM = 49136
PS_DS18B20_Temperature::Requesting temperatures...DONE
PS_DS18B20_Temperature:: Temperature for the device # 1 is: 77.45
Everything: Sending: temperature 77.45
Everything: initDevices ended
Everything: Free RAM = 48848
PS_DS18B20_Temperature::Requesting temperatures...DONE
PS_DS18B20_Temperature:: Temperature for the device # 1 is: 77.45
Everything: Sending: temperature 77.45
PS_DS18B20_Temperature::Requesting temperatures...DONE
PS_DS18B20_Temperature:: Temperature for the device # 1 is: 77.45
Everything: Sending: temperature 77.45

What am I missing?

Youā€™re not missing much. You do need to specify the number of DS18B20 sensors. Right now, it is defaulting to 1. At the top of each of the devicesā€™ source code files, you will find the documentation.


//******************************************************************************************
//  File: PS_DS18B20_Temperature.h
//  Author: Dan G Ogorchock
//
//  Summary:  PS_DS18B20_Temperature is a class which implements both the SmartThings "Temperature Measurement" capability.
//			  It inherits from the st::PollingSensor class.  The current version uses a digital pin to measure the 
//			  temperature from a Dallas Semiconductor One Wire DS18B20 series sensor. 
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::PS_DS18B20_Temperature sensor1(F("temperature1"), 120, 0, PIN_TEMPERATURE, false); (for a single sensor)
//                          st::PS_DS18B20_Temperature sensor1(F("temperature"), 120, 0, PIN_TEMPERATURE, false, 10, 3); (for 3 sensors)
//
//			  st::PS_DS18B20_Temperature() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - either "temperature1" for a single sensor, or "temperature" for multiple sensors
//				- long interval - REQUIRED - the polling interval in seconds
//				- long offset - REQUIRED - the polling interval offset in seconds - used to prevent all polling sensors from executing at the same time
//				- byte pin - REQUIRED - the Arduino Pin to be used for the One-Wire DS18B20 sensor conenction
//				- bool In_C - OPTIONAL - true = Report Celsius, false = Report Farenheit (Farentheit is the default)
//				- byte resolution - OPTIONAL - DS18B20 sensor resolution in bits.  9, 10, 11, or 12.  Defaults to 10 for decent accuracy and performance
//				- byte num_sensors - OPTIONAL - number of OneWire DS18B20 sensors attached to OneWire bus - Defaults to 1
//				- byte sensorStartingNum - OPTIONAL - Starting number for sending temperature sensor data when using multiple sensors on one pin - Defaults to 1
//