Wifi controlled switching - hacking a Sonoff device

Поделиться
HTML-код
  • Опубликовано: 29 окт 2024

Комментарии • 70

  • @MrBobWareham
    @MrBobWareham 10 месяцев назад +2

    Well done for spending all that time and going down the rabbit hole only to find it goes a lot deeper than you expected.

  • @SimpleElectronics
    @SimpleElectronics 3 года назад +5

    Holy crap! This is what I need in my life! This is an awesome project and I can see it being expanded to so many things!

    • @DrexProjects
      @DrexProjects 3 года назад +1

      I think I have 8 of them running lights, fans and water taps for gardening. Regular plants... Not Weed.

  • @deankq4adj125
    @deankq4adj125 3 года назад +1

    Great project, and for those naysayers saying that version of pi doesn't work, I guess you proved them wrong. Great setup and idea.

    • @pileofstuff
      @pileofstuff  3 года назад +1

      I still would recommend that people use the supported hardware, but in my case I use the most basic feature s so I don't overload the poor little guy.

  • @EsotericArctos
    @EsotericArctos 3 года назад +2

    Itead also have a Zigbee version of this. Most of the Itead WiFi stuff is highly hackable as they are based around the ESP8285 chip, which is pretty well an ESP8266 with 1mb RAM onboard.
    They are a really great devices. Very popular with "Makers." The SonOff Mini is also great if you have less space. You can modify the SonOff Basic t0 be a dry contact relay as well. I use one with Tasmota as a "smart" thermostat.

  • @vegaswayne247
    @vegaswayne247 3 года назад +1

    You have a Sonoff Basic R2, which is why GPIO 14 was not found. The older ones don't have the large black wires for the mains current. The GPIO 2 pin with cause a boot failure if it is held low when the unit is powered on. I've done several with the external switch connected to the RX pin (GPIO3). Programming was easy using Hpme Assistant and ESPHome. Using GPIO3 (RX) will let you use a toggle switch, for example, a standard light switch. You just have to flash it before soldering on the switch wires. The program can be updated over-the-air so the serial connections won't be necessary after flashing.

  • @777Thibs
    @777Thibs 3 года назад +1

    Neat lighting on your Ender 3. I did similar, instead running a strip inside the bottom-facing v slot of the top rail. I also placed a short strip directly onto the hotend cover to illuminate under there. I still haven't gotten around setting up Octoprint, but I have all the parts to get it working.

  • @Flying-Toast
    @Flying-Toast Год назад +1

    This is awesome, I just used two of these in my latest video! Thanks for the tutorial :)

  • @duckyducky2497
    @duckyducky2497 2 месяца назад +1

    Thank you for your time and nice video. I would assume Tasmotizer tool would be much easy to set up your GPIO pins. Haven't tried with ESP tool to flash the chip yet. May do it sometimes.
    Sorry I missed how you connected the push button switch to the R2 device. Would assume you wired one end to GPIO2 where you connected 10K Ohm between GPIO2 to 3V3 pin. Then the other end of the switch wired to the GND pin. If that is what you did, I would like to give a shoot. This will be a cool to use the R2 to control a light through App/HA or a physical switch button. Thank you.

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist 3 года назад +1

    I have about 6 running tasmota connected in the power cord, the lights don't have an earth so wiring is easy. I've also go two in 6gang extension leads. I just cut the outer cover of the cord away, cut the L and N then run the earth over the top of the pcb. This way you don't need a connector on the earth to find room for in the box. Nice beer.

  • @GadgetReboot
    @GadgetReboot 3 года назад +1

    This might be useful for me as a basement workshop hazardous (mainly thermal) kill switch and double checker, like if I was using hot air or a hot plate, I want to keep certain appliances like that on a dedicated power bar I can switch off upstairs if I forget and maybe have it semi-automated where I know I only need the stuff for a few hours so I set a 6 hour power strip shut down timer and have it protect me from myself

  • @PIXscotland
    @PIXscotland 3 года назад +4

    I would have just gone Tasmota on that. It comes with a UI for the web, can be direct driven by URL Post commands.
    The default button is an on/off by default as well. The external switch is a useful addition for your use case though.

    • @pileofstuff
      @pileofstuff  3 года назад +1

      I looked into tasmota a bit, but they focus so much on the MQTT / home assistant stuff that I never found that info.
      After several people mentioned that there actually is a web interface I finally found it buried deep in the project's web pages.
      Oh well, this was a fun challenge. And I learned some stuff.

    • @EsotericArctos
      @EsotericArctos 3 года назад +1

      @@pileofstuff MQTT is a great way to communicate with these. Tasmota does have a lot of Home Assistant fans, so it is easy to get lost in the documentation. Home Assistant seems to be popular :)

    • @AnotherMaker
      @AnotherMaker 3 года назад +1

      @@pileofstuff One day I will get you on Node-red and MQTT. I think you'll genuinely love it...but this was a good project in its own right and I learned some stuff along the way.

  • @PablumMcDump
    @PablumMcDump 3 года назад +2

    The Sonoff S31 has regular AC receptacles, and does Kill-a-watt-like power monitoring, which I've seen used for interesting things like detecting when the washer's done by the drop in power draw. An interesting member of the Sonoff family (I'm using with Tasmota and Home Assistant).

    • @grimninja2004
      @grimninja2004 3 года назад +1

      btw, the s31 is not supported by the sonoffs web interface still , cant even be turned on or off . the camera cant trigger a scene like they say it can. and ittt support is usless unless you want to pay for iftt and the advancded sonoff subscribion

  • @MrGmanGB
    @MrGmanGB 3 года назад +1

    Hi - You should flash these Basic units using Tasmotizer. The R2 also has a switch built in. I also run Octoprint with the tasmota plugin which allows you to switch everything off from the octoprint webpage. I have all of this setup on my printer for the last few years and works perfectly.

  • @wallacebrown3151
    @wallacebrown3151 3 года назад +1

    The button on the sonoff originally is programmed to manually turn the unit on/off. Cool that you were able to add a second switch and enclose it in an electrical box and I don't blame you for not wanting to use the factory software. Security concerns aside, seems a little strange to send the commands all the way to China and back if you don't need to access over the internet

    • @elvinhaak
      @elvinhaak 3 года назад +1

      Yep. But it can be handy to have some internet-accessible server if you want to control it from your mobile phone, for example when that is not on your wifi but using 4G for its connection. Also when at your own home.
      I really like this idea though and simply use the webbrowser while on local site!

  • @AnotherMaker
    @AnotherMaker 3 года назад +2

    Fantastic work. It really never crossed my mind to try to program that thing directly. I've flashed tasmota on them and that's pretty cool, but I could really see some benefit to running fully custom code. I need to make some ESP8266s that are directly powered by AC and this may be the way to go. Thank you.

    • @grimninja2004
      @grimninja2004 3 года назад +1

      probably 100% uslsess, but i wonder if the espixel firmware or similar could run on these. it has 1 pin of io and thats all you need to drive ws2211........ it may even be able to power small strips

    • @AnotherMaker
      @AnotherMaker 3 года назад +1

      @@grimninja2004 I may have to check that out!

  • @DrexProjects
    @DrexProjects 3 года назад +1

    I used the dual switch plastic boxs for my SonOffs. Left plenty of room for reset and pushbuttons.

    • @pileofstuff
      @pileofstuff  3 года назад

      I looked for those, but as I said, plastic electrical boxes are not very common here.

    • @DrexProjects
      @DrexProjects 3 года назад +1

      @@pileofstuff Got mine at Home Hardware.

    • @pileofstuff
      @pileofstuff  3 года назад

      @@DrexProjects Didn't try there - the closest one is quite a distance away.

    • @DrexProjects
      @DrexProjects 3 года назад

      @@pileofstuff Oh ya st. b is miles from nowhere.

  • @DrGreenGiant
    @DrGreenGiant 3 года назад +1

    Point to note. You had some issues after programming with it doing funny things. You still had the UART dongle connected. There's a very good chance that dongle won't be providing enough power to run the wi-fi. I've had this issue before at least. After connecting the mains is worked fine

  • @AJB2K3
    @AJB2K3 3 года назад +2

    Those Back box's don't exist in the UK which is a shame as they look so useful!

  • @JWH3
    @JWH3 3 года назад +1

    I'm doing something very similar to this only in hacking a smart bulb for fun. I picked a difficult one on accident because it's RGB seems to be set via a serial protocol. But I have control over the white right now.
    I want to write it myself in Arduino for learning and just need to tap it's direct programming lines as it's esp8255 based (esp8266 with less flash) but otherwise I should be good to go.

  • @PaulOvery001
    @PaulOvery001 3 года назад +1

    Well done

  • @martink9785
    @martink9785 3 года назад +1

    Great project 👍

  • @markfergerson2145
    @markfergerson2145 3 года назад +2

    I kinda followed along but my OCD got hung up on that 12V relay. Where do its coil contacts go on the board? Are you just supposed to kludge 12V in from the outside world?

    • @pileofstuff
      @pileofstuff  3 года назад +1

      No idea. I'll have to dig deeper when i have time.
      I suspect those relays are simply the wrong ones.

    • @elvinhaak
      @elvinhaak 3 года назад +1

      @@pileofstuff Were they ment to be switching something on 12 V like in a car? Easy to hook up 12 Volt from that for the relais and have the other end of the coil be switched by fet or transistor or even optocoupler but a bit hash to directly link to a GPIO-output

    • @pileofstuff
      @pileofstuff  3 года назад

      @@elvinhaak The problem, as I see it, is there is no way to get 12 volts onto the board.

  • @Chris_the_Muso
    @Chris_the_Muso 3 года назад +2

    14:20 "Hey, it's uploading". I actually got a laugh out of this. Nothing ever works for me first time even if I do follow the instructions (or think I have). It always seems to take some phutzing around and alignment of the planets before I work out what the secret sauce is.

    • @edgarcastiel321
      @edgarcastiel321 3 года назад

      i realize I'm kinda randomly asking but does anybody know a good website to watch newly released tv shows online ?

    • @brentleyzayden7428
      @brentleyzayden7428 3 года назад

      @Edgar Castiel I watch on FlixZone. You can find it on google =)

  • @edwardfletcher7790
    @edwardfletcher7790 3 года назад +1

    The Tasmota FW is one of the best options for these units.

    • @pileofstuff
      @pileofstuff  3 года назад +1

      I mostly did this for the challenge and the learning.

    • @edwardfletcher7790
      @edwardfletcher7790 3 года назад +1

      @@pileofstuff I figured as much, just wanted to give you something to add easy functionality if you decide to extend your Home Assist. network...

  • @anthonycalia1317
    @anthonycalia1317 3 года назад +3

    Flash it with Tasmota and you get everything you want and lots more

    • @pileofstuff
      @pileofstuff  3 года назад +2

      That is an option.
      I feel that I learned more doing it this way, though.

  • @camolas71
    @camolas71 3 года назад +1

    Hi, a relay connected to pi gpio can do the same. There are a script to do it on octopy

    • @pileofstuff
      @pileofstuff  3 года назад

      It can turn everything off, but it can't turn the Pi itself on remotely.

  • @tengelgeer
    @tengelgeer 3 года назад +1

    Note: If you select the D1 Mini as a board you can just use Dx directly in code like "byte relayPin = D5" So no need to add that conversion in the comments. And you can just use the button on the Basic to do the toggle. That's what the stock firmware does as well. And an ESP does come with internal pull up's on most of it's pins just like a basic Arduino ;)
    Also, Tasmota i still VERY usable without Home Assistant. I would certainly check it out because you could have done all this with Tasmota as well without a line of code ;)

    • @pileofstuff
      @pileofstuff  3 года назад

      I though about using the built-in button, but I didn't feel like messing with extending it outside the case.
      Some days I have an odd mix of laziness and doing pointlessly hard things...

  • @matambale
    @matambale 3 года назад +1

    Did you just say "Snot-soldered" @17:42? Every time I tack-solder something, henceforth it shall be called "snot-soldered".

  • @fredflintstone1
    @fredflintstone1 3 года назад +1

    A nice video and fun to watch tell the truth did teenager help a tad with the code:-)

    • @pileofstuff
      @pileofstuff  3 года назад +1

      It was the other teenager.

  • @HazeAnderson
    @HazeAnderson 3 года назад +2

    If you clean up too much you find yourself changing channel name to neaterpilesofstuff 😏

  • @ste76539
    @ste76539 3 года назад +1

    All very good, but you do know you could have done the same thing with just one of those relays and one GPIO pin on your Raspberry Pi? There's an Octoprint plugin that adds a power button on the Octoprint web server, took me about ten minutes to set everything up and cost virtually nothing to implement. K.I.S.S.

    • @pileofstuff
      @pileofstuff  3 года назад

      I thought about that, but i couldnt figure out how to use the Pi's GPIO to remotely turn the PI on.

    • @ste76539
      @ste76539 3 года назад +1

      You leave it on. Just log into Octoprint, upload a file, pre-heat and print, when it's done, you just turn off the printer again (there's probably a plugin that will do this automagically by now, but I prefer to do it manually), job done. Mine's been on non stop for nearly two years without any issues. Costs virtually nothing to run.

    • @pileofstuff
      @pileofstuff  3 года назад

      @@ste76539 That's an option, but where mine is it gets unplugged by other people sometimes, so I prefer to shut it down properly when I'm not using it.

  • @jw200
    @jw200 Год назад

    I dont see point in these things.
    I thought sonoff can be controlled thru any internet. My home is in city A and i want to control my light from city B. It means I cant do that?
    It only works in local server. That sucks

  • @frankowalker4662
    @frankowalker4662 3 года назад +1

    Nice. But I prefer a switch I can just turn on and off without relying on a computer or WIFI conection..

    • @pileofstuff
      @pileofstuff  3 года назад +1

      I'm trying to reduce the number of times I have to run up and down the stairs.
      My knees arent getting any younger...

    • @johncoops6897
      @johncoops6897 3 года назад +1

      @@pileofstuff - Well, most people just switch things on when they go upstairs, and switch them off before they come down!