Tag Archives: Arduino

Arduino Two-Way Bluetooth Communication Tutorial

Welcome to another Arduino Tutorial! Today we are going to learn how to use Bluetooth to exchange data between two Arduino boards! As a demonstration project, we are going to build a simple weather station. There is a lot to cover so let’s get started!

Arduino Two-Way Bluetooth Communication Tutorial – [Link]

Decoding and Encoding JSON with Arduino or ESP8266

In this blog post you’re going to learn how to decode (parse a JSON string) and encode (generate a JSON string) with the ArduinoJson library using the Arduino with the Ethernet shield. This guide also works with the ESP8266 and ESP32 Wi-Fi modules with small changes.

Decoding and Encoding JSON with Arduino or ESP8266 – [Link]

Control a 12V Lamp via SMS with Arduino

In this tutorial we’re going to show you how you can turn a 12V lamp on and off by sending SMS to your Arduino with the text “ON” and “OFF”, respectively. You can also request the current lamp state by sending an SMS with the text “STATE”, the Arduino should reply back with the text “Lamp is on” or “Lamp is off”

Control a 12V Lamp via SMS with Arduino – [Link]

Get Sensor Data From Arduino To Smartphone Via Bluetooth

Hariharan Mathavan at allaboutcircuits.com designed a project on using Bluetooth to communicate with an Arduino. Bluetooth is one of the most popular wireless communication technologies because of its low power consumption, low cost and a light stack but provides a good range. In this project, data from a DHT-11 sensor is collected by an Arduino and then transmitted to a smartphone via Bluetooth.

Required Parts

  • An Arduino. Any model can be used, but all code and schematics in this article will be for the Uno.
  • An Android Smartphone that has Bluetooth.
  • HC-05 Bluetooth Module
  • Android Studio (To develop the required Android app)
  • USB cable for programming and powering the Arduino
  • DHT-11 temperature and humidity sensor

Connecting The Bluetooth Module

To use the HC-05 Bluetooth module, simply connect the VCC to the 5V output on the Arduino, GND to Ground, RX to TX pin of the Arduino, and TX to RX pin of the Arduino. If the module is being used for the first time, you’ll want to change the name, passcode etc. To do this the module should be set to command mode. Connect the Key pin to any pin on the Arduino and set it to high to allow the module to be programmed.

Circuit to connect HC-05 with Arduino
Circuit to connect HC-05 with Arduino

To program the module, a set of commands known as AT commands are used. Here are some of them:

AT Check connection status.
AT+NAME =”ModuleName” Set a name for the device
AT+ADDR Check MAC Address
AT+UART Check Baudrate
AT+UART=”9600″ Sets Baudrate to 9600
AT+PSWD Check Default Passcode
AT+PSWD=”1234″ Sets Passcode to 1234

The Arduino code to send data using Bluetooth module:

//If youre not using a BTBee connect set the pin connected to the KEY pin high
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(4,5); 
void setup() {
 String setName = String("AT+NAME=MyBTBee\r\n"); //Setting name as 'MyBTBee'
 Serial.begin(9600);
 BTSerial.begin(38400);
 BTSerial.print("AT\r\n"); //Check Status
 delay(500);
 while (BTSerial.available()) {
 Serial.write(BTSerial.read());
 }
 BTSerial.print(setName); //Send Command to change the name
 delay(500);
 while (BTSerial.available()) {
 Serial.write(BTSerial.read());
 }}
void loop() {}

Connecting The DHT-11 Sensor

To use the DHT-11, the DHT library by Adafruit is used. Go here to download the library. When the letter “t” is received, the temperature, humidity, and heat index will be transmitted back via Bluetooth.

circuit to connect DHT-11 with Arduino
circuit to connect DHT-11 with Arduino

The code used to read data from the DHT sensor, process it and send it via Bluetooth:

#include "DHT.h"
#define DHTPIN 2 
#define DHTTYPE DHT11 
DHT dht(DHTPIN, DHTTYPE);
void setup() {
 Serial.begin(9600);
 dht.begin();}

void loop()
{ char c; 
if(Serial.available()) 
 { 
 c = Serial.read(); 
 if(c=='t')
 readSensor();
 }}
