Today I have commited a scriptable I2C system prototype.
I2C system will be used to map I2C devices inputs and outputs to our internal OpenBK7231 channels.
Right now, I have added support for one device - TC74 temperature sensor:
Connection requirements are simple - solder wires to I2C1 port of WB3S:
Connect power, ground, SDA and SCL to I2C device.
Also connect 4.7k pull up resistors on the I2C bus.
You can use multiple I2C devices, as long as they have different addresses.
Here is my setup with two TC74 (A0 and A2 version, two different addresses):
I2C devices can be added to any BK device. I have used Tuya 4 channels relay controller for this example.
Relay controller was already configured:
I2C devices can be added only by commands. They will be most likely saved in LittleFS config file.
In order to setup TC74, you must reserve a channel that is not used for relays.
In this case, channels 5 and latter are not in use.
So, mark a channel as temperature:
Then register I2C TC74 which will save output to channel 5 (0x48 here is I2C device address, I2C1 is the name of hardware I2C bus to use):
Result:
Same, for second TC74:
Now, for a test, let's warm up one sensor with soldering iron:
Both sensors work.
Now, as you most likely already realize, having temperature values in MQTT automatically allows us to expose them to Home Assistant, just like with any other variables.
WARNING: This is experimental feature, if you're a beginner and not a developer, please wait few weeks before using it.
Now I really need to get that lightbulb with Beken and I2C RGBCW controller, do anyone know where I can buy one?
OTA also didn't work for me on N version, despite me changing the OTA partition address to correct one (partition addresses are different on N and on T).
I am not sure what else to change. Will have to look into it, but I have very few N devices (only 2?). You can also try asking @btsimonh . BK7231 OTA is using entirely Beken OTA system, it was already in place, we just activate it by saving firmware to the OTA section of flash memory.
Fix should only affect device when it gets disconnected from WiFi, so that's really strange. I will look into it.
Thanks, added to repo.
I am integrating your changes, but some of them are incorrect. Are you sure that adding 1 to tm_hour is a correct way to handle timezone? That way you'd get a 23 + 2 = 25 instead of wrapping the day counter. You should rather add a hour offset before using gmtime function.
Anyway, watch for the next commit, today or tomorrow.
Helpful post? Buy me a coffee.
I2C system will be used to map I2C devices inputs and outputs to our internal OpenBK7231 channels.
Right now, I have added support for one device - TC74 temperature sensor:
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/9908646600_1649281681_thumb.jpg)
Connection requirements are simple - solder wires to I2C1 port of WB3S:
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/3453345400_1649281749_thumb.jpg)
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/1428451200_1649281775_thumb.jpg)
Connect power, ground, SDA and SCL to I2C device.
Also connect 4.7k pull up resistors on the I2C bus.
You can use multiple I2C devices, as long as they have different addresses.
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/1685538300_1649281822_thumb.jpg)
Here is my setup with two TC74 (A0 and A2 version, two different addresses):
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/9024360200_1649282762_thumb.jpg)
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/5990566400_1649282761_thumb.jpg)
I2C devices can be added to any BK device. I have used Tuya 4 channels relay controller for this example.
Relay controller was already configured:
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/9096613700_1649282087_thumb.jpg)
I2C devices can be added only by commands. They will be most likely saved in LittleFS config file.
In order to setup TC74, you must reserve a channel that is not used for relays.
In this case, channels 5 and latter are not in use.
So, mark a channel as temperature:
setChannelType 5 temperature
Then register I2C TC74 which will save output to channel 5 (0x48 here is I2C device address, I2C1 is the name of hardware I2C bus to use):
addI2CDevice_TC74 I2C1 0x48 5
Result:
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/8088447100_1649282246_thumb.jpg)
Same, for second TC74:
setChannelType 6 temperature
addI2CDevice_TC74 I2C1 0x4A 6
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/3497166800_1649282315_thumb.jpg)
Now, for a test, let's warm up one sensor with soldering iron:
![[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant](https://obrazki.elektroda.pl/6921795800_1649282379_thumb.jpg)
Both sensors work.
Now, as you most likely already realize, having temperature values in MQTT automatically allows us to expose them to Home Assistant, just like with any other variables.
WARNING: This is experimental feature, if you're a beginner and not a developer, please wait few weeks before using it.
Now I really need to get that lightbulb with Beken and I2C RGBCW controller, do anyone know where I can buy one?
theosoft wrote:
I am trying do use OTA on BK7231N devices. No success...
OTA also didn't work for me on N version, despite me changing the OTA partition address to correct one (partition addresses are different on N and on T).
I am not sure what else to change. Will have to look into it, but I have very few N devices (only 2?). You can also try asking @btsimonh . BK7231 OTA is using entirely Beken OTA system, it was already in place, we just activate it by saving firmware to the OTA section of flash memory.
ExploWare wrote:
My four devices, one of the four was very steady, it was an older version,not connected to the MQTT. The wifi fix did not solve the connectivity, if anything, it worsened it according to this one way of testing.
Fix should only affect device when it gets disconnected from WiFi, so that's really strange. I will look into it.
theosoft wrote:
For wifi scanning in http_fns.cCode: C / C++
Thanks, added to repo.
absinth84 wrote:IT use harcoded timezone (+1) but I start to implement the possibility to customize it from web console.
I am integrating your changes, but some of them are incorrect. Are you sure that adding 1 to tm_hour is a correct way to handle timezone? That way you'd get a 23 + 2 = 25 instead of wrapping the day counter. You should rather add a hour offset before using gmtime function.
Anyway, watch for the next commit, today or tomorrow.