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

I am not a coder, and 6 weeks ago I thought Arduino was a village in Italy. Not. Anyway, bought a Uno kit, along with a NodeMCU ESP8266, and other bits and pieces, so getting along in figuring this all out.

I would appreciate some guidance:
What would be the easiest way to send 1 of 5 non-PWM values to my sketch from HE? I plan to use the values as the index to an array, which contains step position values for a stepper motor. I did look at the Servo and Dimmer drivers/sketches but they both seem to use the switchLevel capability to send a PWM value to a pin (along with a lot of other capabilities that I would not use), so modifying those would be an immense undertaking (for me at least).

Background:
My use case is to tilt (not raise) 2" blind slats using a stepper motor. Now I have read a lot of the posts in this thread re the pros/cons of steppers vs servos for blind tilting, with one of the biggest cons against steppers being the need to implement limit switches. I am using 28BYJ-48 steppers in bipolar mode, and driving them with A4988s. Note though that this post is not to rehash the merits of each solution, but my own preference is steppers (at least for now).

I found a very easy implementation of using one Hall affect sensor to set the Home Position upon restart/startup, using Accelstepper.h. Once the HP is set, further stepper movements are determined by an input of the new target positions, which I set in the array - and hence the need to be able to send the index value from HE. The step position limits are set in the code, so once the HP is set there is no need for any physical limit switches. I also added in Sleep for the driver when not moving.

I tested my sketch with index inputs from the Serial Monitor, and it does exactly what I want. In my case I do not need a slider, since I find that 90% of the time I open/close blinds to certain positions - and hence the 5 position values in the array would meet my needs without having the capability to fine tune positions.

Again, any suggestions would be appreciated.

As an FYI, this is the post that started the above for me. I replaced the mechanical limit switch with a Hall effect sensor, and as mentioned also added in the array that contains the position step values:

I think the biggest argument in favor of using servo's instead of steppers is that there's already a Hubduino Library for servos and there isn't one for steppers. So, one would have to be written to implement the functionality that you mention.

But how are you going to hit those positions without the accuracy of a servo? Unless you home your stepper before every movement, you're not going to get enough accuracy.

I get that, and hence my question if there is a way for me to get 5 non-PWM values from HE to my sketch?

I can modify (or wreck) stuff as needed if I get some pointers, and would not necessarily look to others to develop it. Having said that, a substantial part of this community is all about learning new things, and thinking outside the box (yourself included . . . :slight_smile: ). As I had mentioned, one of the biggest pushbacks against steppers was the need for limit switches - and hence the acceptance of servos. I now have the Hall effect sensor in place that takes care of the need for limit switches, and if I can make this work it could very well be useful to someone else for whatever purpose . . . .

In my case high precision is moot. With 2048 steps/revolution, if the motor was off by 1 step, that equates to 0.17 degree. Even if it was off by 10 steps (1.7 degrees) it would not be visible to the naked eye in tilted blinds.

However, steppers are used in most (if not all) high-precision applications that we use every day - for example an inkjet printer sitting on my desk, DVD/CD players, etc. Then there are CNC machines in manufacturing, where 100% accuracy is required. In addition, the use of Hall effect sensors is used widely in industry.

I'm sorry, I don't follow. Why would you have to send all 5 values at once? Why couldn't you just send each value when it was needed? Also, noting says that you have to use PMW values. You could send a value of anything you like. You might find it easier to use the ESP8266 wifi example sketch rather than the ST_Anything example. This shows you how to implement communication between the hub and the board to pass any type of data you want. It can be found in the same repo in the following directory.
\Arduino\libraries\SmartThings\examples\SmartThings_On_Off_LED_ESP8266WiFi

Then you could send over any value you wanted and do anything you wanted with it.

My bad. As I wrote in my original post - only 1 of 5 values will be sent.

I had only looked at the Switch and Dimmer sketches/drivers, and in those they send PWM values. I will take a look at that sketch you sent. Thnx.

Thanks for the above.

Ok so I have the OTA set up, and I can "send data" from the HubDuino Parent Device page to the ESP8266 - to toggle the LED on/off.

How would I send the data from a Tile or Rule and not the Device page? I assume that would only be possible once a Child device is created on the Arduino and Replicated on the HE Parent, correct?

They are not PWM values, they are percentages. But you can translate that into any number you want. I don't know why you think a percentage is a PWM value.

I'm sorry, I thought, based on your insistence about steppers, that you had more experience with Arduino and Hubitat.. I don't think you're going to be able to do what you're trying to do. I suggest switching to a servo.

Just found Hubduino and it is awesome...

Having trouble with the ST_Anything pulseCounter library. Causes the Esp8266 to go into a reboot loop. Rst2 code reboot.

Trying to use this to measure pulses from my electricity meter.

