• No results found

Visualisering av dörröppningar - En trådlös prototyp

N/A
N/A
Protected

Academic year: 2021

Share "Visualisering av dörröppningar - En trådlös prototyp"

Copied!
36
0
0

Loading.... (view fulltext now)

Full text

(1)

Visualisering av dörröppningar

- En trådlös prototyp

A n n a N o r d s t r ö m S o f i a S v e n s s o n

(2)
(3)

Detta examensarbete har utförts i samarbete med Karolinska Universitetssjukhuset Solna Handledare på Karolinska Universitetssjukhuset Solna:

Carola Kunze och Veronica Ramirez Johansson

A n n a N o r d s t r ö m S o f i a S v e n s s o n

Visualisering av dörröppningar

- En trådlös prototyp

Visualization of door openings

- A wireless prototype

(4)
(5)

Förord

Under vårterminen 2015 har detta kandidatexamensarbete utförts som en del av Civilingenjörsprogrammet medicinsk teknik vid Kungliga Tekniska Högskolan.

Vi vill tacka Carola Kunze, Veronica Ramirez Johansson och Britt Persson Askling på Karolinska Universitetssjukhuset för deras handledning och engagemang under projektets gång. Vi vill även tacka vår handledare på KTH, Anna Bjällmark, för din tillgänglighet och hjälp.

Vi vill också rikta ett stort tack till Jonas Wåhslén för din inspiration och för att du alltid tagit dig tid att svara på frågor. Din hjälp har varit ovärderlig för oss.

(6)
(7)

Sammanfattning

Dörröppningar till en operationssal under en pågående operation ökar infektionsrisken. På Centraloperation, Karolinska Universitetssjukhuset Solna, öppnas dörrarna till operationssalen fler gånger än nödvändigt. Muntlig information till personalen har inte minskat antalet dörröppningar på lång sikt. En trådlös tekniklösning som räknar och visualiserar antalet dörröppningar tros ha en mer långvarig effekt, därför skulle en prototyp tas fram. En litteraturstudie gjordes för att hitta komponenter och för att med dessa skapa prototypen.

Prototypen kan räkna och visualisera antalet dörröppningar från en dörr. Då en

operationssal oftast har tre dörrar är visualiseringen förberedd för att kunna visa antalet för dessa. Prototypen behöver vidareutvecklas för att kunna användas på under en operation.

Nyckelord

(8)
(9)

Abstract

Door openings to an operating theatre, during an ongoing operation, increases the risk of infection. At the Central operation department, Karolinska University Hospital Solna, the doors open more frequently than necessary. Oral information to the staff has not reduced the number of door openings for a longer time. A wireless solution that counts and visualizes is believed to have a more longlasting effect, therefore a prototype would be created. A literature study was performed in order to find components and with those build the prototype.

The prototype is able to count and visualize the number of door openings from one door. However, since many operating theatres have three doors, the visualization is prepared for this. To be able to use this system during an operation the prototype needs to be further developed.

Keywords

(10)
(11)

Innehållsförteckning

1. Inledning   1   1.1 Syfte och mål   1   2. Bakgrund   2   3. Metod   3   3.1 Material   3   3.2 Prototypframtagning   3   4. Resultat   6   5. Diskussion   7  

6. Slutsats och framtida arbete   9  

(12)
(13)

1

1. Inledning

Patientförsäkringens projekt PRISS (ProtesRelaterade Infektioner Ska Stoppas), har tagit fram rekommendationer för att minska antalet infektioner i samband med ledprotesoperationer. I rekommendationerna föreslås åtgärder för att uppnå mikrobiologisk renhet i luften i operationssalen. En av åtgärderna är att minska antalet dörröppningar (PRISS expertgrupp 4, 2014). Luften kontamineras genom bakteriebärande partiklar från personer som vistas i operationssalen, ju fler personer desto mer bakteriebärande partiklar. Rörelser och dörröppningar i operationssalar påverkar luftens renhetsgrad negativt. Studien Något om skyddsventilation i operationsrum (Nordenadler, 2011) visar att det finns ett samband mellan antalet dörröppningar, antal personer och förekomsten av bakteriebärande partiklar i närheten av operationssår.

Avhandlingen Patient Safety in operating room - focus on infection control and prevention baseras bland annat på en studie av dörröppningar. I den noterades ett stort antal dörröppningar som inte var nödvändiga för operationerna. Det registrerades totalt 928 stycken dörröppningar, varav ingen orsak kunde identifieras till 142 stycken av dem. Sociala besök stod för ytterligare 57 stycken dörröppningar. (Erichsen Andersson, 2013) Tillsammans stod dessa två grupper för drygt 20 % av det totala antalet och ansågs inte vara nödvändiga för operationerna.

Carola Kunze, Expertsjuksköterska hygien på Karolinska Universitetssjukhuset, har med en arbetsgrupp inom hygienområdet genomfört ett antal mätningar på dörröppningar under pågående operationer. De har då sett att beteendet kring dörröppningar och personal i operationssalarna inte är i enlighet med vad som främjar luftkvaliteten. Endast nödvändiga dörröppningar och minsta möjliga antal personal inne på salen är faktorer som minskar nivån av bakteriebärande partiklar och därmed främjar luftkvaliteten. Artikeln Frekvens av dörröppningar till operationssal under pågående aktivitet (Lindberg, 2006) visar också på att det höga antalet dörröppningar är ett utbrett problem. Arbetsgruppen inom hygien har märkt att muntlig information till personalen inte gett en långvarig förändring. De har därför uttryckt en önskan om en teknisk lösning som räknar och visualiserar informationen. Detta skulle även spara tid för hygiengruppen, då mätningarna inte skulle ske manuellt.

1.1 Syfte och mål

Syftet var att med en teknisk lösning ändra personalens beteende så att antalet dörröppningar under pågående operationer minskas.

(14)

2

2. Bakgrund

Några metoder som mätsystem kan baseras på är ultraljud, infraröd strålning och mekaniskt tryck. För dessa metoder kan ett mikrokontrollerkort användas, vilket fungerar likt en begränsad dator. Arduino är en typ av mikrokontrollerkort (Arduino (1), 2015) och kan kopplas ihop med andra enheter, produktbeskrivning återfinns i Appendix 1. Exempel på en sådan enhet är ESP8266 som tillsammans med Arduinon kan kopplas upp på ett nätverk. För att skapa en mekanisk räknare kan en Arduino tillsammans med en mikrogapsströmställare användas. En mikrogapsströmställare är en mekanisk sensor som detekterar tryck. Sensorn kan därmed känna av tryck från en stängd dörr och avsaknad av tryck från en öppen dörr.

Arduinos utvecklingsmiljö heter Arduino IDE, Integrated Development Environment. Ett program i utvecklingsmiljön kallas för en sketch. Den består alltid av två funktioner, setup() och loop(). I den förstnämnda kan begynnelsevillkor placeras medan i den andra placeras händelser som ska upprepas (Arduino (2), 2015).

(15)

3

3. Metod

En litteraturstudie gjordes för att undersöka möjliga lösningar för trådlösa mätsystem och dess komponenter. De databaser som användes var Google Scholar och PubMed. Litteraturstudien resulterade i att en mikrogapsströmställare, Arduino Uno och Wi-Fi modulen ESP8266 valdes. Arduino Uno går hädanefter under namnet Arduinon. Kunskap om komponenterna inhämtades bland annat via produktbeskrivningar och tidigare arbeten med dem.

3.1 Material  

Materialet som användes finns nedan i tabell 1.

Objekt Produktinformation Antal

Arduino Uno Arduino, Italien 1

Arduino Software (IDE) 1.6.3 Arduino, Italien 1

MacBook Air 13’’ Apple, Kina 1

Kopplingsdäck 270 anslutningar E-call enterprise company limited, Taiwan 1 Mikrogapströmställare, VX-56-1A3 Omron, Japan 1 Platta för arduino och kopplingsdäck Sparkfun Electronics, USA 1 ESP8266 (Wi-Fi-modul) Seedstudio, Kina 1 Hylslist 2,54mm 1*8p TE connectivity, Tyskland 1 Flatkabel IDC (IDE-kontakt) Olimex, Bulgarien 1 Batteri 9V GP Ultra GP Batteries, Malaysia 2 Batterihållare 9V med DC-plugg Daier electron company, Kina 2

