Environmental Monitoring using Grove pi


#1

Hi
I am trying to make a room environmental monitoring system using the grove pi. I would like to have temp and humidity, moisture, gas and air quality. I want it to display on an exterior display (preferably a 3.5 screen but if it needs to be a LCD monitor I will make it work. I want to be able to read it while in the room not on my phone/website. I am new to raspberry pi/grove but I have the pi working and the grove pi installed. When I try to run the sample weather monitoring on the tutorials page it gives me an error. I also have an Astro Pi hat that is working fine but it is difficult to read because it is scrolling.

Any and all help would be appreciated.
Thanks


#2

Hi @jarrells,

Can you tell us little about your setup, what all are connected to your GrovePi, when you are running the sample code. Also can you post a screenshot of the error that you are getting along with the code that you are using.

-Shoban


#3

I am running noobs and have installed grove pi and grove pi examtples and they are on the desktop.


#4

I have a raspberry pi and grove pi with the ten sensor and lcd monitor


#5

When trying to do the test script from the website
Here is the code I am using


#6

Here is the error code from that script

Thanks for the help


#7

Hi @jarrells,

The error seems to be because you aren’t connecting an RGB LCD to the GrovePi. The example program requires the DHT sensor and a RGB LCD . The LCD monitor that you have connected is for the RaspberryPi. The LCD this example uses is a small display given along with the basekit.

So to solve this issue, you can either connect the RGB LCD to I2C port of the GrovePi or comment the lines shown here.

Please let us know if this helps,
-Shoban


#8

We’ve been trying to set up the temperature and humidity sensor to display on the lcd using the sample code however we have encountered a few errors.

  1. Initially the temperature and humidity would display on the monitor but not on the LCD (The LCD would light up but would not display anything). I did a firmware update and also updated the version of the software and now when we run the sample code, the temperature and humidity are not showing correctly on the screen or on the LCD.
    Here is a picture of my setup and the message on the screen.

Would appreciate any assistance. Thanks in advance.


#9

Hi @clydesouza,

The error looks like an IO error. Can you post the code that you are using and also can you follow this guide, generate a test log and post it on the forums.

-Shoban


#10

Thanks!
When I double click the icon with the guy with a hard hat and wrench - it opens a command window. The window that is shown in the video does not open.
Any suggestions?


#11

Hi @clydesouza,

Can you do an update following the instructions show in the video here, that should help. After doing the update try double clicking the troubleshoot icon.

-Shoban


#12

Hi Shoban,

I went through the update process and when the update GUI opened up it did not have the “Update Raspbian” option. I went ahead and updated the dexter software and the firmware for Grove Pi. I then clicked the troubleshoot icon and it still does not open.

I tried running the weather station software code once again but it did not work I used this code (https://www.dexterindustries.com/GrovePi/projects-for-the-raspberry-pi/raspberry-pi-temperature-sensor/). The DHT sensor had errors and the LCD was not lit up or displaying anything.

Any suggestions?

Thanks,

Clyde

PS: I am using the SD card I purchased from dexter - it should already have raspbian for robots installed - correct?


#13

I tried restarting the raspberrry pi and when it is restarting a couple of times I saw the word “Failed” in red at the left of the screen…it moved too fast to be able to read what failed to load.


#14

You should be running Raspbian for robots. My guess is the SD card is corrupted. Maybe try redoing it.


#15

Thanks!
How do I reinstall the software on the SD card?


#16

https://www.dexterindustries.com/howto/install-raspbian-for-robots-image-on-an-sd-card/


#17

Ok I am getting closer. I have installed the rasperian for robots image (although I do not see a difference) and the Grove Pi Software. I have tried running the weather script located in the python folder. Here is the script
from grove_oled import *
import json
import urllib

#Get the weather
city="Orlando"
url=“http://openweathermap.org/city/4167147ando”+city
jsonurl = urllib.urlopen(url.read(“http://openweathermap.org/city/4167147ando”))

weather_desc=text[“weather”][0][“description”] # General description of the weather
temp=float(text[“main”][“temp”])-273.15 # Temperature in C
pressure=text[“main”][“pressure”] # Pressure in hPa
humidity=text[“main”][“humidity”] # Humidity %
wind_speed=text[“wind”][“speed”] # Wind speed mps

print(weather_desc,temp,pressure,humidity,wind_speed)

#Print the data on the OLED

#Initialize the OLED
oled_init()
oled_clearDisplay()
oled_setNormalDisplay()
oled_setVerticalMode()
time.sleep(.1)

line=0
oled_setTextXY(line,0)
oled_putString(“WEATHER:”)
line+=2

oled_setTextXY(line,0)
oled_putString(weather_desc[:12])
line+=1

oled_setTextXY(line,0)
oled_putString(“Temp:”+str(temp)+“C”)
line+=1

oled_setTextXY(line,0)
oled_putString(“Hum:”+str(humidity)+"%")
line+=1

oled_setTextXY(line,0)
oled_putString(“Wind:”+str(wind_speed)+“mps”)
line+=2

oled_setTextXY(line,0)
oled_putString(“Pressure:”)
line+=1

oled_setTextXY(line,0)
oled_putString(str(pressure)+“hPa”)

Here is the error I am getting
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type “copyright”, “credits” or “license()” for more information.

================================ RESTART ================================

Traceback (most recent call last):
File “/home/pi/Desktop/weather1.py”, line 34, in
jsonurl = urllib.urlopen(url.read(“http://openweathermap.org/city/4167147ando”))
AttributeError: ‘str’ object has no attribute ‘read’

Ple\us my OLED monitor is only half the screen and various dots. If the OLED is the problem, I can have it go to a screen using hdmi.

Our competition is in 2 weeks so I would really like to get this working.

Thanks


#18

The oled screen is not the issue. It’s most likely in here:

I’ll try to find the exact issue. I’m not too much of an expert on this stuff.

EDIT

It appears you are reading the weather from the website itself. That data is being set to a string and you are trying to read that. Please anybody let me know if i’m wrong, probably am! :wink:

Here’s a page on stack overflow on reading data from websites in python.
https://stackoverflow.com/questions/15138614/how-can-i-read-the-contents-of-an-url-with-python

Can I suggest that you just use the api? Open weather supplies a free api. That way you don’t have to extract the data from the website.

https://openweathermap.org/api