1
1
/*
2
- Weather station based on NIXIE lamps
3
- Ver 6.5
2
+ Weather IOT station based on NIXIE lamps
3
+ Ver 0.1
4
4
5
5
Hardware required:
6
6
- Temperature sensor DS18B20
7
7
- Humidity sensor DHT11 (DHT12,DHT21,DHT22)
8
8
- 433 MHz radio receiver (MX-RM-5V)
9
+ - ESP8266 on TX-RX
9
10
10
11
Autor: V. Nezlo
11
12
E-mail: vlladimirka@gmail.com
@@ -22,6 +23,7 @@ uint8_t k;
22
23
#define ADDRESS 111
23
24
// radio
24
25
26
+ #include < EasyTS.h>
25
27
#include < OneWire.h>
26
28
#include " DHT.h"
27
29
#include < GyverTimer.h>
@@ -39,6 +41,7 @@ int digits[4]; // nums
39
41
char display_mode; // mode
40
42
char display_mode_temp; // for cathode healing
41
43
char P=0 ; // for carhode healing
44
+ int sendmode;
42
45
43
46
bool connection=0 ; // connection flag
44
47
bool farenheit; // celsium or farenheit
@@ -73,6 +76,7 @@ GTimer Tcathode_switch(MS, 500);//cathode healing switch time
73
76
GTimer Tled_lowbat (MS, 300 );// led switching (low battery)
74
77
GTimer Tled_noconn (MS, 800 );// led switching (noconnection)
75
78
GTimer Tvalidate_radio (MS, 600000 ); // time to validate data
79
+ GTimer Tsend_data (MS,15000 ); // ThingSpeak send data timer
76
80
77
81
const int bright = 1 ; // Value of "bright" of indicators
78
82
@@ -102,9 +106,8 @@ void check_radio(void){
102
106
103
107
// dot1f = 1;
104
108
105
- connection=TRUE ;
109
+ connection=true ;
106
110
Tvalidate_radio.reset ();
107
- // Serial.println("Connection established");
108
111
}
109
112
110
113
}
@@ -113,9 +116,7 @@ void check_radio(void){
113
116
void check_validate_radio (void ){
114
117
if (Tvalidate_radio.isReady ())
115
118
{
116
- connection=FALSE ;
117
- // Serial.print("Connection lost and value is ");
118
- // Serial.println(connection);
119
+ connection=false ;
119
120
}
120
121
}
121
122
@@ -225,11 +226,10 @@ void pin_set(void){
225
226
}
226
227
227
228
void led_blinking (void ){
228
- if (connection==FALSE ) {
229
+ if (connection==false ) {
229
230
if (Tled_noconn.isReady ())
230
231
{
231
232
dot1f = !dot1f;
232
- // Serial.println("blink!");
233
233
}
234
234
}
235
235
else if (voltage<370 ){
@@ -253,8 +253,6 @@ void check_sensors_first(void){
253
253
void check_humidity (void ){
254
254
float h = dht.readHumidity ();
255
255
humi=h*10 ;
256
- // Serial.print("Humidity is ");
257
- // Serial.println(humi);
258
256
}
259
257
260
258
void conversion_start (void ){
@@ -264,13 +262,11 @@ void conversion_start(void){
264
262
}
265
263
266
264
void conversion_read (void ){
267
- // Serial.println("Im start lagging boiii");
268
265
ds.reset (); //
269
266
ds.write (0xCC );
270
267
ds.write (0xBE );
271
268
ds_data[0 ] = ds.read ();
272
269
ds_data[1 ] = ds.read ();
273
- // Serial.println("Im done");
274
270
275
271
float temperature = ((ds_data[1 ] << 8 ) | ds_data[0 ]) * 0.0625 ;
276
272
@@ -283,8 +279,6 @@ void conversion_read(void){
283
279
if (tempin>0 ) tempin_z = 7 ;
284
280
else tempin_z = 8 ;
285
281
286
- // Serial.print("In temperature is ");
287
- // Serial.println(tempin);
288
282
}
289
283
290
284
void displayMode (void ){
@@ -383,7 +377,6 @@ void displayMode(void){
383
377
{
384
378
display_mode = display_mode_temp; // restore mode after healing
385
379
Tmode_switch.resume ();
386
- // Serial.println("Display mode restored");
387
380
P=0 ;
388
381
}
389
382
}
@@ -394,7 +387,6 @@ void displayMode(void){
394
387
void switchMode (void ){
395
388
if (Tmode_switch.isReady ())
396
389
{
397
- // Serial.println("Display mode switched");
398
390
switch (display_mode)
399
391
{
400
392
case 0 :
@@ -410,7 +402,6 @@ if (Tmode_switch.isReady())
410
402
break ;
411
403
412
404
case 2 :
413
- // Serial.println("Current mode is out,switching to in");
414
405
display_mode=0 ;
415
406
delay (30 );
416
407
break ;
@@ -425,26 +416,45 @@ void cathodeHeal(void){
425
416
display_mode_temp = display_mode;// save display_mode value
426
417
display_mode=3 ;
427
418
Tmode_switch.stop ();
428
- // Serial.println("Cathode healing enable");
429
419
}
430
420
431
421
}
432
422
423
+ void iot_senddata (){
424
+ char String_senddata[30 ];
425
+ if (Tsend_data.isReady ()){
426
+ switch (sendmode){
427
+ case 0 :
428
+ sprintf (String_senddata, " %u.%u" , tempin/10 , tempin%10 );
429
+ easyts.send (" VF5VWODQICAG5BG3" , 1 , String_senddata);
430
+ sendmode=1 ;
431
+ break ;
432
+ case 1 :
433
+ sprintf (String_senddata, " %d" , humi);
434
+ easyts.send (" VF5VWODQICAG5BG3" , 2 , String_senddata);
435
+ sendmode=2 ;
436
+ break ;
437
+ case 2 :
438
+ sprintf (String_senddata, " %u.%u" , tempout/10 , tempout%10 );
439
+ easyts.send (" VF5VWODQICAG5BG3" , 3 , String_senddata);
440
+ sendmode=0 ;
441
+ break ;
442
+ }
443
+ }
444
+ }
445
+
433
446
void setup (){
434
447
435
- Serial.begin (9600 );
448
+ Serial.begin (115200 );
449
+ easyts.std_connect (" Nokia 7.1" ," 12345678" );
436
450
radio_init ();
437
451
pin_set ();
438
452
dht.begin ();
439
453
delay (300 );
440
454
check_sensors_first ();// first run with delay
441
455
check_humidity ();
442
456
farenheit = digitalRead (A0);
443
-
444
457
445
- // Serial.print("farenheit is ");
446
- // Serial.println(farenheit);
447
-
448
458
display_mode=0 ;
449
459
}
450
460
@@ -455,6 +465,7 @@ void loop(){
455
465
check_validate_radio ();
456
466
led_blinking ();
457
467
cathodeHeal ();
468
+ iot_senddata ();
458
469
}
459
470
460
471
0 commit comments