Announcement

Collapse
No announcement yet.

arduino plugin and sonoff

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

  • arduino plugin and sonoff

    I need some info...
    Sonoff is "only" an esp8266 board with 1 o 4 relays connected to related GPIO.
    So, if I program a sonoff pro with an .ino firmware I should be able to command relays.
    I need only to know the relays related GPIO and the I can upload .ino firmware...
    Seems to be simple or I'm wrong?

    Thanks

    Cris

  • #2
    Yep, I've loaded and run my app which usually runs on ESP8266 nodeMCU. It ran OK but I did not find it as stable and it did not have enough RAM to do OTA.

    The sonoff I used was the standard unit. You mention the pro, it might be more capable.

    Robert

    Comment


    • #3
      Thank you Robert for replay,
      I don't need a special function.
      I'd like to connect sonoff to the Enigmathatre's arduino plugin in order to no need to install mqtt plugin (server etc...).

      A basic funciton: if a #1-2-3-4 button is pressed, toggle the #1-2-3-4 relay (and report status to homeseer).

      Comment


      • #4
        Hi Cris/Rob

        I was also going to look at loading in the Arduino code to use this plugin on the SONOFF devices. After researching MQTT and Tasmota, the functionality of Tasmota is amazing so thasts the path I ended up going down.

        The critical stuff in the house is on Arduino MEGA on ethernet, the "discretionary" stuff like lighting and "Alexa, turn on Mancave (Sonoff POW that turns on my workbench) is all via MQTT/Tasmota.

        Ended up being a blend :-)

        After last nights session of Sonoff firmware loading and tinkering :-)

        Happy hacking....
        Attached Files
        HS 2.2.0.11

        Comment


        • #5
          Ok, I'm starting to move in this challenge way :-)

          I found the first info for sonoff basic:
          LED = GPIO13;
          RELAY = GPIO12;

          I cant find GPIO for the button and the GPIO about sonoff 4CH PRO Rev2.

          I'm waiting for my new sonoff 4ch pro to start some tests.

          @petez69: Wow, I love your lab!!!

          Comment


          • #6
            From Tasmota source code for 4CH and Basic

            { "Sonoff 4CH Pro", // Sonoff 4CH Pro (ESP8285)
            GPIO_KEY1, // GPIO00 Button 1
            GPIO_USER, // GPIO01 Serial RXD and Optional sensor
            GPIO_USER, // GPIO02 Optional sensor
            GPIO_USER, // GPIO03 Serial TXD and Optional sensor
            GPIO_REL3, // GPIO04 Sonoff 4CH Red Led and Relay 3 (0 = Off, 1 = On)
            GPIO_REL2, // GPIO05 Sonoff 4CH Red Led and Relay 2 (0 = Off, 1 = On)
            0, 0, 0, // Flash connection
            GPIO_KEY2, // GPIO09 Button 2
            GPIO_KEY3, // GPIO10 Button 3
            0, // Flash connection
            GPIO_REL1, // GPIO12 Red Led and Relay 1 (0 = Off, 1 = On)
            GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
            GPIO_KEY4, // GPIO14 Button 4
            GPIO_REL4, // GPIO15 Red Led and Relay 4 (0 = Off, 1 = On)
            0, 0
            },
            { "Sonoff 4CH", // Sonoff 4CH (ESP8285)
            GPIO_KEY1, // GPIO00 Button 1
            GPIO_USER, // GPIO01 Serial RXD and Optional sensor
            GPIO_USER, // GPIO02 Optional sensor
            GPIO_USER, // GPIO03 Serial TXD and Optional sensor
            GPIO_REL3, // GPIO04 Sonoff 4CH Red Led and Relay 3 (0 = Off, 1 = On)
            GPIO_REL2, // GPIO05 Sonoff 4CH Red Led and Relay 2 (0 = Off, 1 = On)
            0, 0, 0, // Flash connection
            GPIO_KEY2, // GPIO09 Button 2
            GPIO_KEY3, // GPIO10 Button 3
            0, // Flash connection
            GPIO_REL1, // GPIO12 Red Led and Relay 1 (0 = Off, 1 = On)
            GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
            GPIO_KEY4, // GPIO14 Button 4
            GPIO_REL4, // GPIO15 Red Led and Relay 4 (0 = Off, 1 = On)
            0, 0
            },

            { "Sonoff Basic", // Sonoff Basic (ESP8266)
            GPIO_KEY1, // GPIO00 Button
            GPIO_USER, // GPIO01 Serial RXD and Optional sensor
            0, // GPIO02
            GPIO_USER, // GPIO03 Serial TXD and Optional sensor
            GPIO_USER, // GPIO04 Optional sensor
            0, // GPIO05
            0, // GPIO06 (SD_CLK Flash)
            0, // GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT)
            0, // GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT)
            0, // GPIO09 (SD_DATA2 Flash QIO)
            0, // GPIO10 (SD_DATA3 Flash QIO)
            0, // GPIO11 (SD_CMD Flash)
            GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
            GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
            GPIO_USER, // GPIO14 Optional sensor
            0, // GPIO15
            0, // GPIO16
            0 // ADC0 Analog input
            },


            If you use the Tasmota firmware you do not need to know this level of detail. Control and status are at a message rather than a pin level.

            Comment


            • #7
              Cris

              I went down the mcsmqtt and tasmota path for the sonoff.......good luck with your project, as always let us know how you go.....

              Pete
              HS 2.2.0.11

              Comment


              • #8
                Thanks guys,
                today will arrive my sonoff board.
                I need to decide the way:
                -tasmota and Michael's MQTT plugin. The hard work is already done. I need to install and configure MQTT plugin.

                -write a new firmware/sketch in order to connect sonoff directly to Greig's arduino plugin.

                In any case, I want to try to write a sketch for a test.

                Next step: project and realize a custom board sonoff-like with nodemcu.

                Comment


                • #9
                  Ok, started with tasmota firmware and works ok.
                  My board is a sonoff 4ch pro r2 so with a different board layout but no problem.

                  Now I'm writing a firmware for arduino plugin.
                  In order to start the flash mode, we need to put GPIO0 to GND when power up the board.
                  But seems that BUTTON1 is connected to GPIO0... I'm wrong or not?
                  What if in my sketch I set GPIO0 as input and enable the internal pull_up?
                  Could be that a I can't re-enable flash mode again?

                  Comment


                  • #10
                    Press BUTTON1 when powering up for a second or two.

                    Write you sketch or bin file to your SonOff.

                    Could be that a I can't re-enable flash mode again?

                    Just unpower your Sonoff and start again. It will work or not work. I have small LEDs on the USB programmer that flash when programming the flash.

                    Make sure too that you do not have your Sonoff 4ch Pro R2 powered on (5-24VDC). For flashing you only need to power up via 3.3VDC.

                    It does not matter to the Arduino / Sonoff bootloader that you have set your GPIO0 as input on your sketch relating to flashing the Arduino.

                    Make sure you are utilizing your 3.3VDC pin and not your 5.0VDC pin on your USB programmer.

                    [ATTACH]70106[/ATTACH]
                    Last edited by Pete; July 22nd, 2018, 06:21 PM.
                    - Pete

                    Auto mator
                    Homeseer 3 Pro - 3.0.0.500 (Linux) - Ubuntu 18.04 64 bit Intel CPU - Mono 5.18
                    Homeseer Zee2 (Lite) - 3.0.0.531 (Linux) - ARMBian Ubuntu 18.04 64 bit Arm CPU - Mono 5.20

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

                    Comment


                    • #11
                      Here have modded two Sonoff WiFi Basic modules.

                      I am amazed what you can do with these devices.

                      These are utilizing Michael's modded Sonoff Tasmota firmware.

                      Cut traces for 120VAC relay making it a low voltage relay.

                      Removed DS18B20 sensor pins, drilled tiny hole on cover and passed 3 wires to main SonOff board for a DS18B20 temperature sensor gluded on the top case.

                      Inside have wired 2 3.3VDC pins, 1 5.0VDC pin, 2 Ground pins, GPIO 1,3,4 and 14.

                      You can switch power source from 120VAC to 12VDC easy enough if you want to switch.

                      Might glue a tiny PIR or microwave sensor and 6 terminals to cover.

                      [ATTACH]70118[/ATTACH]
                      Last edited by Pete; July 23rd, 2018, 11:26 AM.
                      - Pete

                      Auto mator
                      Homeseer 3 Pro - 3.0.0.500 (Linux) - Ubuntu 18.04 64 bit Intel CPU - Mono 5.18
                      Homeseer Zee2 (Lite) - 3.0.0.531 (Linux) - ARMBian Ubuntu 18.04 64 bit Arm CPU - Mono 5.20

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

                      Comment


                      • #12
                        Thank you Pete for all precious information.

                        My first flash, was done with an 12V external power.
                        I haven't connected the 3.3V pin and flash was ok.
                        I have read this information from a blog... "...if your FTDI usb-serial converter can't provide a lot power, you can connect external power and disconnect 3.3V pin..." For me worked.

                        Comment


                        • #13
                          Yes here just utiilize the USB port on the laptop (USB 3.0 ==> 900mA) to provide 5VDC and 3.3VDC to the FTDI USB to serial converter.

                          That said too disconnected the 120VAC mains to the SonOff device while the board is open so as not to get an electrical shock.

                          12VDC would be easier to deal with.

                          I would like to find a 3D printer drawing to make a small cover for the temperature sensor.

                          Once the firmware is installed via JTAG then you can switch to upgrading firmware via OTA via the Sonoff-Tasmota (MCS) firmware.
                          - Pete

                          Auto mator
                          Homeseer 3 Pro - 3.0.0.500 (Linux) - Ubuntu 18.04 64 bit Intel CPU - Mono 5.18
                          Homeseer Zee2 (Lite) - 3.0.0.531 (Linux) - ARMBian Ubuntu 18.04 64 bit Arm CPU - Mono 5.20

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

                          Comment


                          • #14
                            Originally posted by Pete View Post
                            Yes here just utiilize the USB port on the laptop (USB 3.0 ==> 900mA) to provide 5VDC and 3.3VDC to the FTDI USB to serial converter.

                            That said too disconnected the 120VAC mains to the SonOff device while the board is open so as not to get an electrical shock.

                            12VDC would be easier to deal with.
                            Oh yesss, sure, 220V (in my case) is disconnected!

                            I would like to find a 3D printer drawing to make a small cover for the temperature sensor.

                            Once the firmware is installed via JTAG then you can switch to upgrading firmware via OTA via the Sonoff-Tasmota (MCS) firmware.
                            You're encouraging me to try the MQTT/MCS plugin.
                            A question: if I push a button1 on sonoff, relay1 toggle status and for example switch to ON. With MCS plugin do I have a feedback on HS3? Change status my device?

                            I already installed Tasmota firmware but in your previous message you say "These are utilizing Michael's modded Sonoff Tasmota firmware"
                            Where can I find the Michael's modded Sonoff Tasmota firmware?
                            I don't know if is better tray to write my firmware and use sonoff with Greig's Arduino plugin or move on MCS/MQTT plugin.
                            Do you think will be possible to use the second solution with HS3 linux version on raspberry?

                            Comment


                            • #15
                              With MCS plugin do I have a feedback on HS3? Change status my device?

                              Yes utilizing Mosquitto and the mcsMQTT plugin.

                              With Mosquitto you will have status and two way communication to the Sonoff device.

                              Here is a console view with the Sonoff in the garage (car port). Not all connected at this time and just testing.

                              18:17:23 MQT: /GarageDoor2/SENSOR = {"Time":"2018-07-23T18:17:23", "Switch1":"On", "Switch2":"On", "DS18x20":{"DS1":{"Type":"DS18B20", "Address":"280D7E5B04000049", "Temperature":95.2}},

                              The mcsMQTT plugin runs fine in Windows or Linux Homeseer 3 lite, standard or Pro.

                              Where can I find the Michael's modded Sonoff Tasmota firmware?

                              It is one bin file for the Sonoff basic WiFi and the Sonoff 4ch Pro R2.

                              mcsTasMota firmware June, 2018

                              Here have HS3 Lite (Zee2) running on a Pine64 ARM CPU with 2Gb of RAM doing Ubuntu 16.04 64 bit server. It is the same as running on the RPi 2-3 Stretch (32 bit).

                              One RPi in the attic is used for ZNet like device in attic, Node Red OWFS 1-wire temperature/humidity sensors, NOAA SDR radio for satellite downloads.

                              Another RPi in the basement is also doing Node Red OWFS 1-wire combo sensors. Another RPidoes Lightning detection.

                              and running HS3 Pro on another computer iSeries Haswell chipset with 16Gb of RAM running Ubuntu 16.04 64 bit and doing aux Oracle Virtual boxes running Windows Homeseer stuff.

                              It's been a few years now here that I purchased a few Arduino's with sensor kits. Never did play with them much though until I started to tinker with the Sonoff stuff.

                              Much easier cuz everything is all included in one little Sonoff device.
                              Last edited by Pete; July 23rd, 2018, 12:33 PM.
                              - Pete

                              Auto mator
                              Homeseer 3 Pro - 3.0.0.500 (Linux) - Ubuntu 18.04 64 bit Intel CPU - Mono 5.18
                              Homeseer Zee2 (Lite) - 3.0.0.531 (Linux) - ARMBian Ubuntu 18.04 64 bit Arm CPU - Mono 5.20

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

                              Comment

                              Working...
                              X