Skip to content

Non-blocking ESP32 implementation for reading digital dial gauges and meters

License

Notifications You must be signed in to change notification settings

rubegartor/CaliperRead

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dial / Caliper Reader

Example of digital dial/caliper indicator reader implemented on an ESP32 with non-blocking code

It will output though Serial connection the result in mm (respect the International System of Units, fuck the inches)

How it works 🚀

To carry out the tests, the following material was used:

Logic Analyzer tests

0.00mm test:

0.0mm

1.75mm test: 0.0mm

Time between readings: timing

How to decode bit buffer:

First, we need to convert the pulses into a sequence of bits (first bit of sequence is ignored), then a for loop is used to loop through each element of the buff array. If the value at the current position of the buff array is equal to 1 (HIGH), the corresponding bit is set to val using the bit shift operator (<<) and the bitwise OR operator (|). For negative readings, the bit in position 20 is used, if it is equal to 1 (HIGH) it will be a negative value.

1.75_draw

// Code to perform manual calculation

#define BUFFER_SIZE 23

uint8_t buff[BUFFER_SIZE] = { 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

void setup() {
  Serial.begin(115200);

  delay(1000); 

  int16_t val = 0;

  for (uint8_t i; i < BUFFER_SIZE; i++) {
    if (buff[i] == 0x1) {
      val |= 1 << i;
    }
  }

  Serial.println(val / 100.00);
}

void loop() {}

Output will be:

1.75

Authors ✒️

License 📄

This project is under the GPL-3.0 license - LICENSE.MD for more details

About

Non-blocking ESP32 implementation for reading digital dial gauges and meters

Resources

License

Stars

Watchers

Forks

Languages