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

I tend to use Rule Machine mostly for complicated automations. I use the other built-in Hubitat Apps for most other automations, as they are purpose-built for those tasks. Rule Machine is a very powerful tool once you get your arms around it. Often, the quickest way to understand RM is to post a question in the form of "How would I accomplish ?" There are some very skilled rule writers that can assist you early on to keep things from going into the weeds.

3 Likes

Many thanks. Once I got started it all started to make sense. I have a couple of sensors up and going, a DHT22 and BME280 they work just fine. I have a servo attached to an 8266 that works well. I tried copying the lines from the 8266 for the servo to an ESP32 sketch. I think I added everything but when I compile, I get

/root/Arduino/My_servos_ESP32WiFi/My_servos_ESP32WiFi.ino: In function 'void setup()':
    My_servos_ESP32WiFi:241:14: error: 'EX_Servo' in namespace 'st' does not name a type
       static st::EX_Servo executor1(F("servo1"), PIN_SERVO_1, 0);  

    My_servos_ESP32WiFi:301:32: error: 'executor1' was not declared in this scope
       st::Everything::addExecutor(&executor1);

Could you point me to what I might have missed?

Looks like you may simply be missing a #include statement at the top of the ESP32 sketch.

Like

#include <EX_Servo.h>        //Implements Executor (EX)as an Switch Level capability via a PWM output to a servo motor

I did have that. Don't remember exactly, but I think I added three items from the 8266 sketch. The
#include <EX_Servo.h>
#define PIN_SERVO_1 27
static st::EX_Servo executor1(F("servo1"), PIN_SERVO_1, 0);

I am guessing there may have been an error even earlier in the build? I do not believe the ESP32 supports the same Arduino commands for the Arduino 'analogWrite()' and 'Servo' commands/libraries due to differences in how it implements PWM digital outputs. You may be much better off just using an ESP8266.

Perhaps someone else with more ESP32 experience will chime in? I am away from my development PC so I cannot test anything now.

OK thank you sir. I will move some temp sensors to the ESP32 and leave the servo where it was.
I would like to consolidate 2 BME280s to a single ESP32 since I don't think you can do that with an 8266. Would there be anything special I would need to do?

I think you should be able to do 2 BME280s on one ESP8266 if they are connected I2C... Not sure if they are connected SPI (EDIT: you can, see end of post).

BME280s have 2 addresses possible, so you couldn't go over 2 (easily), but should be able to do 2.

Something like:
#define BME280_I2C_ADDRESS1 (0x76)
#define BME280_I2C_ADDRESS2 (0x77)

This isn't specific to ESP8266, but illustrates the point:

Google says you can do it on SPI, too:

2 Likes

Yes you can, although I haven't tried setting up the second. In my mind i was thinking one thing and writing another. I have three BME280s and you can only have one I2C channel on an 8266 but there are 2 on an ESP32. I get an idea on how I am going to organize things but each time I plug something in it changes everything. I always had trouble combining devices on a single board. This certainly makes it easier.

1 Like

How would you do that in Hubduino?

I would beg @ogiewon for help. :slight_smile:

1 Like

Just read the comments section at the top of the BME280 class .h or .cpp file... :wink:

The constructor allows the user to specify the I2C address.

//******************************************************************************************
//  File: PS_AdafruitBME280_TempHumidPress.h
//  Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
//  Summary:  PS_AdafruitBME280_TempHumidPress is a class which implements the "Temperature Measurement",  
//			  "Relative Humidity Measurement", and "PressureMewasurement" device capabilities.
//			  It inherits from the st::PollingSensor class.  The current version uses I2C to measure the 
//			  temperature, humidity, and pressure from a BME280 series sensor using the Adafruit_BME280 library.  
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::PS_AdafruitBME280_TempHumidPress sensor2(F("bme280_1"), 60, 0, "temperature1", "humidity1", "pressure1", false, 100, 0x77);
//
//			  st::PS_AdafruitBME280_TempHumidPress() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must be unique, but is not used for data transfer for this device
//				- 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
//				- String strTemp - REQUIRED - name of temperature sensor to send to ST Cloud (e.g."temperature1")
//				- String strHumid - REQUIRED - name of humidity sensor to send to ST Cloud (e.g. "humidity1")
//				- String strPressure - REQUIRED - name of pressure sensor to send to ST Cloud (e.g. "pressure1")
//				- bool In_C - OPTIONAL - true = Report Celsius, false = Report Fahrenheit (Fahrenheit is the default)
//				- byte filterConstant - OPTIONAL - Value from 5% to 100% to determine how much filtering/averaging is performed 100 = none (default), 5 = maximum
//              - int address - OPTIONAL - I2C address of the sensor (defaults to 0x77 for the BME280)
//

On the physical device, you’ll need to move a jumper on the second BME280 to change its address (or sometimes you cut a trace.)

1 Like

The example says only use one a time.

//  static st::PS_AdafruitBME280_TempHumidPress sensor1(F("BME280_1"), 60, 0, "temperature1", "humidity1", "pressure1", false, 100, 0x76);  //both BME280 and BMP280 use address 0x77 - only use one at a time
//  static st::PS_AdafruitBMP280_TempPress sensor2(F("BMP280_1"), 60, 5, "temperature2", "pressure2", false, 100, 0x77);  //both BME280 and BMP280 use address 0x77 - only use one at a time

Maybe that should be corrected then.

That refers to the two devices both trying to use the exact same I2C address.

If you’d like to clarify the comments in the code, please feel free to issue a pull request. :blush:

1 Like

If they both use the same I2C address, doesn't that mean that multiple copies of the device would also use the same I2C address? You said you can select the address on the device, so why couldn't you use one BMP280 and one BME280 intead of 2 BMP280?

Why would I do that? I'm asking you how it works because I don't know how it works. How could I possibly clarify it? If I could clarify it, I wouldn't be asking.

Yes, you could use one of each as long as the addresses don’t conflict. In my example sketch, since both devices that I tested with have the same address, I left a note to myself to make sure only one of those two particular lines of code were uncommented. It is just an example sketch, not a substitute for a tutorial on the I2C protocol.

I try very hard to answer all questions regarding this project. However, there is an assumption with my HubDuino/ST_Anything project that users are already familiar with basic Arduino code and low voltage circuitry/wiring. There are tons of tutorials available online to help users get started with the basics. HubDuino is a toolkit to drastically reduce the effort to get started with integrating an Arduino board with Hubitat. It is not a turnkey solution, and thus there is an expectation that the user has a basic understanding.

4 Likes

You are a very patient person.

4 Likes

I meant I don't know how your code works. There is no need to be rude. Don't worry, I won't bother you again.

1 Like

How does that do anything other than antagonize people. I thought this was a place for people to get help. I guess it's just a place for people to put others down. I guess what I've heard about this group was right.

I apologize if you took my post as rude. That was never my intent.

4 Likes

I will say again, You are a very patient person.
One thing we must all remember, almost everything in this community is time, energy, knowledge and understanding given freely to others. I personally appreciate every minute of that time that others have given and the help I have received from them. I would like to add a special thank you to Dan and Son for this incredible piece of work.

4 Likes