433mhz, infrared IR to and from MQTT on ESP8266

Could you point me the datasheet link you are refering please. One user tested this command without success.

Thanks, will try tonight.

Be carefull about maybe the wiring defined in user_config.h and the corresponding pins.

Quick noob question.

I have currently the NodeMCU and RF receiver, but my plan is to also include HM-10 for BT (when it arrives).

If I upload the gateway code now (while HM-10 is not physically connected), can I maintain the user config to already consider it to be a BT gateway, or should I just keep RF and then re-upload to also be BT, once I have the HM-10 connected?

Thanks in advance.

Hello, it should work but it s nevertheless better to comment ZgatewayBLE

1 Like

Hi,

Firmware v540 on a cheap Chinese clone of HM-10 (AT-09) also works using flashing method described below. I think most of the easily available HM-10 modules are, in fact, clones.

With its default firmware, AT-09 it’s not recognized by nodemcu (even, though, bluetooth devices can connect to it).

I’ve tried flashing newer firmware versions (v550/549) on it after upgrading to v540, however although the flashing is successful, the module doesn’t work (led is red stable as if associated) and does not respond to AT commands.

After flashing with v540, needs AT+START (although led blinks as if working) and then it can be removed from the computer and placed on the remote BT/RF/IR gateway.

Unfortunately, the bluetooth module causes the gateway to crash (randomly); nodemcu looses connectivity and then restarts.

Tracking works great with Tile as it does not require enabling/disabling bluetooth connection on the phone each time when at home (although it requires that Tile it’s not associated).

Clone:
https://www.aliexpress.com/item/AT-09-Android-IOS-BLE-4-0-Bluetooth-module-for-arduino-CC2540-CC2541-Serial-Wireless-Module/32822551059.html

Genuine??? (maybe, most of the time HM-10 is described as having a black PCB and this is significantly more expensive than the generic module):
https://www.aliexpress.com/item/HM-10-transparent-serial-bluetooth-4-0-bluetooth-serial-port-module-with-logic-level-transformation/32238168582.html

Flashing process:

good news,i have at-09,and i want to know can i flash the fireware throug the nodemcu not arduino uno?

Yes, it works (I flashed v540 again, this time using nodemcu)

Just remember to modify the sketch for CCLoader.ino in order to use nodemcu pins:

  • the sketch uses pins 4,5 and 6 on the Arduino however pin 6 is not connected on nodemcu;
  • modify section “// Debug control pins & the indicate LED” to the actual pins on the nodemcu (for convenience purposes :smiley: I added a D in front of each pin from Arduino):
    int DD = D6;
    int DC = D5;
    int RESET = D4;

Also, it’s no need to look for the v540 firmware on that malware infested site mentioned in the video (it is already included in ccloader repository)

great,thanks,i’ll try that

could you share an example of bt yaml file

try this to fix the led,and try v546 firmware
https://forum.arduino.cc/index.php?topic=393655.msg3137812#msg3137812

Actually the led is not the issue on >v540, it’s the board :smiley: there is no reply from it (semi-brick). I can re-flash it with v540 afterwards.

I’m not a software engineer so there might be easier (and better) ways to do it, but here it is.

The expire_after option sets the sensor value to unknown after a reasonable amount of time (you need to set yours based on the measurement of seconds between beacons). I’ve then added the binary sensor component as it can be used with “to: (on or off) for: minutes: x” (sensors cannot be used with “for”) in automations.

I guess further adjustments could be used (such as a binary sensor with a state “leaving home” if the sensor’s value drops below -80 or “coming home” if it’s above -75/-70 and increasing) however this method I think is not 100% accurate and it should be connected with other presence sensors.

I. Create a mqtt sensor:

  • platform: mqtt
    state_topic: “home/BTtoMQTT/BTADDRESS”
    name: btdevice1
    expire_after: 300

II. Create a binary sensor based on the previous mqtt sensor:

  • platform: template
    sensors:
    btpresence1:
    friendly_name: BT presence Phone
    value_template: >
    {% if is_state(‘sensor.btdevice1’, ‘unknown’) %}
    true
    {% else %}
    false
    {% endif %}
1 Like

Nice, I’ve been waiting for this all the time. How would you implement the Signal Strength of the Beacon in yaml file. I would like to try. The Skybeacon I have i can set the TX power to them.

Again, not an IT professional :smiley:

A) Sensors

- platform: mqtt
  state_topic: "home/BTtoMQTT/BTADDRESS"
  name: btdevice1test
  expire_after: 300
- platform: template
  sensors:
    testbt
      value_template: >
        {% if is_state('sensor.btdevice1test', 'unknown') %}
          -100
        {% else %}
          {{states.sensor.btdevice1test.state | float}}
        {% endif %}

I guess it could be done in just one step in order not to have 2 sensors for the same job, but I prefer to keep things separate to know where the bad smell came from (when the device is offline/away the RSSI value will be a small negative number, -100 or -120 for example). Also, having this second sensor would allow for easier calibration (add/subtract any number from the RSSI value determined in first instance).

- platform: statistics
  entity_id: sensor.btdevice1
  name: btdevice1stats
  sampling_size: 10 

B) Binary sensor:

