AT Commands for classic bluetooth

  • Hi,

    I have bought an M5 Stack grey because I think it could work nice for a project I want to make.
    First I should say I am new to Arduino, although I have used a teensy to make a gaming mouse in C before, but this project is quite different.

    I'm using this guide:
    (sorry its not in English, but google translate works well).

    Basically I want to communicate with an OBD2 (ELM327) scanner over classic bluetooth, say for example, get the current engine RPM from it and display it on the M5Stack screen. The OBD2 scanner needs to have a pin sent to it to connect (eg "1234"). So the idea is, the M5Stack and OBD2 scanner sit in my car, when I turn on the ignition, the M5Stack will request data from the OBD2 reader, and display whatever is requested on the screen and constantly update it. It can potentially get quite a lot of information and display it in all sorts of ways, but I just want something simple, and also something I can share with my friends who also want something like this (I am aware you can get these kinds of thing on ebay, but my car is old and most don't support it).

    I understand how to do pretty much everything in the guide with the M5 Stack, but the one thing that I'm having trouble with is the AT Commands at the start.

    I have set up ESP-IDF, and there is a AT application for it here:

    It just seems so complicated and there's a lot of things I don't know. On the HC-05, it looks very easy, so I have ordered one of those just to have as a fallback, and to get the project started (since its hard to begin anything without being able to connect to the OBD2 scanner).

    So on the HC-05, I can just use some firmware to communicate with it over serial, after pressing the AT button on the HC-05, I can send AT Commands. But with the M5Stack/ESP32, there is no button, and I don't know if the firmware supports all the commands. It seems it's not so simple as pressing a button, loading some firmware, and sending the commands.

    Of course I would rather use the bluetooth on the M5Stack in the end, since it seems a shame to attach a HC-05 to it when it has perfectly functional bluetooth capability built in.

    I found these two videos, I was following it for a while, until he started using one USB port for flash and one for AT commands, I don't know what's going on there.

    I'm really surprised how difficult it is, I don't have anything against it being difficult, its just surprising to me, I thought it was going to be easy ;) I guess it IS easy but I'm just not able to find the information I need, theres so much you can do, and if you want to do one little thing, its hidden in the vast amounts of information.

    So my question is, am I going in the right direction? Can I use esp32-at to do what I need to do? Or is there some much more simple way to do it, that I've missed?

    Thanks for any help you can give me.

  • I'm making an interface on the M5stack to the car.
    I purchased the Vgate iCAR Pro BLE 4.0 interface and installed the BT terminal on the phone.
    Through this terminal he tries to send all the codes to the car and see what comes back.
    In my opinion it's the only way not to burn yourself.
    iCAR Pro BLE 4.0 also supports BL 2.0 and bl 3.0
    Below are the codes that I have already decrypted to establish the transmission between the interface and the car

    String commandQueue[commandQueueCount] = {
    "AT Z", // Reset all
    "AT I", // Print the version ID
    "AT E0", // Echo off
    "AT L0", // Linefeeds off
    "AT S0", // Printing of spaces on
    "AT H0" // Headers off, on in (debug only)
    // Loop from (Alfa Romeo GULIETTA)

    "AT PP2CSV01"			// 01 == CAN 29 ISO 15765-4, fixed DLC 8 byte, 	7 orders <commandQueueLoopFrom>
    "AT PP2CON"				// Write to eeprom
    "AT PP2DSV0A"			// baud rate == 500 / yy "0A" == 50 kbps
    "AT PP2DON"				// save eeprom
    "AT Z"							// Reset all ?? ATWS
    "AT SPB"						// set USER1 protocol
    "AT DP"						// Vgate send CAN29/50 ?? ATDPN 
    "AT CRA"						// reset all filters
    "AT CP18"					// set CAN priority bit to 18
    "AT CRA18DAF140" 	// set the CAN Rx address to 18DAF140
    "AT SHDA40F1"			// set the Tx Header to DA40F1
    "AT AT0"						// adaptive timing control == disable, AT1 == enable
    "AT ST19"					// set timeout in 4 msec steps. 0x19 == 100 msec 
    "AT CAF0"					// auto formatting OFF, 8 byte, 				


  • In the end I took the TX/RX pins inside the OBD reader and connected them with wires to the RX/TX pins on the M5Stack. I wrote a program for it and it works really well.

    There is one problem I have with it though, I've set it up like this:

    I have a relay which is activated by the ACC wire on the stereo, this joins a positive cable, for a USB connector which is powered from the fuse box in the car. The M5Stack is plugged into this USB connector, with its battery removed, so that it turns on and off with the car (otherwise, it won't be able to do its start up routine, lets say I turn the engine on and then off, the M5Stack will stay on, but the OBD will have reset, so it'll need its start up codes, but the M5stack doesn't know it has to send them). The OBD is also turned on and off by the ACC wire too.

    So the problem I have is that the M5Stack doesn't always want to turn back on after I've started the engine. I have to unplug and plug the USB cable back in, and then it turns on.

    The process is:

    1. Ignition on, M5stack turns on
    2. Engine cranks, M5stack turns off (which should happen, because ACC is cut when the engine cranks)
    3. Engine is on, M5stack remains off - it should turn back on again, but it doesn't.

    It seems that if I start the engine fast enough, it doesn't have this problem. If I put the key in and just instantly turn it all the way to start the engine, it doesn't get the chance to turn on until the engine has started.

    So it doesn't seem to like being turned on, and then being turned off, then back on again. I think what I need to find is something that is only powered when the engine is on, rather than using ACC. But I'm not sure if that exists or not.

    If anyone else knows, or can think of a solution I'd be grateful, its the only problem I have left to solve with it now :)
    Little pic of my OBD speedo (not great quality):

  • Can download my code for the speedo here, if anyone wants it. All you need to do is connect the TX/RX pins, make sure your protocol is correct, maybe adjust it if you need kph instead of mph, and it should work: download

  • This post is deleted!

  • Banned

    This post is deleted!