Create Android App Using MIT App Inventor With Blynk API

How to use Blynk without Blynk app?

Introduction

Blynk app is very popular among students in IoT (Internet of Things) project development. However, since it is very easy to use, it makes your project looks simple. Yes, you can create your own app, server, API, but it will take time, and require a lot of resources too. So we try to make it not too easy and not too hard. We create our own app using MIT App Inventor with Blynk API. It means, you create app, but still using Blynk server and API.

This tutorial require basic knowledge for:

  • Raspberry Pi – Know how to start, connect to the internet and access your Pi.
  • Blynk – Register to get Blynk Authentication Token, familiar with the layout and know about Blynk virtual pin.
  • MIT App Inventor – Register, familiar with the layout and know how to connect to your Android phone.

Video

This video shows how to create Android App Using MIT App Inventor With Blynk API.

Hardware Preparation

This is the list of items used in the video

Sample Program

Program your Raspberry Pi with following code. Before that, please install python3 library for Blynk and DHT22 module using command line in Terminal.

sudo pip3 install blynk-library-python

git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo python3 setup.py install
from gpiozero import LED
import Adafruit_DHT
import BlynkLib
from time import time
# Initialize Blynk
BLYNK_AUTH = 'YourBlynkAuthToken'
blynk = BlynkLib.Blynk(BLYNK_AUTH)
led8 = LED(19)
sensor_type = Adafruit_DHT.DHT22
sensor_pin = 17
# Register Virtual Pins
@blynk.VIRTUAL_WRITE(0)
def my_write_handler(value):
v0 = int(format(value[0]))
print('Current V0 value: {}'.format(v0))
led8.value = v0
def sendSensorData():
humidity, temperature = Adafruit_DHT.read_retry(sensor_type, sensor_pin)
print('Humidity = {:.2f}%\tTemperature = {:.2f}C'.format(humidity, temperature))
blynk.virtual_write(1, '{:.2f}'.format(temperature))
blynk.virtual_write(2, '{:.2f}'.format(humidity))
prevTime = 0
interval = 2
try:
while True:
blynk.run()
if time() prevTime > interval:
sendSensorData()
prevTime = time()
except KeyboardInterrupt:
sys.exit(0)

view raw
BlynkDHT22.py
hosted with ❤ by GitHub

For Android App, please download following file and open it using MIT App Inventor.

Note: To connect to your Android phone, you need to install MIT AI2 Companion app.

Thank You

References:

Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

2 thoughts on “Create Android App Using MIT App Inventor With Blynk API”

  1. madhu brahmankar

    When I am using the app the button is working until I am using it constantly. when I am leaving it for a while the on and off of led is not taking place

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Rainbow Spark in Mini House using Maker Uno.
TinyML on Arduino using Edge Impulse
Tutorials of Cytron Technologies Scroll to Top