Introduction: Particle Photon Salinity Meter

We made a measurement device to measure the salinity of water using a magnetic field and a linear hall sensor.
To make it we used a Particle Photon, but an Arduino could also be used as they work practically the same way.

To make this project you need a couple of things:

- Particle/arduino including a breadboard and some cables

- a linear hall sensor

- some magnets(we used small but strong neodymium magnets)

- a pen

- some tape

Step 1: The Container

The pen will be used as a container so go ahead and take out the pin so you'll only have the plastic container.

Close the small hole with some tape, and tape the magnets near the small hole on the side of the pen.

Step 2: Connect the Particle/Arduino

Connect the particle or arduino to the breadboard. Also connect the linear hall sensor the same way as on the picture, the top pin to 3.3V, the middle pin to GND and the bottom pin to an analog input.

Step 3: The Code

On the particle photon you can just press on the pin you used as input and use the function analogRead to get the value from the hall sensor.

If you want it done automatically or if you're using an arduino you'll need a code looking something like this:

//the pin to measure from
int analogPin = A0;

//the amount of time, in milliseconds, between measurements.

//since you can not publish too many events, this has too be at least 1000

int delayTime = 5000;

//an event name so you'll recognize the measurements flowing in

String eventName = "measurement/Salinity";

String laag = "Low";

String middel = "Medium";

String hoog = "High";

void setup(){

}

void loop(){

int measurement = analogRead(analogPin);

if(measurement<=1750){

Particle.publish(eventName, laag); }

if(measurement>=1751 && measurement<=1830){

Particle.publish(eventName, middel);

}

if(measurement>=1831 && measurement<=2100){

Particle.publish(eventName, hoog);

}

if(measurement>=2101){

}

delay(delayTime);

}

Step 4: Measure!

Ofcourse the values in the code will have to be calibrated to the salinity you're using so go ahead and get 3 cups of water. Cup 1 will be just water, Cup 3 will be fully saturated with salt and Cup 2 will be somewhere in between.

Grab one of the cups and pour some of the water into the pen.

Hold the pen next to the hall sensor with the magnets sticking out the other side( so the water will be sandwiched between the magnets and the sensor)

Use the function analogRead to see the value for the water you're using and use that value in the code.

The values we measured were:

just water: 1720

Saturated with salt: 1840

somewhere in between: 1760