Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

It's been a few weeks since my Sonoff B1 WiFi LED bulb has arrived. I've had an idea to set it up as a rear wall illumination around my TV to enhance the gaming/movie experience by having the bulb match its colour to the most prominent colour on the screen. I'm a step closer to realising this idea now. In this post I'll show how this bulb can be hacked to run custom firmware which allows it to be controlled via HTTP.

I've written a previous article that explains how to open this bulb to access its circuitry, have a read of that first before continuing.

After everything was connected, the setup with an RS232 FTDI device looked something like this (minus the GPIO/GND wires for setting programming mode)...
DSC02838.JPG


However the first step that needed to be done was to set up the software. I did all of this on a Mac so if you're following along and aren't using a Mac, some directories will be different. I installed the Arduino IDE 1.8.5 first.
sonoffb1hack_1.png


After installing the IDE, in its Preferences I added http://arduino.esp8266.com/stable/package_esp8266com_index.json to the Additional Board Manager URLs setting.
sonoffb1hack_2.png


Then I clicked the Tools > Board > Board Manager... menu item.
sonoffb1hack_3.png




From the Board Manager, I found the esp8266 module and installed it.
sonoffb1hack_4.png


After installing that module, I downloaded a clone of the arendst/Sonoff-Tasmota git repository and copied all of the directories from the Sonoff-Tasmota-development/lib directory to ~/Documents/Arduino (this location will be different if you're on Windows).
sonoffb1hack_6.png


The IDE was more or less setup now but needed to be restarted first. After restarting I openined the Sonoff-Tasmota-development/sonoff/sonoff.ino file.
The Sonoff B1 bulb is an ESP8285 device, so that's what I selected from the Tools > Boards menu.
sonoffb1hack_5.png


Next it was time to make some modifications to the B1 PCB. I soldered a header to some wires and then to the 3.3V, RX, TX and GND pads on the B1 PCB.

DSC02834.JPG DSC02837.JPG



Then, I added an additional two connectors to the GPIO and the centre GND pads on the B1 PCB. These were used for setting the B1 into programming mode and I needed to be able to be connect/disconnect these. I used a male connector on one end and a female connector on the other.

DSC02840.JPG DSC02841.JPG


Back to the Arduino IDE, I opened the user_config.h file and modified the following defines (change as required)...
 user_config.h
#define WIFI_IP_ADDRESS "192.168.1.200"
#define WIFI_GATEWAY "192.168.1.1"
#define WIFI_SUBNETMASK "255.255.255.0"
#define WIFI_DNS "192.168.1.2"
#define STA_SSID1 "MyWiFiNetwork"
#define STA_PASS1 "wifi_password"
#define MQTT_USE 0


With my WiFi and IP settings in place it was time to connect everything and upload the new firmware. The RX pin on the FTDI was connected to the TX pin on the B1 and TX on FTDI to RX on the B1. The GND pins were connected together and the 3.3v B1 pin was connected to VCC on the FTDI. The FTDI was set to 3.3v of course.

Before connecting the FTDI to the computer, the blue wires (GPIO and GND) on the B1 were connected together. Then, after connecting the FTDI to the computer and waiting a few seconds, the blue wires on the B1 were disconnected. This put the B1 into programming mode as mentioned earlier.

In the Arduine IDE Tools menu, I had to make a couple of extra changes. The Flash Size was changed to 1M (64K SPIFFS). The Port was set to /dev/cu.usbserioal-00000000 (this could be different depending on your FTDI and OS).

DSC02839.JPG DSC02843.JPG


Finally it was time to upload the firmware! This was done by clicking Sketch > Upload. A couple of minutes later the firmware was compiled and uploaded to the B1.
sonoffb1hack_7.png



I disconnected the FTDI from my computer, disconnected the B1 from the FTDI and plugged the B1 into my mains light bulb socket and then switched it on.

The web UI was available pretty much immediately from the IP address I set up in user_config.h, in my case it was http://192.168.1.200/. First thing to do here was to tell the Tasmota firmware that it was controlling the B1 module. That was done from Configuration > Configure Module.

sonoffb1hack_8.png sonoffb1hack_9.png


I set the module type to 26 Sonoff B1 and saved. After getting back to the main screen I could toggle the B1 on/off. Success! I went over to the Console and played around with some colour setting commands, it was working as expected too.

sonoffb1hack_10.png sonoffb1hack_12.png


I was able to change the colour of the RGB LEDs as well as control the blue/warm settings for the while LEDs.

DSC02844.JPG DSC02845.JPG DSC02846.JPG


That's it for this part of the project. I'm going to put together a Java app to allow me to control the B1 further and in a way that responds to the colours on my screen. Should be cool once it's done. Stay tuned!

-i

Please leave your comments or feedback below!
comments powered by Disqus
Other posts you may like...
Hi! You can search my blog here ⤵
Or browse the recent top tags...

Recent Blog Posts

How to stop macOS adding shadows to window screenshots

How to run Atari Lynx games on the SNES Classic Mini

Maven dependency scopes with relation to WAR file packaging and the WEB-INF/lib directory

Hacking the Sonoff B1 WiFi LED bulb to run custom firmware

What does an idle WebLogic server run on the hour to cause a CPU spike

How to open the Sonoff B1 wifi LED bulb to access its internal circuitry

Australian release SNES mini classic unboxing and a quick play through

Troubleshooting high CPU usage for JVM threads

How to fix WebLogic high CPU usage due to a corrupted file store

Mini review of the Sonoff B1 WiFi light bulb

Recent Galleries

Atari Lynx repair - Part 5 - McWill LED screen mod installation

Atari Lynx repair - Part 4 - screen cover replacement

Atari Lynx repair - Part 2 - re-capping the motherboard

Atari Lynx repair - Part 3 - broken speaker replacement

Atari Lynx repair - Part 1 - introduction and case disassembly

Building a custom Atari Lynx game box storage shelf unit in a day

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

Monument Valley 2 is released and does not disappoint

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity