![]() With a 200 Ohm pull-down resistor, it has shown to me an average of 300 (in a 16-bit scale), which means an equivalent of 0,015V. I’ve experienced that even with nothing attached and the pull-down resistor a small value comes from the Raspberry PI Pico analog PIN. It starts by defining a “noise” variable. This function simply shows a banner in your SSD1306 OLED display that will show the user that the device is ready to test a battery: def open_circ(): Then, a first custom function named open_circ() will handle the moments when no batteries are detected, which means that the circuit is open. If you are using a different analog PIN from your Raspberry PI Pico, please change the related number here: Vin=ADC(26) The following line initializes the PIN to analog and sets the PIN number. In the beginning, we’ll import the required modules: from machine import Pin, I2C, ADC A more detailed explanation of the SSD1306 OLED display is already available in my Add an OLED display to Raspberry PI Pico with MicroPython. The following paragraphs will describe my code line by line. ![]() Please remember that when you’ll need to run the battery checker program without a computer plugged into RPI Pico, you will need to rename the “battery-check.py” file to “main.py” in your Raspberry PI Pico storage. ![]() Moreover, please download my battery-check.py script on your computer and open it with Thonny. You can get it from my download area with the following link: Please download and add the SSD1306.py library in your Raspberry PI Pico root folder, according to Adding external modules to MicroPython with Raspberry PI Pico tutorial. Get OLED Library and Raspberry PI Pico Battery Checker codeĬonnect RPI Pico to Thonny (you can refer to my tutorial about First steps with Raspberry PI Pico). Please find below some pictures from my lab. This resistor will keep the reading low when nothing is connected, not affecting the battery voltage reading. This is common with all the Raspberry PI boards. It’s a pull-down resistor and is used to avoid that the Raspberry PI Pico reads unstable values when nothing is connected. Please note that the wiring includes a 220 Ohm resistor. The following table will help with wiring: RPI Pico GP Please prepare the wiring as shown in the following picture, according to Raspberry PI Pico pinout: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |