Recipe to Measure Temperature with an Arduino
This recipe uses an Arduino and a Grove Temperature Sensor to measure temperature. The sensor is connected to an Arduino analog input.
For this recipe, you will need:
You can find the Script in the Scripts "examples" area. The Script is called "temperature_sensor.script". The Script is as follows:
To run this Script, you need 2 parameters: the arduino_port and temp_sensor_pin parameters. The arduino_port parameter is the name of the USB port where the Arduino is plugged in. On *nix hosts, the USB port name is in the "/dev" directory. To see the devices in order of their creation, type "ls -lrt /dev" at a shell prompt and look near the bottom of the list for your Arduino's USB port. The temp_sensor_pin parameter defines the Arduino pin where the temperature sensor is located. It has a default value of "A0" (analog input 0).
As an example, for an Arduino at USB port "/dev/ttyUSB0" with a Grove temperature sensor at pin A0, the Script parameters are:
Running the Script
Run this Script and then go to the Device Explorer page. Click on the "arduino" device and look at its "temp_F" (or "temp_C") terminal and see the temperature in Fahrenheit (or Celsius).