How to Receive Water Temperature Data in Real-Time Using Raspberry Pi and Python

Part I: Connecting Raspberry Pi to a Laptop using Wifi

Deborah Kewon
Nov 22, 2020 · 6 min read
Image for post
Image for post
Photo by wembley on Unsplash

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!

I. What We Need….

Image for post
Image for post
  1. Raspberry Pi
  2. USB C Hub * you may not need this. I had to use it because my Mac doesn’t have an SD card reader
  3. SD Card
  4. Raspberry Pi Power Supply

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”.

Image for post
Image for post

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!”.

Image for post
Image for post

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”.

Image for post
Image for post

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.

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Wifi or Hotspot Name"
psk="Wifi or Hotspot Password"
key_mgmt=WPA-PSK
}

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.

Image for post
Image for post
Image for post
Image for post

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)

Image for post
Image for post

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.

Image for post
Image for post

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 pi@xxx.xxx.xx.xxx *your raspberry pi IP address*

Terminal will ask you for the password. The default password for Raspberry Pi is “raspberry”.

Image for post
Image for post

When you see “pi@raspberrypi” in green, use the following script to configure.

sudo raspi-config

Let’s enable some items. When the below screen pops up, go to “Interface Options”.

Image for post
Image for post

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.

Image for post
Image for post

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

Image for post
Image for post

Once you set your password, open VNC Viewer you downloaded earlier and add your Raspberry Pi IP address.

Image for post
Image for post

Type the password you just set.

Image for post
Image for post

If, in case, your VNC Viewer shows this message, go to Display Options → Resolution → DMT Mode 82. It will resolve the issue.

Image for post
Image for post
Image for post
Image for post

Welcome to Raspberry Pi!

Voila! we are finally done! Set your country, language, and timezone.

Image for post
Image for post

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.

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data…

By Analytics Vidhya

Latest news from Analytics Vidhya on our Hackathons and some of our best articles! Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Deborah Kewon

Written by

Data Analyst with a degree in International Relations— Lifelong Learner — Explorer

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Deborah Kewon

Written by

Data Analyst with a degree in International Relations— Lifelong Learner — Explorer

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store