void readSensor() {
 float h = dht.readHumidity();
 float t = dht.readTemperature();
 if (isnan(h) || isnan(t)) {
 Serial.println("Failed to read from DHT sensor!");
 return;
 }
 float hic = dht.computeHeatIndex(t, h, false);
 Serial.print("Humidity: ");
 Serial.print(h);
 Serial.print(" %\t");
 Serial.print("Temperature: ");
 Serial.print(t);
 Serial.print(" *C ");
 Serial.print("Heat index: ");
 Serial.print(hic);
 Serial.print(" *C ");
}

Developing The Android App

The flow diagram of the Android app is illustrated below,

Flow diagram of the Android app
Flow diagram of the Android app

As this app will be using the onboard Bluetooth adapter, it will have to be mentioned in the Manifest.

uses-permission android:name="android.permission.BLUETOOTH"

Use the following code to test if Bluetooth adapter is present or not,

BluetoothAdapter bluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
if (bluetoothAdapter == null) {
Toast.makeText(getApplicationContext(),"Device doesnt Support Bluetooth",Toast.LENGTH_SHORT).show();
}

The following part of the code deals with reading the data,

int byteCount = inputStream.available();
 if(byteCount > 0)
 {
 byte[] rawBytes = new byte[byteCount];
 inputStream.read(rawBytes);
 final String string=new String(rawBytes,"UTF-8");
 handler.post(new Runnable() {
 public void run()
 {
 textView.append(string);
 }
 });
 }

To send data, pass the String to the OutputStream.

outputStream.write(string.getBytes());

The complete source code of the Android application can be downloaded from here.

Testing

Power up the Arduino and turn on the Bluetooth from your mobile. Pair with the HC-05 module by providing the correct passcode – 0000 is the default one. Now, when “t” is sent to the Arduino, it replies with the Temperature, Humidity, and Heat Index.

the application screen
the application screen

Attiny Programmer (using Arduino UNO)

by @ instructables.com:

The Arduino UNO is small, but if you require your project to be in a small enclosure, the UNO might be way too big. You could try using a NANO or MINI, but if you really want to go small, you go tiny, Attiny to be precise.

They are quite small, cheap chips (basically small Arduinos) and can be programmed in the Arduino IDE, however you might notice that there is no USB connection. So how do we program it???

Attiny Programmer (using Arduino UNO) – [Link]

STM32 Arduino Tutorial – How to use the STM32F103C8T6 board with the Arduino IDE

In this Arduino Tutorial, we are going to take a first look at the STM32 Arduino Compatible Board. This board is powerful and inexpensive. Let’s see what it has to offer!

STM32 Arduino Tutorial – How to use the STM32F103C8T6 board with the Arduino IDE – [Link]

FemtoUSB Board (Atmel ARM Cortex M0+)

Arduino compatible, Atmel SAM D21 chip, open source!

This is one of the smallest ARM powered boards in the world. If you are ready to transition away from AVR 8-bit hardware to the very powerful ARM 32-bit stuff, this is the way to learn! The board design, schematic, and parts lists are completely open-source.

FemtoUSB Board (Atmel ARM Cortex M0+) – [Link]

Arduino compatible high precision frequency counter

The concept of this board is to build an open, very versatile frequency counter, so it can be used to measure a wide variety of signals. It is designed to be customizable in every possible way.

Freq_LF_HF v1.0 board uses the famous AVR microcontroler Atmega328p-AU. This is not the newest ATMEL model but this chip is standard on Arduino UNO v3.0 board. It is a powerfull microcontroller and very small (TQFP- 32). This gives the opportunity for users to benefit from the Arduino community support and the many software libraries. The firmware uses a couple of the wonderfull functionnalities of this chip, namely the 16 bits timer, interrupts and comparator to an external precision voltage reference.

Meet Spritzer, Sony New Arduino

Sony has recently launched one of its new products, Spritzer! Spritzer is an Arduino-compatible board for IoT applications that has built-in GPS, audio codec, and low power consumption.

While it is Arduino-compatible, the board allows any developer to easily start app development using the free Arduino IDE and an ordinary USB cable. In fact, the board features a processing chip with a unique combination of low power consumption and a rapid clock speed of 156MHz. Thus, it is extremely versatile and it can be deployed for a vast range of use cases.

For the first time, the company demonstrated the board at Tokyo Maker Faire last month with a drone utilizing the GPS and the 6-axis sensor support, a smart speaker utilizing the audio functions, a self-driving line-tracing miniature car, and a low-power smart sensing IoT camera using the camera interface of Spritzer.

Sony Spritzer specifications

  • MCU – Sony CDX5602 ARM Cortex-M4F ×6 micro-controller clocked at up to 156 MHz with 1.5MB SRAM
  • Storage – 8MB Flash Memory, micro SD card
  • GNSS – GPS, GLONASS, supported
  • Audio – 3.5mm audio jack
  • Expansion I/Os
    • Digital I/O Pins – SPI, I2C, UART, PWM ×4 (3.3V)
    • Analog Pins – 6ch (3.3V range)
    • Audio I/O – 8ch Digital MICs or 4ch Analog MICs, Stereo Speaker, I2S, CXD5247 audio codec with 192 kHz/24bit High-Resolution audio
    • 2x camera interfaces
  • USB – 1x micro USB port for programming
Spritzer Block Diagram

“You’ll have to connect external module to get Bluetooth, WiFi, and LTE, a display up to 360×240 resolution can be used via SPI, all sort of sensors can be connected via the expansion header, the board is suitable for microphone arrays, and it can be powered by batteries thanks to a charger circuit and fuel gauge inside CXD5247 audio codec / PMU chip.” – CNXSoft

More details about the board will be available by 2018. Until then, check this Japanese official page about Spritzer, or this translated page.

Learn Arduino Easily with The Arduino Inventor’s Guide

Are you looking for Arduino tutorials? Already over-whelmed by the guides and videos available on the internet? Sparkfun is making Arduino and electronics easier for you with its new book ” The Arduino Inventor’s Guide”!

First of all, the authors of this book , Brian Huang and Derek Runberg, are both working in the department of Education at SparkFun Electronics. Since they are experienced in electronics and educating engineering in schools, they are working towards making electronics easy and fun.

In fact, this 10-project guide is a project-packed introduction to building and coding with Arduino microcontroller. With each hands-on project, total beginners learn useful electronics and coding skills while building an interactive gadgets. Accordingly, this guide is within the introductory-level educational series introduced by No Starch Press and Sparkfun.

“We wanted to share the magic that happens when you build something interactive with electronics,” says Huang. “The goal is to teach real, valuable hardware skills, one project at a time,” adds Runberg.

Content of the book

  • Introduction
  • Electronics Primer
    101 electronics
  • Project 1: Getting Started with Arduino
    Blinking an LED
  • Project 2: A Stoplight for Your House
    A miniature traffic light
  • Project 3: The Nine-Pixel Animation Machine
    An LED screen that displays animated patterns and shapes
  • Project 4: Reaction Timer
    A fast-paced button-smashing game to test your reflexes
  • Project 5: A Color-Mixing Night-Light
    A light-sensitive, color-changing night-light
  • Project 6: Balance Beam
    A challenging ball-balancing game
  • Project 7: Tiny Desktop Greenhouse
    A temperature-sensing mini greenhouse with an automated fan and vent
  • Project 8: Drawbot, the Robotic Artist
    A motorized robot that you can control
  • Project 9: Drag Race Timer
    A racing timer for toy cars
  • Project 10: Tiny Electric Piano
    A tiny electric piano that you can actually play!
  • Appendix: More Electronics Know-How

Reviews

The Arduino Inventor’s Guide will appeal to the gadget freak as well as those who like to put their own spin on things.” —Microcontroller Tips

“This is probably the best Arduino starter book out there! I highly recommend it for every library and classroom.” —Sequential Tart

To sum up, the book is available for $30 on No Starch Press as a printed book and for $25 as an Ebook. In addition, you can check this page for more insights. Also download Project 2: A Stoplight for Your House, and the sketches, templates, and diagrams used in this book.