How to Receive Water Temperature Data in Real-Time Using Raspberry Pi and Python
During this COVID-19 pandemic, my favorite activity at home is watching my fish. I love watching my clownfish rubbing his body against corals, goby sifting sand, and cleaner shrimp cleaning the rock. When I first set up my saltwater aquarium, one of my biggest concerns, was a heater. Since fish are sensitive to temperature changes, I wanted to buy a perfect heater for them. However, it wasn’t so easy (I read so many reviews about “cooked” fish!). For this reason, I decided to set up a system where I can get the water temperature of my aquarium in real-time using Raspberry Pi and Python.
In this article (Part I), I will explain how I connected my Raspberry Pi to my Mac using Wi-Fi. In the next article (Part II), I will demonstrate how I used the DS18B20 Temperature Sensor, Raspberry Pi, and Python to receive real-time water temperature data.
That being said, let’s start!
II. Download Software
- Raspberry Pi OS (https://www.raspberrypi.org/software/operating-systems/)
- SD Card Formatter (https://www.sdcard.org/downloads/formatter/eula_mac/index.html)
- Etcher (https://www.balena.io/etcher/)
- Angry IP Scanner (https://angryip.org/download/#mac)
- VNC Viewer (https://www.realvnc.com/en/connect/download/viewer/)
III. Format an SD Card
Once you download all the software, insert your SD card into your computer, open your SD Card Formatter, and click “Format”. You can choose your card under “Select card” if you have multiple SD cards. I labeled mine “boot”.
Now, we are going to open balenaEtcher. Select “Flash from file” and click the zip file you downloaded from the Raspberry Pi website (“2020–08–20-raspios-buster-armhf”). Target will be your SD card. Click “Flash!”.
IV. Create “ssh” text file in your SD card
When you are done with formatting your SD card, click your SD card (in my case “boot”) and create a blank text file named “ssh”.
V. Create wpa_supplicant.conf file in your SD card
Here is the important part. We need to make sure our laptop and Raspberry Pi are in the same network. Create a text file containing the following script. Don’t forget to include your Wifi/Hotspot name and password in the script.
ssid="Wifi or Hotspot Name"
psk="Wifi or Hotspot Password"
Once you are done, take your SD card from your laptop and insert it into your Raspberry Pi, and power your Raspberry Pi as shown below.
VI. Scan your IP Address
Windows users often use Advanced IP Scanner to scan IP address, but since I’m a Mac user, I used Angry IP Scanner.
Finding an IP address in Mac is quite easy (System Preferences → Network →TCP/IP)
Once you find your IP address, open Angry IP Scanner. Change the last digit to 1 and 254, and type them in the IP Range respectively. If everything is correctly done, you will see “raspberrypi.local” and its IP address as shown below.
VII. Access your Raspberry Pi using Terminal
Now that we have our Raspberry Pi IP address, we can access it.
Go to your terminal and paste the following script.
ssh email@example.com *your raspberry pi IP address*
Terminal will ask you for the password. The default password for Raspberry Pi is “raspberry”.
When you see “pi@raspberrypi” in green, use the following script to configure.
Let’s enable some items. When the below screen pops up, go to “Interface Options”.
Click “P2 SSH” and enable SSH.
It is always nice to see the desktop of our Raspberry Pi — Let’s also enable VNC. With VNC viewer, we will be able to remotely access/control our Raspberry Pi.
VIII. VNC Viewer
In order to use VNC Viewer, you might need to go to “Sharing” and set a password.
System Preferences → Sharing → Computer Setting
Once you set your password, open VNC Viewer you downloaded earlier and add your Raspberry Pi IP address.
Type the password you just set.
If, in case, your VNC Viewer shows this message, go to Display Options → Resolution → DMT Mode 82. It will resolve the issue.
Welcome to Raspberry Pi!
Voila! we are finally done! Set your country, language, and timezone.
I hope this article was helpful and easy to follow. In the next article, I will explain how we can automatically save the water temperature data in a designated place using Raspberry Pi and Python.
Also, feel free to check out my other articles: