Closed mgaved closed 6 years ago
Hi,
the second way is the correct one, you should create a separate python file for each sensor. So each measurement will be associated with a different sensor of the same device (raspberry).
It is like: deployment > device > sensor A deployment can have multiple devices and a device can have multiple sensors.
Ok thanks for the clarification, I will go ahead and give this a try.
Ok, so I gave it a try, so now On the MAZI server I have 5 sensor files:
pi@mazizone:~ $ sudo ls /root/back-end/lib creeknet1.py creeknet3.py creeknet.py rpiSht1x-1.2.tar.gz sensehat.py creeknet2.py creeknet4.py rpiSht1x-1.2 RTIMULib.ini sht11.py pi@mazizone:~ $
On the 'outside' Pi I have 5 similar files, and I have set them to return known values:
pi@raspberrypi:~/development/1w-temp/back-end/lib $ sudo bash /root/back-end/mazi-sense.sh -n creeknet -t creeknet temperature 21.1 pi@raspberrypi:~/development/1w-temp/back-end/lib $ sudo bash /root/back-end/mazi-sense.sh -n creeknet1 -t creeknet1 temperature -5.0 pi@raspberrypi:~/development/1w-temp/back-end/lib $ sudo bash /root/back-end/mazi-sense.sh -n creeknet2 -t creeknet2 temperature -10.0 pi@raspberrypi:~/development/1w-temp/back-end/lib $ sudo bash /root/back-end/mazi-sense.sh -n creeknet3 -t creeknet3 temperature -15.0 pi@raspberrypi:~/development/1w-temp/back-end/lib $ sudo bash /root/back-end/mazi-sense.sh -n creeknet4 -t creeknet4 temperature -20.0 pi@raspberrypi:~/development/1w-temp/back-end/lib $
However if I write the values to the MAZI server,e.g:
pi@raspberrypi:~/development/1w-temp/back-end/lib $ sudo bash /root/back-end/mazi-sense.sh -n creeknet4 -t --store -D 192.168.1.118 creeknet4 temperature -20.0
I don't see them appear on the portal:
Sorry I'm not sure why the previous comment has some of the code struck out... That was not my intention.
Hi,
It seems that you are correctly gathering measurements. Please check your mySQL database in 192.168.1.118 and you will probably see the measurements coming from your sensors.
You have to wait a bit more to see measurements coming from multiple sensors in the Portal. We are working on it.
Ok thanks, struggling a bit though to see where the values are getting stored, so I guess I may be looking on the wrong place? On the MAZI portal server I tried:
mysql -u mazi_user -p (password)
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | sensors | +--------------------+ 2 rows in set (0.00 sec)
mysql> use sensors; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed mysql> show tables; +-------------------+ | Tables_in_sensors | +-------------------+ | sensor_1 | | type | +-------------------+ 2 rows in set (0.00 sec)
mysql> select * from type; +----+----------+----------+ | id | name | ip | +----+----------+----------+ | 1 | sensehat | 10.0.0.1 | +----+----------+----------+ 1 row in set (0.00 sec)
So I suspect I may be looking on the wrong database? Can you give me a hint about where I should be looking to find the sensor readings? Many thanks.
Hi,
It seems that you are using a previous version of the MAZI toolkit. You should be able to see the monitoring database in the MySQL, where we store the measurements. So it would be a good idea to make an update through the admin interface of the portal, in order to take the latest code.
Ok, I think I managed to get to the bottom of it. As I mentioned I was logging onto MySQL as user 'mazi_user' and I guess I should have been logging on as 'root'. When I use the root account I can see a lot more databases including one with the sensor measurements in it.
So I can see now that my sensors are correctly writing values into the MySQL database on the 'inside' MAZI portal server
Yes you are right. You have to connect as root user and see all the databases.
The only one you need is named "monitoring" and you can find inside some tables with your measurements.
We will be releasing soon a new version of the portal which fixes some bugs in the user interface, so you will be able to see measurements coming from multiple sensors in the MAZI user interface.
This is now solved in v2.4.6
Our 'outside' Pi has 5 temperature sensors attached, ideally I would like to be able have one Python file called creeknet.py and be able to say:
python3 /root/back-end/lib/creeknet.py -t1
temperature1 13.2
python3 /root/back-end/lib/creeknet.py -t4
temperature4 14.6
etc etc....
Then within my data collection code I can say:
/root/back-end/mazi-sense.sh -n creeknet -t1 --store -D 192.168.1.34 /root/back-end/mazi-sense.sh -n creeknet -t2 --store -D 192.168.1.34 /root/back-end/mazi-sense.sh -n creeknet -t3 --store -D 192.168.1.34 /root/back-end/mazi-sense.sh -n creeknet -t4 --store -D 192.168.1.34 /root/back-end/mazi-sense.sh -n creeknet -t5 --store -D 192.168.1.34
And have 5 separate temperature graphs appear on the MAZI portal. Will this work?
The Documentation seems to suggest that the sensors can only read 1 temperature value, i.e:
"Usage:
sudo bash mazi-sense.sh [SenseName] [Options] [SensorOptions]
[SenseName]
-n,--name The name of the sensor
[Options]
-s , --store Stores the measurements in the database -d , --duration Duration in seconds to take a measurements -i , --interval Seconds between periodic measurements -a , --available Displays the status of the available sensors -D,--domain Sets a remote server domain (default is localhost) --status Displays the status of store process
[SensorOptions] -t , --temperature Get the Temperature -h , --humidity Get the Humidity -p , --pressure Get the current pressure in Millibars -m , --magnetometer Get the direction of North -g , --gyroscope Get a dictionary object indexed by the strings x, y and z The values are Floats representing the angle of the axis in degrees
-ac , --accelerometer Get a dictionary object indexed by the strings x, y and z The values are Floats representing the acceleration intensity of the axis in Gs"
So I suspect this might not be the correct way to do it?
Alternatively should I have 5 different files called:
/root/back-end/lib/creeknet1.py /root/back-end/lib/creeknet2.py /root/back-end/lib/creeknet3.py /root/back-end/lib/creeknet4.py /root/back-end/lib/creeknet5.py
And have each one return a single value from a specific sensor:
python3 /root/back-end/lib/creeknet1.py -t
temperature 12.3
python3 /root/back-end/lib/creeknet4.py -t
temperature 15.6
Is this a better way to do it? Again I'm not sure if this will work as it appears the 'temperature from creeknet' graph on the portal shows all of the temperature readings from ANY of the sensors that return temperature values?