Definately the pulse part having issues. If I comment out
st::PS_PulseCounter sensor3(F("power1"), 60, 5, PIN_PULSE, FALLING, INPUT_PULLUP, 1.0, 0);
It doesn’t crash.

Any ideas appreciated.
Cheers Chris

Hmmmm... I don't recall any other user reporting that particular issue. I haven't fired up that code in quite some time. I originally wrote the pulse counter library for a user who wanted to monitor water flow through a sensor that generated a pulse train. Your use case makes perfect sense as well.

Does the board crash even if no field wiring is attached? If you have just the USB connection attached, does it still crash? Also, does it crash immediately? I am trying to recall if I added any watchdog support to the ESP8266 code to try to recover in the event of a lockup that some experienced after their hubs locked up... If that is in there still, I wonder if there is any chance it is causing the issue? I'll need to fire up a system when I have some free time.

@Ryan780 wrote "I suggest switching to a servo"

Tried it last night, and got it up and running in 30 mins, so servos is the way to go now. Will keep on tinkering with the steppers . . .

I re-visited Amazon. My previous search for "high torque" servos showed them to be running $16-$20 per servo (which influenced my earlier decision to use steppers), but last night found 4 x 995s for less than $20. Reading through the numerous posts re servos, it would seem that the 995s would be fine for 5 foot 2" faux wood blinds. Any thoughts?

Then, I noticed something else:
I plan to use the servos connected to the tilt shafts on the left and right sides of blinds. Using a Dimmer or Level slider with a range from 0 - 100 would "close" the blind to 0 at the bottom tilt position, and "open" the blind to the top tilt position at 100. This flips to 100 for open at the bottom, and 0 for close at the top since the direction of shaft travel flips from CCW to CW depending on the location (L or R) of the servo on the shaft.

Is there a way to "invert" the Level depending on L or R installation, so that 0 would always be at the bottom?

This is the servo that I am using for my long, 8' 2" faux wood blinds.

https://www.amazon.com/gp/product/B073F92G2S

Yes, it's a little more expensive but it works flawlessly with the newest servo library for Hubduino. Also, it requires a 6-7v power supply, not 5. So, that can be a factor as well.

I read that earlier you were using 996r. If you don't mind me asking, how did those work out and why did you change

They work great. I originally got them because the others weren't able to move my 8' blinds. But that was with a different set of software for my ESP board that would move the blinds much, MUCH more slowly. There were delays built in after each movement. So it would move about 1/10th as quick, therefore causing much more friction. I don't know how a simple 996 would work with 8' blinds with Hubdiono. But I already had this servo so I used it.

Any thoughts on my level question above? I can use it as is, but it would mean that I would, for example set it to 20% for a L servo, and to 80% on R servo to achieve the same result. Kinda funky, and would negate putting those blinds into a group . . .

They are not going to move at the same time, even in the same group. The only way two servos would work is if you link them at the board layer, not at the Hubitat layer.

You could modify the Child Servo Device handler to invert the 0 - 100 as 100 to 0 fairly easily just before data is sent to the micro-controller, and again when it is received. You could even add a user preference to make it easy to choose left-hand versus right-hand configurations.

If you did the above, then you could add these all to a single Hubitat Group and control them together. The timing may not be perfect, but it would be pretty close. There was a change implemented during the great overhaul of HubDuino Servo logic that allows multiple servos connected to one micro-controller to move simultaneously. Previously, each servo had to complete its motion before the next one could start.

Thanks for the suggestion! I had a look in the DH, and flipped the 100 and 0 in this statement, but assume that is incorrect, since it just jammed the sliders at max:
level = Math.max(Math.min(level.toInteger(), 100), 0)

I just want to clarify that is it not just the 0 and 100 that would need to be flipped, but rather the whole "range" for want of a better word. In an R mounted servo it would rotate CCW to 0% (which I refer to as "Open"), and in a L mounted servo it would have to rotate CW to get to Open (which would now would be 100% on the slider). So if I wanted both blinds to open to say 15%, I would set the R servo to 15, but the L servo would need to be at 85 (100 minus 15) ; and 35% would equate to 35 (R) and 65 (L), etc . ..

So my term to "invert" 0 - 100 is not quite accurate.

Any thoughts?

Finally figured it out in the DH, so it works now for R or L, and will create a L version DH for my use. Adding the user preference? Well that might have to wait till I get to the big school . . . :slight_smile: Thanks for the suggestions though!

1 Like

As long as your group is only being created to control multiple blinds and not 2 servos on one set of blinds, doing it hubitat would be fine. I originally thought your question was asking if you could use a group to control 2 servos connected to one set of blinds.

Hi,

Thanks for the reply. No field wiring connected at present. Have tried on multiple different esp8266 boards and the same.

Error from serial.

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld

Have tried the PS-Water library which doesn't cause an issue. I just can't figure out what in the PS_PulseCounter that is so much different that can be causing it.
Hope I am not just doing something silly!
Cheers Chris