- platform: template
  sensors:
      thresholdbtdevice1:
        friendly_name: thresholdbtdevice1
        value_template: '{{ states.sensor.btdevice1stats_mean.attributes["average_change"] | float > 0 }}'

When the average change is negative (the device moves away from the BT gateway, based on the sampling size of 10 beacons) the sensor is off; when the average is positive it means that the RSSI value is increasing and the sensor is on. As mentioned before, having a binary sensor would allow “to & for” in the automation.

C) Then throw all the mess under the carpet (keep in view only the threshold sensor):

  customize_glob:
    "sensor.btdevice1*":
      hidden: true
3 Likes

Yes, you are professional

Is there any chance of a hm-10 clone work with the mqtt gateway? I just got a (not so) cheap one and discovered that it is a MLT-BT05. Not sure if it has all the necessary AT commands to make it work. I found some information about this clone here: https://blog.yavilevich.com/2017/03/mlt-bt05-ble-module-a-clone-of-a-clone/

thanks!

It could, try to connect to it by serial. Test the necessaries command to have a list of ble beacons and if successfull put these commands into ZgatewayBT instead of the standard ones.

Use serial connection with “Both NL&CR” instead of “No line ending” and 9600 baud rate on the original firmware and you can interrogate the module. Depending on the model, it might have some specific procedure for putting it into AT mode.

For clones, only flashing v540 mentioned also in the youtube video works as this firmware includes also the bootloader (the firmware for other versions above 540 from the manufacturer has only 248KB and I think it is due for original HM-10 modules).

Anyway, v540 on clone works with MQTT gateway.

Ignore my previous post about versions above 540 not flashing on clones.

Just need to run the specific command from HMConfigAssistant.exe to put it into update mode (AT+SBLUP). Then HMSoft.exe will be able to run (and firmware without bootloader can be uploaded).

Hey, that’s great! I had it on serial and had limited success in sending AT commands. Which commands should I use to scan/list ble beacons? @Petrica tried the AT+SBLUP and got nothing, so I’m not sure if it understand this command or not. Anyway, i will try the firmware upgrade.

Not really :slight_smile: I wasn’t paying attention to the instructions on how to update after flashing HM-10 thus I was stuck on v540 (command AT+SBLUP, which I was omitting, is the missing link as it is needed to put the device in upgrade mode on v540, thus after replacing original firmware).

In conclusion, steps are as following:
I. Initial flashing of HM-10 firmware
Solder the three pins to Arduino/Nodemcu and flash v540. All steps are described in the thread below. Nodemcu can be used instead of Arduino Uno/Mega, just need to modify pins in the CCLoader.ino sketch so that they match the ones from Nodemcu.

or in the Youtube video: https://www.youtube.com/watch?v=ez3491-v8Og

If everything worked fine, you now have a device with HM-10.

II. Updating HM-10 from v540
Soldering those three pins was needed to have access to the entire device memory and replace the original firmware with HM-10. Firmware v540 is needed for this as it is the only one available that includes also bootloader. Flashing any version above v540 with the above process will cause the device to brick (it can be re-flashed with v540, though; then the whole update process can be started again). For updates there is no further need for bootloader to be included with the firmware as it was already flashed with v540.

a) Download last firmware version from the manufacturer’s site (sometimes there are virus alerts when downloading the files…). Currently, the last version is v550.
The archive with the firmware includes also the two executable files needed for the flash (HMConfigAssistant - needed for the serial connection and HMSoft - for the flashing process). On the manufacturer’s site there’s also the pdf documentation of the upgrading procedure.
b) After playing around with AT commands in HMCofigAssistant.exe (select the proper com port and then click Open Com) send AT+SBLUP so it will enter update mode (note: the module will not respond to any other AT command until flashing is complete and led will stop blinking). Then close the Com port.
c) Open HMSoft.exe, select new firmware file, Com port and then click Load image.

The problem was that I haven’t read literally the instructions related to upgrading from the post mentioned above :slight_smile: :

For future update, the procedure are easier as you can now update the HM-10 via an USB to Serial converter, the firmware and the procedure are on the manufacturer website: www.jnhuamao.cn

Sole current issue is that the bluetooth module with HM-10 causes the host Nodemcu to restart (there is no trace in the serial connection of Nodemcu). I have several gateways in addition to the one with BLE (one with RF gateway on an Arduino Mega with ethernet shield and the others with IR gateway on Nodemcu for controlling AC/receiver/Xbox/etc) and another component for controlling MiLight bulbs (also on Nodemcu). For some 433mhz signals (from PIR sensors and light switches) or some commands sent to the light bulbs, the Nodemcu with BLE gateway restarts itself. Some time it works fine for a few days, then it restarts about 3-4 times per hour. I observed this on both v540 (which I had for some time) and v550.

1 Like

Thanks for the instructions! I did the first part: read the arduino forum instructions, soldered the pins and used a Arduino Uno to upload the CC2541hm10v540.bin file. The flashing seemed to work, but right after that the red led on HM-10 clone turned off. I tried to connect it directly to the usb-serial and it didnt respond to AT commands. A re-flashing procedure seems to work, and the ccloader reports success, also the led turned on during the flashing and then off again at the end. I didnt did the voltage divider and there was people saying it wasnt needed (the clone seems to have the voltage regulator). Maybe this could be the problem…