[Release] HubDuino v1.1.4 - Hubitat to Arduino / ESP8266 / ESP32 / ThingShield Integration (ST_Anything)



I am in the way migrating from smartthings to hubitat and I am using ESP8266 working fine until now. @ogiewon. Has provided full guidance and support all the time


Here you go... I didn't realize that I already had a ESP8266 / MAX31855 sketch in my list of examples. I did modify this version slightly to make it default to the Hubitat hub's port number instead of ST's.

You should end up with a single 'temperature1" device in Hubitat using this sketch, which you can rename in Hubitat by changing the 'label' field of the child device when it is created.

Just the follow the HubDuino ReadMe file and you should be in decent shape. Let us know if you have any questions along the way.

Also, I recently modified the SmartThingsESP8266WiFi.ino communications library file. Please make sure you have an up to date copy of this file, in case you pulled the code a while ago.


I am using an Arduino mega with a 5100 shield, I have compiled and uploaded the sketch. When I look at the serial port output, it says the local IP is I'm assuming that this is why hubitat will not create the child devices as it should. I have been using the same Arduino with the same shield using the Ethernet library before without issue. any help would be appreciated (I have edited the ip address, mac, gateway, DNS, and the port already in the sketch)


Can you upload your sketch here so we can see it?


geez.... I just had to reset the arduino and now it is working. thanks anyway.


No problem. I did notice that you changed the port for the http server. Unless you change the device type handlers to match, then you're going to run into trouble. I would change that back to 8090.


Good call


hmmm. I'm getting this error when I try and send it to the board. it compiles fine.

esptool.py v2.6
Traceback (most recent call last) :
esptool.py v2.6
  File "/Users/jrau/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/upload.py", line 25, in <module>
Serial port /dev/cu.usbmodem14144101
  File "/Users/jrau/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 2652, in main
    esp = chip_class(each_port, initial_baud, args.trace)
  File "/Users/jrau/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 222, in __init__
    self._port = serial.serial_for_url(port)
  File "/Users/jrau/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/pyserial/serial/__init__.py", line 88, in serial_for_url
  File "/Users/jrau/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/pyserial/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/cu.usbmodem14144101: [Errno 2] No such file or directory: '/dev/cu.usbmodem14144101'
An error occurred while uploading the sketch


I believe you have to use v 2.4.2 of the esp8266 library. You're using 2.5.2.


Making progress. I've got it set up and connected to hubitat now. problem is that my temperature1 probe is just reporting the temp as -99. any thoughts?

edit: nevermind. I think I had my pins backwards.


image !!!!!!!!!

it is behaving a bit oddly though. It’ll work and give the correct temp for a while, and then it will start reporting the temp as -99 for a while, then switch back to the correct temp. it seems like if I refresh the parent device it fixes it for a while.


