We can connect HM-10 Bluetooth 4.0 BLE module to PC using FTDI USB-Serial adapter, via USB serial. Such that we can test it by sending AT command using terminal, such as Serial Monitor in Arduino IDE.
Connection:
HM-10 VCC - separated 3.3V
HM-10 GND - FTDI GND
HM-10 Tx - FTDI Rx
HM-10 Rx - FTDI Tx
(both HM-10 and FTDI adapter operate on 3.3V).
- Connect FTDI adapter to PC, via USB adapter.
- Run Arduino IDE, select correct port to FTDI adapter.
- Start Serial Monitor, set baud rate of 9600, and No line ending.
- Supply power (3.3V) to HM-10. Its on-board LED will blink.
- Then you can enter AT command in Arduino Serial Monitor.
By default, the service UUID and Characteristic of HM-10 are:
- Service UUID: 0xFFE0
- Characteristic: 0xFFE1
It can be referenced in HM-10 document. Or obtain from devices using AT command:
(you can set both service UUID and Characteristic using AT command also)
- Query service UUID: AT+UUID?
- Query Characteristic: AT+CHAR?
- document of HM-10 can be downloaded from http://www.jnhuamao.cn, it provide Chinese and English version, *please notice that the site maybe reported containing malware, so I download it in VirtualBox.
AltSoftSerial is a software emulated serial library for Arduino boards, using hardware timers for improved compatibility.
AltSoftSerial is particularly useful when simultaneous data flows are needed. It is capable of running up to 57600 baud on 16 MHz AVR with up to 9 µs interrupt latency from other libraries. Slower baud rates are recommended when other code may delay AltSoftSerial's interrupt response by more than 9 µs.
AltSoftSerial Library can be installed to Arduino IDE using Library Manager.
This post show how to program and run standalone ESP8266/ESP-12 WiFi module. To program ESP8266 board with Arduino, we have to "Install ESP8266 Board to Arduino IDE".
Connect USB-to-Serial adapter to ESP8266/ESP-12 board, FT232RL module is used in this example.
To program ESP8266 board, press the button to connect GPIO0 to GND. Because there are no RTS in my FT232RL module, so I have to power OFF and ON to reset ESP8266 before programming.
Once programmed, power off the board, press the button to release GPIO0, then power on again to run in standalone.
Updated@2015-11-15:
My setup have no RTS, so I add a button to reset the ESP-12 manually.
With ESP8266 Board installed on Arduino IDE, we can program ESP8266 modules as a standalone microcontroller/board, as simple as program Arduino.
Installing with Boards Manager
Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. The ESP8266 packages available for Windows, Mac OS, and Linux (32 and 64 bit).
Install Arduino 1.6.5 from the Arduino website.
Start Arduino and open Preferences window.
Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
In current Arduino Software (IDE) 1.6.5, Arduino Due is not in default Board list. To install Arduino Due:
> Tools > Board > Boards Manager
> Select to install the item for Arduino Due
You can download ZIP file from the library web page, and it to Arduino library, read the video below. After library added, it will be in the folder your_Documents\Arduino\libraries\,
and fritzing parts is in your_Documents\Arduino\libraries\rfid-master\doc\fritzing\.
Connect Arduino Uno and RFID-RF522 module:
In Arduino IDE, Open Example of DumpInfo in MFRC522:
/*
* ----------------------------------------------------------------------------
* This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid
* for further details and other examples.
*
* NOTE: The library file MFRC522.h has a lot of useful info. Please read it.
*
* Released into the public domain.
* ----------------------------------------------------------------------------
* Example sketch/program showing how to read data from a PICC (that is: a RFID
* Tag or Card) using a MFRC522 based RFID Reader on the Arduino SPI interface.
*
* When the Arduino and the MFRC522 module are connected (see the pin layout
* below), load this sketch into Arduino IDE then verify/compile and upload it.
* To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M).
* When you present a PICC (that is: a RFID Tag or Card) at reading distance
* of the MFRC522 Reader/PCD, the serial output will show the ID/UID, type and
* any data blocks it can read. Note: you may see "Timeout in communication"
* messages when removing the PICC from reading distance too early.
*
* If your reader supports it, this sketch/program will read all the PICCs
* presented (that is: multiple tag reading). So if you stack two or more
* PICCs on top of each other and present them to the reader, it will first
* output all details of the first and then the next PICC. Note that this
* may take some time as all data blocks are dumped, so keep the PICCs at
* reading distance until complete.
*
* Typical pin layout used:
* -----------------------------------------------------------------------------------------
* MFRC522 Arduino Arduino Arduino Arduino Arduino
* Reader/PCD Uno Mega Nano v3 Leonardo/Micro Pro Micro
* Signal Pin Pin Pin Pin Pin Pin
* -----------------------------------------------------------------------------------------
* RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
* SPI SS SDA(SS) 10 53 D10 10 10
* SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
* SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
* SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15
*/
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9 //
#define SS_PIN 10 //
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, type, and data blocks..."));
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
void ShowReaderDetails() {
// Get the MFRC522 software version
byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
Serial.print(F("MFRC522 Software Version: 0x"));
Serial.print(v, HEX);
if (v == 0x91)
Serial.print(F(" = v1.0"));
else if (v == 0x92)
Serial.print(F(" = v2.0"));
else
Serial.print(F(" (unknown)"));
Serial.println("");
// When 0x00 or 0xFF is returned, communication probably failed
if ((v == 0x00) || (v == 0xFF)) {
Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
}
}
Due to any reason, you cannot install the Arduino driver on Windows, you can try to update the driver manually in your Device Manager.
Plug in your board and wait for Windows to begin it's driver installation process. After a few moments, the process will fail, despite its best efforts
Click on the Start Menu, and open up the Control Panel.
While in the Control Panel, navigate to System and Security. Next, click on System. Once the System window is up, open the Device Manager.
Look under Ports (COM & LPT). You should see an open port named "Arduino UNO (COMxx)". If there is no COM & LPT section, look under "Other Devices" for "Unknown Device".
Right click on the "Arduino UNO (COmxx)" port and choose the "Update Driver Software" option.
Next, choose the "Browse my computer for Driver software" option.
Finally, navigate to and select the driver file named "arduino.inf", located in the "Drivers" folder of the Arduino Software download (not the "FTDI USB Drivers" sub-directory). If you are using an old version of the IDE (1.0.3 or older), choose the Uno driver file named "Arduino UNO.inf"
Windows will finish up the driver installation from there.
Arduino co-founder Massimo Banzi introduces Atmel Studio 7 and one of its unique features, which enables Makers and designers to import their Arduino sketches and then debug their code.
Atmel Studio 7 is free of charge and is integrated with the Atmel Software Framework (ASF)—a large library of free source code with 1,600 project examples. ASF strengthens Atmel Studio by providing, in the same environment, access to ready-to-use code that minimizes much of the low-level design required for projects. Standard IDEs are suited for creating new software for an MCU project. In addition to this, the Atmel Studio 7 IDP also:
Facilitates reuse of existing software and, by doing so, enables design differentiation.
Supports the product development process with easy access to integrated tools and software extensions through Atmel Gallery.
Reduces time to market by providing advanced features, an extensible software eco-system, and powerful debug integration.
One of the benefit for Arduino developer is Atmel Studio 7 features seamless one-click import of projects created in the Arduino development environment. Your sketch, including any libraries it references, will be imported into Studio 7 as a C++ project. Once imported, you can leverage the full capabilities of Studio 7 to fine-tune and debug your design. Atmel Studio 7 fully supports the powerful embedded debugger on the Arduino Zero board. For other Arduino boards, shield-adapters that expose debug connectors are available, or switch to one of the many available Xplained-Mini/PRO boards to fully leverage the Atmel HW eco-system. Regardless of what you choose, you will surely make something amazing.
An introduction to Atmel Studio 7, the free integrated development environment (IDE) for MCU development using Atmel | SMART ARM-based and AVR MCUs.
Host development platform:
OS: Windows 10
IDE: NetBeans IDE 8.0.2
Programming Language: Java + JavaFX + jSSC
Target platform:
Raspberry Pi 2
OS: Raspbian
IP: 192.168.1.112
Both Host development platform and Target platform in the same Network.
(How to set Remote Java SE Platform to deploy on Raspberry Pi, refer to the video in the post "Java + JavaFX + jSSC run on Raspberry Pi, control Arduino Uno")
remark: due to something wrong on my Raspberry Pi 2 cannot detect monitor correctly, I have to edit /boot/config.txt to set framebuffer_width and framebuffer_height to 500x400. So the screen output may be differency to you.
Arduino Side:
Board: Arduino Uno + 8x8 LED Matrix
Connected to Raspberry Pi 2 with USB. Arduino Side:
Arduino code and connection between Arduino Uno and 8x8 LED Matrix, refer last post.
Java/JavaFX/jSSC code, program on Windows 10/NetBeans, run on Raspberry Pi 2:
(Basically same as last post, with moving btnExit to vBoxMatrix, such that user can exit the program in raspberry Pi UI.
It's a example to control Arduino Uno + 8x8 LED Matrix, from USB connected PC running Windows 10, programmed with Java + JavaFX + jSSC(java-simple-serial-connector).
Arduino Side:
Connection between Arduino Uno and 8x8 LED:
UnoSerialInMatrix.ino
// 2-dimensional array of row pin numbers:
const int row[8] = {
2, 7, 19, 5, 13, 18, 12, 16
};
// 2-dimensional array of column pin numbers:
const int col[8] = {
6, 11, 10, 3, 17, 4, 8, 9
};
// 2-dimensional array of pixels:
int pixels[8][8];
int incomingByte = 0;
void setup() {
// initialize the I/O pins as outputs
// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(col[thisPin], OUTPUT);
pinMode(row[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(col[thisPin], HIGH);
}
clearScr();
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
doProcess(incomingByte);
}
// draw the screen:
refreshScreen();
}
const int SYNC_WORD = 0xFF;
const int ST_0_IDLE = 0;
const int ST_1_WAITX = 1;
const int ST_2_WAITY = 2;
const int ST_3_WAITB = 3;
int prc_State = ST_0_IDLE;
int dotX, dotY, dotB;
void doProcess(int b){
switch(prc_State){
case ST_0_IDLE:
if(b == SYNC_WORD){
prc_State = ST_1_WAITX;
Serial.println("1");
}
break;
case ST_1_WAITX:
dotX = b;
prc_State = ST_2_WAITY;
Serial.println("2");
break;
case ST_2_WAITY:
dotY = b;
prc_State = ST_3_WAITB;
Serial.println("3");
break;
case ST_3_WAITB:
if(b == 1){
pixels[dotY][dotX] = LOW;
}else{
pixels[dotY][dotX] = HIGH;
}
prc_State = ST_0_IDLE;
Serial.println("0");
break;
default:
prc_State = ST_0_IDLE;
}
}
void clearScr(){
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
pixels[x][y] = HIGH;
}
}
}
void refreshScreen() {
// iterate over the rows (anodes):
for (int thisRow = 0; thisRow < 8; thisRow++) {
// take the row pin (anode) high:
digitalWrite(row[thisRow], HIGH);
// iterate over the cols (cathodes):
for (int thisCol = 0; thisCol < 8; thisCol++) {
// get the state of the current pixel;
int thisPixel = pixels[thisRow][thisCol];
// when the row is HIGH and the col is LOW,
// the LED where they meet turns on:
digitalWrite(col[thisCol], thisPixel);
// turn the pixel off:
if (thisPixel == LOW) {
digitalWrite(col[thisCol], HIGH);
}
}
// take the row pin low to turn off the whole row:
digitalWrite(row[thisRow], LOW);
}
}