Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
justind000 committed Aug 10, 2023
0 parents commit 225e148
Show file tree
Hide file tree
Showing 13 changed files with 632 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/github_actions_arduino_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: arduino/arduino-lint-action@v1
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
documentation.sh
Doxyfile
api.md
./rust/target/*
./javascript/
7 changes: 7 additions & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Thank you for your interest in improving this library.

If you have any questions or have found a bug, please feel free to create an
Issue on this project's GitHub page.

Any suggestions for improvements are welcome as well. Please bring them up as
an Issue or a Pull Request.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Microfire LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Mod-Temp
=======

> [Datasheet](https://docs.google.com/document/d/1xpLEcBNHOzufufisoClGkodkMlKaTpSObjkInAdEXmk/export?format=pdf&%3Bref=microfire-llc&ref=microfire-llc) 📜
Add the ability to measure any 10k NTC temperature to your hardware application with a fully digital interface.

#### Summary ℹ️
* Use any 10K NTC
* Resolution 0.125 °C
* I²C, UART, and USB interfaces
* 25x15 mm for castellated or DIP mounting
* Single point calibration

* * *

### Use

* [I²C Arduino Library Documentation](https://docs.google.com/document/d/1qkSqg-a04shQ1ymTpcTnkoENiLpSfFyuMYOSYcGP5eU/export?format=pdf&ref=microfire-llc)
* [I²C Raspberry Pi Python Documentation](https://docs.google.com/document/d/1RHCg3jZDgGcX70pDZXZN49C9UcAZaMesGkK2WYte2zM/export?format=pdf&ref=microfire-llc)

* * *

### Design ✒️

Adding a module to your own design is straightforward. You'll need:

1. bus connection to your controlling device
2. clean, preferably isolated, power supply
3. probe connection (U.FL, BNC, terminal block)

* * *

### Ask a question 🤙

* [Discord](https://discord.gg/rAnZPdW)
* [[email protected]](mailto:[email protected])

* * *

### Website
[microfire.co](https://microfire.co)
38 changes: 38 additions & 0 deletions examples/Basic/Basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*!
microfire.co for links to documentation, examples, and libraries
github.com/u-fire for feature requests, bug reports, and questions
[email protected] to get in touch with someone
Mod-NTC hardware version 2, firmware 1
*/

#include <Microfire_Mod-NTC.h>
Microfire::Mod_NTC::i2c ntc;

void setup()
{
Serial.begin(9600);
Wire.begin();

// start the sensor after Wire.begin()
ntc.begin();
}

void loop()
{
// take a measurement
ntc.measureTemp();

// display the results
Serial.print(ntc.tempC, 2);
Serial.println(" °C");
Serial.print(ntc.tempF, 2);
Serial.println(" °F");
Serial.print(ntc.tempK, 2);
Serial.println(" °K");
Serial.print(ntc.resistance, 0);
Serial.println(" Ohms");
Serial.println();

delay(1000);
}
46 changes: 46 additions & 0 deletions examples/ErrorHandling/ErrorHandling.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*!
microfire.co for links to documentation, examples, and libraries
github.com/u-fire for feature requests, bug reports, and questions
[email protected] to get in touch with someone
Mod-NTC hardware version 2, firmware 1
*/

#include <Microfire_Mod-NTC.h>
Microfire::Mod_NTC::i2c ntc;

void setup()
{
Serial.begin(9600);
Wire.begin();

// start the sensor after Wire.begin()
ntc.begin();
}

void loop()
{
// take a measurement
ntc.measureTemp();

// display the results
ntc.measureTemp();
switch (ntc.status)
{
case ntc.STATUS_NO_PROBE:
Serial.println("Error: No probe connected");
break;
case ntc.STATUS_NO_ERROR:
Serial.print(ntc.tempC, 2);
Serial.println(" °C");
Serial.print(ntc.tempF, 2);
Serial.println(" °F");
Serial.print(ntc.tempK, 2);
Serial.println(" °K");
Serial.print(ntc.resistance, 0);
Serial.println(" Ohms");
Serial.println();
break;
}
delay(1000);
}
171 changes: 171 additions & 0 deletions examples/Shell/Shell.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
This allows you to run various functions in a command-line like interface.
Enter:
`config` to see the configuration of the device.
Measure Temperature:
temp
Change beta of probe
beta 3950
Change the I2C address:
i2c 0x0F
*/

#include <Arduino.h>
#include <Wire.h>
#include <Microfire_Mod-NTC.h>

Microfire::Mod_NTC::i2c ntc;

String buffer, cmd, p1, p2;
const int fw_compatible = 1;
const int hw_compatible = 2;

