Arduino-based Bluetooth Voltmeter

    Hello, Habr! Today I want to continue the theme of "crossbreeding" arduino and android. In a previous publication I talked about a bluetooth machine , and today we will talk about a DIY bluetooth voltmeter. Another such device can be called a smart voltmeter, “smart” voltmeter or just a smart voltmeter, without quotes. The latter name is incorrect from the point of view of the grammar of the Russian language, however, it is often found in the media. Voting on this topic will be at the end of the article, but I propose to start by demonstrating the operation of the device in order to understand what will be discussed in the article.

    Disclaimer: the article is designed for the average arduino fan, who is usually not familiar with programming for android, therefore, as in the previous article, we will do a smartphone application using the visual development environment of android applications App Inventor 2.
    To make a DIY bluetooth voltmeter we need write two relatively independent programs: a sketch for arduino and an android application. Let's start with the sketch.
    To begin with, you should know that there are three main options for measuring voltage using an arduino, regardless of where you want to output information: to a com port, to a screen connected to an arduino, or to a smartphone.
    The first case: voltage measurements up to 5 volts. Here one or two lines of code are enough, and the voltage is supplied directly to pin A0:
    int value = analogRead (0); // read the readings from A0
    voltage = (value / 1023.0) * 5; // only true if Vcc = 5.0 volts.
    Second case: a voltage divider is used to measure voltages greater than 5 volts. The scheme is very simple, the code too.

    Sketch
    int analogInput = A0;
    float val = 0.0;
    float voltage = 0.0;
    float R1 = 100000.0; // Battery Vin-> 100K -> A0
    float R2 = 10000.0; // Battery Gnd -> Arduino Gnd and Arduino Gnd -> 10K -> A0
    int value = 0;

    void setup () {
    Serial.begin (9600);
    pinMode (analogInput, INPUT);
    }

    void loop () {
    value = analogRead (analogInput);
    val = (value * 4.7) / 1024.0;
    voltage = val / (R2 / (R1 + R2));
    Serial.println (voltage);
    delay (500);
    }

    Arduino Uno
    Bluetooth module
    Third case. When you need to get more accurate about voltage, you need to use not the supply voltage, which can change a little when powered by battery, for example, but the voltage of the internal arduino stabilizer is 1.1 volts. The circuit is the same, but the code is slightly longer. I will not analyze this option in detail, since it is already well described in thematic articles, and the second method is quite enough for me, since I have stable power supply from the laptop’s usb port.
    So, we figured out the voltage measurement, now let's move on to the second half of the project: creating an android application. We will make the application directly from the browser in the visual development environment of Android applications App Inventor 2. We go to the site appinventor.mit.edu/explore, log in using your Google account, click the create button, new project, and by simply dragging and dropping the elements we create something like this:
    I made the graphics very simple, if someone wants more interesting graphics, I’ll remind you to use instead of .jpeg files, .png files with a transparent background.
    Now go to the Blocks tab and create the application logic there like this:

    If everything works out, you can click the Build and save .apk to my computer buttons, and then download and install the application on your smartphone, although there are other ways to fill in the application. here it’s more convenient for anyone. As a result, I got such an application:

    I understand that few people use the App Inventor 2 android application visual development environment in their projects, so many questions may arise about working in it. To remove some of these questions, I made a detailed video on how to make such an application “from scratch” (to view you need to go to YouTube):

    PS A collection of more than 100 training materials on arduino for beginners and pros here
    PPS An online course on arduino at the clock here.
    Well, in conclusion, the vote I promised at the beginning of the article.

    Only registered users can participate in the survey. Please come in.

    What is the most correct name for such a device?

    • 86.6% bluetooth voltmeter 208
    • 8.7% smart voltmeter 21
    • 4.1% smart 10 voltmeter
    • 0.8% smart voltmeter 2
    • 3.3% own version in comments 8

    Also popular now: