Wireless ESP12E Voltmeter Project

 Here a simple ESP12E WiFi module based Wireless digital voltmeter is illustrated.The ESP12E is used to detect voltage using it's analog to digital converter pin. Using this ADC pin we can sample voltage and send the voltage data to PC or Mobile Phone with WiFi connection. Here Processing has been used create a analog type meter with digital value that displays the voltage read.


The following picture shows how the meter looks like when voltage is read.


In this demonstration, ESP12E has been used but any ESP8266/ESP32 can be used. For illustration a 10KOhm is used as an input to the ESP12E Wifi module ADC input channel A0. The tutorial PWM example using ESP8266 ESP12E showed how to read analog input using ESP8266 ADC. This ADC value is sent wirelessly using UDP protocol to the PC or mobile phone where we have set up the voltmeter interface using processing. 

 This project can be useful in getting sensor data and displaying on user interface over wifi network. This can be extended to make different kinds of IoT applications. Here the ESP12E communicates with PC with different IP address on the same network. The ESP12E has IP address of and the PC has IP address of The access point or the router default gateway IP address is The ESP12E wifi module gets voltage input reading from its analog input and using Open Sound Control library wraps the analog value read into UDP packets. This is then sent to the PC using the WiFi network. The port of the PC to which it is send is 9999 which must be specified. The PC runs the voltmeter which is build using processing software. The PC which is running the processing sketch dissembles the received UDP packets and gets the analog value sent which is then displayed by the meter using meter library in processing. The following picture illustrates the wireless network communication using ESP12E and PC.

ESP12E and PC WiFi network communication diagram

Video Demonstration

 The following video demonstrates this. 


The following is the connection of ESP12E wifi module on breadboard with 10KOhm potentiomenter connected to the analog input pin A0.

ESP12E wifi module with potentiometer

Program codes

The following are Arduino sketch and processing sketch to make the WiFi Voltmeter using ESP8266

Arduino Sketch

#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <WiFiManager.h>         //https://github.com/tzapu/WiFiManager

const char ssid[] = "yourSSID";
const char password[] = "yourPASSWORD";

WiFiUDP Udp;                                // A UDP instance to let us send and receive packets over UDP
const IPAddress outIp(192, 168, 1, 103);     // PC Receiver of OSC UDP
const unsigned int outPort = 9999;          // PC receiver port to receive OSC UDP

void setup() {
  //WiFi Connection
   WiFiManager wifiManager;
   Serial.print(F("WiFi connected! IP address: "));

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("*** Disconnected from AP so rebooting ***");


void potRead(){
    int a = analogRead(A0);
   // Send OSC message
    OSCMessage msg("/analog");

    Udp.beginPacket(outIp, outPort);



    Udp.beginPacket(outIp, outPort);


void loop() {


In the above code, in the setup() function, we have made the usual WiFi connection for ESP12E. Since we want use transfer the potentiometer value read using UDP connection we have included the WiFiUdp.h header file and the Open Sound Control OSCMessage.h file. In this we have used the WiFimanager to auto connect to the last IP address if connection fails. Since UDP is not a reliable transport protocol we have used this here. But other wifi connection without WiFimanager library should also work. See for example of other WiFi connection in the tutorials WiFi controlled LED using ESP8266 and Read & Display Switch State on Web Page with ESP8266 Web Server. In the loop() function we call the potRead() function. This potRead reads the potentiometer value and wraps the value into a UDP packet which is then sent over the WiFi connection. To send the value or data using UDP protocol we have used the Open Sound Control library.

Processing Sketch

import oscP5.*;
import netP5.*;
import meter.*;
OscP5 oscP5;

int analogVal;

Meter m;

void setup() {
  size(500, 400);
  //set this to the receiving port
  oscP5 = new OscP5(this,9999);
  m = new Meter(this, 25, 100, true);
  // Meter Scale Design
  String[] fontList = PFont.list();
  m.setTitle("Voltage Range");
  String[] scaleLabelsT = {"0V", "0.25", "0.5", "0.75", "1", "1.25", "1.5", "1.75","2", "2.25", "2.5", "2.75","3", "3.3V"};

void draw() {
  //get values
  float pot = map(analogVal, 0, 1023, 0, 255);
  textAlign(CENTER, CENTER);
  text("ESP12E WiFi Voltmeter",250,50);
  text(nf(pot*(3.3/256), 0, 2)+"V", 250, 350);

// incoming osc message are forwarded to the oscEvent method. 
void oscEvent(OscMessage theOscMessage) {
  if (theOscMessage.addrPattern().equals("/analog")){
    analogVal = theOscMessage.get(0).intValue();

 In the above processing sketch, we have used the open sound control library which requires the network library and the meter library. The open sound control library is used to receive the UDP packet send from the ESP12E wifi module. The meter library is used to make the analog type meter.

Post a Comment

Previous Post Next Post