Wiring:
I have my master device connected to the USB to TTL converter.
The slave device is simply being powered by an STM32 (I have plans later to make a controller for a pong game)
To keep things simple for now I have a terminal emulator that I made in python so that I can send commands to the master device.
Here is the code for that:
import traceback
import serial
import time
import threading
import sys
PORT = "COM4"
BAUDRATE = 9600
print(f"Opening {PORT} at {BAUDRATE} baud...")
ser = serial.Serial(PORT, BAUDRATE, timeout=5)
time.sleep(1)
print("Connected. Type AT commands and press Enter to send.")
print("Type 'quit' to exit.\n")
def print_data():
while True:
try:
if ser.in_waiting:
data = ""
data += ser.readline().decode(errors="ignore")
if data.strip():
for line in data.strip():
sys.stdout.write(f"{line}")
sys.stdout.flush()
print("\n")
time.sleep(0.05)
except:
traceback.print_exc()
threading.Thread(target=print_data, daemon=True).start()
try:
ending = "\r\n"
while True:
cmd = input("").strip()
time.sleep(0.50)
if cmd.lower() == "noclrf":
ending=""
if cmd.lower() == "nocr":
ending="\r\n"
if cmd.lower() == "quit":
break
if cmd.lower() == "clrf":
ending="\r\n"
if cmd:
ser.write((cmd+ending).encode())
except (KeyboardInterrupt, EOFError):
pass
ser.close()
print("\nClosed.")
I would say I am at an intermediate level of understanding of embedded systems so anything UART related I understand. (e.g. I know not to connect tx to tx and rx to rx).
I am able to send commands between through the serial monitor.
for reference here is a list of (mostly) available commands:
AT+HELP
********************************************************************
* Command Description *
* ---------------------------------------------------------------- *
* AT Check if the command terminal work normally *
* AT+RESET Software reboot *
* AT+VERSION Get firmware, bluetooth, HCI and LMP version *
* AT+HELP List all the commands *
* AT+NAME Get/Set local device name *
* AT+PIN Get/Set pin code for pairing *
* AT+BAUD Get/Set baud rate *
* AT+LADDR Get local bluetooth address *
* AT+ADDR Get local bluetooth address *
* AT+DEFAULT Restore factory default *
* AT+RENEW Restore factory default *
* AT+STATE Get current state *
* AT+PWRM Get/Set power on mode(low power) *
* AT+POWE Get/Set RF transmit power *
* AT+SLEEP Sleep mode *
* AT+ROLE Get/Set current role. *
* AT+PARI Get/Set UART parity bit. *
* AT+STOP Get/Set UART stop bit. *
* AT+INQ Search slave model *
* AT+SHOW Show the searched slave model. *
* AT+CONN Connect the index slave model. *
* AT+IMME System wait for command when power on. *
* AT+START System start working. *
* AT+UUID Get/Set system SERVER_UUID . *
* AT+CHAR Get/Set system CHAR_UUID . *
* -----------------------------------------------------------------*
* Note: (M) = The command support master mode only. *
Some commands do not work, and some are not listed. For example when connected to another device AT+DISC will disconnect.
AT+MODEx is also a command, I'm honestly not to sure what it does but I've experimented with different modes and the command seems to do nothing.
Right now my goal is pretty simple. Confirm that I am seeing data come through when I connect my two HM-10's together.
Here is what I have been trying with my python program:
Opening COM4 at 9600 baud...
Connected. Type AT commands and press Enter to send.
Type 'quit' to exit.
AT+ROLE1
+ROLE=1
AT+INQ
+INQS
Scanning...
+INQ:1 0x5DE841771F71
+INQ:2 0x0E48FFB575C7
+INQ:3 0xF082C0761589
+INQ:4 0x7C010A391308
+INQ:5 0x4940FBAC4E18
AT+CONN4
+CONN:4
Connected
SENDING THIS MESSAGE SHOULD FLICKER THE LED ON THE RX PIN OF THE SLAVE
My issue now is that the LED will not flicker.
I also know the SLAVE is connected as the STATE LED is on.
I know the LED works as shown by this picture:
I also have tried using my oscilloscope (not that it would change anything) to see if I get any signal and again nothing.
Tools I have available:
- 3 STM32F411's
- Oscilloscope
- Multimeter
- CCLoader if I wanted to try flashing new firmware (Already bricked one board this way so I'd prefer another route)
- Logic Analyzer