Go Down

Topic: How to flash genuine HM-10 firmware on CC2541 (make genuine HM-10 from CC41) (Read 116186 times) previous topic - next topic

hoechin

Hello all,

I've managed to successfully updated my CC41-A chip on a ZS-040 board with the guide. It is now discovered on my iphone with Bluelight as HMSoft.

However, i can only send limited AT command. When i send in AT, i'll get a OK reply. Anything else would also just get a single OK. if i send AT+NAME? i get an OK as well.

This is my code which sends the AT command over serial

Code: [Select]
/************************************************************
BLE CC41A Bluetooth
This is a clone of the HM10 BLE board
In the Serial Monitor ensure that 'Both NL and CR' is selected
Select a Baud Rate of 9600
********************************************************/
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(9, 10); // RX, TX

void setup()
{
// Start the hardware serial port
Serial.begin(9600);
pinMode(13, OUTPUT); // onboard LED
digitalWrite(13, LOW); // switch OFF LED
bluetooth.begin(9600);
}

void loop()
{
bluetooth.listen();
// while there is data coming in, read it
// and send to the hardware serial port:
while (bluetooth.available() > 0) {
char inByte = bluetooth.read();
Serial.write(inByte);
}

// Read user input if available.
if (Serial.available()){
delay(10); // The DELAY!
bluetooth.write(Serial.read());
}
}

My serial monitor is running at 9600 baud and has no line ending.

Please help.

hoechin

Problem is solved. I realised that the serial code i was using was not working. I used the SoftwareSerialExample program to end the AT commands. I had to change both baud rates to 9600. But other than that, i dont have to edit much of the code.

Code: [Select]
/*
  Software serial multple serial test

 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.

 The circuit:
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)

 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

 Not all pins on the Leonardo and Micro support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example

 This example code is in the public domain.

 */
#include <SoftwareSerial.h>

SoftwareSerial bluetooth(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  bluetooth.begin(9600);
  bluetooth.println("Hello, world?");
}

void loop() { // run over and over
  if (bluetooth.available()) {
    Serial.write(bluetooth.read());
  }
  if (Serial.available()) {
    bluetooth.write(Serial.read());
  }
}


Anyone has the latest Version 546 working? I downloaded the official firmware from the china website but the AT commands did not work. End up, i had to flash it back to V540. If anyone is keen to try, i've uploaded the official firmware and the release note for reference. Please take not that it DID NOT work for me.

hammer5858

There is an app for iOS that makes using the HM-10 easy to use. It is for a single pin output. There is also a link the sketch for it. I used it with Arduino Nano, HM-10, a Relay, junction box, and an outlet to turn my room light off at night without getting out of my bed. The app is FatBeard HM10 here https://itunes.apple.com/us/app/fatbeard-hm10/id1198432512?mt=8

kutysam

Hi guys, i managed to flash HM10 onto my AT09 [Same chip as https://www.youtube.com/watch?v=ez3491-v8Og ]

I realized, LEDs do NOT work. but there is a fix.
Furthermore, the firmware messes with your pins and at
5V - Max current --> 55mA
3.3V - Max current --> 28mA

Activate mode is supposed to be 9mA but this is definetly way toooo high!

Here is a fix.
AT+BEFC080
AT+AFTC088

Enter these two commands.
After powering up, PIO4 will be 1. Don't ask me why, but this greatly decreases power!

After connecting, light will turn on and its 9mA [PIO8]

Also, please do ensure that your BLE is under sleep mode always! AT+PWRM0

Findings after this fix,
After connecting to phone --> 8.7mA
After disconnecting, immediately goes to sleep --> 0.5mA (500 nano Amps!)

And, for the guy above, I managed to flash v546 without any issues! It's running that now!

EDIT: Also run a AT+RENEW command after every flash. To revert back to factory settings!

songotag

For those trying to flash hm10 using Arduino Nano clones - it is important to connect a 10uF capacitor between RESET and GND pins of Nano - see the photo.


For those trying to flash using Linux:
1/ compile ccloader ( /CCLoader-master/SourceCode/Linux/main.c from the zip archive):
gcc main.c -o ccloader
2/ run it:
./ccloader /dev/ttyUSB0 CC2541hm10v540_from_hexor.bin 0

The flashing is quite slow, takes about 5min and pauses couple of times in the process. But it worked for me - many kudos to Hexor!!! I did not use 5v->3.3v level shifting - connected the 5v nano pins directly to DD and DC pins of CC2541.

After flashing the HM10 module announces itself as HMSoft (used to be BT05) and paired with android easily using pin 000000.

Hexor - you are the Man!


Thanks to Hexor and to you, don't work with the 5v-> 3.3V adaptor.

Now my clone will have a new life !    ;-)

bIG_dEAL

Hi.

I seem to be able to flash everything correctly. All goes smooth as in the instructions.


BUT:

After successfully flashing the FW using the CCloader I can't get all related AT commands to work.
This was obviously the case before flashing, as this is a cloned module. I used AT+RENEW and +RESET and still the same.

One example of what is going on:
Before the flash AT+NAME would return HM-BL5 (not sure exactly) now the same command returns nothing at all. Even when I set it with AT+NAMEXXXXX. I get OK and when querying the name again, no reply.

I am trying to use this as an iBeacon.
All AT commands described here Instructables - make an iBeacon work and get confirmation, but the module still does not show up in ane iBeacon scan or before entering iBeacon mode as a btooth device.

also setting the name gets a confirmation but AT+NAME results in no reply at all, not showing up on any btooth scan either.

I even used the manufacturer's HMSoft updater and updated to the 540, 541 and 545 version and still getting the same.  I tried different serial port comm apps too...

...just seems as if commands are received and set but for some reason it's not working and trying to query the settings returns nothing...

I do realize I have a clone of the original HM-10, but since the flashing went OK without a hitch, all the commands execute and get OK, my arduino uno works fine too, I am just stumped...

Do you guys think there's any point in trying a different approach or should I just give up and buy a new module from reputable seller?
(btw. I had no idea there was a whole clone industry for HM-10, only after it did not work I found out that it's actually pretty hard to find a genuine product... )

EDIT: After re re-flashing the latest fw ver. 546 from manufacturers website the module still soes not return any specific AT responses but it has for the first time showed up in an ibeacon scanner app. My iPhone also picked it up. Don't know how long it will last or if any reset later on will not break this again...

still... I would appreciate any help in figuring out this weird AT commands inconsistency.

jaykup

I was able to get mine working from the original post and this post:

I realized, LEDs do NOT work. but there is a fix.
AT+BEFC080
AT+AFTC088

After connecting, light will turn on and its 9mA [PIO8]
How did you know to use those AT commands?  What do they mean?

Is it possible for the LED light to flash when nothing is connected?

And, for the guy above, I managed to flash v546 without any issues! It's running that now!
How did you do this?

I tried flashing v546 using CCLoader, it loaded but the BLE module wouldn't work.  Had to re-flash to V540.  I don't think the V546 file has the bootloader with it.

I also tried with AT+SBLUP and the exe tool that was in the V546 zip, but it wouldn't connect.  I also had to re-flash after running that command as it doesn't accept AT commands after that.

marco_c

Thanks very much. Great tutorial and worked first time.

My setup with a Uno and no voltage dividers.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

kutysam

I was able to get mine working from the original post and this post:

How did you know to use those AT commands?  What do they mean?

Is it possible for the LED light to flash when nothing is connected?

How did you do this?

I tried flashing v546 using CCLoader, it loaded but the BLE module wouldn't work.  Had to re-flash to V540.  I don't think the V546 file has the bootloader with it.

I also tried with AT+SBLUP and the exe tool that was in the V546 zip, but it wouldn't connect.  I also had to re-flash after running that command as it doesn't accept AT commands after that.
Okay, I used the AT commands at bluetooth40_en.pdf (attached) or u can get it at
http://www.huamaosoft.com/bluetooth40_en.zip

Based on the guide,
3FF == 0011 1111 1111

Pin Order: XX23 4567 89AB
XX = 0 1 but you can't control it via here. so just leave it as 0.

AT+BEFC080
080 == 0000 1000 0000
Means, pin 4 is on by default!


AT+AFTC088
088 == 0000 1000 1000
Means, pin 4 and pin 8 are on.


BEFC = When you switch on the device it will immediately follow the order.
AFTC = AFTER bluetooth is connected, this pins will be followed in that order.


I hope this clears part 1 of your question.


Now for part 2,
Here is how i did it.
1) Flashed the 1st page's firmware via ccloader.
2) Did a AT+RENEW
3) Did a AT+SBLUP
4) Used HMSoft.exe and loaded 546 config file (http://www.huamaosoft.com/rom/HMSoft-10-2541-V546.zip)
5) Did AT+RENEW

and done.

Take note, mine is originally an AT-09 chipset (as a bonus, I've attached AT-09 commands too*Strictly for AT-09)
If you use another 'fake' hm-10, you may run into issues as the PIOs may be different etc.

Even for AT-09, it was different and that's why I had to use the AT+BEFC080 AT+AFTC088 commands.

And MOST IMPORTANTLY! Remember, nowonwards, the commands will be without a newline!
Which means, AT+RENEW should not have an enter when you send the command etc.

Hope this helps.

bilekj

Hi,
thanks for the great tutorial.
I soldered the 3 wires, powered the HM-10 (counterfeit) from arduino and flashed it easily. I executed AT+RENEW then.

The HM-10 now responds to new AT-commands as expected but bluetooth connection is somewhat weird. Using BLE scanner on my Android phone I can see the device shortly after AT+RESET or AT+ROLE0 but then it disappears. So I am not able to connect nor read characteristics from the device.
The same misbehaviour I observe when I setup the HM-10 as iBeacon (according to another topic in this forum). Application in my phone (Beacon Scanner) finds the beacon but doesn't update the beacon information until AT+RESET on HM-10.
I'd say the HM-10 behaves like it is disconnecting the radio after a very short period of inactivity. The LED blinks all the time, though.

Does anybody have a tip how to get the HM-10 working?
Thanks.

alto777

I just flashed HMSoft V540 to the first of a few HM-10 modules. It needed it! The original firmware sorta worked, but not well enough to do simple examples.

The tips here were invaluable, here's what did and didn't:

0. The original firmware (or something) did not like to be powered from the 3.3 volt FTDI I was using. I used a separate 3.3 volt power supply. This is a mystery, but it got me on the air w/ the original firmware. I'll try again now that I have the new firmware down on there.

1. I thought I would be clever and use a 3.3 volt Pro Mini. CCLoader was unable to connect to it, and the modification to CCLoader outlined earlier on this thread did not help. Has nothing to do with the HM-10 - you can pre-test your CCLoader.ino <-> CCLoader.exe connection w/o hooking up the HM-10 at all. It will succeed in failing rather than fail to succeed.

No more Mr. Nice guy:

2. I switched up to a real UNO and used a bi-directional level shifter on the data, clock and reset lines that CCLoader.exe and CCLoader.ino use. (I went back to the unmodified CCLoader.ino)

Successful upload!

3. I forgot to remember (!) that with the "real" software, no line ending is needed. I used the Arduino Serial Monitor and set "No line ending" and now have a working HM-10.

I say working, I have only tried a few AT commands, but ones that didn't work with the original, so right now my confidence is high…

Here is a case if ever for saying YMMV, but the recipe does work.

Worst: very pesky soldering to the HM-10 module! If you think it might be a problem, get the ones that are slightly "broken out". Gee, maybe they'd even come from the source with V540 on 'em already.

That, of course, would be no fun at all.

alto777

CrossRoads

"did not like to be powered from the 3.3 volt FTDI I was using"
Might have been current lacking - the FTDI chip creates just 50mA of 3.3V current from an on-chip regulator.

Uno has 150mA 3.3V regulator. As does the 3.3V Promini.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

alto777

"did not like to be powered from the 3.3 volt FTDI I was using"
Might have been current lacking - the FTDI chip creates just 50mA of 3.3V current from an on-chip regulator.

Uno has 150mA 3.3V regulator. As does the 3.3V Promini.
Indeed. That explains why it also took down the serial connection. Hard.

I had thought of current draw and measured less than 10 mA drawn from the supplemental power supply. I did not even then put 2 + 3 together as you have!

Just now a glance at the datasheet looks like 50 mA would more than cover any max current the HM-10 would draw, but there is no arguing with failure as is said. I am maybe overlooking something HM-10ish or FTDIish.

I'm curious too about the 3.3 Pro Mini fail. Perhaps I can blame the FTDI necessary for that arrangement. I don't have any 3.3 Arduinos or clones thereof that have USB on board to try instead. I haven't pinned anything (else) on the FTDI…

alto777

Marco_Segato

guys i'm afraid i wasted my sh-hc 08

the flash of the firmware went well but now it doesn't turn on at all, the led stays off...

time to buy a new one?

Anton_Zeppelin

just for motivation. it works for "my" MLT-BT05-V4.0
but I had a hard time to discover that the serial communication is very sensitive to CR and LF.
For AT commands as well for transparent serial communication.
So not every app will work. (I did not find the right one for android, for iOS App named serial works)

Go Up