Skip to content

Commit b0737a7

Browse files
committed
Merge pull request arduino#105 from tbowmo/master
Update micro sketch
2 parents c137b84 + 11fabe0 commit b0737a7

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

libraries/MySensors/examples/MysensorMicro/MysensorMicro.ino

+15-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// Define a static node address, remove if you want auto address assignment
1919
//#define NODE_ADDRESS 3
2020

21+
#define RELEASE "1.1"
22+
2123
// Child sensor ID's
2224
#define CHILD_ID_TEMP 1
2325
#define CHILD_ID_HUM 2
@@ -59,13 +61,18 @@ float lastTemperature = -100;
5961
int lastHumidity = -100;
6062
long lastBattery = -100;
6163

64+
bool highfreq = true;
6265

6366
void setup() {
6467

6568
pinMode(LED_PIN, OUTPUT);
6669
digitalWrite(LED_PIN, LOW);
6770

6871
Serial.begin(115200);
72+
Serial.print(F("Sensebender Micro FW "));
73+
Serial.print(RELEASE);
74+
Serial.flush();
75+
6976
// First check if we should boot into test mode
7077

7178
pinMode(TEST_PIN,INPUT);
@@ -74,7 +81,7 @@ void setup() {
7481

7582
digitalWrite(TEST_PIN,LOW);
7683
digitalWrite(LED_PIN, HIGH);
77-
84+
7885
#ifdef NODE_ADDRESS
7986
gw.begin(NULL, NODE_ADDRESS, false);
8087
#else
@@ -84,8 +91,9 @@ void setup() {
8491
digitalWrite(LED_PIN, LOW);
8592

8693
humiditySensor.begin();
87-
88-
gw.sendSketchInfo("Sensebender Micro", "1.0");
94+
Serial.flush();
95+
Serial.println(F(" - Online!"));
96+
gw.sendSketchInfo("Sensebender Micro", RELEASE);
8997

9098
gw.present(CHILD_ID_TEMP,S_TEMP);
9199
gw.present(CHILD_ID_HUM,S_HUM);
@@ -103,10 +111,9 @@ void loop() {
103111

104112
// When we wake up the 5th time after power on, switch to 1Mhz clock
105113
// This allows us to print debug messages on startup (as serial port is dependend on oscilator settings).
106-
if (measureCount == 5) switchClock(1<<CLKPS2); // Switch to 1Mhz for the reminder of the sketch, save power.
114+
if ((measureCount == 5) && highfreq) switchClock(1<<CLKPS2); // Switch to 1Mhz for the reminder of the sketch, save power.
107115

108-
if (measureCount > FORCE_TRANSMIT_INTERVAL
109-
) { // force a transmission
116+
if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
110117
forceTransmit = true;
111118
measureCount = 0;
112119
}
@@ -202,6 +209,7 @@ void switchClock(unsigned char clk)
202209
CLKPR = 1<<CLKPCE; // Set CLKPCE to enable clk switching
203210
CLKPR = clk;
204211
sei();
212+
highfreq = false;
205213
}
206214

207215

@@ -213,7 +221,7 @@ void testMode()
213221
byte tests = 0;
214222

215223
digitalWrite(LED_PIN, HIGH); // Turn on LED.
216-
224+
Serial.println(F(" - TestMode"));
217225
Serial.println(F("Testing peripherals!"));
218226
Serial.flush();
219227
Serial.print(F("-> SI7021 : "));

0 commit comments

Comments
 (0)