This knowledge logging system can be utilized to interface an exterior or inside sensor of Raspberry Pi Pico board. The undertaking has many benefits, together with using inside temperature sensor of Raspberry Pi Pico board; so an exterior temperature sensor shouldn’t be required. Second, the simply removable microSD card can be utilized to file completely different temperature knowledge at a specific place or industrial setup. The SD card will be eliminated and carried to laboratory or management room for evaluation or future reference. The undertaking additionally consists of non-compulsory exterior sensors, equivalent to drive and light-weight sensors.
Elements required for the undertaking are given within the Desk under.
The creator’s prototype wired on the breadboard is proven in Fig. 1 and the connection of information logging system with microSD card and Raspberry Pi Pico is proven in Fig. 2. An LDR or every other appropriate analogue sensor, such because the drive sensor proven, could also be used.
The setup makes use of serial peripheral interface (SPI) pins MOSI, MISO, CS, and CLK of Raspberry Pi Pico Board1. Exterior sensor (gentle sensor, gentle dependent resistor, or drive sensor) is related to GP26 pin of Board1.
LDR sensor is used to file gentle situation within the space the place it’s put in. The microSD card module is interfaced with Raspberry Pi Pico board pins GP1, GP3, GP4, and GP5. VBUS from the board is used as energy provide for microSD card and LDR. A 10k pull-down resistor is related to GP26 pin of Board1 for interfacing exterior sensors.
Software program
The undertaking is managed by the Python program developed on Mu editor. Mu editor is a straightforward code editor that works with Adafruit CircuitPython boards, together with Raspberry Pi Pico, and on most working programs, together with Home windows and Linux. CircuitPython relies on Python programming language and is simple to know.
Each Mu and CircuitPython are required for this undertaking. Mu editor will be downloaded from https://codewith.mu after which put in utilizing directions given at hyperlink. After putting in Mu editor, run it and you will notice the window proven in Fig. 3.
CircuitPython model 7.1.1 was used throughout testing of this undertaking. CircuitPython board requires a bootloader referred to as UF2 (USB flashing format) that makes putting in and updating CircuitPython a fast and simple course of. Obtain the latest model of CircuitPython bootloader .UF2 file from click on this hyperlink.
Putting in CircuitPython on the board is simple. Simply copy and paste the file as defined right here. First press the BOOTSEL button on the Raspberry Pi Pico board, whereas inserting the USB cable of the RPI board to laptop computer/PC, and launch it after a brand new drive (RPI-RP2) window seems, as proven in Fig. 4.
Subsequent, copy adafruit-circuitpython-raspberry_pi_pico-en_US-7.1.1.uf2 file downloaded in earlier step. Paste it into the brand new window, as proven in Fig. 5. Now open Mu editor window and shut all different home windows.
Subsequent, the very first thing to do in Mu is to pick out ‘Mode’ from the primary menu. On this undertaking, you must choose RP2040 possibility in Choose Mode window, as proven in Fig. 6.
Begin coding on the Mu editor window or load the present code. You may load the analog_sensor.py code that comes together with this undertaking. This code will work with both LDR or drive sensor however not with each on the identical time.
Join LDR to the circuit, as proven within the schematic, and run the code by clicking Run button. If you cowl the LDR with an opaque object and uncover it once more, you will notice the sunshine depth’s arbitrary values range between 0 and 32, with 0 being the darkest and 32 being the brightest gentle.
A further characteristic of Mu is its potential to show the information waveform. When you choose the Plotter possibility from the primary menu, you will notice the output waveform, as proven in Fig. 7. Equally, you’ll be able to change LDR with every other analogue sensor like drive sensor. The sensor knowledge shall be displayed on the display screen together with the waveform.
Allow us to now discover the inbuilt temperature sensor on Raspberry Pi Pico board and retailer the temperature knowledge on the microSD card that’s usually utilized in your cell phone. Right here, we use CircuitPython libraries together with the primary code (Sdcard_temp_data.py). It is advisable to import adafruit libraries for SD card to interface it with the Raspberry Pi Pico board. For that obtain the libraries (Bundle for Model 7.x) from this hyperlink.
Unzip the Bundle folder and duplicate adafruit_bus_device and adafruit_register folders, paste them into ‘lib’ folder in CIRCUITPY(E) drive. Additionally copy adafruit_sdcard.mpy file from the Bundle folder and paste into ‘lib’ folder, as proven in Fig. 8.
Open Mu editor and cargo the primary code beneath Code.py file. Save the file and run it. If one thing goes mistaken, you’ll get error message on the backside of the Mu editor window. For instance, if SD card shouldn’t be related correctly to the circuit, you’ll get “OSError: no SD card” error message, as proven in Fig. 9.
If every part is okay, as a substitute of error message you will notice following textual content (see Fig. 10) under the Mu editor window: “The primary line of textual content on SD card, Examine temperature knowledge on SD card”
Now, give up Mu editor and unplug the SD card from its adaptor. Insert SD card into the microSD card slot in your laptop computer/PC and test the varied temperature values accessible in textual content file format.
Building and testing
The entire circuit will be assembled on a breadboard or general-purpose PCB. Most Raspberry Pi Pico boards don’t include header pins related or soldered on the boards. With out these pins, the board can’t be interfaced with exterior gadgets, equivalent to sensors, motors, or any gadget required for the undertaking. Wires will be soldered instantly onto the holes supplied on the board, however that may be a bit dangerous as chances are you’ll injury the board.
So, to entry GPIO pins, solder every pin fastidiously utilizing male Berg strip connectors with an applicable soldering iron. You may then both mount the pins on the breadboard or join every pin with jumper wire to different parts or modules.
In spite of everything connections are carried out, recheck appropriate polarities, specifically Vcc and floor pins. Notice that VBUS at pin 40 is often 5V, which is the primary Vcc provide within the circuit. Earlier than inserting the microSD card first format it in FAT32 system and solely then insert it into the slot supplied within the adaptor.
If you plug in your Raspberry Pi Pico to your laptop computer the primary time, Mu editor makes an attempt to auto-detect your board on start-up and searches for CIRCUITPY drive within the board. So, previous to this, be sure that CircuitPython is correctly put in within the drive, as defined above. Subsequent, choose the mode and run the code analog_sensor.py.
Should you get correct sensor output knowledge and waveform, open the primary code by clicking on Load possibility on the primary menu bar. Run the code and ensure you get the output message on the backside of the Mu editor window. You may give up this system and swap off the circuit any time you want to test the sensor knowledge on the SD card from any laptop having microSD card slot.
Obtain supply code
Sani Theo is an electronics fanatic, circuit designer, and technical editor