## Introduction

 It is interesting to reflect on what exactly do we mean by a measurement. A measurement is determining some value and comparing it to a known reference of similar values. In the entire world (except USA) todays temperature is measured by determing a value of a column of mercury or alcohol and comparing that value with the values measured in an ice bath and in steam (at 1ATM); Hence these measurements, indeed maybe all measurements, are just inferences against something that is known. We will explore this in the following with the following caviat.  This is not a textbook, just some notes taken along the journey. Data cycle Data collection Data storage Data processing Information retrieval Information reporting Inferring Most of the following will deal with temperature. What is it, how is it measured, how are those measurement stored, retrieved, displayed and analysed.

## Getting started

 The following modules explore how things can be done. Let us pause and reflect on what can be done. Remember, the reason you log data is to see how something changes with time. Usually the data is displayed with a graph. The Primary Science Teaching Trust (PSTT) The Primary Science Teaching Trust (formerly the AstraZeneca Science Teaching Trust) provides financial assistance to help improve the learning and teaching of science in the UK. The Trust was established in April 1997 as an independent charity operating with a substantial Trust Fund donated by AstraZeneca PLC. PSST website A really good resource The IT in Science book of Datalogging and control

## Electrical conductivity

 The periodic table of elements sorts all the elements known in the universe into metals and non metals. Electrical conductivity with temperature The green line is the boundary, and like most things in the world, do not obey the rules. Metals conduct electriciy, non metals dont, and those in the middle sometimes do it one was, some the other. Resistance is th property of a body to resist the flow of electricity. This is a fixed value for anything at constant temperature.  However, as temperature changes, so does the reisitance. If the resistance changes, so does the applied potential (voltage) and if it has a voltage, we can measure it with an Arduino. A practical experiment

## Reading a sensor : the LDR

 A LDR is a light sensitive resistor which can change its electrical conductivity in response to incident light. (Light shining directly on it) One thing that this project demonstrates is the use of a voltage divider. You can vary the reading on the analogue pin by changing the voltage. /*this code reads a light dependant resistorand then prints it out in the serial window of the Arduino SDK mweber290414*/ int reading1; void setup(){ Serial.begin(9600); // this communicates //with the serial window pinMode(A0, INPUT);}void loop(){ reading1 = analogRead(A0); delay(5); Serial.print("sensor =>, ");// note print                                      // note comma     Serial.println(reading1);   // and println delay(500);} As a quick and dirty method, you can copy data from the serial window and paste it into a spreadsheet. From there you can graph the data to gain information. Vocabulary Analogu, digital, serial, BAUD, CSV, spreadsheet, graph, print, println, output

## Analogue and digital

 An analogue signal is one that changes contiuously in smooth incriments. Think of an analogue watch with the second hand moving slowly. In Arduino, 1024 steps between 0-5V. A digital signal has only two states. On and off. In Aduino 0 and 5 volts.

## Reading data and writing to a SD card

 Reading and writing to an SD card is really cool. It means we can now construct wxperiments where we can enclose out Arduino and data logger in some sort of water proof container write data to the SD card over an extended time. Later, bring it to the lab and analyse the data. /* SD card read/write This example shows how to read and write data to and from an SD card file The circuit: * SD card attached to SPI bus as follows: ** MOSI - pin 11 ** MISO - pin 12 ** CLK - pin 13 ** CS - pin 4 created Nov 2010 by David A. Mellis modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. */ #include #include File myFile; void setup(){ // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } Serial.print("Initializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. // Note that even if it's not used as the CS pin, the hardware SS pin // (10 on most Arduino boards, 53 on the Mega) must be left as an output // or the SD library functions will not work. pinMode(10, OUTPUT); if (!SD.begin(4)) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. myFile = SD.open("test.txt", FILE_WRITE); // if the file opened okay, write to it: if (myFile) { Serial.print("Writing to test.txt..."); myFile.println("testing 1, 2, 3."); // close the file: myFile.close(); Serial.println("done."); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } // re-open the file for reading: myFile = SD.open("test.txt"); if (myFile) { Serial.println("test.txt:"); // read from the file until there's nothing else in it: while (myFile.available()) { Serial.write(myFile.read()); } // close the file: myFile.close(); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); }} void loop(){ // nothing happens after setup}

## Temperature and humidity dht11

 http://www.instructables.com/id/Mini-Arduino-enviroment-monitor/step1/Test-the-DHT11-sensor/

## Reading data to a Nokia 5110 screen

 When purchasing components, it helps to keep in ming economies of scale.  Back in the nineties, Nokia sold millions of mobile phones with LCD dosplays. Hence, the cost of producing such massive amounts of screens went down per unit. A Nokia 5110 screen on ebay sells for under \$aus5 making it an affordable addendum to any project. /* This sketch will display a reading in degrees centigrade on a Nokia 5110 screen pinouts nokia 51111 2 3 4 5 6 7 8r c d d c v l gs e c i l c g nt n k c t d code from https://www.youtube.com/watch?v=ga_1dqGjsbo hacked by numbat mark */ #include #include #include #define ONE_WIRE_BUS 2 // it reads the digital pin LCD5110 lcd(3,4,5,6,7); extern unsigned char SmallFont[];extern unsigned char BigNumbers[];extern uint8_t temperatureIcon[]; char temperatureF[6];char temperatureC[6]; OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); float tempC = 0;float tempF = 0; void setup(void){lcd.InitLCD();lcd.setFont(BigNumbers);sensors.begin();} void loop(void){ lcd.clrScr();// lcd.drawBitmap(0, 0, temperatureIcon, 84, 48);sensors.requestTemperatures();tempC = sensors.getTempCByIndex(0);tempF = sensors.toFahrenheit(tempC);// convertToString(tempF);convertToString(tempC); //Uncomment this for degrees Celsius // lcd.print(temperatureF,25,11);lcd.print(temperatureC,25,11);lcd.update(); delay(1000);} void convertToString(float number){//dtostrf(number, 3, 1, temperatureF);dtostrf(number, 3, 1, temperatureC);}
• ### Topic 12

 Arduino does not really have the capacity to store a large amount of data on it's chip. So to get data to be stored on a computer we need use an external language. After a quick straw poll, we have decided on Python as it is taught on Code Academy and is the language of choice for the Pi. To get your computer to talk to a serial port, you must first download a library called Pyserial. Getting started with Python Download Python here. Pyserial here Install Pyserial Reading a file, then writing it. Be carful. Check which port the Arduino is connected to. It is unlikely to be COM4 import serialimport timeser = serial.Serial('COM4', 9600, timeout=0) while 1: try: print (ser.readline()) time.sleep(1) except ser.SerialTimeoutException: print('Data could not be read') time.sleep(1) How to do this.

## Reading data and writing  to a file on a computer with Python

 / this opens a file and write to it file = open("newfile.txt", "w")file.write("hello world in the new file\n")file.write("and another line\n")file.close() / this opens a file and writes it to the screenfile = open("newfile.txt", "r")print (file.read())file.close()

## Moisture sensor : Hl-01 and HL-69

 Looking on youtube.com will find lots of projects where people have just expanded on this code to turn on monitor gardens and turn on reticulation systems. You can fir a system based un a UNO into a soap holder or one baed on a mini pro into a mint tin. /* reading the moisture content from a hl-01/hl-69 sensor system. Details on youtube https://www.youtube.com/watch?v=wml_umFrcTc garduino this read the anaolgue value at A0 this code can be adapted for monitoring or data logging */ void setup(){ Serial.begin(9600);} void loop(){ Serial.print("Moisture Sensor Value:"); Serial.println(analogRead(0)); delay(1000);}