-
1Solder Header Pins Onto The Adafruit MCP9808 Temperature Sensor
After acquiring the necessary components, the first step is to solder header pins onto the Adafruit MCP9808 temperature sensor, in order to secure a firm connection for data transfer. To accomplish this I used a Weller Soldering Kit, helping hands platform and protective eye goggles.
The soldering process, from start to finish, took me roughly thirty minutes. Although said session was my first ever attempt at soldering. So, depending on your experience level, this step may take less time for you.
After completing this step, to ensure the header pins were properly connected, I removed the newly assembled sensor from the helping hands platform and gently attempted to "wiggle" the header pins loose. To my great delight, my soldering firmly embedded the header pins into the sensor board.
-
2Connect The Adafruit MCP9808 Sensor To The Raspberry Pi Zero 2 WH GPIO Pins
Assuming your soldering of the MCP9808 header pins was successful, the next step is to connect the sensor to your Raspberry Pi Zero 2 WH using four jumper wires. To accomplish this, I used four female-to-female jumper wires purchased online.
Before connecting the jumper wires to either the sensor or the RPi, please make sure your Raspberry Pi computer is powered off. This is to avoid short circuits or accidental damage. As well, your jumper cables should ideally be twelve inches or less in length, to avoid picking up unwanted environmental noise.
Once your preparations for this step are complete, the specific connections you will need to make are as follows:
- VIN (MCP9808) to 3.3V (Pin 1 on the Pi)
- GND (MCP9808) to GND (Pin 6 on the Pi)
- SCL (MCP9808) to GPIO3 (SCL) (Pin 5 on the Pi)
- SDA (MCP9808) to GPIO2 (SDA) (Pin 3 on the Pi)
Make sure the jumper wires you are connecting the temperature sensor to the Raspberry Pi with are snug and well-fit.
-
3Power On The Raspberry Pi Zero 2 WH And Verify The Temperature Sensor Is Detected
With your Adafruit MCP9808 temperature sensor connected to your Raspberry Pi via jumper cables, it is time to power on the RPi computer. Which is accomplished by plugging the correct power cable into the Raspberry Pi 2 WH and letting the unit boot. Once the Raspberry Pi OS has loaded, open a terminal on the Pi, either through direct access with a monitor, keyboard and mouse. Or through a SSH connection from another machine.
The I2C interface needs to be enabled for the Raspberry Pi to communicate with the MCP9808 sensor. Accomplished by running the following command in your open terminal: sudo raspi-config. Then navigate through the menu using your keyboard's arrow keys by first selecting Interfacing Options. Next, select I2C and choose Enable. Press Enter to confirm and exit the configuration tool. Now reboot the Raspberry Pi to apply the changes by running the following command in your terminal: sudo reboot.
To check if the Adafruit MCP9808 sensor is connected, install the i2c-tools package by running the following commands in a new terminal window: sudo apt update and then sudo apt install -y i2c-tools. This package provides tools to scan and communicate with I2C devices. Finally, run the following command in an open terminal window on your Raspberry Pi Zero 2 WH computer to scan I2C devices on bus one: i2cdetect -y 1.
You should see a grid output with 0x18 as the address for the MCP9808 sensor.
-
4Transfer The Associated Python File From Your Development Computer To The Raspberry Pi
Make sure SSH is enabled on the Raspberry Pi Zero 2 WH, and your main development computer has access to the RPi over your local area network. To confirm SSH is active, first enter this command into a Raspberry Pi terminal session: sudo raspi-config. Then select Interfacing Options, followed by Enable SSH.
Working with the assumption you are using Linux as the OS on your development computer, enter the following command: scp /path/to/app.py pi@192.168.1.100:/home/pi/. Making sure to replace "/path/to/app.py" with the correct path to the app.py file. Also use the correct IP address and username, instead of "pi@192.168.1.100". This will place a copy of the Python file onto your Raspberry Pi.
Verify the Python file has been transferred to the Raspberry Pi Zero 2 WH by first entering the following command: ssh pi@192.168.1.100. Again, replacing "pi@192.168.1.100" with the correct username and IP address. Finally, to locate and confirm the app.py file has been transferred, use this command: ls -l ~/app.py.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.