|
Post by backyardhops on Jan 24, 2021 7:21:24 GMT -8
Greetings tinkerers, If you are here it is because you can't leave well alone. Once it works it gets boring, so break it and make it better. In that spirit I want to create my own browser dashboard and add sensors. Have any of you connected the software to Node Red? Node-Red reads JSON files, which I assume means the first step is to tap into the WeatherStation JSON file. The next step will be to identify the published Topic. No? This will be my project this week. I will share my results. Please do the same! Initial finding: There are a lot of *.json files on my Raspberry... Charles
|
|
|
Post by backyardhops on Jan 24, 2021 8:52:15 GMT -8
Progress being made. Clearly everything ends up in MariaDB. So I'll work on getting it out of there... Yes, I installed PHP MyAdmin because I prefer a nice GUI. Clearly temp is in Celsius.
|
|
|
Post by Jason on Jan 24, 2021 9:03:00 GMT -8
I use NodeRED, MQTT, Blynk, and PostgreSQL. I’ve been tinkering with Grafana on a RPi cluster and it talks directly to PostgreSQL. I added MQTT to the readWeatherSensors.py script in order to publish readings from the rack to a topic.
Jason
|
|
|
Post by Jason on Jan 24, 2021 9:06:03 GMT -8
Quick caution on Grafana. Store all of your date times or time stamps in UTC. It will save you a ton of frustration with Grafana.
Jason
|
|
|
Post by Jason on Jan 24, 2021 9:07:31 GMT -8
|
|
|
Post by backyardhops on Jan 25, 2021 20:40:42 GMT -8
Hi Jason, that's REALLY helpful! However I'm a wee bit of a newbie. I get the following error: [email protected]:~/SDL_Pi_WeatherRack2 $ sudo python3 readWeatherSensors.py Traceback (most recent call last): File "readWeatherSensors.py", line 42, in <module> with open('config.json', 'r') as config_file: FileNotFoundError: [Errno 2] No such file or directory: 'config.json' This is Line 42: # load configuration file with open('config.json', 'r') as config_file: config = json.load(config_file) I suspect settings.json is not in the path? I can't find it.
|
|
|
Post by SDL on Jan 26, 2021 10:10:13 GMT -8
Boy hopper! You are rocking! Jason, you too. How about writing a blog article and I'll publish this and share it with others!
BP
|
|
|
Post by Jason on Jan 26, 2021 14:00:03 GMT -8
Hi Jason, that's REALLY helpful! However I'm a wee bit of a newbie. I get the following error: [email protected]:~/SDL_Pi_WeatherRack2 $ sudo python3 readWeatherSensors.py Traceback (most recent call last): File "readWeatherSensors.py", line 42, in <module> with open('config.json', 'r') as config_file: FileNotFoundError: [Errno 2] No such file or directory: 'config.json' This is Line 42: # load configuration file with open('config.json', 'r') as config_file: config = json.load(config_file) I suspect settings.json is not in the path? I can't find it. Yeah I may not have checked mine into the repository. My apologies for that. Do you have an MQTT broker running already? Thanks, Jason
|
|
|
Post by Jason on Jan 26, 2021 14:02:45 GMT -8
backyardhops I actually did include a version of my config.json file in that repository. It should like as follows: { "station": { "name": "ws/cameron" }, "mqtt": { "host": "localhost", "port": 1883, "topic_suffix": "/telemetry/", "qos": 0 } } Thanks, Jason
|
|
|
Post by Jason on Jan 26, 2021 14:30:08 GMT -8
Let me give a bit more of an explanation. My WeatherRack2 talks to a RPi in my office inside the house. On that RPi, I've setup Mosquitto MQTT broker and NodeRED. That RPi is also where I'm running my version of readWeatherSensors.py. Additionally, I have a Pi cluster in my office on which Grafana and PostgreSQL run. Honestly, everything could run on a single Pi but what fun is that?!? ;-)
Every message received by my readWeatherSensors.py script is published to an MQTT topic on my MQTT broker. NodeRED is configured to subscribe to the topic on the MQTT broker so that every reading is processed. Once inside NodeRED, the readings are simultaneously routed to Blynk so I can nerd out on them on my iPhone and PostgreSQL so I can do additional analytics on the data such as daily, monthly, quarterly rainfall and so on. I've also been messing with linear regression in the database to monitor weather trends such as increasing/decreasing temperature or barometric pressure.
Grafana has a plugin for talking to PostgreSQL. As a result, it is very simple to build a dashboard once the data is sitting in the database. The biggest challenge I faced with Grafana was the timestamp. I had modeled my table for the readings to accept the current local time without any time zone. Huge mistake! All my panels in Grafana would only show data if I set the range to a value greater than my local UTC offset :-(. I ended up dumping about a month of sensor data in order to rebuild the table properly.
Anyway, hope this helps. Holler if you have more questions.
Jason
|
|
|
Post by backyardhops on Jan 26, 2021 16:22:02 GMT -8
|
|
|
Post by backyardhops on Jan 26, 2021 16:37:36 GMT -8
Jason, YOU ROCK!!!!!!!!!!!!!!
It worked.
I'll keep on trekking and do a Tutorial - I'll work with you Jason if you are interested.
|
|
|
Post by Jason on Jan 26, 2021 18:57:03 GMT -8
Jason, YOU ROCK!!!!!!!!!!!!!! It worked. I'll keep on trekking and do a Tutorial - I'll work with you Jason if you are interested. Yeah lemme know if I can help. Jason
|
|
|
Post by Jason on Jan 27, 2021 5:56:44 GMT -8
Python natively supports JSON but doesn't natively support it like JavaScript. In my mind the easiest way to think about it as follows:
1. If you need to work with JSON in Python, you need to convert it to a Python dictionary using json.load() or json.loads() 2. If you need to push JSON out of Python for other languages to use, you need to convert the Python dictionary back to JSON using json.dump() or json.dumps()
Hope this helps!
Jason
|
|
|
Post by SDL on Jan 29, 2021 10:51:21 GMT -8
Jason is exactly right. JSON must be translated both ways to be used with Python.
BP
|
|