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

Here you go:

1st capture changing level on Servo 1 only. Moves at the expected slow rate of 3500:

Everything: Received: servo1 0:3500
EX_Servo::beSmart level = 0
EX_Servo::beSmart rate = 3500
EX_Servo::beSmart OldAngle = 180
EX_Servo::beSmart TargetAngle = 0
EX_Servo::beSmart CurrentRate = 3500
EX_Servo:: Servo motor angle set to 0

And this is the capture when changing level of the Group. Moves fast (and per the trace, rate is 1). Note that - per my posts of a few days ago, some servos are R mounted and other L mounted - which would explain why in the trace two servos move to 180, and the other to 0.

Everything: Received: servo1 0:1
EX_Servo::beSmart level = 0
EX_Servo::beSmart rate = 1
EX_Servo::beSmart OldAngle = 180
EX_Servo::beSmart TargetAngle = 0
EX_Servo::beSmart CurrentRate = 1
EX_Servo:: Servo motor angle set to 0

Everything: Received: servo2 100:1
EX_Servo::beSmart level = 100
EX_Servo::beSmart rate = 1
EX_Servo::beSmart OldAngle = 0
EX_Servo::beSmart TargetAngle = 180
EX_Servo::beSmart CurrentRate = 1
EX_Servo:: Servo motor angle set to 180

Everything: Received: servo3 100:1
EX_Servo::beSmart level = 100
EX_Servo::beSmart rate = 1
EX_Servo::beSmart OldAngle = 0
EX_Servo::beSmart TargetAngle = 180
EX_Servo::beSmart CurrentRate = 1
EX_Servo:: Servo motor angle set to 180

EX_Servo::update() move complete
Everything: Sending: servo2 100:180:1
EX_Servo::update() move complete
Everything: Sending: servo1 0:0:1
EX_Servo::update() move complete
Everything: Sending: servo3 100:180:1

In your group did you set the child servos as a "switch" or "dimmer".

Mine are set as a dimmer and travel at the slower rate I have defined (3000ms) in the child device.

Mike

So, I believe the issue is being caused by the following setLevel() function in the Child Servo Driver.

def setLevel(level, rate = null) {
    if (rate == null) rate = rateValue.toInteger()
    
    if (logEnable) log.debug "setLevel >> level: ${level}, rate: ${rate}"
    
    level = Math.max(Math.min(level.toInteger(), 100), 0)
    rate = Math.max(Math.min(rate.toInteger(), 30000), 0)
    
    sendData("${level}:${rate}")
}

Specifically, the first line of code

if (rate == null) rate = rateValue.toInteger()

My guess is that the Group Device is setting the 'rate' variable, which is then overrriding the user preference in the device.

Try changing that line of code as follows:

rate = rateValue.toInteger()

which will always use the Device's 'rate' preference value, instead of what is being passed in.

This is an interesting issue... Since I don't use servos, I am not sure if I should make this change permanent or not... Thoughts everyone?

I don't believe there is an issue with Hubduino (servos) as I have various groups of blinds with 3000ms rates set and they all work correctly when controlled as a group from Alexa, Simple Lighting, Hubitat dashboards and button devices using the Advanced Button Controller hubitat app.

Mike

1 Like

Thanks Dan, it works - both at individual and group level change.

This would be the 3rd change in the child driver I have made. Previously I had modified it to allow for L or R mounted servos, and later added in the Preference so the user can select R or L in the Device page.

In my case I will use Group to control 3 blinds next to each other, and a similar situation in a different room at a later point. I can live with my custom driver as is, but if you want to include all changes in a new official version could be helpful to another soul down the line . . .

1 Like

Thanks @ogiewon for HubDuino! I have just purchased my very first Arduino UNO with the Ethernet shield and I've got it working using HubDuino.
I've got a question though. Since I'm using the Ethernet shield with the UNO, I only have 7 digital pins available to me (2,3,5,6,7,8,9 - please correct me if I'm wrong). I have an 8-channel relay module that I was going to control with the UNO, but I am one pin short of being able to control all 8 channels.
I did a quick google search and it looks like the analog pins also could be used as an output. In my case, I only need a high output for the relay so I thought outputting 5v on an analog pin might work for triggering the relay.
Is there already something built in to the Hubduino drivers to accomplish this? It would be great if the relay switch was also available on the analog pins, but I presume I can also use a switch.

Using an UNO may be a bit tight on memory (2K RAM). But if you're just using relays, it might all fit. I definitely recommend the MEGA (8K RAM) if you want to stay with the classic Arduino boards.

I believe on an UNO or MEGA you can use the Analog pins as if they were digital pins. Just use the names A0 - A5 instead of 0 - 13 and see what happens.

1 Like

Brilliantly simple solution that works a treat! Thanks!

1 Like

Please Private Message me a copy of your Child Servo Driver. I'll take a look at your changes while I have the hood open on all of the Child drivers.


All,

I am in the process of cleaning up all of the Hubitat child drivers to remove the old SmartThings 'tiles' section and the custom 'lastUpdated' attribute. The lastUpdated attribute is generating needless events which can only negatively impact the overall performance of the hub, and increase the size of your hub's database. It is simple enough to click on the EVENTS link on the device details page if one is curious about when the last time a new event was generated from a child device. This is the same method used for all Z-Wave and Zigbee devices, so I don't feel HubDuino needs to be special in this regard.

Also, the Parent device's 'Presence' Capability is what can easily be used to know whether or not the micro-controller has lost communication with the hub. It also makes it simple to create a notification using the Hubitat Notifications App or Rule Machine should your micro-controller go offline.

Thanks!

2 Likes

FYI - If anyone is interested in possibly automating your Keurig coffee machine, I wrote a sketch for a SmartThings user that you may find interesting.

NOTE: I do not have a Keurig machine, so I have no knowledge of any of the wiring required. The sketch uses 4 timed relay devices, to create a sequence of 'button presses' on the coffee maker to trick it into believing a person has turned it on, opened and closed the lid, pressed the brew button, and then turned the machine off 15 minutes later.

1 Like

Nothing about automatically drinking the coffee and washing the cup. Will that be added at some point? :wink:

4 Likes

I have uncovered a small anomaly - unrelated to the driver. I am using 3 x servos on my ESP8266, connected to D5,6, &7. All three are in a group, and I use a reduced rate, as well as the new rate "override". What I noticed is that one of the servos would perform a last "twitch" of approx. 10 or so degrees at the end of movement. It is always the same servo, and the other two do not exhibit this behavior. Note that this was observed with the old driver as well.

In each of the servo sketch statements below, there are three "variables": "executorx" ; "servoy", and "PIN_SERVO_z". I played around with all possible combinations of x, y , and z, and found the "culprit" to be servo3 - regardless of Executor or PIN_SERVO numbering. The anomaly followed "servo3" regardless of PIN assignments, executor, or physical servo.

Now this could be a limitation of having 3 servos on the board, but wanted to see if you have any comments.

I don’t have any idea why servo3 would behave differently than the others. They are all running the exact same code, just another copy.

What model of servo do you have? There are a lot of fakes out there that will jitter.

Like I wrote, it is not related to any of the physical servos/pins. It follows "servo3" wherever that goes in the sketch . . . .

I am using cheap MG995s. It is not a jitter per se. Rather, the servo stops for a fraction of a second +/- 10 degrees or so before reaching the target, and then proceeds to complete the movement. Almost like a brief interrupt . . .

It could be due to the ESP8266 sending WiFi data for the other servos that have finished their motion just prior to the last one. Since we’re running everything in a single thread, anything that is a blocking call will cause any servo that is in motion to stutter.

If you have attached other sensors to this same ESP8266, those could be preempting the last servo from being serviced by the CPU.

2 Likes

Nothing else connected to this board.

I did not see anywhere in the sketch or libraries where servo1/2 or 3 are defined, so I assume they are just "names", names propagated back to HE. The weird part is it is always "servo3". The stutter follows that "virtual" servo name, and not the physical servos or pins. It will stutter even if contained within the 1st executor, or the 2nd . . .

Having said that, I believe Dan is correct.

I gave physical servo3 (that now coincides with virtual server3) a slightly faster rate than the other two, and now it is one of the others that is stuttering. I can work around that.

2 Likes

I’ve got a feature request. Would it be possible to add a “motion retrigger” threshold to the motion sensor driver like the one used for the Philips Hue sensor for example?

I’ve noticed that when my motion sensor is sensing motion the HE device is very jittery with many active/inactive triggers. I presume this behaviour is caused by the signal the sensor is sending rather than any issues with any HubDuino components. If there was a motion retrigger option, that would then be able to even out these signals.

I believe that setting for the Philips Hue Motion Sensor is actually sending that 30 second time to the device via a Zigbee configuration command. Thus, the device is actually responsible for respecting that setting, not the Driver.

What type of motion sensor are you using with HubDuino? Many PIR sensors have an adjustable timeout and a jumper which configures the output signal (either as a pulsing square wave, or a constant signal to indicate motion or lack thereof.) Perhaps you could simply adjust the physical sensor?

1 Like

I've written a couple of motion sensors with Arduino and ESP32's. I implemented the timeout there because it was very chatty.

1 Like