Program Slampher Smart Light Socket (with ESP8285, Not ESP8266)
I tested my following instructions at least twice. They may help with re-programming other devices with ESP8285 processors.
Caution: Previous techniques for programming this device with new firmware are still relevant, but may need adjustment because of circuit board changes. This thread documents programming a www.itead.cc Slampher Smart Light Socket whose board is labelled V2.0, 2017-4-14 (shown below). I encourage you to see jimkernsjr's info-filled documentation of programming Sonoff Singles upon which this thread builds.
Important notes: For me, old-fashioned incandescent bulbs worked in the Slampher, but not inexpensive CFL or LED bulbs. Also to work, the Slampher must be powered by a powered bulb socket. (As below, the Slampher's socket can be programmed to be on shortly after power up. This allows the Slamphered bulb to come on with the wall switch. Then IF the socket is still powered, the OpenHAB User Interface or programming can toggle the Slamphered bulb off or on.)
See the following pic with dimensions to consider if a Slampher will fit in a bulb socket. For example, Slamphers may not fit in a lamp socket that has a "harp." I was not able to purchase Slamphers in the U.S., just from China.
Change seems to be the "constant" with smart devices like the Slampher. So far & very appreciated, (unlike other manufacturers) all Itead devices I've used have some programming header holes (including for the Slampher as pictured below) & use some processor in the ESP82xx family.
How the Slampher circuit board V2.0, 2017-4-14 differs from previous pics & docs like here & here: 1) The board pictured in this thread uses an ESP8285 processor which has 32 pins vs ESP8266's 40 & has onboard rather than seperate 1MB memory. With a some changes (below), we can still use the updated Arduino IDE as before. 2) ESP8285's GPIO0 pin (needed to enter into programming mode) is connected to R9's left solder pad (see middle right of pic), not near a previously located R20. We can use tinkerman's approach at the new GPIO0 connection.
The following documents re-programming new firmware on the V2.0 circuit board & how one might use the resulting node.
Expose the Slampher's circuit board: Remove the Slampher case's two screws, cut the flimsy seal, & open the case at the seams. BTW I found the case screws stiff to remove & reinstall so stripping the heads was easy to do. Before reassembling the case, you might enlarge the screw holes with a 7/64 inch drill bit.
These (besides a Slampher) are needed: an FTDI programmer with USB cable which must be able to function in 3.3 volts (much more can damage the Slampher's processor). I use this one. jimkernsjr uses this one.
Short dupont cables (4 colors including redish & black or brown), male on one end for the Slampher programming holes & on the other end male or female to connect to FTDI sockets. One more wire, bare on one end & on the other end a way to connect to FTDI GND (I used an alligator clip.)
Also needed: a computer running the Arduino IDE. Adapted from what jimkernsjr said here,
Install support for the ESP8266-related boards. Follow instructions here ... but stop at the heading "Selecting the ESP8266 Thing Board", you don't need to go any further
After installing support for ESP8266-related boards ... make the proper settings in the Arduino IDE environment. Open Arduino IDE (at least version 1.6.8). -In Tools menu, under boards, scroll down to the ESP8266 boards section, and select "Generic ESP8285 Board", NOT ESP8266. This will give you all options! -Don't touch ... CPU frequency, leave at default. ... -Select 1M(128K SPIFFS) from the flash size.
Cautions: Make sure the FTDI programmer is in 3.3 volt mode. NEVER EVER connect your FTDI programmer while the Slampher is in a powered bulb socket!!!
Using the dupont cables, create a DIY 4-wire cable ready to create the following connections (& like the pics below):
In order, starting at "square" hole, Slampher holes on stripto be connected to FTDI's 3v3 (VCC) ........................................VCC Rx .................................................. Tx Tx ..................................................Rx GND .................................................. GND separate from 4-wire cable: R9's left solder pad (for GPIO0) FTDI's GND (only at power up)
(Not shown in the pics: the bare-ended wire to GND GPIO0) In the pics, see how I used color-coded male to male dupont cables (VCC is red, GND is black, etc). I taped together the Slampher header cable ends in the needed order. right: FTDI programmer left: cable ends for Slampher programming header
Connecting the Programming Cable to the Slampher Circuit Board & Programming the Slampher with ANY New Firmware
There's too little room on the circuit board's bottom (what's shown in the pic) to solder breakaway female header sockets & still close the case. It looks like you could solder them on the board's opposite side. (See this post about using breakaways.) However ...
Though awkward, you could avoid soldering with a method like jimkernsjr used:
(Again, the Slampher is NOT in a powered socket & FTDI is in 3.3 volt mode.)
Have the new firmware programming opened in Arduino IDE. (This could be any new firmware. Below, I'll provide the firmware we use on this forum). << 4 cable pins in circuit board programming holes ("4 O'Clock" on the board) Alligator clip (tape insulation prevents touching next pin) on the pin through the GND hole, black wire on alligator clip has another bare end ready to touch R9's left solder pad as explained below.
Have the circuit board's bottom (as in the pic) facing up. Insert your cable's pins from the opposite side. With one hand, steadily push the board's top toward a table beneath to "lean" the pins in their holes. << WHILE doing this, plug the FTDI programmer's USB cable into the computer with your other hand. In the Arduino IDE tools/port menu, select the (Com) port your FTDI programmer uses when connected to USB. Put the cursor over the IDE's upload button. Then UN-plug the FTDI programmer from the computer's USB.
The next step starts like the last step, but goes further: Now again with one hand, steadily push the top of the board toward a table beneath to "lean" the pins in their holes AND at the same time, press the bare-ended wire to ONLY the LEFT solder pad of R9. << WHILE doing this, plug the FTDI programmer's USB cable into the computer with your other hand. If successful, this will GND GPIO0 & the LED will NOT (faintly) flash & the device will be in programming mode. Maintain steady pressure on the board to keep programming pins connected, but you can remove the wire from R9. While maintaining pressure, start the Arduino IDE compiling & uploading the sketch. Repeat this process until uploading is successful.
Reassembling the Slampher & Putting It into Operation Over the Air Programming
Once uploading is successful, reassemble the case. Again I found the case screws stiff to remove & reinstall so stripping the heads was easy to do. Before reassembling the case, you might drill out the case's screw holes with a 7/64 inch bit. Via my local network router's settings, I give my Slamphers permanent IP addresses. That might make them more likely to reconnect automatically after a power outage.
When the re-programmed & reassembled Slampher is in a powered light bulb socket, you can now use its Over the Air programming ability.
To reprogram this Slampher "Over the Air" (via the WiFi connection), the light socket holding the Slampher must be powered. Also for the following to work, you'll likely need to close & reopen the Arduino IDE. In the IDE's tools/port menu, see & select this node's OTA name. Make your desired changes in the firmware programming for this node. Upload the changed package.
I renamed jimkernsjr's ESP_SonoffAndEcoPlug.ino to ESP82xx_Devices.ino & added an UNcommented, active include (SlamphrMstrBth33.h) for a Slampher device customization. In SlamphrMstrBth33.h, I set node 33, OnAtPowerup, etc. EnToggle is left UNdefined since a Slampher probably is not a motion light. See jimkernsjr's thread for more about the options & also more GitHub files for other devices.
So far, for the Sonoff type devices, Itead seems to use the same GPIOs for button (0), relay (12), & LED (13). Thus the Slampher uses the same pins as Sonoff Singles.
BTW for a helpful database of smart devices & their GPIO pins for button, relay, & LED, see here AND here.
Programming the Slampher with This Forum's Firmware, Continued
Open ESP82xx_Devices.ino (downloaded above) with Arduino IDE. SlamphrMstrBth33.h should also open in another tab. Customize SlamphrMstrBth33.h with your WiFI SSID, WiFi password, & IP of the computer running your MQTT server. Follow this post's instructions to upload this firmware to the Slampher.
After the upload finishes successfully, momentarily release the pressure on the board & dupont pins in the programming strip (depower the board). Then reapply pressure (power the board). The LED should flash once & then stay on steady indicating the Slampher has connected to your local WiFi network & MQTT. You should not need to program the Slampher this way any more. You can now remove the FTDI programmer & dupont cable connections & reassemble the Slampher in its case.
Again I found the case screws stiff to remove & reinstall so stripping the heads was easy to do. Before reassembling the case, you might drill out the case's screw holes with a 7/64 inch bit. Via my local network router's settings, I give my Slamphers permanent IP addresses. That might make them more likely to reconnect automatically after a power outage.
To reprogram this Slampher "Over the Air" (via the WiFi connection), the light socket holding the Slampher must be powered. Also for the following to work, you'll likely need to close & reopen the Arduino IDE. In the IDE's tools/port menu, see & select this node's OTA name (SlamphrMstrBth33). Make your desired changes in the header file for this node (SlamphrMstrBth33.h). Upload the changed package.
To reprogram firmware on other Slamphers, use an editor like Notepad++ to copy, customize (node ID, etc), & rename the SlamphrMstrBth33.h file accordingly. Edit ESP82xx_Devices.ino: Comment out (//) #include "SlamphrMstrBth33.h" AND add a new UNcommented include line for the next Slampher's .h header file. Repeat the steps above for flashing the firmware on the next Slampher.
.rules file rule "Random timer for Output ON around 8:16pm" // Master Bathroom Activity on (Node33) when Time cron "0 11 20 * * ?" then // Schedule a random ON event up to 15 minutes from now createTimer(now.plusMinutes((new java.util.Random).nextInt(15)) ) [| sendCommand(Act_Node61, ON) ] end
rule "Random timer for Output OFF around 8:32pm" // Master Bathroom Activity done (Node33) when Time cron "0 27 20 * * ?" then // Schedule a random OFF event up to 15 minutes from now createTimer(now.plusMinutes((new java.util.Random).nextInt(15)) ) [| sendCommand(Act_Node61, OFF) ] end
papa, this is a great tutorial and I am happy you share all this information with us. I am using arendst firmware because I can connect this to FHEM, a perl server. I am having a problem getting the Slampher into programming mode. I am using a "standard" USB-TTL, I have connected Vcc to 3.3V and Rx-Tx as well as Tx-Rx. Of course, grounding the left pin of R9 is a bit tricky but doable. But if I connect R9 to GND, the LED flashes very short red and then continuously green.
Since this is the same if I do not ground R9 I suspect the Slampher is not going into programming mode. Do you have any idea why or how? I have uploaded two pictures:
Last Edit: Sept 9, 2017 19:22:40 GMT by andies: pictures added
ESP8285's GPIO0 pin (needed to enter into programming mode) is connected to R9's left solder pad (see middle right of pic), not near a previously located R20
but if I look at the documents provided by itead (Slampher-View.pdf) then at least on part of R20 is still connected to E-FW which is itself connected to GPIO0. So why cannot we use still R20? It is not that cumbersome.
andies, welcome, to this DIY Home Automation forum. Thanks for the appreciation.
You wrote: "I suspect the Slampher is not going into programming mode. Do you have any idea why or how?"
papa: BEFORE you connect the USB-TTL to the computer, do you touch the LEFT solder pad of R9 with a wire connected to GND? (You can release the R9 wire afterwards) Maybe you are doing this, but I cannot tell from what you wrote.
Some USB-TTL devices do not supply enough current consistently so that the processor resets rather than enter programming mode. Possible ways to address this: 1) In addition to connecting USB-TTL, connect a large capacitor (greater than 219 microFarads, match the polarity) between Slampher vcc & GND (this can help smooth power supply) OR 2) Instead of USB-TTL VCC / GND connecting to Slampher, connect a separate 3.3 volt power supply OR 3) Use a more robust 3.3 volt USB-TTL.
You wrote: "if I look at the documents provided by itead (Slampher-View.pdf) then at least on part of R20 is still connected to E-FW which is itself connected to GPIO0. So why cannot we use still R20?"
papa: I'm not sure that schematic in Slampher-View.pdf is current, at least with the Slampher model I have. The schematic has the ESP8266 chip. My version (V2.0, 2017-4-14) has ESP8285 (at U3) which does not need a separate memory chip. If your Slampher board is an older version & has the ESP8266 chip, perhaps touching a GND wire near R20 is needed for programming mode. I cannot tell for certain from your pictures, but it looks like you have the same board as mine. If R9's left pad is connected to GPI00 (as on my board), its closeness to the processor make it the best choice, I believe.
I try to flash it exactly as you said: before powering the Slampher I connect R9 to GND. So it must be the power supply, I have already read about this in different forums. Do you think that an arduino provides a more stable supply?
Regarding the circuit diagram: I realized that it is the old version, not v2.0 from 2017-14-04. I will ask itead whether they provide a newer one in their wiki.
I am now sure that it is a power issue. I did the following. Power (3.3V) was provided by an arduino, so I connected 3.3V <-> VCC(Slampher) and GND <-> GND(Slampher). I then used another USB-TTL where I crossed Rx-Tx and this USB-TTL was connected to the arduino IDE to flash the Slampher. I was able to get into flashing mode (a little tricky but doable), so the LED was not blinking.
Der Sketch verwendet 486608 Bytes (54%) des Programmspeicherplatzes. Das Maximum sind 892912 Bytes. Globale Variablen verwenden 43228 Bytes (52%) des dynamischen Speichers, 38692 Bytes für lokale Variablen verbleiben. Das Maximum sind 81920 Bytes. /Users/andies/Library/Arduino15/packages/esp8266/tools/esptool/0.4.9/esptool -vv -cd ck -cb 115200 -cp /dev/cu.SLAB_USBtoUART -ca 0x00000 -cf /var/folders/l6/myrckv8d12z9_06fl49fm36h0000gn/T/arduino_build_691636/sonoff.ino.bin esptool v0.4.9 - (c) 2014 Ch. Klippel <email@example.com> setting board to ck setting baudrate from 115200 to 115200 setting port from /dev/tty.usbserial to /dev/cu.SLAB_USBtoUART setting address from 0x00000000 to 0x00000000 espcomm_upload_file espcomm_upload_mem opening port /dev/cu.SLAB_USBtoUART at 115200 tcgetattr tcsetattr serial open opening bootloader resetting board trying to connect espcomm_send_command: sending command header espcomm_send_command: sending command payload espcomm_send_command: receiving 8228 bytes of data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data trying to connect espcomm_send_command: sending command header espcomm_send_command: sending command payload serialport_receive_C0: F8 instead of C0 trying to connect espcomm_send_command: sending command header espcomm_send_command: sending command payload serialport_receive_C0: E0 instead of C0 resetting board
Then I thought it maybe an issue because GND from the arduino as well as from the USB-TTL have no connection. So I connected both and run the same procedure. I got
... opening port /dev/cu.SLAB_USBtoUART at 115200 tcgetattr tcsetattr serial open opening bootloader resetting board trying to connect espcomm_send_command: sending command header espcomm_send_command: sending command payload serialport_receive_C0: 00 instead of C0 trying to connect espcomm_send_command: sending command header espcomm_send_command: sending command payload serialport_receive_C0: 00 instead of C0 trying to connect espcomm_send_command: sending command header espcomm_send_command: sending command payload serialport_receive_C0: 00 instead of C0 I cannot use the arduino directly because RxTx provide 5V (just measured using a voltmeter), it would fry my Slampher. I hope you have an idea.
The trick with left pad of R9 did it. My problem was the power supply, so anyone who reads this please check your power supply. The FTDI/USB-TTL power supply was not enough and gave me strange error messages. I had to use an Arduino to get constant and reliable 3.3V.
Since I wanted to program it with the USB-TTL, I connected everything as follows
FTDI Arduino USB-TTL(->Arduino IDE)Slampher ------------------------------------------------------------------------ 3.3V (not 5V) ................. not connected ........................... Vcc GND ............................... GND ...................................... GND not connected ................... Tx ......................................... Rx not connected ................... Rx ......................................... Tx
Flashing only worked for me after everything was connected at the beginning. If the R9-trick does not work immediately, start everything all over again - disconnect Vcc, connect Vcc again while R9 is connected to GND. If the LED does not flash you were successful, R9 can now be left alone and you can concentrate on USB-TTL/Arduino. I used an Arduino Nano, btw.
papa: Thanks for reporting back, andies. What you wrote confirms my experience & you've clearly described how to deal with the possibility of the Slampher board resetting (& not going into programming mode) because of not having enough electrical current supplied. You also made clear the need for Arduino, USB-TTL, & Slampher to share a common GND. You've made a helpful contribution to the forum.
U are awesome! You have made it very easy to use the Slampher with MQTT and therefore any generic home automation system.
This tutorial worked flawlessly. Thank you for that!
papa: Thanks, Varuna. Your feedback helps this volunteer know that my efforts are beneficial to others & that encourages me to keep going. Your letting us know that this thread worked for you will help others have confidence to try it.
Enjoy your home automation & remember: When you learn something (small or large, what works, what does not work), give back to the forum so that it can be the best possible resource.