Router, TEW-711BR Trendnet, Kina 1

Tabell 1. Material

3.2 Prototypframtagning  

1. För att installera Arduinon och Arduino IDE följdes 9 steg via Arduinos hemsida, dessa återfinns i Appendix 2 (Arduino (3), 2015).

2. Mikrogapsströmställaren kopplades till Arduinon via kopplingsplattan.

Mikrogapsströmställaren har tre sladdar, en ingång och två utgångar. Ingången kopplades till 5V medan utgångarna kopplades till digital pin 4 respektive 7. 3. En adapter mellan ESP8266 och kopplingsplattan skapades genom att löda

ihop hylslisten med IDE-kontakten.

(16)

4

Anslutning  på  ESP8266   Digital  pin  på  Arduino  

1   3,3V   2   3,3V   3   3,3V   4   2   5   8   6       7       8   GND  

Tabell 2. Kopplingar mellan ESP8266 och Arduino

5. Routern kopplades in och genom installationsguiden valdes ett lösenord. Datorn ihopkopplad med Arduinon anslöts till routerns nätverk.

6. Ett nytt program i Arduino IDE skapades genom att klicka Fil – Ny i menyraden. 7. Ursprungskoden (Wang, 2014) för att sätta upp Wi-Fi på ESP8266

modifierades. Några viktiga delar i koden är att koppla upp ESP8266 till routern, tilldela ESP8266 en IP-adress samt att sätta den som en server. 8. Ursprungskoden (Wang, 2014) utökades med variabler som antingen var

HIGH eller LOW beroende på läget hos mikrogapsströmställaren. Ytterligare lades variabeln counter till som fungerade som en räknare. Se koden i Appendix 3.

9. Programmet laddades upp genom att klicka på ikonen Ladda upp medan USB-kabeln satt i mellan Arduinon och datorn.

10. Två batterier parallellkopplades genom lödning på batterihållarnas sladdar. 11. USB-kabeln togs bort och de parallellkopplade batterierna sattes in. Arduinons

reset-knapp trycktes in.

12. Visualiseringsenheten, i detta fall en läsplatta, kopplades upp på routerns nätverk.

(17)

5 Anslutningar: 5 – 1 6 – 2 7 – 3 8 – 4

Figur 1. Anslutningar på ESP8266

(18)

6

4. Resultat

Prototypen bestod huvudsakligen av ett mikrokontrollerkort, en Wi-Fi modul, en mekanisk sensor, en router och en läsplatta. Uppställningen ses nedan i figur 3. Den mekaniska sensorn placerades så att den var intryckt då dörren var stängd och utsläppt då dörren var öppen. Vid intryckt läge registrerades digital pin 4 som HIGH och digital pin 7 som LOW. Vid varje dörröppning ökade värdet på variabeln counter. Tiden för systemet att registrera och visualisera en dörröppning varierar. Mätningar visade att det kan variera mellan cirka fem sekunder och en minut.

Figur 3. Uppställning av prototypen

Antalet dörröppningar visualiserades i ett webbläsarfönster på en läsplatta som var uppkopplad till routerns nätverk. Prototypen räknade endast öppningarna från en dörr men visualiseringen var förberedd för tre dörrar. Se figur 4.

(19)

7

5. Diskussion

Inför komponentval gjordes en litteraturstudie och Arduino Uno valdes framför andra liknande komponenter. Detta för att den var välanvänd och kompatibel med det befintliga operativsystemet som fanns till befogande. Troligtvis hade systemet blivit enklare att utforma om en mer avancerad typ av Arduino valts då mindre omfattande programmering behövts. Exempelvis har typen Arduino Mega flera portar för att kunna skicka och ta emot data medan Arduino Uno bara har en. Därav söktes mer information för att kunna skapa ytterligare en port genom programmeringen, vilka båda var tidsomfattande processer.

Mikrogapsströmställaren valdes för att den enkelt kan simulera en dörröppning. Ultraljud och infrarödstrålning baseras på reflektion och ställer därför krav på placering och avstånd mellan system och dörr vilket den mekaniska sensorn inte gör. En annan fördel med den mekaniska sensorn är att den utgörs av en del medan både ultraljud och infrarödstrålning ofta består av två delar, sändare och mottagare.

För att göra systemet trådlöst krävdes en enhet som har den funktionen, enheten ESP8266 valdes för dess låga kostnad. Ett alternativ hade varit en så kallad Wi-Fi-sköld som litteraturstudien visade vara det vanligaste alternativet men då den var betydligt dyrare valdes den bort.

Anledningen till att systemet inte alltid reagerar i en önskad hastighet misstänks vara informationsöverföringen. Med multimeter visades det att mikrogapsströmställaren reagerar direkt och därför misstänks felet ligga i överföringen. En felkälla till detta tros vara ESP8266 då det är den enhet som sköter den trådlösa överföringen. Den utbredda användningen av Wi-Fi-sköldar kan tyda på att det skulle kunna vara ett snabbare alternativ. En annan felkälla rörande hastigheten kan vara programmeringen. Då ingen av projektmedlemmarna tidigare arbetat i Arduinos utvecklingsmiljö finns risk att koden inte är optimalt utformad. Även de långa kopplingstrådarna samt lödningarna kan vara felkällor som kan påverka systemet negativt, detta i form av ett långsammare system samt eventuella glapp.

Resultatet kan användas för att vidareutveckla prototypen till en produkt som är anpassad till operationssalens antal dörrar samt har en snabbare reaktionshastighet. Vissa dörrar i en operationssal kan öppnas automatiskt och en sådan dörröppning varar i cirka tio sekunder. Därför skulle en rimlig tid för systemet att svara på en dörröppning och sedan visualisera den vara kring tio sekunder.

(20)
(21)

9

6. Slutsats och framtida arbete

6.1 Slutsats

Prototypen gör det möjligt att visualisera antalet dörröppningar. Systemets stabilitet i avseende på reaktionstid behöver vidareutveckling för att uppnå önskvärd hastighet.

 

 

6.2 Framtida arbete

För att systemet ska kunna användas under operationer behöver det vidareutvecklas. Det viktigaste att arbeta vidare med är systemets hastighet. Nästa steg är rimligtvis att anpassa systemet till tre dörrar. Vidare kan visualiseringen utvecklas genom att använda kunskap om människans kognitiva förmåga, exempelvis kan olika färger användas vid ett visst antal dörröppningar.

(22)

10

7. Referenser

Arduino (1). (2015). Arduino. Hämtat från Products-Arduino-Arduino Uno: http://arduino.cc/en/Main/ArduinoBoardUno den 16 04 2015

Arduino (2). (2015). Arduino. Hämtat från Learning -Getting started-Foundations-Sketch: http://www.arduino.cc/en/Tutorial/Sketch den 03 05 2015

Arduino (3). (2015). Arduino. Hämtat från Learning-Getting Started-Mac OS X: http://arduino.cc/en/Guide/MacOSX den 16 04 2015

Erichsen Andersson, A. (2013). Patient Safety in the Operating Room - Focus on Infection

Control and Prevention. Göteborg: University of Gothenburg. Sahlgrenska Academy.

Lindberg, M. (2006). Frekvens av dörröppningar till operationssal under pågående aktivitet.

Uppdukat , ss. 24-29.

Nordenadler, J. (2011). Något om skyddsventilation i operationsrum. Stockholm: KTH. PRISS expertgrupp 4. (den 13 10 2014). Patientförsäkringen LÖF. Hämtat från

PRISS-rekommendationer:

http://www.patientforsakring.se/resurser/dokument/priss/PRISS-Expertgrupp-4-Optimal-oper ationsmiljoe.pdf den 16 04 2015

Wallin, M. K., Marve, T., & Håkansson, P. K. (11 2005). Modern Wireless Telecommunication Technologies and Their Electromagnetic Compatibility with Life-Supporting Equipment.

Anesthesia & Analgesia , ss. 1393-1400.

Wang, R. (den 14 12 2014). Rayshobby. Hämtat från Archive - October 2014 - First Impression on the ESP8266 Serial-to-WiFi Module:

http://raysfiles.com/arduino/ESP8266a_arduino.ino den 14 05 2015

Muntlig

Kunze, C. (den 13 02 2014). Expertsjuksköterska hygien Karolinska universitetssjukhuset. (A. Nordström, & S. Svensson, Intervjuare

Appendix

Appendix 1: Arduino. (2015). Arduino. Hämtat från Products-Arduino-Arduino Uno: http://arduino.cc/en/Main/ArduinoBoardUno den 16 04 2015

(23)

i

Appendix 1

Produktbeskrivning Arduino Uno

Arduino Uno R3 Front

Overview

The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the

microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.

The Uno differs from all preceding boards in that it does not use the FTDI

USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.

Revision 2 of the Uno board has a resistor pulling the 8U2 HWB line to ground, making it easier to put into DFU mode.

Revision 3 of the board has the following new features:

• 1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two other new pins placed near to the RESET pin, the IOREF that allow the shields to adapt to the voltage provided from the board. In future, shields will be

compatible with both the board that uses the AVR, which operates with 5V and with the Arduino Due that operates with 3.3V. The second one is a not

connected pin, that is reserved for future purposes. • Stronger RESET circuit.

(24)

ii

"Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino, moving forward. The Uno is the latest in a series of USB Arduino boards, and the reference model for the Arduino platform; for a comparison with previous versions, see the index

of Arduino boards.

Summary

Microcontroller ATmega328

Operating Voltage 5V

Input Voltage (recommended) 7-12V

Input Voltage (limits) 6-20V

Digital I/O Pins 14 (of which 6 provide PWM output)

Analog Input Pins 6

DC Current per I/O Pin 40 mA

DC Current for 3.3V Pin 50 mA

Flash Memory 32 KB (ATmega328) of which 0.5 KB used by bootloader

SRAM 2 KB (ATmega328) EEPROM 1 KB (ATmega328) Clock Speed 16 MHz Length 68.6 mm Width 53.4 mm Weight 25 g

Schematic & Reference Design

EAGLE files: arduino-uno-Rev3-reference-design.zip (NOTE: works with Eagle 6.0 and newer)

Schematic: arduino-uno-Rev3-schematic.pdf

(http://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf)

Note: The Arduino reference design can use an Atmega8, 168, or 328. Current

models use an ATmega328, but an Atmega8 is shown in the schematic for reference. The pin configuration is identical on all three processors.

Power

The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.

The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be

unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

(25)

iii

• VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.

• 5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.

• 3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.

• GND. Ground pins.

• IOREF. This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs for working with the 5V or 3.3V.

Memory

The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM

library).

Input and Output

Each of the 14 digital pins on the Uno can be used as an input or output, using

pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each

pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions:

• Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

• External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the

attachInterrupt() function for details.

• PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

• SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.

• LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and

the analogReference() function. Additionally, some pins have specialized

functionality:

(26)

iv

Wire library.

There are a couple of other pins on the board:

• AREF. Reference voltage for the analog inputs. Used with analogReference(). • Reset. Bring this line LOW to reset the microcontroller. Typically used to add a

reset button to shields which block the one on the board.

See also the mapping between Arduino pins and ATmega328 ports. The mapping for the Atmega8, 168, and 328 is identical.

Communication

The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An

ATmega16U2 on the board channels this serial communication over USB and

appears as a virtual com port to software on the computer. The '16U2 firmware uses the standard USB COM drivers, and no external driver is needed. However, on

Windows, a .inf file is required. The Arduino software includes a serial monitor which

allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1).

A SoftwareSerial library allows for serial communication on any of the Uno's digital

pins.

The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus; see the documentation

for details. For SPI communication, use the SPI library.

Programming

The Arduino Uno can be programmed with the Arduino software (download). Select "Arduino Uno from the Tools > Board menu (according to the microcontroller on your board). For details, see the reference and tutorials.

The ATmega328 on the Arduino Uno comes preburned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol (reference, C header files).

You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header using Arduino ISP or similar; see these

instructions for details.

(27)

v

• On Rev1 boards: connecting the solder jumper on the back of the board (near the map of Italy) and then resetting the 8U2.

• On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to ground, making it easier to put into DFU mode.

You can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X and Linux) to load a new firmware. Or you can use the ISP header with an external programmer (overwriting the DFU bootloader). See this user-contributed tutorial for more information.

Automatic (Software) Reset

Rather than requiring a physical press of the reset button before an upload, the Arduino Uno is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of the

ATmega8U2/16U2 is connected to the reset line of the ATmega328 via a 100

nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.

This setup has other implications. When the Uno is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the Uno. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time

configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data.

The Uno contains a trace that can be cut to disable the auto-reset. The pads on either side of the trace can be soldered together to re-enable it. It's labeled "RESET-EN". You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line; see this forum thread for details.

USB Overcurrent Protection

The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.

Physical Characteristics

(28)

vi

(29)

vii

Appendix 2

Getting Started w/ Arduino on Mac OS X

This document explains how to connect your Arduino board to the computer and upload your first sketch.

1 | Get an Arduino board and USB cable

2 | Download the Arduino environment

3 | Install the Software

4 | Connect the board

5 | Launch the Arduino application

6 | Open the blink example

7 | Select your board

8 | Select your serial port

9 | Upload the program

1 | Get an Arduino board and USB cable

In this tutorial, we assume you're using an Arduino Uno, Arduino Duemilanove, Nano,

Arduino Mega 2560 , or Diecimila. If you have another board, read the corresponding

page in this getting started guide. You also need a standard USB cable (A plug to B plug): the kind you would connect to a USB printer, for example. (For the Arduino Nano, you'll need an A to Mini-B cable instead.)

2 | Download the Arduino environment

Get the latest version from the download page.

When the download is finished, double click the .zip fle. This will expand the Arduino application.

3 | Install the Software

Copy the Arduino application into the Applications folder (or elsewhere on your computer). If you're using an Arduino Uno or Mega 2560, you don't have any drivers to install. Skip ahead to the next step.

If you're using an older board (Duemilanove, Diecimila, or any board with an FTDI driver chip.

(30)

viii

double click the package, and follow the instructions in the installer. You'll need to restart your computer after installing the drivers.

4 | Connect the board

The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power from either the USB connection to the computer or an external power supply. If you're using an Arduino Diecimila, you'll need to make sure that the board is configured to draw power from the USB connection. The power source is selected with a jumper, a small piece of plastic that fits onto two of the three pins between the USB and power jacks. Check that it's on the two pins closest to the USB port.

Connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.

If you're using the Arduino Uno or Arduino Mega 2560, a dialog box will appear telling you that a new network interface has been detected. Click "Network Preferences...", and when it opens, simply click "Apply". The Uno or Mega 2560 will show up as "Not Configured", but it's working properly. Quit System Preferences.

5 | Launch the Arduino application

Double-click the Arduino application. (Note: if the Arduino software loads in the wrong language, you can change it in the preferences dialog. See the environment page for details.)

6 | Open the blink example

Open the LED blink example sketch: File > Examples > 1.Basics > Blink.

7 | Select your board

(31)

ix

Selecting an Arduino Uno

For Duemilanove Arduino boards with an ATmega328 (check the text on the chip on the board), select Arduino Duemilanove or Nano w/ ATmega328. Previously, Arduino boards came with an ATmega168; for those, select Arduino Diecimila, Duemilanove, or Nano w/ ATmega168. (Details of the board menu entries are available on the

environment page.)

8 | Select your serial port

Select the serial device of the Arduino board from the Tools > Serial Port menu. On the Mac, this should be something with /dev/tty.usbmodem (for the Uno or Mega 2560) or /dev/tty.usbserial (for older boards) in it.

(32)

x

Selecting an older FTDI-based board

9 | Upload the program

Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear in the status bar. (Note: If you have an

Arduino Mini, NG, or other board, you'll need to physically present the reset button on the board immediately before pressing the upload button.)

A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in orange). If it does, congratulations! You've gotten Arduino up-and-running.

If you have problems, please see the troubleshooting suggestions. You might also want to look at:

• the examples for using various sensors and actuators • the reference for the Arduino language

The text of the Arduino getting started guide is licensed under a Creative Commons

Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the

public domain.

(33)

xi

Appendix 3

Kod i Arduino IDE

//Visualization of door openings

//Anna Nordstrom and Sofia Svensson /* ====== ESP8266 Demo ====== * Print out analog values

* (Updated Dec 14, 2014)

* ========================== *

* Change SSID and PASS to match your WiFi settings.

* The IP address is displayed to soft serial upon successful connection. *

* Ray Wang @ Rayshobby LLC * http://rayshobby.net/?p=9734 */

#define BUFFER_SIZE 512 #include <SoftwareSerial.h>

SoftwareSerial esp(2,8); // use pins 2, 8 for software serial #define kul Serial

#define SSID "TRENDnet711" // WiFi SSID #define PASS "qwertyqwerty" // WiFi password #define PORT "8080"

//Define variables

const int SENSORPIN = 4; int sensorState = 0;

int lastState = 1; int counter = 0;

char buffer[BUFFER_SIZE];

// Function to wait for ESP8266 to respond char OKrn[] = "OK\r\n";

byte wait_for_esp_response(int timeout, char* term=OKrn) { unsigned long t=millis();

bool found=false; int i=0; int len=strlen(term); while(millis()<t+timeout) { if(esp.available()) { buffer[i++]=esp.read(); if(i>=len) {

(34)

xii break; } } } } buffer[i]=0; kul.println(buffer); return found; } void setup() {

//baud rate set to 9600 for both esp.begin(9600); kul.begin(9600); esp.println("AT"); wait_for_esp_response(2000); esp.println("AT+RST");//Restart ESP8266 wait_for_esp_response(2000); esp.println("AT+CWLAP"); wait_for_esp_response(2000); esp.println("AT+CWMODE?"); wait_for_esp_response(2000);

esp.print("AT+CWJAP=\"");//Join the accesspoint esp.print(SSID); esp.print("\",\""); esp.print(PASS); esp.println("\""); wait_for_esp_response(5000); esp.println("AT+CIPSTO=30"); wait_for_esp_response(1000);

esp.println("AT+CIPMUX=1"); //Set multiple connections wait_for_esp_response(2000);

esp.println("AT+CIPSERVER=1,8080"); //Set server wait_for_esp_response(2000);

esp.println("AT+CIFSR"); //Get IP-adress for ESP8266 wait_for_esp_response(10000);

(35)

xiii bool read_till_eol() {

static int i=0; if(esp.available()) { buffer[i++]=esp.read(); if(i==BUFFER_SIZE) i=0;

if(i>1 && buffer[i-2]==13 && buffer[i-1]==10) { buffer[i]=0; i=0; kul.print(buffer); return true; } } return false; } void loop() {

//Get web page info int ch_id, packet_len; char *pb;

if(read_till_eol()) {

if(strncmp(buffer, "+IPD,", 5)==0) {

sscanf(buffer+5, "%d,%d", &ch_id, &packet_len); if (packet_len > 0) { pb = buffer+5; while(*pb!=':') pb++; pb++; if (strncmp(pb, "GET /", 5) == 0) { wait_for_esp_response(1000); serve_homepage(ch_id); } kul.print(ch_id); } } } }

void serve_homepage(int ch_id) {

String header = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\nRefresh: 5\r\n";

sensorState = digitalRead(SENSORPIN); if (!sensorState && lastState) {

counter++; delay(10000); }

// To display number of door openings String content="";

(36)

xiv int sensorReading = analogRead(analogChannel);

References

Related documents

As shown in Figure 12 and 13, for both male and female directors the basic remuneration has increased. However, the increase has been higher for the male directors

Therefore, the problem I will solve in this thesis is to connect a lightweight computer to the Internet of Things network by an IoT platform as well as evaluation about how the

The purpose of the thesis is to design and develop a radio frequency technology system where the frequency emitter device (transmitter beacon) would be attached to the bird and

Insamlingen av inspirationsmaterial kan vara både aktiv och passiv, en designer kan aktivt vara på jakt efter en bild som skall förmedla en viss känsla eller idé, men det kan även

Daily meetings, called performance management meetings, are held to keep the team on track with the performance indicators, goals and improvement activities in focus.. In this

Al contrario dell’IDE di Ardui- no, basato sul linguaggio Wiring (un progetto di Hernando Barragàn), che facilita il programma- tore offrendo un modo semplice per accedere

A commonly used method for strength grading is based on dynamic excitation in the longitudinal direction of the board to obtain an average dynamic longitudinal

Since analog HES are able to register different level of magnetic flux, they could be used in the project to register either black or white pieces by having magnets with