void config()
{
ntc.update();
Serial.println((String) "Microfire Mod-NTC Sensor: " + (ntc.connected() ? "connected" : "*disconnected*"));
if (!ntc.connected())
return;
if ((ntc.fwVersion != fw_compatible) || (ntc.hwVersion != hw_compatible))
{
Serial.println("*This version of shell was designed for a different hardware revision or firmware version*");
}
Serial.print("β: "); Serial.println(ntc.beta);
Serial.print("hardware:firmware version: ");
Serial.print(ntc.hwVersion);
Serial.print(":");
Serial.println(ntc.fwVersion);
}

void beta()
{
ntc.setBeta(p1.toFloat());
Serial.print("β: "); Serial.println(ntc.beta);
}

void temperature()
{
while (Serial.available() == 0)
{
ntc.measureTemp();
switch (ntc.status)
{
case ntc.STATUS_NO_PROBE:
Serial.println("Error: No probe connected");
break;
case ntc.STATUS_NO_ERROR:
Serial.print(ntc.tempC, 2);
Serial.println(" °C");
Serial.print(ntc.tempF, 2);
Serial.println(" °F");
Serial.print(ntc.tempK, 2);
Serial.println(" °K");
Serial.print(ntc.resistance, 0);
Serial.println(" Ohms");
Serial.println();
break;
}
delay(1000);
}
}

void i2c()
{
uint8_t i2c_address;
char *p;

if (p1.length())
{
i2c_address = strtoul(p1.c_str(), &p, 16);
Serial.println(i2c_address);
if (i2c_address == 0)
{
Serial.println("Error: malformed I2C address");
}
else if ((i2c_address <= 0x07) || (i2c_address > 0x7f))
{
Serial.println("Error: I2C address not in valid range");
}
else
{
ntc.setI2CAddress(i2c_address);
}
}
}

void help()
{
Serial.println(F("List of available commands"));
Serial.println(F("config -or- c : no parameters : Displays all configuration and system information."));
Serial.println(F("i2c : I2C_address : Changes the module's I2C address."));
Serial.println(F("temp -or- t : no parameters : Starts a temperature measurement"));
Serial.println(F("beta -or- b : no parameters : Saves a new probe beta"));
}

void cmd_run()
{
if ((cmd == "conf") || (cmd == "config") || (cmd == "c"))
config();
if ((cmd == "temp") || (cmd == "t"))
temperature();
if (cmd == "i2c")
i2c();
if ((cmd == "beta") || (cmd == "b"))
beta();
if ((cmd == "help") || (cmd == "h"))
help();
}

void cli_process()
{
while (Serial.available())
{
char c = Serial.read();

switch (c)
{
case '\n':
Serial.println();
cmd = buffer.substring(0, buffer.indexOf(" ", 0));
cmd.trim();
buffer.remove(0, buffer.indexOf(" ", 0));
buffer.trim();
p1 = buffer.substring(0, buffer.indexOf(" ", 0));
p1.trim();
buffer.remove(0, buffer.indexOf(" ", 0));
buffer.trim();
p2 = buffer.substring(0, buffer.indexOf(" ", 0));
p2.trim();
cmd_run();

Serial.print("> ");
buffer = "";
break;

case '\b': // backspace
buffer.remove(buffer.length() - 1);
Serial.print("\b \b");
break;

default: // everything else
buffer += c;
Serial.print(c);
}
}
}

void setup()
{
Wire.begin();
ntc.begin();
Serial.begin(9600);
Serial.println("Type `help` for a list of commands");
Serial.println("Type `t` to take a temperature measurement");
config();
Serial.print("> ");
}

void loop()
{
cli_process();
}
28 changes: 28 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#######################################
# Syntax Coloring Map
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

#######################################
# Methods and Functions (KEYWORD2)
#######################################

begin KEYWORD2
connected KEYWORD2
measureTemp KEYWORD2
setI2CAddress KEYWORD2
update KEYWORD2


#######################################
# Instances (KEYWORD2)
#######################################

#######################################
# Constants (LITERAL1)
#######################################
Class ==================================
Mod_Temp KEYWORD1
20 changes: 20 additions & 0 deletions library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Microfire Mod-NTC",
"keywords": "temperature, digital, ntc",
"description": "Add the ability to measure any 10k NTC temperature to your hardware application with a fully digital interface.",
"repository": {
"type": "git",
"url": "https://github.com/u-fire/Mod-NTC.git"
},
"authors": [
{
"name": "Microfire LLC",
"email": "[email protected]",
"url": "https://microfire.co",
"maintainer": true
}
],
"version": "2.0.0",
"frameworks": "arduino",
"platforms": "*"
}
Loading

0 comments on commit 225e148

Please sign in to comment.