[RELEASE] ST_Anything - Arduino/ESP8266/ESP32

What are you using this on?

@Glock43 - Thank you for the LinkNode R8 example sketch. I have added it to my ST_Anything GitHub Repository.

It’s just that I had the boards and all the connections for the Due to my garage door and lights, controlled with a couple keyfobs that I had.

Either way, got it working. Part of the issue was I downloaded anything v2.1, and the other was the redefinition of ringbuffer class. Just renamed the class and all the calls to it and it worked.

Now Esp-01 does not connect to my WiFi (WAP2) . FW is too old seems like 0.91. Will flash with latest FW and verify again.

Thanks for the good work.

1 Like

I am looking to add an OLED to my ESP8266WiFi temperature sensor. I followed the ESP8266WiFi Temperature sketch and got everything to work within smartthings. The OLED is to display the temperature on the senesor it self for a quick check. I can use ST to control the devices in the background. I was able to get it to work by adding the sensor, libraries, etc… to the ESP8266WiFi sketch. This seems redundent as I am sure this is done on the PS_DS18B20_Temperature.h file. Is there a way to call the sensor data to the ESP8266WiFi sketch to use for a display?

Thank you,

Chris

I recommend uncommenting the serial.print statements in the “callback()” routine in the example sketch. This will allow you to see the data that is being sent to ST. By tapping into this data stream, you can then add whatever calls you want to update your OLED display. Just be sure to never add any delay() or blocking calls that prevent ST_Anything from servicing the GPIO pins and the Network communications.

Just a FYI for anyone using the new Samsung app. I put in a bunch of tiny code changes to add metadata to some of the DTH’s so that they will work with the new app. I didn’t do all of them, just some of the main ones like temperature, humidity, contact, Etc. I’ll look into doing the other ones in the future but these are the ones I had time for. @ogiewon merged my changes in a couple days ago so you’ll have to go into the IDE and update your device handlers if you haven’t.

Unfortunately that’s not all you’ll have to do to make the new app show them correctly. It seems there is a ongoing bug where the new app holds onto the device Handler the first time it sees a device and doesn’t like to update it. The fix on Android phones is to go into settings than apps than the new SmartThings app, force close it, then clear its cashe (storage). Once you do that go into your IDE and switch the device Handler for each devices to something else, honestly it doesn’t matter, and save it then go back into the device and switch it back to the correct device Handler. Once that’s done start the new app backup and it will pull the device Handler information again which will now be correct. I have no idea how to do this on an Apple but I’m assuming you just uninstall the app, do the device Handler change thing, then reinstall the app.

Although it takes getting used to the history feature on the new app is kind of nice. Unfortunately I’m not sure why it only is working on humidity and not temperature but I’m looking into that too.

1 Like

Yes, I did, if you’re referring to using an ultrasonic sensor to determine if a garage is occupied or not.
It was more luck (and obviously help from @ogiewon) than anything else, as I had never before had anything to do with an Arduino and I no nothing about programming. The system is fairly reliable, with the sensors losing connection with the wi-fi network every few days. I’ve not been able to figure out why. (It is not a range issue, as both Adruino’s used in the garage, are within 4m from the AP.) A power cycle of the Arduino’s or rebooting the AP bring them back to live.
It there anything specific you wanted to know?

Yes, I am curious about how you made this work.

I can get the garage door opener working using the ST_Anything_GarageDoors_ESP8266WiFi sketch and I can get a modified version of ST_Anything_Ultrasonic_ESP01WiFi working. Modified to get distance rather than volume.

I am trying to create a mashup of both similar to the way that the Garage Doors sketch uses both the relay for open/close and the contact sensor for status.

Have you combined the two or are they separate devices and devices?

@ogiewon Dan,

Like Hendre, I want to use a ultrasonic sensor to indicate the status of my garage doors.

I have successfully got the garage doors working under one parent without the contact sensors.

I have successfully recoded the ultrasonic device handler and sketch to calculate distance rather than volume.

All good but I would like to replace the contact sensor in the garage doors code with the ultrasonic sensor. I am struggling to combine the two.

Any suggestions. It looks like I might have to mess with the IS_DoorControl.h and IS_DoorControl.cpp code

Yep, that might be a decent place to start. Just change the code to perform the ultrasonic measurement and covert the distance into an “open” or “closed” value. Don’t bother using the ultrasonic Device Handler code. Just trick the system into thinking it is a normal contact sensor.

