├── README.md └── openQCM_FW_1_3 └── openQCM_FW_1_3.ino /README.md: -------------------------------------------------------------------------------- 1 | # openQCM-Arduino 2 | 3 | [openQCM](http://openqcm.com/) firmware for Arduino Micro Board 4 | 5 | ## Intro 6 | This is Arduino firmware version 1.3 for using openQCM. The repository is designed for the contributors community of the open source project. The openQCM Arduino firmware measures the frequency of the quartz crystal microbalance using the [FreqCount library](https://github.com/PaulStoffregen/FreqCount) developed by Paul Stoffregen. 7 | Measure Temperature using [Adafruit_MCP9808_Library](https://github.com/adafruit/Adafruit_MCP9808_Library) written by Kevin Townsend/Limor Fried for Adafruit Industries 8 | 9 | ## License 10 | openQCM ia free software licensed under [GNU GPL v3.0](http://www.gnu.org/licenses/gpl-3.0.txt) General Public License 11 | 12 | ## Info 13 | Follow the wiki for more info and the latest update on openQCM Arduino firmware. 14 | 15 | ## Acknowledgements 16 | - [Novaetech S.r.l.](http://www.novaetech.it/en/) for supporting and powering the openQCM project. 17 | - Paul Stoffregen for developing the [FreqCount library](https://github.com/PaulStoffregen/FreqCount). 18 | - Lady Ada aka Limor Fried and Kevin Townsend at Adafruit Industries for devloping [Adafruit_MCP9808_Library](https://github.com/adafruit/Adafruit_MCP9808_Library) 19 | -------------------------------------------------------------------------------- /openQCM_FW_1_3/openQCM_FW_1_3.ino: -------------------------------------------------------------------------------- 1 | /* LICENSE 2 | Copyright (C) 2014 openQCM 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.txt 16 | 17 | INTRO 18 | openQCM is the unique opensource quartz crystal microbalance http://openqcm.com/ 19 | openQCM Java software project is available on github repository 20 | https://github.com/marcomauro/openQCM 21 | 22 | Measure QCM frequency using FreqCount library developed by Paul Stoffregen 23 | https://github.com/PaulStoffregen/FreqCount 24 | 25 | Measure Temperature using Adafruit_MCP9808_Library written by Kevin Townsend/Limor Fried for Adafruit Industries 26 | https://github.com/adafruit/Adafruit_MCP9808_Library 27 | 28 | NOTE - designed for 6 and 10 Mhz At-cut quartz crystal 29 | - 3.3 VDC supply voltage quartz crystal oscillator 30 | - MCP9808 I2C temperature sensor 31 | 32 | author Marco Mauro - openQCM team 33 | version 1.3 34 | date December 2016 35 | 36 | */ 37 | 38 | // include library for frequency counting 39 | #include 40 | // include EERPOM library 41 | #include 42 | #include "Adafruit_MCP9808.h" 43 | #include 44 | 45 | // fixed "gate interval" time for counting cycles 1000ms 46 | #define GATE 1000 47 | // current address in EEPROM series 48 | #define ADDRESS_SERIES 0 49 | // current address in EEPROM first number 50 | #define ADDRESS_NUMBERFIRST 1 51 | // current address in EEPROM second number 52 | #define ADDRESS_NUMBERSECOND 2 53 | 54 | // Create the MCP9808 temperature sensor object 55 | Adafruit_MCP9808 tempsensor = Adafruit_MCP9808(); 56 | // QCM frequency by counting the number of pulses in a fixed time 57 | unsigned long frequency = 0; 58 | // temperature 59 | int temperature = 0; 60 | 61 | // boolean variable for debug 62 | boolean DEBUG = false; 63 | 64 | // print data to serial port 65 | void dataPrint(unsigned long Count, int Temperature) { 66 | Serial.print("RAWMONITOR"); 67 | Serial.print(Count); 68 | Serial.print("_"); 69 | Serial.print(Temperature); 70 | Serial.write(255); 71 | } 72 | 73 | 74 | // measure temperature 75 | int getTemperature(void) { 76 | int Temperature = 0; 77 | // Don't remove this line! required before reading temp 78 | tempsensor.shutdown_wake(0); 79 | // Read temperature 80 | float c = tempsensor.readTempC(); 81 | if (DEBUG) { 82 | Serial.print("Temperature"); 83 | Serial.println(c); 84 | } 85 | Temperature = c * 10; 86 | return (Temperature); 87 | } 88 | 89 | void setup() { 90 | Serial.begin(115200); 91 | // init the frequency counter 92 | FreqCount.begin(GATE); 93 | // begin temperature sensor 94 | tempsensor.begin(); 95 | // wake up sensor temperature 96 | tempsensor.shutdown_wake(0); // Don't remove this line! required before reading temp 97 | } 98 | 99 | void loop() { 100 | // read the openQCM serial number at the connection 101 | if (Serial.available()) { 102 | int val = Serial.parseInt(); 103 | if (val == 1) { 104 | byte valueSeries = EEPROM.read(ADDRESS_SERIES); 105 | byte valueNumberFirst = EEPROM.read(ADDRESS_NUMBERFIRST); 106 | byte valueNumberSecond = EEPROM.read(ADDRESS_NUMBERSECOND); 107 | Serial.print("SERIALNUMBER"); 108 | Serial.print(valueSeries, DEC); 109 | Serial.print(valueNumberFirst, DEC); 110 | Serial.print(valueNumberSecond, DEC); 111 | Serial.write(255); 112 | } 113 | } 114 | // 115 | // read quartz crystal microbalance frequency and temperature 116 | if (FreqCount.available()) 117 | { 118 | 119 | frequency = FreqCount.read(); // measure QCM frequency 120 | temperature = getTemperature(); // measure temperature 121 | dataPrint(frequency, temperature); // print data 122 | 123 | } 124 | } 125 | 126 | 127 | 128 | --------------------------------------------------------------------------------