element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Community Hub
Community Hub
Member Blogs The simplest Capacitance sensor, simplified.
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Community Hub to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: SensoredHacker0
  • Date Created: 30 May 2024 7:10 PM Date Created
  • Views 355 views
  • Likes 3 likes
  • Comments 1 comment
  • capacitor
  • arduino nano
  • arduino
Related
Recommended

The simplest Capacitance sensor, simplified.

SensoredHacker0
SensoredHacker0
30 May 2024

Not Gonna lie, Im a big fan of what Mirko Pavleski does, and when I saw his simple capacitance sensor I knew I had to build my very own.
Right away, I noticed He is using an LCD screen that isnt in my stock pile, and Im not about to add another to my collection, when I already have a box full of them.

If you already have a ST7565 LCD screen, maybe just follow his instructions, I'm sure they'll work.
https://www.hackster.io/mircemk/how-to-make-simplest-possible-autorange-capacitance-meter-ea7f00

<br>
when I looked at Mirko's code, it reminded me of the way I used to code. The only comments are that which has been commented out. I'm not claiming to have wrote better code, only that what I wrote is more easily understandable to me.

<br>Anyway, the hardware I have on hand is a bunch of I2C LCD backpacks from adafruit, and a pile of 16x2 LCD panels. Some with back lights, others not.

It took me about an hour to figure out what Mirko's code is doing, and to make my initial conversion code. Once I figured it out, I wanted to approach it a bit differently, in a simpler sort of way.

So I'm using the fact that the line length is 16, and results from the Capacitor library are never longer than 7 digits. Also, units are always in ( F ) Farads.




#include <Adafruit_LiquidCrystal.h>
#include <Capacitor.h>
Capacitor cap1(7,A2);  //both are 6th pin in from usb conector

Adafruit_LiquidCrystal lcd(0); //i2c lcd init
void clrLine();   //clear line 1
void setup() {
  //using adafruit i2c Lcd
  Serial.begin(115200);
 
    // set up the LCD's number of rows and columns:
  if (!lcd.begin(16, 2)) {
    Serial.println("Could not init backpack. Check wiring.");
    while(1);
  }
  Serial.println("Backpack init'd.");
  lcd.setBacklight(HIGH);  
  lcd.print("CAPACITANCE");
}
void loop(){
  float CPM = cap1.Measure(); //Cin pF
  if(CPM<1){
    Serial.println("No Connection");
    lcd.setCursor(0,1);
    lcd.print("NOT CONNECTED");
    }
  if(CPM < 1000 && CPM >= 1){
    Serial.print(CPM);
    Serial.println("pF");
    lcd.setCursor(0,1);
    lcd.print(CPM);
    lcd.setCursor(6,1);
    lcd.print("  pF   ");
    }
  if(CPM >= 1000 && CPM < 1000000){
    Serial.print(CPM);
    Serial.println("nF");
    lcd.setCursor(0,1);
    lcd.print(CPM);
    lcd.setCursor(6,1);
    lcd.print("  nF   ");
    }
  if(CPM >= 1000000){
    Serial.print(CPM);
    Serial.println("uF");
    lcd.setCursor(0,1);
    lcd.print(CPM);
    lcd.setCursor(6,1);
    lcd.print("  uF   ");
    }  
    delay(800); //slow down
  }

Still not a lot of comments, ok fine.
Could I make this code even simpler?
yeah maybe, but I like using libraries, and I think this code is a lot easier to read.

Still trying to make a box up for this thing. This project was also an excuse to weed through my LCD screens, and see what works.

I made a variant using a Vellman vma203 and an arduino Uno, because Making a case for it seemed easier.
Vellman VMA203 LCD capacitance meter, reading not connected. Looser OP forgot to bust out the probe leads from the case.


Here is a github repo for this project. Ill probably make the same number of variants, as LCD screens I have.

https://github.com/FOSSBOSS/TestCap/

  • Sign in to reply
  • shabaz
    shabaz over 1 year ago

    Interesting project.

    Possibly one thing worth modifying, is the text, from:

    CAPACITANCE
    NOT CONNECTED

    to:

    DISCHARGE CAP
    BEFORE CONNECT!
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube