STM32F103C8T6_WIFI_Heating_system

Dependencies:   mbed mbed-STM32F103C8T6 eeprom_flash Watchdog PinDetect DS1820

  1. Bluepill STM32F103C8T6 Heating system
    1. _This project is core part of bigger heating system project!_

Features - Reading temperature from four DS18B20 sensors - Making a decision about switching on/off heater and pomp - Executing simple user commands from UART - Storing state parameters to program memory (EEPROM emulation)

Revision:
22:32beca745706
Parent:
21:819277430a55
Child:
23:33d6689834c6
--- a/main.cpp	Wed Sep 12 20:30:34 2018 +0000
+++ b/main.cpp	Thu Sep 13 18:19:14 2018 +0000
@@ -34,8 +34,17 @@
 int main() {
         
     confSysClock();     //Configure system clock (72MHz HSE clock, 48MHz USB clock)
+    
     DigitalOut  myled(LED1);
-                    
+    
+    float temp[5] = {
+                    85,85,85,85,85  // initial temperature
+                };
+                
+    int error[5] = {
+                    0,0,0,0,0       // initial state
+                };
+                        
     string labels[5] = {
                         "OUTDOOR", 
                         "LITOS", 
@@ -52,9 +61,6 @@
                             DS1820(PA_5)  // substitute PA_6 with actual mbed pin name connected to the HOT WATER
                         };
     
-    float   temp = 0;
-    int     error = 0; 
-    
     pc.attach(&rxCallback, Serial::RxIrq);
     pc.baud(115200);  
     pc.printf("Wifi Heating system\r\n"); 
@@ -90,35 +96,44 @@
 
         
         wait(1.0);                 // let DS1820 complete the temperature conversion 
-
-        for ( int j=0; j < 5; j++ ) {
-            error = ds1820[j].read(temp); // read temperature from DS1820 and perform cyclic redundancy check (CRC)
-            switch(error) {
-            case 0:    // no errors -> 'temp' contains the value of measured temperature
-                pc.printf("%s = %3.1fC \r\n", labels[j].c_str() , temp);
-                break;
-            case 1:    // no sensor present -> 'temp' is not updated
-                pc.printf("no %s sensor present \r\n", labels[j].c_str() );
-                break;
-            case 2:    // CRC error -> 'temp' is not updated
-                pc.printf("%s sensor CRC error \r\n", labels[j].c_str() );
-            }; 
-        };
-             
-        
-        
-        
+            
         if (recieved == 1) {
             
             // command was recieved
             pc.printf(a);
+            pc.printf("\r\n");
+            
+            // process_command(a);
             
             // ready for new command
             recieved = 0;
             a[0] = '\0';
             i = 0;
         };  
+        
+        
+
+        for ( int j=0; j < 5; j++ ) {
             
-    }
-}
+            error[j] = ds1820[j].read(temp[j]); // read temperature from DS1820 and perform cyclic redundancy check (CRC)
+            
+            switch(error[j]) {
+            case 0:    // no errors -> 'temp' contains the value of measured temperature
+                pc.printf("%s = %3.1fC \r\n", labels[j].c_str() , temp[j]);
+                break;
+            case 1:    // no sensor present -> 'temp' is not updated
+                //pc.printf("no %s sensor present \r\n", labels[j].c_str() );
+                break;
+            case 2:    // CRC error -> 'temp' is not updated
+                pc.printf("%s sensor CRC error \r\n", labels[j].c_str() );
+            };
+             
+        };
+        
+        pc.printf("State %d|%d|%d|%d|%d\r\n", error[0], error[1], error[2], error[3], error[4] );
+        pc.printf("Temp %3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", temp[0], temp[1], temp[2], temp[3], temp[4] );
+        pc.printf("=======================================");
+
+    };
+};
  
\ No newline at end of file