Announcement

Collapse
No announcement yet.

SonOff WiFi Basic temperature / humidity sensor project

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SonOff WiFi Basic temperature / humidity sensor project

    This project is for creating a 1-wire temperature / humidity hub with a SonOff WiFi basic module and temperature and humidity sensors.

    Note that this project is for temperature and temperature humidity 1-wire sensors only. (DS18B20's and DHT22's).

    Hardware list for making one combo hub. Note here used Amazon Prime (faster delivery higher price).

    Colors will be Red for VCC, Black for Ground and Yellow for DQ. Went to utilizing 22/4 stranded alarm cable for runs here (new) and repurposed old cat5e runs.

    1 - SonOff basic Wifi module

    Click image for larger version  Name:	SonOff basic.jpg Views:	1 Size:	46.9 KB ID:	1260012

    2 - Temperature and Humidity sensors

    DHT22 combo Temperature and Humidity sensors (indoor)

    Click image for larger version  Name:	DHT22.jpg Views:	1 Size:	55.7 KB ID:	1260013
    DS18B20 cabled outdoor / indoor temperature sensors

    Click image for larger version  Name:	DS18B20Cabled.jpg Views:	1 Size:	41.2 KB ID:	1260014

    DS18B20 sensors

    Click image for larger version  Name:	DS18B20.jpg Views:	1 Size:	14.2 KB ID:	1260015

    3 - terminal posts (optional)

    Click image for larger version  Name:	terminalposts.jpg Views:	1 Size:	63.6 KB ID:	1260016
    4 - header pins (optional) and wire (various colors).

    Click image for larger version  Name:	headerpins.jpg Views:	1 Size:	81.4 KB ID:	1260017

    Note: this is the way I configured my SonOff WiFi basic modules.

    Hardware Modifications for use

    SonOff Basic WiFi hardware modification and terminal installation

    1 - CUT 120VAC power to relay traces and soldered jumper. This time used a small hack saw rather than the dremel tool.
    Tested cut using VOM. Connected 120VAC and tested relay terminals for 120VAC voltage (none present after cut).

    2 - JTAG + GPIO terminal installation (solder terminals to SonOff board).
    Used a tiny drop of Elmers glue to glue terminals to board then soldered the terminals to board. Color coded each terminal post.

    Taking the 3/3 terminals to the case terminals such that I do not have to open up the case anymore. 2 of the terminals will be 3.3VDC and 2 will be ground and two will be GPIO pins.

    Click image for larger version  Name:	Relay-GPIO.jpg Views:	1 Size:	117.6 KB ID:	1260563
    3 - wires to surface mounted terminals (soldered wires inside of case)
    Drilled 5 holes in case for terminals. Used a tiny bit of glue to glue terminals to case then soldered wires to terminals.

    Typically here use black wires for ground, red wires for VCC and yellow, blue et al wires for GPIO pins. Personally here will upgrade firmware and prewire and close case such that I do not have to tinker inside of the SonOff wifi module. Wiring is a bit tight using 22-24 guage wire. Carefull with the button on the stalk as here have accidently removed it making it disfunctional.

    I have a bunch of old 1-wire stuff here like the AAG weather station, dual counters, barometer, old lightning sensor et al.

    Disconnected the AAG weather station and barometer. Left dual counters running (water meters), lightning sensor, Dallas tipping bucket and two digital rain guages up. Went to using a wireless Davis weather station (plus a generic one a few years back).

    Started in the 1990's-2000's using Midon's Temp05, Temp08, Maxim serial / USB devices ===> multiple serial devices and used xAP at the time.

    For weather started with AAG weather station then Davis and a couple of el cheapo weather stations. Sticking with Davis / wireless to console or meteo stick. Not entertaining or even looking at any cloud connected weather stations at this time.

    Personally transitioning over to WeeWx with multiple weather instruments from CumulusMX.

    BUT I am configuring a Davis to Cumulus and a cloud connected weather station to a London Homeseer user who has dedicated a box to just weather.
    Last edited by Pete; November 19th, 2018, 05:36 PM.
    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
    Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

  • #2
    One DHT22 worked for a bit with a 30 foot run of wire. After a bit now getting a data error. Just found out too that I cannot daisy chain DHT22.

    DHT22 @ GPIO14 Data Error

    Reading a bit looking at specfications it states up to 20 meters (60 feet) so it should be working fine.

    I am though seeing around 3.1 VCC in status and just read:

    VCC - red wire Connect to 3.3 - 5V power. Sometime 3.3V power isn't enough in which case try 5V power.

    Also reading DHT22 and AM2302 often have a pullup already inside, but it doesn't hurt to add another one.

    Tested 3 DHT22 sensors one at a time directly connected to the terminals on the SonOff Basic and all three worked fine before extending runs.

    Tried a pull up resistor and after a minute or so it went back to an error. Connected second DHT22 in basement and temps and humidity are good except run is shorter than main floor sensor. Going to switch the main floor combo DHT22 with a DS18B20 sensor next.

    So may connect the VCC to a ~5 VCC which I utilized for the GDO and it worked fine. Means a take apart and tap another pin with 5VDC.

    and add another pull up resistor between DQ and VCC.

    Well and went to the DHT22 because I read it is better than a DHT11. There isn't much of a difference between the two though.

    So may change direction here using daisy chained DS18B20 sensors only for said project.

    and maybe do one off SonOff's for reading humidity levels in basement, main floor and 2nd floor of home.

    Changed over to DS18B20's. Two work fine directly connected to Sonoff basic. Extending one sensor then both do not work.

    Intially was testing using garage door #2 sensor for multiple DS18B20's all extended and all worked fine with mcsTasmota firmware.
    Last edited by Pete; November 21st, 2018, 07:28 PM.
    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
    Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

    Comment


    • #3
      Pete

      I've got an interesting troublesome Sonoff Basic here. AM2301 and a TSL2561. Randomly reboots or locks up, suspect its an issue wtih the TSL2561 driver. I've been testing ESPeasy on a nodemcu board, its far more reliable :-) I had serious DS18B20 errors on a number of PIs, randomly dropping off....in the end I found it was low voltage to the PI causign it....(5v).

      Are you sure they are both DS18B20 ? Get them under a magnifying glass.....there are variants

      Pete
      HS 2.2.0.11

      Comment


      • #4
        Thank you Pete.

        Originally testing SonOff WiFi basic was using three extended DS18B20's using a duplicate of Michael's mcsTasmota firmware. Worked great for months now.

        The new testing SonOff WiFi basic went to using Espurna with DS18B20's (just the chips, shielded cable DS18B20's and older mounted on a circuit board DS18B20's).

        I did not look at the chips with a magnifying glass. Connected 6 terminals posts (3 and 3) to the case. Two are ground and two are 3.3 VDC. One is GPIO 14 and the other is one of the JTAG ports. Only tested with GPIO14.

        Soldered color coded leads to the DHT22 and DS18B20's (red black yellow or white).

        And single DHT22's connected to GPIO14.

        All of the above works fine directly connected with short wires to the SonOff WiFi module. IE: one DHT22 and DS18B20s (up to three).

        No rush here in testing. Might go back to using an RPi / OWFS / Node Red ==> Mosquitto.

        Used a 4.7k resistor on the DS18B20's for testing. None was needed with the DHT22's.

        - Pete

        Auto mator
        Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
        Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

        X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

        Comment


        • #5
          Good video for sensor expansion with I2C that may give you some ideas. https://www.youtube.com/watch?v=VixBNNKykIg

          Comment


          • #6
            Thank you Michael.

            I have read that I can daisy chain i2C sensors.

            - Pete

            Auto mator
            Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
            Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

            X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

            Comment


            • #7
              Update SUN, November 25, 2018

              Found out that only Michael's mcsTasmota modded firmware V 5.9.13g works with 4 extended DS18B20 sensors with 4.7k resistor at terminals and using 22/4 cable in a star fashion for said sensors.

              I am aware that I can daisy chain i2C sensors but already have many DS18B20 and DHT22 sensors. I do not think that I can purchase i2C sensors at $3 each or even less than $10 each.

              Current release of ESPurna 1.13.1 and Tasmota V.6.X will not work in this fashion.

              More issues though relating to using Tasmota V6.X versions of firmware. Works great using JTAG upload via software compiling. Rebooting a few times always connected to WAPs. Once powered by 120VAC doesn't connect to WAP. Never seen this issue with Tasmota V5.X firmware builds.

              I have posted this issue on the ESPurna bugs posts.

              Want to keep it to hopefully using daisy chained DS18B20's and one DHT22 (on a separate GPIO). The 2 3 wire terminals glued to the cover are using common 3.3VDC and Ground and GPIO14 and flexible GPIO ports inside for number 2 3 wire terminal.

              Tried one DS18B20 on GPIO14 and one DHT22 on GPIO4 and it doesn't work yet.

              Very ODD ....left the 3 DS18B20 sensors plugged in using the Espurna firmware. One is using a short wire and two are using longer wires and it is working now. Well showed three sensors for a couple of minutes then went back to one sensor.

              Last edited by Pete; November 25th, 2018, 07:30 PM.
              - Pete

              Auto mator
              Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
              Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

              X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

              Comment


              • #8
                Update MON, November 26, 2018

                Got 5 DS18B20 sensors working now with the ESPurna firmware. At the SonOff WiFi basic end terminals have one 4.7k ohm resistor. At the most distant run put another 4.7k ohm resistor.

                Next steps are to run two extended DHT22 combo sensors on different GPIO pins (modifying Espurna firmware).

                Click image for larger version

Name:	Espurna-5 sensors.jpg
Views:	252
Size:	39.9 KB
ID:	1262421
                For using mcsMQTT using the HASS tab here (well also running Home Assistant on another computer these days)

                sensor:
                - name: ICS_SonOff1_temperature
                platform: mqtt
                state_topic: SonOff-1Wire-1/temperature/0
                unit_of_measurement: °F


                sensor:
                - name: ICS_SonOff1_temperature
                platform: mqtt
                state_topic: SonOff-1Wire-1/temperature/1
                unit_of_measurement: °F


                sensor:
                - name: ICS_SonOff1_temperature
                platform: mqtt
                state_topic: SonOff-1Wire-1/temperature/2
                unit_of_measurement: °F


                sensor:
                - name: ICS_SonOff1_temperature
                platform: mqtt
                state_topic: SonOff-1Wire-1/temperature/3
                unit_of_measurement: °F


                sensor:
                - name: ICS_SonOff1_temperature
                platform: mqtt
                state_topic: SonOff-1Wire-1/temperature/4
                unit_of_measurement: °F

                Now documenting last 4 digits of the 1-wire mac addresses as I lose track here.

                xxxxx
                - Pete

                Auto mator
                Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
                Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

                X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                Comment


                • #9
                  Changed the base firmware to DS18B20 sensors only and not getting DHT errors. Next is to configure the DHT sensors on another GPIO port.

                  [401068] [MQTT] Sending SonOff-1Wire-1/temperature/0 => 67.9 (PID 354)
                  [401072] [MQTT] Sending SonOff-1Wire-1/temperature/1 => 70.6 (PID 355)
                  [401074] [MQTT] Sending SonOff-1Wire-1/temperature/2 => 70.0 (PID 356)
                  [401078] [MQTT] Publish ACK for PID 354
                  [401083] [MQTT] Sending SonOff-1Wire-1/temperature/3 => 71.5 (PID 357)
                  [401088] [MQTT] Publish ACK for PID 355
                  [401092] [MQTT] Sending SonOff-1Wire-1/temperature/4 => 67.8 (PID 358)

                  Thinking I can go a bit higher on the DS18B20's such that will workbench test upping the number of DS18B20's.
                  - Pete

                  Auto mator
                  Homeseer 3 Pro - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU - Mono 6.4X
                  Homeseer Zee2 (Lite) - 3.0.0.534 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.4X

                  X10, UPB, Zigbee, ZWave and Wifi MQTT automation.

                  Comment

                  Working...
                  X