Another idea would be to perform the ultrasonic measurement/calculation inside the sketch’s loop() function. Once you determine open/closed status, you could simply output that status to a GPIO pin. Then tie that pin to the door control’s contact sensor pin, thereby tricking the system into thinking that you are using contact sensors.

Have fun with it!

Could you post your recoded ultrasonic device handler. I would like to have distance capability but am not knowledgeable enough to develop anything.

Thanks

Tom

If you just want distance values from an ultrasonic sensor, simply create the device in your sketch as follows:

st::PS_Ultrasonic sensor1("voltage1", 60, 0, PIN_ULTRASONIC_T, PIN_ULTRASONIC_E);

As you can see I assigned it the name “voltage1” instead of “ultrasonic1”. This will cause it to create a Child Voltage device instead of the Child Ultrasonic device. This will report the simple numeric value from the sensor.

Thanks Dan.

Much easier than my approach. I think the output will still need some manipulation in the sketch to get the unit of measure desired.

Dan do you know if this will return the unit of time for the echo to do a return trip or will it return the distance traveled during that time?

Appears to be the distance, if my comments in the code are to be believed… :wink: I would have copied this probably directly from an example sketch for using the ultrasonic sensor.

Feel free to hack away at your local copy of the PS_Ultrasonic.cpp file to make it suit your needs. That’s the beauty of open source software! :blush:

	void PS_Ultrasonic::getData()
	{
		
		//int m_nSensorValue=map(analogRead(m_nAnalogInputPin), SENSOR_LOW, SENSOR_HIGH, MAPPED_LOW, MAPPED_HIGH);
		long duration;
		// Clears the trigPin
		digitalWrite(m_nDigitalTriggerPin, LOW);
		delayMicroseconds(2);
		// Sets the trigPin on HIGH state for 10 micro seconds
		digitalWrite(m_nDigitalTriggerPin, HIGH);
		delayMicroseconds(10);
		digitalWrite(m_nDigitalTriggerPin, LOW);
		// Reads the echoPin, returns the sound wave travel time in microseconds
		duration = pulseIn(m_nDigitalEchoPin, HIGH);
		// Calculating the distance
		m_nSensorValue = duration*0.034/2;

		// queue the distance to send to smartthings 
		Everything::sendSmartString(getName() + " " + String(m_nSensorValue));
	}

Sorry. That part I got. It was the voltage name that threw me off.

It seems as if you know a lot more than what I do? Did you manage to get this working? I’ll gladly fire up my PC at home to share “my” sketch if necessary.

@949BFN Hendre,

I do not yet have this fully working. What I have is two ultrasonic sensors and two 5v relays working on a single NodeMCU board. I use a modified version of ST_Anything_GarageDoors_ESP8266WiFi sketch I have made no other code changes - yet. After the above dialogue with @ogiewon I am attempting to follow his lead and use as much existing code as possible and understand if I make changes the best place to make them. Ideally I will only modify the sketch.

The in process sketch creates four children due to two separate calls to PS_Ultrasonic and two calls to IS_DoorControl. The door controls work however the status on the door controls is not integrated with the status of the sensors. The sensors read distance accurately in cm using the voltage type as @ogiewon said it would.

More to come as I stumble through this. @ogiewon - this is amazingly powerful stuff!

2 Likes

Post withdrawn

Hi, I have not yet installed this to my SmartThing.
But I have a lot of arduino and have been a user of smartthings for many years.

I have a water tank that I want to have 4 sensors, each sensor is connected to my arduino.
From there I can have 4 LED indicating status of water level.

But as I understand from this thread, I can get this info directly I to my SmartThing?

How will it look inside my ST app?
Can I use it inside ActionTiles also?
Can I make my own icons and symbols inside the ST App to visual indicate a water tank?

I can’t find any screenshot from the app.

Thank you for all help. :slight_smile:

@ogiewon - Dan,
Could you give me some guidance. I am trying to create a child device handler and similar to your door control/contact sensor using an ultrasonic sensor instead of a contact sensor.

I have an esp8266 with two relays and two sensors. I can control the switches using your sample sketch and i can read the sensors using either the voltage or the ultrasonic sketch.

Where would you point me to create a combination that opens and closes the doors and reflects the status based on an ultrasonic sensor?

I love this platform and would like to get this to work.

Thanks