I've had these OpenSource RF wireless arduino shields for awhile with the intent of logging temperature differences throughout the house. Admittedly, I've been dragging my feet getting things set up. With cooler weather, however, I've been motivated time to poke around and get things set up.
I used the Adafruit DHT11 library and source code to log the temperature. The whole DHT11 tutorial, including a wiring diagram, can be found here. The basic setup is pretty easy.

Note: You cannot upload a sketch to the arduino if the serial switch is on the RF wireless shield is ON

Once I got the shields communicating with one another, I install pySerial. It's a module that allows python to read from the serial port, which is what the arduino is sending data through.
Next I wrote a small python script to read the data from the arduino and write it to a CSV file. The intent is to eventually graph the data and watch trends over time.

At first I had some issues with data being clipped while reading from the two arduinos. Originally the arduinos were just blasting the data and I had the python script set up to catch it. That didn't work 100% every time so I had to come up with another solution.
I modified my approach by having each arduino sit patiently waiting to hear something. I then set up python to send a specific message to each arduino. Since they're each set up for a different specific character, there should be no conflict with with messages being sent.

So once an arduino receives it's specific message, it repsonds with the humidity and temperature. The python script then logs the data in a CSV file.

Once I felt comfortable with how the python script was working, I placed two arduinos around the house.
Then I hooked up the Wireless RF USB dongle that I came with the arduino shields to the Raspberry Pi. It took a moment to figure out the tty assignment in Linux. Here's what I did.

Determining tty assignment for RF USB dongle in Linux:
  • go to dev folder (type cd /dev at the command line)
  • type ls and read the list. There should be a ttyUSB0
    • If you're unsure you can always unplug the device and run ls again in the /dev folder
Once I had the assignment figured out, I updated the python script with the path to the USB dongle.

Since I want the data to log automatically at certain intervals, decided to use cron. I did had some issues getting a python script to execute properly from a cron job on the Raspberry Pi, so instead I created a shell script to execute the python script. I'm not entirely sure why python partially executes in cron, but for now this work around is solves the problem.

Overall the system has been working pretty good for the last week. The next step is to set up automatic data graphing. I've had some minor success, but I'm not 100% sure how I want to proceed quite yet.

If you're interested, I've tossed everything up on github.

Software Requirements:
Materials Used:


Very interesting. Your article is so convincing that I can never stop myself from saying anything about it. You are doing a great job, thanks for sharing such a great blog. watlow pm6

This comment has been removed by the author.

Share great information about your blog , Blog really helpful for us .ESP32 DIN

Post a Comment