openHASP: An MQTT driven Touchscreen / Scene controller

One of the best home assistant addon!

My work in progress…



Thanks

3 Likes

Hey guys just got my wt32-sc01 device and I’m working on bringing it online.
I want to connect a MH-Z19 co2 sensor to it but need some guidance.
It needs rx/tx pins, can I use any of the GPIO pins?

And here, which type of pin should I use and what default state/resistor values to pick?
image

The GPIO config is for simple digital input/outputs only, i.e. a LED, relay, switch or push-button.

For other sensors you will need to compile your custom code into the firmware. That way you can add an additional serial port and poll the sensor at regular intervals.

Thanks for the link, I had a look but I am still not 100% on how to code my mh-z19e sensor like that.
Any chance someone has some examples/code to share so I can modify it for my needs?
I would guess I just need to set tx/rx to some of the pins, can any be used? On the d1 mini I am currently using with esphome and this co2 sensor rx/tx are GPIO03/01 pins for example

My understanding is that on the esp32

  1. There are 3 hardware uarts

  2. You can use any gpio for a uart, so long as it isn’t used for anything else and has the ability to do input or output (as the case may be); and

  3. One of the three hardware uarts is linked to onboard spi memory can’t be used.

See this page ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

Looks like the same pins can be used:
image

However by looking at the pin diagram of the WT32-SC01, I can’t seem to be able to match those pins

As in where is GPIO01 and GPIO03 on this 40 pin header?

Why do you need gpio1 and gpio3? Did you read my last post?

Ok but even so what goes in the custom code file?
GPIO10 is the tenth pin in the 40 pin header?
The numbering on the wt32 diagram is all over the place

There are several Arduino libraries that can do the binary serial communications. They will let you select the pins to use too. I don’t own the chip so I can’t really provide any assistance coding for it, but it’s like writing any Arduino sketch.

Yes, as @nickrout mentioned, any pin can be configured as Serial1 interface. The default Serial port is already used by openHASP for the serial logging and console. TXD0 and RXD0 are hard-wired to the USB interface anyways, so can’t be used for the sensor. Just pick any two free IO’s on the header.

There is no relationship between the GPIO number and the pin number on the header. The diagram shows where each IOxx is located on the header (xx being the GPIO number). The PCB schematics are available in the datasheet.

Another way to go about this is to have the D1 mini with esphome send the values to HA and then let HA update the display… That way you won’t need special firmware on the WT-SC01.

I could but I would like to get rid of the esp8266 and use the wt32 in its place.

As an example, in the arduino library the mh-z19 can be used like this:

#include <Arduino.h>
#include "MHZ19.h"                                        
#include <SoftwareSerial.h>                                // Remove if using HardwareSerial

#define RX_PIN 10                                          // Rx pin which the MHZ19 Tx pin is attached to
#define TX_PIN 11                                          // Tx pin which the MHZ19 Rx pin is attached to
#define BAUDRATE 9600                                      // Device to MH-Z19 Serial baudrate (should not be changed)

MHZ19 myMHZ19;                                             // Constructor for library
SoftwareSerial mySerial(RX_PIN, TX_PIN);                   // (Uno example) create device to MH-Z19 serial

unsigned long getDataTimer = 0;

void setup()
{
    Serial.begin(9600);                                     // Device to serial monitor feedback

    mySerial.begin(BAUDRATE);                               // (Uno example) device to MH-Z19 serial start   
    myMHZ19.begin(mySerial);                                // *Serial(Stream) refence must be passed to library begin(). 

    myMHZ19.autoCalibration();                              // Turn auto calibration ON (OFF autoCalibration(false))
}

void loop()
{
    if (millis() - getDataTimer >= 2000)
    {
        int CO2; 

        /* note: getCO2() default is command "CO2 Unlimited". This returns the correct CO2 reading even 
        if below background CO2 levels or above range (useful to validate sensor). You can use the 
        usual documented command with getCO2(false) */

        CO2 = myMHZ19.getCO2();                             // Request CO2 (as ppm)
        
        Serial.print("CO2 (ppm): ");                      
        Serial.println(CO2);                                

        int8_t Temp;
        Temp = myMHZ19.getTemperature();                     // Request Temperature (as Celsius)
        Serial.print("Temperature (C): ");                  
        Serial.println(Temp);                               

        getDataTimer = millis();
    }
}

Will all that code simply go in the void custom_setup(); and void custom_loop(); functions?

Basically yes, but of course you will need to test and tweak the example sketch. Like use Serial1 instead of SoftwareSerial etc.

Good day. Using openhasp with Lanbon L8; has anyone lost the antiburn switch with this HA (2022.4) release?

I checked my setup and indeed the antiburn switch is unavailable.
I don’t use it so I can’t say for sure that upgrading to 2022.4 caused it on my end. I’m not using the switch for anything.

We are looking into this issue and hope to get this sorted during the weekend.

@fvanroie
Thank you for your prompt response and once again thank you for this great component.
I’ve now been running it with 24 lanbons for about 5 months and it just works very well.

The issue has been fixed in the openHASP Custom Component 0.6.5. Thanks @dgomes!

@juan11perez Wow… That’s a lot of Lanbons! I’m glad you like the combo with openHASP.
Would you mind sharing a bit of information or some images to understand how you are using it?

image

I have received one of the WT-0-S2-240NW1 knob devices and I can confirm that it does not have a touchscreen. It behaves like a large rotary encoder with press to ENTER and long press to go BACK…

This means the device won’t be suitable for openHASP at the moment. The ESP32-S2 solo MCU still makes it a viable option for other DIY projects.

@fvanroie as I said they just work! Happy to share any specifics.
I basically replaced all switches in my house with Lanbons. They have 3 relays, so in several places I was able to reduce the number of individual switches to 1 lanbon.
I dont have any particularly ‘impressive’ designs. I’ve essentially modified the examples in the documentation to suit.
Below find some pictures of some of the plates:

plate02-1
plate02
plate04
plate09
plate24

I loaded on all of the plates the files for restart on wifi disconnect and the default relay set up in case communication is lost. So if all fails they revert to being ‘normal’ switches with 3 buttons.

One issue I did encounter at the begining was that it seems the plates are quite chatty. I run unifi at home and I had a USG. It struggled to handdle the traffic/connections.

I ended up upgrading to a UDM pro and the problem went away. no disconnects, no issues.

They work fine.

Additionally the convenience of ‘designing’ your own layout is just amazing. I no longer have any zigbee buttons or anything of the sort to control devices without physical control
I just add a page wherever, create a button and Im done.

Again thank you very much for this project

4 Likes

Good day, did you eventually find a way for this?

We are currently looking for testers of the 0.6.3-rc3 release, because it contains a lot of bug fixes and new features. You can download the firmware from https://install.openhasp.com or install it via the Web installer.

Please leave feedback here or in the Github discussion thread.
If there are no issues reported i’ll turn it into the next release of openHASP.