arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.17k stars 4.8k forks source link

Physical push button alongside DHT22 sensor? #1172

Closed C-Duv closed 6 years ago

C-Duv commented 6 years ago

Hello, I have an already working setup of a Sonoff Basic running Tasmota (v5.2.4) and reading temperature and humidity on a DHT22 connected on GPIO14 (in Module settings page, GPI014 Sensor is set to 03 DHT22). Both relay state and DHT22 values are retrieved on home automation software via MQTT).

I would like to add a push (momentary) button to this setup so that pushing the button toggles the relay (directly but also sends the new state MQTT message). I know I'll have to configure the SwitchMode and/or SwitchTopic but I am more concerned about how and where connect the push button...

I have found issue #508 (Toggle Switch on GPIO 1(RX) or 3(TX)) which suggest to use GPIO03 (RX) but it uses a toggle/maintained switch not a push/momentary like I want, so I am not sure the following schema works: sonoff_basic-with_dht22_and_push_button_switch

(Ignore the gray "F" zones: they symbolizes female pins on a male header I soldered on the Sonoff board)

ionciubotaru commented 6 years ago

Yes, your schema is OK and must work fine If you receive false triggers from push button add a small cap between gpio3 and gnd

smadds commented 6 years ago

100nF across the switch will help debounce the switch

Rene-Auberger commented 6 years ago

@smadds do you mean the capacitor will be connected to GND and GPIO3/VCC in parallel to the switch? Or where is it located exactly (sorry, I'm a software guy ;-) and currently refreshing my electronics skills).

smadds commented 6 years ago

It can be either end of the wire - it's just easier to mount it on the back of the switch. Effectively it's between the I/O pin and gnd

C-Duv commented 6 years ago

@ionciubotaru @smadds If I get this correct: I should first try with the 4.7k resistor only. Then, if I get false triggers, I should add the 100nF capacitor (keeping the resistor).

2e0vet commented 6 years ago

I dont suppose you have documented how you get the temp readings, I have been trying for ages to get this working without success

C-Duv commented 6 years ago

@2e0vet I used a AM2302 sensor connected as follows on the Sonoff:

AM2302 pins:

Pin number Usage
1 VDD (Power)
2 SDA (Data)
3 Nothing
4 GND (Ground)

(Pins are numbered from left to right: see this specification document).

Connection to the Sonoff:

DHT22/AM2302 Sonoff
VCC (pin 1) 3V3
SDA (pin 2) GPIO14
GND (pin 4) GND

(See GPIO Locations for Sonoff pins locations)

Then of the Tasmota web interface, go to Configuration > Configure Module and set the GPI014 Sensor field to 03 DHT22. Click the Save button and the Sonoff should reboot. After a few seconds (~30s) temperatures and readings should be displayed on the web interface main page.

C-Duv commented 6 years ago

My setup (only using a 4.7kΩ resistor) works fine.

In Configuration > Configure Module page, I set GPIO3 Serial In to the value 09 Switch1. And changed the SwitchMode to 3 by accessing the following URL: curl http://THE.SONOFF.IP.ADDRESS/cm?cmnd=SwitchMode1%203 (SwitchMode1%203 = SwitchMode1 3 = Set SwitchMode for relay 1 -My Sonoff only has one- to mode 3)