You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Collapse file: libraries/Dragino/examples/IoTServer/Cayenne and TTN/cayenne and ttn example/lora_shield DHT11 and Relay on the cayenne and ttn_examples/lora_shield_cayenne_and_ttn-abpClient/lora_shield_cayenne_and_ttn-abpClient.ino
Copy file name to clipboardExpand all lines: libraries/Dragino/examples/IoTServer/Cayenne and TTN/cayenne and ttn example/lora_shield DHT11 and Relay on the cayenne and ttn_examples/lora_shield_cayenne_and_ttn-abpClient/lora_shield_cayenne_and_ttn-abpClient.ino
+25-5Lines changed: 25 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,8 @@
36
36
37
37
dht DHT;
38
38
#defineDHT11_PIN A0
39
-
constint ctl_pin=4; //define the input pin of realy
39
+
constint ctl_pin=4; //define the output pin of realy
40
+
constint flame_pin=3; //define the input pin of flame sensor
40
41
41
42
// LoRaWAN NwkSKey, network session key
42
43
// This is the default Semtech key, which is used by the early prototype TTN
staticuint8_t LPP_data[10] = {0x01,0x67,0x00,0x00,0x02,0x68,0x00,0x03,0x01,0x00}; //0xO1,0x02,0x03 is Data Channel,0x67,0x68,0x01 is Data Type
63
+
staticuint8_t LPP_data[13] = {0x01,0x67,0x00,0x00,0x02,0x68,0x00,0x03,0x01,0x00,0x04,0x00,0x00}; //0xO1,0x02,0x03,0x04 is Data Channel,0x67,0x68,0x01,0x00 is Data Type
63
64
staticuint8_t opencml[4]={0x03,0x00,0x64,0xFF},closecml[4]={0x03,0x00,0x00,0xFF}; //the payload of the cayenne or ttn downlink //0xO1,0x02 is Data Channel,0x67,0x68 is Data Type
64
65
staticunsignedint count = 1;
65
66
@@ -186,10 +187,11 @@ void dhtTem()
186
187
LPP_data[6] = hum * 2;
187
188
}
188
189
189
-
voidctl_pinread()
190
+
voidpinread()
190
191
{
191
-
int val;
192
+
int val,val1;
192
193
val=digitalRead(ctl_pin);
194
+
val1=digitalRead(flame_pin);
193
195
if(val==1)
194
196
{
195
197
LPP_data[9]=0x01;
@@ -198,6 +200,14 @@ void ctl_pinread()
198
200
{
199
201
LPP_data[9]=0x00;
200
202
}
203
+
if(val1==1)
204
+
{
205
+
LPP_data[12]=0x01;
206
+
}
207
+
else
208
+
{
209
+
LPP_data[12]=0x00;
210
+
}
201
211
}
202
212
203
213
voiddo_send(osjob_t* j){
@@ -206,7 +216,7 @@ void do_send(osjob_t* j){
206
216
Serial.println(F("OP_TXRXPEND, not sending"));
207
217
} else {
208
218
dhtTem();
209
-
ctl_pinread();
219
+
pinread();
210
220
// Prepare upstream data transmission at the next possible time.
211
221
LMIC_setTxData2(1,LPP_data, sizeof(LPP_data), 0);
212
222
Serial.println(F("Packet queued"));
@@ -220,6 +230,8 @@ void setup() {
220
230
Serial.println("Connect to TTN and Send data to mydevice cayenne(Use DHT11 Sensor):");
221
231
222
232
pinMode(ctl_pin,OUTPUT);
233
+
pinMode(flame_pin,INPUT);
234
+
attachInterrupt(1,fire,LOW);
223
235
224
236
#ifdef VCC_ENABLE
225
237
// For Pinoccio Scout boards
@@ -293,6 +305,14 @@ void setup() {
293
305
do_send(&sendjob);
294
306
}
295
307
308
+
voidfire()
309
+
{
310
+
LPP_data[12]=0x00;
311
+
dhtTem();
312
+
LMIC_setTxData2(1,LPP_data, sizeof(LPP_data), 0);
313
+
Serial.println("Have fire,the temperature is send");
314
+
}
315
+
296
316
voidloop() {
297
317
os_runloop_once();
298
318
}
Collapse file: libraries/Dragino/examples/IoTServer/Cayenne and TTN/cayenne and ttn example/lora_shield DHT11 and Relay on the cayenne and ttn_examples/lora_shield_cayenne_and_ttn-otaaClient/lora_shield_cayenne_and_ttn-otaaClient.ino
Copy file name to clipboardExpand all lines: libraries/Dragino/examples/IoTServer/Cayenne and TTN/cayenne and ttn example/lora_shield DHT11 and Relay on the cayenne and ttn_examples/lora_shield_cayenne_and_ttn-otaaClient/lora_shield_cayenne_and_ttn-otaaClient.ino
+28-8Lines changed: 28 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -36,28 +36,29 @@
36
36
37
37
dht DHT;
38
38
#defineDHT11_PIN A0
39
-
constint ctl_pin=4; //define the input pin of realy
39
+
constint ctl_pin=4; //define the output pin of realy
40
+
constint flame_pin=3; //define the input pin of flame sensor
40
41
41
42
// This EUI must be in little-endian format, so least-significant-byte
42
43
// first. When copying an EUI from ttnctl output, this means to reverse
43
44
// the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3,
staticuint8_t LPP_data[10] = {0x01,0x67,0x00,0x00,0x02,0x68,0x00,0x03,0x01,0x00}; //0xO1,0x02,0x03 is Data Channel,0x67,0x68,0x01 is Data Type
61
+
staticuint8_t LPP_data[13] = {0x01,0x67,0x00,0x00,0x02,0x68,0x00,0x03,0x01,0x00,0x04,0x00,0x00}; //0xO1,0x02,0x03,0x04 is Data Channel,0x67,0x68,0x01,0x00 is Data Type
61
62
staticuint8_t opencml[4]={0x03,0x00,0x64,0xFF},closecml[4]={0x03,0x00,0x00,0xFF}; //the payload of the cayenne or ttn downlink
62
63
staticunsignedint count = 1;
63
64
@@ -189,10 +190,11 @@ void dhtTem()
189
190
LPP_data[6] = hum * 2;
190
191
}
191
192
192
-
voidctl_pinread()
193
+
voidpinread()
193
194
{
194
-
int val;
195
+
int val,val1;
195
196
val=digitalRead(ctl_pin);
197
+
val1=digitalRead(flame_pin);
196
198
if(val==1)
197
199
{
198
200
LPP_data[9]=0x01;
@@ -201,6 +203,14 @@ void ctl_pinread()
201
203
{
202
204
LPP_data[9]=0x00;
203
205
}
206
+
if(val1==1)
207
+
{
208
+
LPP_data[12]=0x01;
209
+
}
210
+
else
211
+
{
212
+
LPP_data[12]=0x00;
213
+
}
204
214
}
205
215
206
216
voiddo_send(osjob_t* j){
@@ -209,7 +219,7 @@ void do_send(osjob_t* j){
209
219
Serial.println(F("OP_TXRXPEND, not sending"));
210
220
} else {
211
221
dhtTem();
212
-
ctl_pinread();
222
+
pinread();
213
223
// Prepare upstream data transmission at the next possible time.
214
224
LMIC_setTxData2(1,LPP_data, sizeof(LPP_data), 0);
215
225
Serial.println(F("Packet queued"));
@@ -223,6 +233,8 @@ void setup() {
223
233
Serial.println("Connect to TTN and Send data to mydevice cayenne(Use DHT11 Sensor):");
224
234
225
235
pinMode(ctl_pin,OUTPUT);
236
+
pinMode(flame_pin,INPUT);
237
+
attachInterrupt(1,fire,LOW);
226
238
227
239
#ifdef VCC_ENABLE
228
240
// For Pinoccio Scout boards
@@ -240,6 +252,14 @@ void setup() {
240
252
do_send(&sendjob);
241
253
}
242
254
255
+
voidfire()
256
+
{
257
+
LPP_data[12]=0x00;
258
+
dhtTem();
259
+
LMIC_setTxData2(1,LPP_data, sizeof(LPP_data), 0);
260
+
Serial.println("Have fire,the temperature is send");
0 commit comments