Also check out or community

Modular codePostsVision

Analog sensors


In this tutorial we will take a look at sensors that requires use of analog input only, electricity is of course also required. We will be using a Particle Argon along with a few analog sensors. A lot of other microcontrollers can also be used, that includes for example Particle Photon/Spark/Electron, ESP32 and Arduinos. However, we do recommend Arduino or microcontrollers from Particle if you are a beginner. We will demonstrate 3 different sensors that will run with the exact same simple code. A moisture sensor, flame sensor and a HotPot membrane potentiometer.


1 x Particle Argon

1 x analog sensor

3 x wire

1 x breaboard



Microcontroller(Particle Argon) Sensor
GND (-) GND (-)
3.3V/5V (+) Vcc (+)
Analog pin(for example A1) Signal pin

Connect the GND pin on controller to GND and 3.3V/5V(+) to Vcc(+). Then connect an analog pin from the controller to the signal pin on the sensor.

The picture below shows the wiring of a moisture sensor.

Connect any analog sensor in the same way. Just remember to check the layout of the pins on the sensor, it might be arranged a little different. Below is some example pictures of different sensors.

IR radiation sensor(flame detector)

Moisture/water sensor

HotPot membrane potentiometer

The sensors above will all work with this code.

Source Code

int sensorPin = A1; //The pin on the microcontroller that will gather input from the sensor.
int sensorValue = 0; //Saves the value outside the scope of the loop.
void setup () 
Serial.begin(9600); // Makes it possible to see the inputs in a serial monitor.
pinMode(sensorPin, INPUT); // Tells the sensorPin to take input.
void loop () 
sensorValue = analogRead(sensorPin); // Reads the value from sensorPin
Serial.println (sensorValue); // Print the value to serial monitor
delay (300); 
Related posts

Connecting NB-IoT to RTW with Telenor


Code used to connect to WIFI with Esp32 (Referenced as WifiCode)


Turning on the lights with a clap


Automatic trash can opener based on distance

Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *