I have two HC-05 modules the first one's role as a Master and the other is a slave one.
I've done some AT commands to set up each HC-05 module
= Master's configuration has to be like that: name=Master, Password=2021, only accept connection from one HC-05 module only (for privacy purposes) via the Slave's Address, Baud rate = 9600,0,0.
= Slave's configuration has to be like that: name=Slave, Password=2021, Baud rate = 9600,0,0.
The AT command I used to set this configuration like that:
Slave:
/*Set Slave mode.*/
AT+ROLE= 0
/*Setting up Baud rate (The same as the Master Baud Rate to proper connection).*/
AT+UART= 9600,0,0
/*Rename the module.*/
AT+NAME=Slave.
/*Get the Slave address to save it for Master*/
AT+ADDR?
(The response will be the module Address, I will save it for Master configuration)
let it = 98d3:a1:fd7a0f
Master:
/*Set master mode.*/
AT+ROLE= 1
/*For secured connection make Master accept only one module via its unique Address.*/
AT+CMODE=0
/*Setting up Baud rate (The same as the Master Baud Rate to proper connection).*/
AT+UART= 9600,0,0
/*Save salve address*/
AT+BIND=98d3,a1,fd7a0f
/*Rename the device.*/
AT+NAME=Master.
/*Change Password.*/
AT+PSWD= 2021
I saw a lot of videos the result of all of them is: the two modules are automatically connected to each other when power is on.
but mine is not!
Were I make any mistake!?
these are some videos that I've watched to achieve my goal:
https://www.youtube.com/watch?v=DgFZE16UKTM&t=31s
https://www.youtube.com/watch?v=BXXAcFOTnBo&t=222s
note:
wiring when AT command was Tx->Tx, Rx->Rx, EN->3v3, GND->GND, VCC->VCC.
wiring when normal condition was Tx->Rx, Rx->Tx, EN->(not connected), GND->GND, VCC->VCC.
I saw a lot of videos the result of all of them is: the two modules
are automatically connected to each other when power is on. but mine
is not!
This confuses me, I can't see any command that will let you initiate connection. My guess is that AT+BIND is a command for trusting. However AT+CMODE is explained as:
Param1: Connection mode: 0 -> Connect the module to the specified
Bluetooth address. (Bluetooth address can be specified by the binding
command)
In this case, I would send AT+BIND first rather than setting CMODE.
If we have a look at HC-05 AT command list, we can see that there are other commands that are used to establish classical Bluetooth connection. I would do the following in order:
AT+PAIR=MAC
AT+BIND=MAC
AT+LINK=MAC
I would also check the status via AT+STATE?.
Related
I am writing some code for my arduino nano and I am using an HC-05 module for wireless transfer of data. I am sending my data as such. This is from the serial monitor, using a usb and regular print statements. I want to be able to recieve this data, and the store it in a csv (I know how to store incoming data). I need help recieveing my data.
22:17:46.765 -> =============================================================
22:17:47.770 -> Sleep timer:242
22:17:47.770 -> Light Sleep: 0 Deep Sleep: 0
22:17:47.805 -> Total Light Sleep: 0 Total Deep Sleep: 0
22:17:47.838 -> Total Sleep: 0
22:17:47.871 -> =============================================================
For some reason, when I connect my HC-05 to my windows desktop via bluetooth, and open a serial monitor in com ports 3 or 4, I get no read out.
My ports
I have it set up as so.
My wireless intialization
Then, I use
MySerial.print()
, to send data, yet I get no output, same thing occurs if I use
Serial.print()
.
I tried getting a new HC-05 module, Switched out all the hardware, tried different prints including Serial and MySerial. I though i could get an output.
Python code I tried to use python to extract the data, yet I get no output. I am not sure what to do here.
Not enough information, but I'll answer biased on the experience I've had with these modules.
Here are instructions for changing or verifying the baud rate on the module:
https://www.instructables.com/Change-the-Baud-Rate-of-HC-05-Bluetooth-Module-Usi/
For my module, I could just send AT commands by default without putting it into AT mode. Send 'AT' to the module and it should respond with "OK".
It helps a ton if you have an ftdi cable for troubleshooting. Connect the ftdi to the HC-05, verify the baud rate and that the HC-05 is responding, open a serial monitor for the bluetooth on the pc and one for the ftdi cable. Try sending data back and forth. Also, be 100% sure you're using the correct com port for your bluetooth by unpairing and repairing and see which com port shows up.
It actually is possible to use the HC-05 for programming the Arduino as well if you set the baud rate to 115200 and figure out a way to hit reset on the Arduino as soon as the bluetooth connects(status/state goes solid). I used an ATTiny for that, but you could just use a pin on the nano connected to reset and another pin to monitor the "state" pin which is connected to the led on the HC-05. That way you can have wireless data and wireless programming if you wanted that.
I am currently trying to use Quartus 18.0 IP Catalog suggestions to import a UART RS-232 block to set up this serial interface.
I have set the clock domain and the output pin (using datasheet to DE0-CV board) but when I try to finish the UART setup by pressing "Generate HDL..." I get this error:
Error: rs232_0: The input clock frequency must be known at generation time.
How can I tell Quartus my clock frequency so that it could generate my UART module without errors?
You need to specify a clock source for the UART component you want to create.
This can be done as follow:
In your IP Parameter editor go under Edit > Add...
In the Add instance windows, search for Clock and select "Clock Source" under "Clocks; PLLs and Resets"
Add the Clock and update the default frequency and clock Finish
Go to View > Connections in IP Parameter editor
Tick the boxes to connect the clocks together
Generate and finish should stop giving you an error.
Qsys (under Tools > Platform Designer) maybe easier for the connections, maybe you can also have a look at it.
So I have succesfully attached a Esp8266 to an Arduino Due. I can communicate with it via Serial Monitor if I choose the Baudrate to be 74880. Then all the commands come to it correctly and can be read back correctly. However, when I send the command AT+RST which restarts the Esp8266 I can no longer communicate with it and need to reopen the serial connection with a Baudrate of 115200. I have to repeat this every time I load the code new to the Arduino or when I power off the Esp8266.
Any ideas where this behaviour comes from?
Here you are an explanation about where are the origins of such a behavior:
Baudrate of 74880 Bd is ESP's 'native' baud rate for sending debug messages generated automatically by the system itself during the boot in case there is 26 MHz instead of 40 MHz crystal used on board - and as we can see, mostly that is the case.
With 40 MHz crystal the baudrate would be as expected (115200) but with 26 MHz crystal instead, baudrate is 115200 * 26/40 = 74880.
Later after bootloader ends baudrate is controlled in other way so that's why you have two different baudrates - the first is the default one (74880) and the second is the one that is active later (the one you can set).
I usually set baudrate to 74880 so I can see both the messages generated automatically and the messages I send from the code.
In order to set UART baudrate persistent after a reset you should use AT+UART_DEF.
From the AT instruction :
AT+UART_DEF – default UART configuration This command sets the UART configuration and save it to flash. It is stored as the default
parameter and will also be used as the default baudrate henceforth.
So I thought this would be simple, and I'm new to XBee so it may be, but I want to request a remote XBee to transmit its current I/O pin states to me, whether they be input or output.
Use case: The controller sends state to the XBee and XBee updates to match and then controller goes down. While controller is down, the user at the remote XBee toggles a switch that changes an I/O input pin state. The controller comes back up and needs to know of this change.
How can I request the I/O state from remote routers?
NOTE: Running in API mode
Digi has a useful article in their Knowledge Base about configuring a remote device to send I/O samples on a periodic basis, or when inputs change. You can use ATIR to set a sample rate, or ATIC to configure inputs to monitor for changes. All samples go to the address specified in ATDH and ATDL address registers.
For a one-off sample, you can simply send a remote ATIS command.
I am trying to connect ATmega128 uart to PC using USB-to-RS232 converter so that PC can receive and transmit data from microcontroller using hyper terminal. I set the correct stop bits and baud rate in hyper terminal. It doesn't seem to work.
Can any one tell me if this is possible by USB-to-RS232 converter and if not what other options are there for serial communication between PC and microcontroller ?
You should be able to do this without any issues. I'd suggest putting your USB-to-RS232 cable in loopback mode first (if possible) to ensure you can communicate, then connect it back up to your MCU.
If you aren't seeing what you expect the first thing to look at are the settings, specifically the baud rate. Since your USB-to-RS232 cable is from a third party vendor I'd assume that your settings on the host side are OK. So you should look in to your MCU code to ensure that all your clocks are running at the proper speed and you have indeed performed the correct calculations to achieve your desired baud rate. Debugging here to ensure you are transmitting data out of the device is important.
Additionally, there are tools that can help you debug. Portmon is a tool from Microsoft that lets you look at the serial data path on the host side. I'd also recommend a USB analyzer, such as an Ellisys, that will allow you to view data going across the line from your MCU to the host.