Sonoff B1

115 views
Skip to first unread message

Andreas Klein

unread,
Sep 7, 2019, 5:46:52 PM9/7/19
to MppDevices
Hey Mike!

I got my Sonoff B1 and first time, I was forced to solder... which I am a novice, to be honest.

Nevertheless, I got MppColor flashed onto one B1. I was a little fast after flashing and removed the cables to notice that the B1 does not come up with its AP and does not appear in the network.

Resoldering... :(

But with that, I got MppArduione recognize the bulb.

2019.09.07 17:43:50.731 {"ButtonPin":"0","LedPin":null,"Initial":null,"RedPin":"12","BluePin":"13","GreenPin":"14","WifiPin":"2","WifiActive":null,"NoMulticast":null,"StaticIp":null,"ip":null,"gw":null,"nm":null,"Password":null,"OUTPUTIP":null,"Version":"MppArduino 1.5.0","MppVersion":"MppColor 1.0.0","uid":"dc4f22dd00d7"}

It's now in the IoT wifi, anything special on the config?

Mike P 4 MPP

unread,
Sep 8, 2019, 10:14:57 AM9/8/19
to MppDevices

That looks good, as long as the pins are correct and they work with PWM you should be all set.  You can set the wifi using MppArduino, but I’m a bit puzzled why it didn’t come up in AP mode anyway – you should be able to spot any problems/errors in the MppArduino log too.

Andreas Klein

unread,
Sep 8, 2019, 10:20:41 AM9/8/19
to MppDevices
Yet, it doesn't react on any changes on AM.

And I found this

LED HEX10 Color Codes

The Sonoff B1 uses a TEN charter HEX code for all colors. Colors tested with firmware 5.9.1 20171107:

  • 00000000A0 = WARM
  • 000000A000 = COOL
  • 0000A00000 = BLUE
  • FF14500000 = PURPLE
  • 551A8B0000 = DARK PURPLE
  • A300000000 = RED
  • 00ff000000 = GREEN

I have the B1 R2 (different led layout)



Andreas Klein

unread,
Sep 8, 2019, 10:21:44 AM9/8/19
to MppDevices
Btw. as the B1 has no button, the original firmware uses a triple "on-off" to put the bulb into pairing mode... perhaps that would make sense for MppColor, too...

Mike P 4 MPP

unread,
Sep 8, 2019, 10:35:45 AM9/8/19
to MppDevices
I'm not sure what they mean about the hex settings, but it makes me suspect that the bulb isn't using PWM.  If you don't mind having a look at the Tasmota code to see if you can find where the convert the incoming values to the hardware we can see about getting an MPP device to do the same.

I haven't been able to figure out how to measure the "off" period for an on/off based reset...  if I ever do I can probably add it to the base.

Andreas Klein

unread,
Sep 8, 2019, 10:57:16 AM9/8/19
to MppDevices
How about the opposite... measure the last on time... if it's shorter than 1 sec, increase a counter... if the counter is 3, go to AP mode.

So... you have an internal value.. at boot, you increase it by 1, after 2 secs, you set it to 0.

If the bulb is powered off (hard) within 2 secs, the increase remains... if this happens three times in a row, the counter goes to 3 and you switch to AP mode and set the counter back to zero (so another power cycle resumes normal ops).

It should not hit NVRAM too hard because it only affects a real hard power cycle and not soft switching the light keeping the module powered.

Andreas Klein

unread,
Sep 8, 2019, 11:05:53 AM9/8/19
to MppDevices
The B1 has 3 color leds and additional 12 white leds (6 cool white, 6 warm white).

That needs to be set accordingly, so you can control warm white on/off/brightness, cool white on/off/brightness and RGB on/off/brightness.


Andreas Klein

unread,
Sep 8, 2019, 11:14:57 AM9/8/19
to MppDevices
Regarding the code... any clue... I never digged into the programming of these devices, I pulled the current dev code but where to look there?

Andreas Klein

unread,
Sep 8, 2019, 11:16:41 AM9/8/19
to MppDevices
Right now, the bulb doesn't react at all, on/off, color/brightness/... change... the bulb stays dark.

Mike P 4 MPP

unread,
Sep 8, 2019, 11:32:12 AM9/8/19
to MppDevices
It'll be a while before I can dig into this myself, but if you want to take a look this it what'll be needed:
  1. Start with a new file name, like MppSonoffB1.ino or something like that
  2. Is this a color bulb (full RGB) or only color temperature?  If it's RGB then copy MppColor, if it's color temperature then copy MppPWM
  3. Figure out how to translate either RGB or degrees K into the correct output settings, and then set them into the sonoff like in MppColor.  You might want to skip the transitioning part for now and we can add that later.
  4. AM should recognize the device when it comes up - for color it'll see a color bulb, for MppPWM it'll be an MppLevel you can set the value from the AM UI, and the min/max limits (degrees K) in the file.  Later we may change it to something other than MppLevel but it'll be pretty similar.
  5. Add back in transitions, but MppLevel doesn't support transitions over time right now. 

Andreas Klein

unread,
Sep 8, 2019, 11:36:43 AM9/8/19
to MppDevices
Perhaps it needs to be splitted into three "virtual" bulbs... one for the cool leds, one for the warm leds and one for the RGB leds.

See here for the board and it's features, the B1 R2 has a slightly different layout addressing shadow issues mentioned there.



The Sonoff B1 uses another My-Semi driver, the MY9231 [datasheet, PDF]. The MY9291 is a 4 channels LED driver but the MY9231 is just 3 channels… so how is it possible to do RGB plus white and warm? Well actually these ICs are daisy chainable, so there are two MY9231 controllers in the Sonoff B1, the first one controlling the white power LEDs and the second the 5050 RGB LEDs.

Mike P 4 MPP

unread,
Sep 8, 2019, 11:39:16 AM9/8/19
to MppDevices
I like that, seems the right track.  It's probably what they all do, the "off" time isn't tracked at all.  I was thrown by the "turn off for 3 seconds" they have and couldn't figure out how to time that.  But it's probably picked just long enough for the device to discharge power and turn completely off, and only the "on" time matters - long enough to turn on, and short enough not to clear the counter.  Should be pretty easy.

Mike P 4 MPP

unread,
Sep 8, 2019, 11:41:35 AM9/8/19
to MppDevices
3 would work if they're independent in hardware - easy to add those other devices after.  Maybe for now just pick the RGB and do an version of MppColor as a prototype.

Andreas Klein

unread,
Sep 8, 2019, 11:43:34 AM9/8/19
to MppDevices
That could help as fall back for all devices... and solve the error I ran into with the wrong button assignment.

You could add a flag which is reset at the end of boot so you notice a repeated crash and can (at least temporary) revert to default settings.

Andreas Klein

unread,
Sep 8, 2019, 11:46:37 AM9/8/19
to MppDevices
Could also be 2, refering to the 2 controllers, one virt white led bulb with color temp control and one RGB led bulb

Andreas Klein

unread,
Sep 8, 2019, 11:47:32 AM9/8/19
to MppDevices
Do I need the dev environment for that? Yet, I have nothing of that installed...

Mike P 4 MPP

unread,
Sep 8, 2019, 12:23:09 PM9/8/19
to MppDevices
Yeah, that would be good - I think it'd work that way anyway, I'd set the value and check it before anything else was enabled so if the device crashed N times it'd go into recovery mode and not try to do anything else except clear recover mode for the next boot.  I can think of a few "gotcha's" for me on this but it is promising.

Mike P 4 MPP

unread,
Sep 8, 2019, 12:23:57 PM9/8/19
to MppDevices
Yep, you'll need the Arduino IDE or the Eclipse one - instructions for both are on my site, probably the Arduino is easier to setup but I prefer the eclipse.

Andreas Klein

unread,
Sep 8, 2019, 2:30:18 PM9/8/19
to MppDevices
I'll have a look, but that will take some time... I'm busy the next weeks, too (moving from the US back to Europe)... so I put the 12 bulbs in a closet for the time being, as they can't replace my Hue system right now.

akxa...@gmail.com

unread,
Jun 10, 2021, 2:07:36 PM6/10/21
to MppDevices
Do you see any chance on progress here, I built an adapter for the B1 R2 so I can easily flash these.

Tasmota can easily control them, details are here


The template page shows the GPIO to use (12 + 14)

MikeP 4 MPP

unread,
Jun 11, 2021, 9:09:46 AM6/11/21
to MppDevices
It does look possible.
The chip is http://www.my-semi.com/content/products/product_mean.aspx?id=5, it's an MY9231 as we found out earlier.  They use a serial input for controlling, I've been fiddling a bit with these single wire devices lately (the DS18B20 and some DHT devices) so it should be doable.
There's a espurna implementation that could be a good base, source here: https://github.com/xoseperez/my92xx
I'm happy to give it a shot if you're willing to try it and ok with some trial and error...  Keep the adapter handy in case I mess up, most of the time we can update OTA but occasionally I mess up and the device won't boot so needs to be flashed manually.
Looks like the B1 is no longer available, and tasmota is showing the B02 and B05 replacements as unsupportable... https://templates.blakadder.com/unsupported.html

akxa...@gmail.com

unread,
Jun 12, 2021, 7:07:38 AM6/12/21
to MppDevices
The B1 is easy to open and the adapter is available (I have to flash my remaining ones anyway). So no issues for trial&error. easy to flash & easy to fix.

I am searching for another B1to complete my needs here, B2/B5 indeed not managable, guess they changed the chip. Ordered a B5 from Amazon and will return it.

MikeP 4 MPP

unread,
Jun 12, 2021, 4:57:56 PM6/12/21
to MppDevices
Ok, added MppSonoffB1.bin to https://sites.google.com/site/mppsuite1/wemomanager-betas, please give it a try when you get a chance and let me know what happens.
If I got it correct the colors should work, but I'm less sure about the warm/cold temperature settings as there's not much in the way of documentation.  I did see a warning on the tasmota pages that you should keep in mind - if I've turned on too many LEDs at once the bulb can get hot, if you notice it's abnormally bright or warm use a lower brightness or turn it off, and let me know the settings that caused it.

akxa...@gmail.com

unread,
Jun 13, 2021, 3:40:07 AM6/13/21
to MppDevices
Wow... works like a charm.

Only one set of led is active, the color temp on the white light is more a switch but works... if moved to warm, cold and color are off, if moved to cold, warm and color are off and if color is modified, white leds are off.

Color settings (RGB, saturation) work, brightness works for all.

Excellent, so I can instantly use the bulbs... flashed the first four and integrate them into my setup here later during the day.

I am getting closer to throw the Tuyas out.

Thanks!

akxa...@gmail.com

unread,
Jun 13, 2021, 8:25:58 AM6/13/21
to MppDevices
Update.... there is some work to go together with AM rules.

Using the control tool, everything works fine. As I said, I can switch between the three modes, adjust brightness in each and adjust the color and saturation in the RGB mode.

But using AM to lighten up in RGB mode setting the bulbs to a certain color and bring brightness from 10 to 100% over 5 minutes with:

PrepareBrightness: 10%
SetColor: 219° at 100%
SetDevice ON
SetLevel 10% then 100% over 5 minutes

the bulbs start to flicker after some time and then switch to white mode (cold or warm).

All subsequent commands are executed (for example using the control tool) but show wrong effects... like setting to RGB turns on warm white, if RGB, color cannot be changed any.

After toggling power on the bulbs, control tool works again.

Looks like some internal registers are overwritten by the 10-100% move.

MikeP 4 MPP

unread,
Jun 13, 2021, 11:29:37 AM6/13/21
to MppDevices
Better than I'd hoped :).
For the changes over time I think I was overwhelming the LED controller chip and it probably crashed.  I've posted 1.0.1 that should help sort that.
For the warm/cold setting - it seems like the controller is changing the warm and cold settings close to what we need.   Turning off the color LEDs in "white" mode is expected, and full warm should turn off cool and full cool should turn off warm.
Can you confirm whether, on full warm, the brightness works?  Same on full cool?
Next, try the middle between warm and cool, are both sets of warm/cool LEDs on?  Do the brightness controls do anything in that mode?

Thanks!

akxa...@gmail.com

unread,
Jun 14, 2021, 2:05:13 AM6/14/21
to MppDevices
Mike,
the update solved the crash.

Nevertheless, I configured the brightness change from 10 to 100% over 5 minutes and that happens significantly faster.

The white leds still switch binary, means either the cold or the warm leds are on. On the full left position, I see the cool leds, as soon as I move that a little bit, they're turned off and the warm ones are on.

Brightness works for all 3 (rgb, cold and warm white). But brightness is not applied when mode is changed.

Also, AM reports the bulbs as "on" after a restart (power off) although they're off.

MikeP 4 MPP

unread,
Jun 14, 2021, 9:08:38 AM6/14/21
to MppDevices
Ok, thanks, I should have got these sorted now, we're getting closer.  1.0.2 just posted on that same beta site.

akxa...@gmail.com

unread,
Jun 16, 2021, 12:12:45 AM6/16/21
to MppDevices
From a first glance, the "over time" worked better, as I am out during the week (working in another town) I check in detail next weekend.
Reply all
Reply to author
Forward
0 new messages