Here is the reason for the -99 readings... If the value returned by the 'm_Adafruit_MAX31855.readFarenheit()' call is no a number, I substitute -99 to make sure it is obvious that there is a problem.

	//function to get data from sensor and queue results for transfer to ST Cloud 
	void PS_AdafruitThermocouple::getData()

		m_dblTemperatureSensorValue = m_Adafruit_MAX31855.readFarenheit();
		if (isnan(m_dblTemperatureSensorValue))
			if (st::PollingSensor::debug) {
				Serial.println(F("PS_AdafruitThermocouple:: Error Reading Thermocouple"));
			m_dblTemperatureSensorValue = -99.0;
		Everything::sendSmartString(getName() + " " + String(int(m_dblTemperatureSensorValue)));


Have you tried using one of the Adafruit MAX31855 example sketches to make sure everything works without HubDuino/ST_Anything being involved whatsoever? Doing so helps to eliminate the wiring or hardware as an issue.

I believe the challenge will be figuring which three pins can be used for the SPI bus on the NodeMCU ESP8266

#define PIN_SCLK ?
#define PIN_CS ?
#define PIN_MISO ?

Once you figure that out, using the Adafruit MAX31855 example sketch, serialThermocouple.ino, you should be able to use those same three pins in the example sketch I provided.

UPDATE: Maybe try the following pins/wiring? Since I don't have the hardware on hand, not sure how much more help I can be in figuring out the wiring and pin assignments.

//Thermocouple Pin Assignments for NodeMCU ESP8266
#define PIN_SCLK                  D5 //(GPIO14)
#define PIN_CS                    D8 //(GPIO15)
#define PIN_MISO                  D6 //(GPIO12)

Based on the following NodeMCU Pinout diagram



I can get that to compile, but it won't flash. i tried some other pin outs, which will flash, but still throw the occ -99 error, although seemingly less than previous.


I’d the sketch compiles, it should be able to be flashed to the board. Sometimes you have to cycle power on a NodeMCU to get it to flash new software.

We’re you able to get the MAX31855 library’s example sketch to work? Also, are you sure the MAX31855 board is getting sufficient power?


I have the R8 and would like to try Hubduino on it; the changes look easy enough to add the 4 additional GPIO’s.

My use is to control 4 speeds on my pool pump, plus one relay to control the pool lights.

What’s the benefit of using HubDuino to do this vs writing the esp code or using espeasy and calling HTTP urls via Hubitat to do stuff? Guess getting status info back on what the relays are set as is one benefit? Does each relay show up as it’s own switch?

How would I make sure only one relay is on at a time? Use RM to do the logic? I’ve got the logic built in both espeasy and Arduino to do this today. I also need to build out the color changing logic (series of quick cycles) so would that be RM too or custom app?

Just looking for options since I do plan on only controlling this with Hubitat.



There is a Linksprite 8 Relay example sketch in my GitHub repo already. Each relay will show up in Hubitat as its own switch.

You can implement logic in the sketch to prevent more than one relay being on an a time. There are a couple of callback routines that can be used to implement this type of logic. Too late today to go into more detail.

Using HubDuino is a simple and quick way to accomplish this type of integration. Only you can decide if it is right for your application versus writing your own solution. Happy to help if needed. There are a few other users that monitor this thread that are also very familiar with HubDuino.


That’s sounds like the best of both worlds. Do you have an example of how to do explicit on/off in the esp code using your wrappers and I’ll try to go based on that? I also need to capture info like #of minutes to run at a speed and perhaps color of the pool light. Assuming I can send arguments somehow and parse them as I do using esp http server and server.arg function? Thank you!


On the road, so I can’t provide detailed answers. If you look through this thread, and the one on ST forums, and search for callback, you might some some examples of local logic being added to the sketch. The first rule is to never add delay() statements, as these block the network communications.

Also, there rally is no simple way currently to pass a duration to a switch or timed-relay device from Hubitat to the MCU. The dimmerSwitch class supports it, as does the servo class.

It sounds like you want some pretty complex logic to be handled by the MCU. In that case, you could roll your own completely, using http requests bidirectionally (use the Maker API for MCU to HE traffic) and use a custom driver that can send http requests to the MCU.

Or, you could use just the communications library from HubDuino. The group of “SmartThings...” libraries in my GitHub repo implement the communications. These libraries are used by the ST_Anything library for all communications.

Hubitat affords many more methods for connectivity than ST ever did. It’s good to have options!


Thank you! Sounds like it would be best to implement the “only 1 on at a time” logic on the MCU, but do everything else in a custom driver/app (clean on for 15/30/60 mins and color selections or the light (done by 800ms quick pulses on the relay for x number of times). I’ll take some time to dig through examples and see what I end up with. I do have a spare device I can putz with without messing up my current setup (esp easy but no lighting control)!


Got it working! Very cool! So if wanted to use switch 5 to control the lights, I assume I'd need to create a virtual driver per color that controls that switch and does x number of delays based on the color. I could probably use a preference to set the # of delays so I would really only have to write one driver. How would you tackle this if it was you.

Btw, I added two lines and made it so I could do OTA updates since my device isn’t in a place to easily reflash via serial. If you want me to send you my changes I will. GitHub - scottchiefbaker/ESP-WebOTA

Again, thanks for pointing me in the right direction on this!

void callbackRcvd2(String &msg)
Serial.print(F("ST_Anything CallbackRcvd: Sniffed data = "));

//TODO: Add local logic here to take action when a device's value/state is changed
if (msg == "switch1 on") {
st::receiveSmartString("switch2 off");
st::receiveSmartString("switch3 off");
st::receiveSmartString("switch4 off");

if (msg == "switch2 on") {
st::receiveSmartString("switch1 off");
st::receiveSmartString("switch3 off");
st::receiveSmartString("switch4 off");

if (msg == "switch3 on") {
st::receiveSmartString("switch1 off");
st::receiveSmartString("switch2 off");
st::receiveSmartString("switch4 off");

if (msg == "switch4 on") {
st::receiveSmartString("switch1 off");
st::receiveSmartString("switch2 off");
st::receiveSmartString("switch3 off");

//Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud (uncomment and edit following line)
//st::receiveSmartString("Put your command here!"); //use same strings that the Device Handler would send