Hi.
Has anyone added to the emonTx K-type thermal sensor? I have a sketch for thermal sensor, but I can’t connect it to the original emonTX sketch, so it also moves to emoncms.org.
Thank You if someone helps me.
Here is the Tx sketch
/*
EmonTx Pulse example
-----------------------------------------
Part of the openenergymonitor.org project
Licence: GNU GPL V3
Authors: Glyn Hudson, Trystan Lea
Builds upon JeeLabs RF12 library and Arduino
THIS SKETCH REQUIRES:
Libraries in the standard arduino libraries folder:
- JeeLib https://github.com/jcw/jeelib
Other files in project directory (should appear in the arduino tabs above)
- emontx_lib.ino
*/
/*Recommended node ID allocation
------------------------------------------------------------------------------------------------------------
-ID- -Node Type-
0 - Special allocation in JeeLib RFM12 driver - reserved for OOK use
1-4 - Control nodes
5-10 - Energy monitoring nodes
11-14 --Un-assigned --
15-16 - Base Station & logging nodes
17-30 - Environmental sensing nodes (temperature humidity etc.)
31 - Special allocation in JeeLib RFM12 driver - Node31 can communicate with nodes on any network group
-------------------------------------------------------------------------------------------------------------
*/
#define RF69_COMPAT 1
#define FREQ RF12_433MHZ // Frequency of RF12B module can be RF12_433MHZ, RF12_868MHZ or RF12_915MHZ. You should use the one matching the module you have.433MHZ, RF12_868MHZ or RF12_915MHZ. You should use the one matching the module you have.
const int nodeID = 9; // emonTx RFM12B node ID
const int networkGroup = 210; // emonTx RFM12B wireless network group - needs to be same as emonBase and emonGLCD needs to be same as emonBase and emonGLCD
const int UNO = 1; // Set to 0 if your not using the UNO bootloader (i.e using Duemilanove) - All Atmega's shipped from OpenEnergyMonitor come with Arduino Uno bootloader
#include <avr/wdt.h> // the UNO bootloader
#include <JeeLib.h> // Download JeeLib: http://github.com/jcw/jeelib
#include "EmonLib.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire);
DeviceAddress address_T1 = { 0x28, 0x7E, 0x0C, 0x0F, 0x0A, 0x00, 0x00, 0x44 }; // Huussi Hormi
DeviceAddress address_T2 = { 0x10, 0x5A, 0x5A, 0x8D, 0x02, 0x08, 0x00, 0x4F }; // Huussi Ulko
ISR(WDT_vect) { Sleepy::watchdogEvent(); }
typedef struct {
int power, pulse, T1, T2;
}
PayloadTX;
PayloadTX emontx;
const int LEDpin = 9;
// Pulse counting settings
long pulseCount = 0; // Number of pulses, used to measure energy.
unsigned long pulseTime,lastTime; // Used to measure power.
double power, elapsedWh; // power and energy
int ppwh = 1;
void setup()
{
Serial.begin(115200);
Serial.println("emonTX Pulse example");
delay(100);
sensors.begin();
rf12_initialize(nodeID, FREQ, networkGroup); // initialize RF
rf12_sleep(RF12_SLEEP);
pinMode(LEDpin, OUTPUT); // Setup indicator LED
digitalWrite(LEDpin, HIGH);
attachInterrupt(1, onPulse, FALLING);
if (UNO) wdt_enable(WDTO_8S);
}
void loop() {
sensors.requestTemperatures(); // Send the command to get temperatures
emontx.T1 = sensors.getTempC(address_T1) * 100 / 100,0;
emontx.T2 = sensors.getTempC(address_T2) * 100 / 100,0;
emontx.pulse = pulseCount; pulseCount=0;
Serial.print(emontx.power);
Serial.print("W ");
Serial.println(emontx.pulse);
send_rf_data(); // *SEND RF DATA* - see emontx_lib
Serial.print(emontx.power);
Serial.print("W ");
Serial.println(emontx.pulse);
emontx_sleep(10); // sleep or delay in seconds - see emontx_lib
digitalWrite(LEDpin, HIGH); delay(2); digitalWrite(LEDpin, LOW); // flash LED
}
// The interrupt routine - runs each time a falling edge of a pulse is detected
void onPulse()
{
lastTime = pulseTime; //used to measure time between pulses.
pulseTime = micros();
pulseCount++; //pulseCounter
emontx.power = int((3600000000.0 / (pulseTime - lastTime))/ppwh); //Calculate powerprint_to_serial
}
and here’s k-type sketcs
//
// FILE: max31855_demo0.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.3
// PURPOSE: thermocouple lib demo application
// DATE: 2014-01-01
// URL:
//
// Released to the public domain
//
#include "MAX31855.h"
const int doPin = 8;
const int csPin = 11;
const int clPin = 13;
MAX31855 tc(clPin, csPin, doPin);
void setup()
{
Serial.begin(115200);
Serial.print("Start max31855_demo0: ");
Serial.println(MAX31855_VERSION);
Serial.println();
tc.begin();
}
void loop() {
int status = tc.read();
Serial.print("stat:\t\t");
Serial.println(status);
float internal = tc.getInternal();
Serial.print("internal:\t");
Serial.println(internal);
float temp = tc.getTemperature();
Serial.print("temperature:\t");
Serial.println(temp);
delay(100+00);
}