Arduino category

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]

Arduino Weather Station using DHT11

Using a display to view the temperature and humidity of your environment can be possible using the DHT11 or DHT22 sensor with the easy to use Arduino microcontroller platform and that’s the goal of this project. For this project, we will be using the 16×2 LCD display module to display the temperature and humidity readings gathered from the environment using the DHT11 temperature and humidity sensor.

Arduino Weather Station using DHT11 – [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]

WINXI – Arduino ZERO M0 Stick

WINXI – arduino ZERO Pro M0 compatible stick, RGB led, Micro SD, AtSamD21E18. Arduino zero pro compatible board with USB programming suitable for experienced users.

WINXI – Arduino ZERO M0 Stick – [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

Real Time Clock and Temperature Monitor using DS3231 Module

The DS3231 is a very low power RTC chip, it has the ability to keep time with incredible accuracy such that even after power has been disconnected from your product, it can run for years on a connected coin cell battery. This module has the ability to communicate via I2C or SPI but for this tutorial we will be using the I2C mode for communications between our arduino and the DS3231. The module also comes with a quite accurate temperature sensor which we will be using to get temperature readings. The collected temperature and clock data is then displayed on the 16×2 LCD via the Arduino.

Real Time Clock and Temperature Monitor using DS3231 Module – [Link]

BeanDuino Attiny85 – super small Digispark clone

The BeanDuino is an ATtiny85 based microcontroller development board similar to the Arduino line highly inspired by DigiSpark , BeanDuino is hardware compatible with Adafruit Trinket / Gemma.

Specifications:

  • Support for the Arduino IDE 1.0 and later (OS X, Windows, and Linux)
  • Built-in USB
  • 5 I/O pins (2 are used for USB only if your program actively communicates over USB, otherwise you can use all 5 even if you are programming via USB) or 6 I/O pins if you dissable reset fuse
  • 8 KB flash memory (about 6 KB after bootloader)
  • I2C and SPI (vis USI)
  • PWM on 3 pins (more possible with software PWM)
  • ADC on 4 pins
  • Internal temperature sensor
  • On-board PB1 led – no shield required !!!
  • Keyboard or other HID devices emulation (mouse, gamepad …)
  • reset is enabled you can program this board with USBASP or Arduino via ISP you can easy replace/repair/remove bootloader
  • slim design 11×20 mm
  • breadboard compatible

BeanDuino Attiny85 – super small Digispark clone – [Link]

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]

8 Digit Numerical 7 Segment SPI Display Shield for Arduino UNO

8 Digit serial numerical display shield for Arduino has been designed for various applications like digital clock, stop watch, score display, temperature meter, frequency counter, digital meters etc. The circuit uses popular MAX7219 IC and two common cathode 0.5inch red seven segment displays. The MAX7219 is a compact, serial input/output common-cathode display drivers that interface Arduino UNO to 7-segment numeric LED displays of up to 8 digits. Included on-chip are a BCD code-B decoder, multiplex scan circuitry, segment and digit drivers, and an 8×8 static RAM that stores each digit. Only one external resistor R1 provided to set the segment current for all LEDs. A convenient 3-wire serial interface connects to all Arduino UNO. Individual digits may be addressed and updated without rewriting the entire display. The MAX7219 also allows the user to select code-B decoding or no-decode for each digit. The devices include a 150µA low-power shutdown mode, analog and digital brightness control, a scan-limit register that allows the user to display from 1 to 8 digits, and a test mode that forces all LEDs on. The project works with 5V DC and SPI interface connected to Arduino Digital pins D4, D5 and D6.

8 Digit Numerical 7 Segment SPI Display Shield for Arduino UNO – [Link]