Project - Sonoff B1 Lamp

The Sonoff B1 Lamp has 5 separate LED channels:
  Red ,  Green Blue Cold White  Warm White .

 It is E27, rated 6W, 90 - 250v AC, 2A

The lamp uses an ESP8285 with 1Mb flash memory.

IMPORTANT - DO NOT connect to MAINS while disassembled.

To flash with Annex requires removing the white translucent top cover to reveal pads for connecting a serial UART (click pic to zoom in) .

The cover is a tight fit, and with a touch of superglue, so needs a firm grip and a bit of persistent persuasion to start moving, but it is doable.

Note: The cover simply unscrewed on a later B1 R2 (revision 2)
The outer contact pads are in the same order, but their positioning and spacing differs slightly. Both have a second GND pad near the centre
From left to right (see pics) the pads are  VCC, RX, TX, GND, GPIO0 

I soldered wires directly to the pads.
I also soldered a wire to a GND pad near the central antenna for conveniently connecting GPIO0 to ground to manually start up the device into programming mode.

Best to keep the original device parameters by grounding GPIO0 to put the device into flashing mode then using the blue button to read the device details first, before rebooting again into flashing mode to use the green button with original device parameters.

Remove GPIO0 from GND before flashing to prevent the device restarting into programming mode again after successful completion.
Remember to allow sufficient time for the firmware to format SPIFFS afterwards, then eventually the new wifi SSID should appear...   

Once the lamp is flashed and displaying its new wifi SSID to connect to, the cables can be removed and the lamp cover replaced, because subsequent updates can be done using OTA (save files before doing 1Mb OTA updates because existing SPIFFs contents will be wiped).

When screwing the re-assembled lamp into a lamp-holder, be careful not to over-tighten else it can break the thin metal surrounding the lower centre contact (I had to repair mine using epoxy resin).

Using the Sonoff Lamp is a simple matter of initialising it with "SonoffB1.init" then sending a value from 0 (off) to 255 (full brightness) to the channel(s) you wish to turn on, which will retain their values until changed again,or the device is rebooted.
The SonoffB1.white cold, warm  instruction needs the values for both cold and warm whites even if only one of them is to be changed.
Similarly the SonoffB1.RGB  Red, Green, Blue  instruction needs to be sent all three values even if only one is to be changed.
A simple way to update only some channels without affecting others is to assign them all variables which all get sent together but only any changed variables will cause their channels to change. Similarly another set of variables could be used for holding previous values if wished.
As well as sending 3 individual R,G,B values they can be combined into a single 24bit number, eg:SonoffB1.RGB 255 (gives full blue), SonoffB1.RGB &h00ff00 (gives full green), SonoffB1.RGB 16711680 (gives full red, equivalent to &hFF0000)

White  =  rgb(255, 255, 255)  =  &hFFFFFF  = 16777215

Some projects follow which offer...

Simple UDP control using the RGB sliders from the Toolkit UDP Console
Browser RGB sliders
AutoSave settings for next startup
SoftStart facility
Dim Up, Dim Down
Master slider for pre-selected LEDs
Rotary Dimmer
EasyNet remote control