Buongiorno a tutti, premetto che sono abbastanza nuovo nel mondo dei microcontrolli. Sto cercando di far funzionare un modulo BT HM-10 ZS-040 seguendo questa guida
http://www.martyncurrey.com/hm-10-bluetooth-4ble-modules/
Collegato come da indicazioni con la AltSoftSerial e partitore di tensione solo sulla RX del modulo BT.
All'inizio al comando AT mi veniva risposto un punto interrogativo specchiato "⸮", poi cambiando i baud da 9600 a 115200 (sia per la seriale usb che la softserial) al comando AT ricevo come risposta "ERROR", se provo a connettermi con l'app "BLE Scanner" ricevo sul serial monitor "connected" e il led sul modulo smette di lampeggiare e rimane fisso. Quindi escludo un problema di comunicazione tra la seriale in quanto alla connessione da app ricevo "connected", cosa può essere? Leggo che in genere la scheda HM-10 è in AT mode di default, ho provato a cliccare il tasto presente sulla scheda ma non cambia nulla. Come arduino sto usando un arduino uno r3 clone. Grazie a tutti!
// SerialIn_SerialOut_HM-10_01
//
// Uses hardware serial to talk to the host computer and AltSoftSerial for communication with the bluetooth module
//
// What ever is entered in the serial monitor is sent to the connected device
// Anything received from the connected device is copied to the serial monitor
// Does not send line endings to the HM-10
//
// Pins
// BT VCC to Arduino 5V out.
// BT GND to GND
// Arduino D8 (SS RX) - BT TX no need voltage divider
// Arduino D9 (SS TX) - BT RX through a voltage divider (5v to 3.3v)
//
#include <AltSoftSerial.h>
AltSoftSerial BTserial;
// https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
char c=' ';
boolean NL = true;
void setup()
{
Serial.begin(115200);
Serial.print("Sketch: "); Serial.println(__FILE__);
Serial.print("Uploaded: "); Serial.println(__DATE__);
Serial.println(" ");
BTserial.begin(115200);
Serial.println("BTserial started at 115200");
}
void loop()
{
// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available())
{
Serial.println(BTserial.available());
c = BTserial.read();
Serial.write(c);
}
// Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
{
c = Serial.read();
// do not send line end characters to the HM-10
if (c!=10 & c!=13 )
{
BTserial.write(c);
}
// Echo the user input to the main window.
// If there is a new line print the ">" character.
if (NL) { Serial.print("\r\n>"); NL = false; }
Serial.write(c);
if (c==10) { NL = true; }
}
}

