Logging workshop environment

Already some time ago I have purchased Raspberry PI zero w a small computer with WiFi connectivity and I have paid for it not more than 20 EUR together with shipping, it is small but with rich number of applications. In this case I came up with an idea to build IoT that will be logging environment at my workshop and all will be neatly displayed in Google spreadsheet.

When I was starting winter was just coming and with such device I could monitor temperature in workshop and if it drops below some certain point I will know that I have to turn on heating. Data is being written in Google spreadsheet it is possible to add Google Apps scripts and receive notifications if a certain condition is met, then you will never miss when heating has to be turned on.

To add some senses to my “Zero” device I have added to it Enviro Phat then by importing python library I was able to read temperature, light and pressure values, but it was missing humidity readings. For humidity readings I am using DHT22, which gives humidity value together with temperature value.

To give assembly some structure and protection I have decided to enclose electronics with poly-carbonate sheets. Parts was milled on my router here below from material which was laying in workshop.

Milling poly-carbonate enclosure parts

For this project I have chosen to have simple protection for the electrical components stacked them in poly-carbonate layers.

This is how all looks together. One note here, initially I had difficulties with temperature readings because when Raspberry PI and Enviro Phat are stacked closely together it gives wrong temperature readings due to small proximity of pi chip. During normal operation it heats up so in normal room temperature reads about 35 C degrees, that is why it was needed to increase distance between these components and I have used middle poly-carbonate part to minimize error.

Finished IoT assembly

So when hardware is in place i can proceed with developing python code for the device.

In python I have written code that every 30 min reads environment variables and writes these values in google spreadsheet. To set up Envro Phat it was necessary to import its library. Details on how to do that are here. And for DHT22 have installed this library. To ensure that my script is executed with 30 min frequency I am using crontab that launches python script every 30 minutes and command for that is:

00,30 * * * * (cd ~/Environment/factory/ && python environmentLog.py)
And to start edit Crontab file execute command
crontab -e
Then it come to step where Google spreadsheet has to be configured to give permission for sheet editing. Here is good YouTube video on how to configure that.
But in short needed steps for that was:
  1. On Raspberry PI zero to python you have to add following packages.
  • gspread
  • oauth2client
Use command: pip install gspread oauth2client
  1. Configure on google side and create credentials that will be used for authentication for Google services.
  2. In Google spreadsheet share it with created credentials id.
Once again, please refer to Video mentioned above.
Here is BOM with all components.
Total Price, EUR
Raspberry PI Zero W
Poly-carbonate parts
Milled poly-carbonate parts
25mm Pins
Connecting pins length 25 mm
Polyurethane spacers
Polyurethane spacers cut from pneumatic tube 6×1
M3 plastic washers
White plastic washers.
M3 nuts
M3 nuts
M3 bolts
M3 bolts
Connecting wire
DHT22 connecting wire

End words

Already see where this project can be expanded. One is adding Google app scripts that can send notifications depending on conditions it workshop. Then another idea, create a web server, add relays, so it is possible to control some appliance in workshop.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s