Sensor data location on raspberry pi filesystem when GrovePi sensor connected


#1

Hi Friends

I am new to both GrovePi and the Raspberry Pi.
I am following a blog series where it is described how to capture sensor data via a raspberry pi and send it to a cloud database.

In the blog post however, the author has directly connected the sensor to the raspberry pi using some soldering, which of course we avoid with the GrovePi. The author then uses Java code (deployed on Raspberry) to extract the sensor data from a file. The file he uses is /sys/bus/w1/devices followed by the folder created by adding the sensor followed by /w1_slave. Below is a snippet of the code.

	String result = null;
	String filename = "/sys/bus/w1/devices/" + SENSOR_HARDWARE_ID + "/w1_slave";

	String fileContent = null;
	fileContent = readFile(filename);
	String sensorValue = null;

	if (fileContent != null && fileContent.length() > 0) {
		String[] temp = fileContent.split("t=");
		sensorValue = temp[1].trim();
		System.out.println(" - Measured temperature on sensor >" + SENSOR_HARDWARE_ID + "< is " + sensorValue);
		result = buildUrlParameters(sensorId, sensorValue, valueUnit, sensorValueMultiplier, sensorValueCalibration);
	}

I want to use the same code but need to understand where the sensor data of my sensor is stored. On my Pi, the folder /sys/bus/w1/devices is empty, and I assume I need to go to the i2c folder under some structure (but am not sure).

Can someone assist where I can get the sensor data file that I can parse and reuse the provided Java code?

Regards
Suneet


#2

Hey Suneet, quick question: where is the post? Can you share it with us?


#3

Hi John,

Sure. As I mentioned its part of a blog series, and I came across this requirement in the 3rd part of the series.
http://scn.sap.com/community/developer-center/cloud-platform/blog/2014/11/21/raspberrypi-on-sap-hcp--iot-blog-series-part-3-sending-sensor-data-from-raspberry-pi-to-your-cloud-app

Best Regards
Suneet


#4

Hey,
That post uses a sensor which has direct support for it in the linux kernel that’s why he was able to set up in /dev in the first post. GrovePi does not work like this. The easiest thing that you can do. is to deploy a socket server in Python which reads a temperature value from the GrovePi and sends it to a Javi client which is requesting the sensor data and send it to the cloud.

You should be able to find some examples for communicating b/w a python socket Server and a Java client on the internet.

-Karan


#5

Hi Karan

Thanks. I knew that GrovePi works differently than a sensor directly connected to the Raspberry Pi.
I was hoping that there was a place (folder on filesystem) where the GrovePi writes the sensor values from where I could pick it up.

When you say “… reads a temperature value from the GrovePi…”, you mean directly from the sensor, not from any location on the file system where GrovePi sensor values are written, right?

Thanks, I will take up your suggestion.
Meanwhile I have also found some code on github which might be of assistance.

https://github.com/SAP/iot-starterkit/blob/master/src/hardware/raspberry-pi/README.md
https://github.com/SAP/iot-starterkit/blob/master/src/examples/python/iot-starterkit-for-pi-and-grove-peripherals/iot_starterkit_pi_and_grove_peripherals.py

I’ll keep you posted.

Best Regards
Suneet Agera


#6

Hi Suneet,
Thanks for sharing the link, that project seems to be doing something similar to using a socket connection but it directly receives and sends the data to/from the cloud. This might be the easiest way to get the Grove Sensors working.

The sensor data from the grove sensors is not stored on disk right now, you just call the functions and it returns a value read directly from the GrovePi. To read a sensor you actually send/receive commands/data from the Pi to the GrovePi and you do not have direct access to the sensor.

It should be fairly straightforward to write it to the file. If you start with something like the the temperature and humidity sensor: https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_dht_pro.py you can just read the sensor data and store it in a file in JSON or any other format that you like.

Hope this helps and feel free to ask any more questions.

-Karan


#7

Suneet,
I am interested on doing some tests with GrovePi related to SAP HCP, have you finally been able to solve this?
Otherwise, I may start building everything from the scratch.
Thanks and regards.
Alejandro.


#8

Hi Alejandro, sorry but I had to stop on this project temporarily. So I am afraid I have to give you the bad news that you may have to start from scratch.