Components and supplies
ELM327
Breadboard (generic)
Jumper wires (generic)
Arduino MKR1000
NEO-6M
Project description
Code
RPM gauge - Swift code
swift
For iOS application
1// 2// Otacky.swift 3// RingViewRPM 4// 5// Created by Kardan on 19/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10 11struct Otacky: View { 12 var otacocky:CGFloat = 0 13 var body: some View { 14 ZStack{ 15 Text("Otacky") 16 .font(.largeTitle) 17 .fontWeight(.semibold) 18 .foregroundColor(Color.yellow) 19 .multilineTextAlignment(.center) 20 .padding(.top,200) 21 Circle() 22 .trim(from: 0.0, to: 0.5) 23 .stroke(Color.blue, style: StrokeStyle(lineWidth: 12.0, dash: [8])) 24 .frame(width: 400, height: 300) 25 .rotationEffect(Angle(degrees: -180)) 26 27 Circle() 28 .trim(from: 0.0, to: otacocky/16000) 29 .stroke(Color.blue, lineWidth: 12.0) 30 .frame(width: 400, height: 300) 31 .rotationEffect(Angle(degrees: -180)) 32 .animation(.easeOut(duration: 0.5)) 33 Text("\\(Int(otacocky)) RPM") 34 .font(.largeTitle) 35 .fontWeight(.semibold) 36 .multilineTextAlignment(.center) 37 .padding() 38 .transition(.opacity) 39 40 41 } 42 .padding(.top) 43 } 44 } 45
MapView - Map with annotation mark Swift code
swift
For iOS application
1// 2// MapView.swift 3// RingViewRPM 4// 5// Created by Kardan on 01/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10import MapKit 11 12 13struct MapView: UIViewRepresentable { 14 var predtym:Double 15 var nazov:String="sevas" 16 var dlzka = 34.011286 17 var sirka = -116.166868 18 @State var prava:Bool=true 19 20 func makeUIView(context: Context) -> MKMapView { 21 MKMapView(frame: .zero) 22 } 23 24 func updateUIView(_ uiView: MKMapView, context: Context) { 25 26 27 let coordinate = CLLocationCoordinate2D( 28 latitude: dlzka, longitude: sirka) 29 let sponka=MKPointAnnotation() 30 sponka.coordinate=coordinate 31 sponka.title=nazov 32 let span = MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01) 33 let region = MKCoordinateRegion(center: coordinate, span: span) 34 uiView.setRegion(region, animated: true) 35 let annotations = uiView.annotations 36 uiView.removeAnnotations(annotations) 37 uiView.addAnnotation(sponka) 38 39 40} 41 42 43 44} 45 46
Velocity gauge - Swift code
swift
For iOS application
1// 2// Rychlost.swift 3// RingViewRPM 4// 5// Created by Kardan on 19/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10 11struct Rychlost: View { 12 var rychlostka:CGFloat = 0 13 var body: some View { 14 ZStack{ 15 Text("Rychlost") 16 .font(.largeTitle) 17 .fontWeight(.semibold) 18 .foregroundColor(Color.yellow) 19 .multilineTextAlignment(.center) 20 .padding(.top,200) 21 Circle() 22 .trim(from: 0.0, to: 0.5) 23 .stroke(Color.blue, style: StrokeStyle(lineWidth: 12.0, dash: [8])) 24 .frame(width: 400, height: 300) 25 .rotationEffect(Angle(degrees: -180)) 26 27 Circle() 28 .trim(from: 0.0, to: rychlostka/500) 29 .stroke(Color.blue, lineWidth: 12.0) 30 .frame(width: 400, height: 300) 31 .rotationEffect(Angle(degrees: -180)) 32 .animation(.easeOut(duration: 0.5)) 33 Text("\\(Int(rychlostka)) km/h") 34 .font(.largeTitle) 35 .fontWeight(.semibold) 36 .multilineTextAlignment(.center) 37 .padding() 38 .transition(.opacity) 39 40 41 } 42 .padding(.top) 43 } 44 } 45
Battery voltage gauge - Swift code
swift
For iOS application
1// 2// Napatie.swift 3// RingViewRPM 4// 5// Created by Kardan on 19/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10 11struct Napatie: View { 12 var napaticko:CGFloat = 0 13 var body: some View { 14 ZStack{ 15 Text("Napatie baterie") 16 .font(.largeTitle) 17 .fontWeight(.semibold) 18 .foregroundColor(Color.yellow) 19 .multilineTextAlignment(.center) 20 .padding(.top,200) 21 Circle() 22 .trim(from: 0.0, to: 0.5) 23 .stroke(Color.blue, style: StrokeStyle(lineWidth: 12.0, dash: [8])) 24 .frame(width: 400, height: 300) 25 .rotationEffect(Angle(degrees: -180)) 26 27 Circle() 28 .trim(from: 0.0, to: napaticko/30) 29 .stroke(Color.blue, lineWidth: 12.0) 30 .frame(width: 400, height: 300) 31 .rotationEffect(Angle(degrees: -180)) 32 .animation(.easeOut(duration: 0.5)) 33 Text("\\(Int(napaticko)) V") 34 .font(.largeTitle) 35 .fontWeight(.semibold) 36 .multilineTextAlignment(.center) 37 .padding() 38 .transition(.opacity) 39 40 41 } 42 .padding(.top) 43 } 44} 45
Header file premenne.h
arduino
1MQTTClient client(1024); // Vytvorime MQTT klienta - 256 bytov urcuje velkost buffera (defaultne je 128 bytov) 2float latitude=40.5; 3float longitude=18.5; 4 5String statepmot; 6String engine_temp; //1 7String suengine_temp; 8int vengine_temp; 9 10String stanapat; 11String napatie; //2 12String snapatie; 13int vnapatie; 14 15String stazta; 16String zatazm; //4 17String szatazm; 18int vzatazm; 19 20String stateplosan; 21String teplotasania; //5 22String steplotasania; 23int vteplotasania; 24 25String staotac; 26String otackyA; //6 27String sotackyA; 28int votackyA; 29String otackyB; //6 30String sotackyB; 31int votackyB; 32 33String starychl; 34String rychlost; //7 35String srychlost; 36int vrychlost; 37 38String staVIN; 39 40String inba; 41String inbc; 42String inbd; 43String inbf; 44 45////////////////PREMENNE PRE VIN CISLO 46String vincislo; 47String podvincislo; 48String vinpole[33]; 49String vinpole2[33]; 50String ziskanevin; 51int vina=0; 52 53 54 55////////////////////FUNKCIE 56 57String pTeplotum(){ 58 Serial1.println("0105"); 59 engine_temp = Serial1.readString(); 60 suengine_temp=engine_temp.substring(12,14); 61 vengine_temp = (strtol(suengine_temp.c_str(),NULL,16))-40; 62 63 64 String pengine_temp = "{\\"TeplotaMotora\\":"; 65 pengine_temp += vengine_temp; 66 pengine_temp += "}"; 67 return pengine_temp; 68} 69 70 71String pNapatie(){ 72 Serial1.println("atrv"); 73 napatie = Serial1.readString(); 74 snapatie=napatie.substring(6,15); 75 vnapatie=snapatie.toInt(); 76 Serial.println("PRVY RIADOK"); 77 Serial.println(napatie); 78 Serial.println("DRUHY RIADOK"); 79 Serial.println(vnapatie); 80 81 String p_napatie = "{\\"Napatie\\":"; 82 p_napatie += vnapatie; 83 p_napatie += "}"; 84 return p_napatie; 85} 86 87String pZatazm(){ 88 Serial1.println("0104"); 89 zatazm = Serial1.readString(); 90 szatazm=zatazm.substring(12,14); 91 vzatazm = (strtol(szatazm.c_str(),NULL,16))/2.55; 92 Serial.println(vzatazm); 93 94 String p_zataz = "{\\"ZatazMotora\\":"; 95 p_zataz += vzatazm; 96 p_zataz += "}"; 97 return p_zataz; 98} 99 100String pTeplotasania(){ 101 Serial1.println("010F"); 102 teplotasania = Serial1.readString(); 103 steplotasania=teplotasania.substring(12,14); 104 vteplotasania = (strtol(steplotasania.c_str(),NULL,16))-40; 105 Serial.println(vteplotasania); 106 107 String p_tesania = "{\\"TeplotaSania\\":"; 108 p_tesania += vteplotasania; 109 p_tesania += "}"; 110 return p_tesania; 111} 112 113//////////********* 114String pOtacky(){ 115 Serial1.println("010C"); 116 otackyA = Serial1.readString(); 117 sotackyA=otackyA.substring(12,14); 118 sotackyB=otackyA.substring(15,17); 119 votackyA = ((256*(strtol(sotackyA.c_str(),NULL,16)))+(strtol(sotackyB.c_str(),NULL,16)))/4; 120 Serial.println(votackyA); 121 122 123 String p_otacky = "{\\"Otacky\\":"; 124 p_otacky += votackyA; 125 p_otacky += "}"; 126 return p_otacky; 127} 128 129 130String pRychlost(){ 131 Serial1.println("010D"); 132 rychlost = Serial1.readString(); 133 srychlost=rychlost.substring(12,14); 134 vrychlost = (strtol(srychlost.c_str(),NULL,16)); 135 Serial.println(vrychlost); 136 137 String pcar_speed = "{\\"Rychlost\\":"; 138 pcar_speed += vrychlost; 139 pcar_speed += "}"; 140 return pcar_speed; 141} 142 143 144 145String pGPSRychl(){ 146 Serial1.println("010D"); 147 rychlost = Serial1.readString(); 148 srychlost=rychlost.substring(12,14); 149 vrychlost = (strtol(srychlost.c_str(),NULL,16)); 150 Serial.println(vrychlost); 151 152 String pcar_speed = "{\\"Longituda\\":"; 153 pcar_speed += String(longitude, 6); 154 pcar_speed += ",\\"Latituda\\":"; 155 pcar_speed += String(latitude, 6); 156 pcar_speed += ",\\"Rychlost\\":"; 157 pcar_speed += vrychlost; 158 pcar_speed += "}"; 159 return pcar_speed; 160} 161 162String pGPS(){ 163 String navka = "{\\"Longituda\\":"; 164 navka += String(longitude, 6); 165 navka += ",\\"Latituda\\":"; 166 navka += String(latitude, 6); 167 navka += "}"; 168 return navka; 169} 170 171String GPSmotora(){ 172 Serial1.println("0105"); 173 engine_temp = Serial1.readString(); 174 suengine_temp=engine_temp.substring(12,14); 175 vengine_temp = (strtol(suengine_temp.c_str(),NULL,16))-40; 176 177 String pengine_temp = "{\\"Longituda\\":"; 178 pengine_temp += String(longitude, 6); 179 pengine_temp += ",\\"Latituda\\":"; 180 pengine_temp += String(latitude, 6); 181 pengine_temp += ",\\"Teplota\\":"; 182 pengine_temp += vengine_temp; 183 pengine_temp += "}"; 184 return pengine_temp; 185} 186 187 188String pGPSnapatie(){ 189 Serial1.println("atrv"); 190 napatie = Serial1.readString(); 191 snapatie=napatie.substring(6,15); 192 vnapatie=snapatie.toInt(); 193 194 String p_napatie = "{\\"Longituda\\":"; 195 p_napatie += String(longitude, 6); 196 p_napatie += ",\\"Latituda\\":"; 197 p_napatie += String(latitude, 6); 198 p_napatie += ",\\"Napatie\\":"; 199 p_napatie += vnapatie; 200 p_napatie += "}"; 201 return p_napatie; 202} 203 204 205 206String pGPSotacky(){ 207 Serial1.println("010C"); 208 otackyA = Serial1.readString(); 209 sotackyA=otackyA.substring(12,14); 210 sotackyB=otackyA.substring(15,17); 211 votackyA = ((256*(strtol(sotackyA.c_str(),NULL,16)))+(strtol(sotackyB.c_str(),NULL,16)))/4; 212 Serial.println(votackyA); 213 214 String p_otacky = "{\\"Longituda\\":"; 215 p_otacky += String(longitude, 6); 216 p_otacky += ",\\"Latituda\\":"; 217 p_otacky += String(latitude, 6); 218 p_otacky += ",\\"Otacky\\":"; 219 p_otacky += votackyA; 220 p_otacky += "}"; 221 return p_otacky; 222} 223 224String pVIN(){ 225 Serial1.println("0902"); 226 vincislo = Serial1.readString(); 227 vincislo.replace("\ 228",""); 229 vincislo.replace(" ",""); 230 vincislo.replace(":",""); 231 podvincislo=vincislo.substring(15,21)+vincislo.substring(22,36)+vincislo.substring(37,51); 232 for (int i=0; i<33; i++){ 233 if (i%2 == 0){ 234 vinpole[i]="0x"+(podvincislo.substring(i,i+2)); 235 vinpole2[i]=(char)(strtol((vinpole[i]).c_str(),NULL,16)); 236 } 237 } 238 while (vina<33){ 239 ziskanevin+=vinpole2[vina]; 240 vina+=2; 241 } 242 243 String pVIN = "{\\"VIN\\":\\""; 244 pVIN += ziskanevin; 245 pVIN += "\\"}"; 246 return pVIN; 247} 248
Temperature Gauge - Swift code
swift
For iOS application
1// 2// Teplota.swift 3// RingViewRPM 4// 5// Created by Kardan on 19/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10 11struct Teplota: View { 12 @State var rozhodni=0 13 var hodnotka:CGFloat = 0 14 var body: some View { 15 ZStack{ 16 Text("Teplota motora") 17 .font(.largeTitle) 18 .fontWeight(.semibold) 19 .foregroundColor(Color.yellow) 20 .multilineTextAlignment(.center) 21 .padding(.top,200) 22 Circle() 23 .trim(from: 0.0, to: 0.5) 24 .stroke(Color.blue, style: StrokeStyle(lineWidth: 12.0, dash: [8])) 25 .frame(width: 400, height: 300) 26 .rotationEffect(Angle(degrees: -180)) 27 28 Circle() 29 .trim(from: 0.0, to: hodnotka/200) 30 .stroke(Color.blue, lineWidth: 12.0) 31 .frame(width: 400, height: 300) 32 .rotationEffect(Angle(degrees: -180)) 33 .animation(.easeOut(duration: 0.5)) 34 Text("\\(Int(hodnotka)) °") 35 .font(.largeTitle) 36 .fontWeight(.semibold) 37 .multilineTextAlignment(.center) 38 .padding() 39 .transition(.opacity) 40 41 42 } 43 .padding(.top) 44 } 45} 46
Node-RED flow
json
1[ 2 { 3 "id": "5c322bcd.0d7e24", 4 "type": "tab", 5 "label": "Flow 1", 6 "disabled": false, 7 "info": "" 8 }, 9 { 10 "id": "fe020458.d37fb8", 11 "type": "ibmiot in", 12 "z": "5c322bcd.0d7e24", 13 "authentication": "boundService", 14 "apiKey": "", 15 "inputType": "evt", 16 "logicalInterface": "", 17 "ruleId": "", 18 "deviceId": "IDkontroler", 19 "applicationId": "", 20 "deviceType": "Mikrokontroler", 21 "eventType": "+", 22 "commandType": "", 23 "format": "json", 24 "name": "IBM IoT", 25 "service": "registered", 26 "allDevices": "", 27 "allApplications": "", 28 "allDeviceTypes": false, 29 "allLogicalInterfaces": "", 30 "allEvents": true, 31 "allCommands": "", 32 "allFormats": false, 33 "qos": 0, 34 "x": 70, 35 "y": 80, 36 "wires": [ 37 [ 38 "82d427c1.5f1e38", 39 "43f37536.a7fcec", 40 "1435a819.13f948", 41 "6388de69.38c86", 42 "7b79441a.0c9a0c", 43 "34e21a58.f23676", 44 "4f372508.eed40c", 45 "ffca5f60.a2836", 46 "1d98f4df.46248b", 47 "a0a16110.3d97d", 48 "9cbffc43.6fae4", 49 "804e7a.3d19e188", 50 "c95b86aa.ff9988", 51 "e2afa857.055908", 52 "f050f736.555a78", 53 "2887474f.3903a8", 54 "c334c204.254a9", 55 "a11eb45f.d38ef8", 56 "9d5ef054.3aeed" 57 ] 58 ] 59 }, 60 { 61 "id": "c2fcb0e4.9df3c", 62 "type": "ibmiot out", 63 "z": "5c322bcd.0d7e24", 64 "authentication": "boundService", 65 "apiKey": "", 66 "outputType": "cmd", 67 "deviceId": "IDkontroler", 68 "deviceType": "Mikrokontroler", 69 "eventCommandType": "spojka", 70 "format": "json", 71 "data": "{}", 72 "qos": 0, 73 "name": "IBM IoT", 74 "service": "registered", 75 "x": 840, 76 "y": 620, 77 "wires": [] 78 }, 79 { 80 "id": "4f20b8e8.6d0368", 81 "type": "ui_button", 82 "z": "5c322bcd.0d7e24", 83 "name": "", 84 "group": "b15ee046.8c935", 85 "order": 1, 86 "width": 0, 87 "height": 0, 88 "passthru": false, 89 "label": "Engine temp", 90 "tooltip": "", 91 "color": "", 92 "bgcolor": "", 93 "icon": "", 94 "payload": "\\"1\\"", 95 "payloadType": "json", 96 "topic": "spojka", 97 "x": 110, 98 "y": 460, 99 "wires": [ 100 [ 101 "c2fcb0e4.9df3c" 102 ] 103 ] 104 }, 105 { 106 "id": "aec1cc46.8c43a", 107 "type": "ui_button", 108 "z": "5c322bcd.0d7e24", 109 "name": "", 110 "group": "f7606a4e.234618", 111 "order": 1, 112 "width": 0, 113 "height": 0, 114 "passthru": false, 115 "label": "Engine load", 116 "tooltip": "", 117 "color": "", 118 "bgcolor": "", 119 "icon": "", 120 "payload": "\\"3\\"", 121 "payloadType": "json", 122 "topic": "spojka", 123 "x": 110, 124 "y": 540, 125 "wires": [ 126 [ 127 "c2fcb0e4.9df3c" 128 ] 129 ] 130 }, 131 { 132 "id": "180233f4.ae6cdc", 133 "type": "ui_button", 134 "z": "5c322bcd.0d7e24", 135 "name": "", 136 "group": "f943ae3.4d5b75", 137 "order": 1, 138 "width": 0, 139 "height": 0, 140 "passthru": false, 141 "label": "Intake air temp", 142 "tooltip": "", 143 "color": "", 144 "bgcolor": "", 145 "icon": "", 146 "payload": "\\"4\\"", 147 "payloadType": "json", 148 "topic": "spojka", 149 "x": 120, 150 "y": 580, 151 "wires": [ 152 [ 153 "c2fcb0e4.9df3c" 154 ] 155 ] 156 }, 157 { 158 "id": "3da42317.916b5c", 159 "type": "ui_button", 160 "z": "5c322bcd.0d7e24", 161 "name": "", 162 "group": "b3c559b3.3e97d8", 163 "order": 1, 164 "width": 0, 165 "height": 0, 166 "passthru": false, 167 "label": "Battery voltage", 168 "tooltip": "", 169 "color": "", 170 "bgcolor": "", 171 "icon": "", 172 "payload": "\\"2\\"", 173 "payloadType": "json", 174 "topic": "spojka", 175 "x": 120, 176 "y": 500, 177 "wires": [ 178 [ 179 "c2fcb0e4.9df3c" 180 ] 181 ] 182 }, 183 { 184 "id": "29d384f.73d7a7c", 185 "type": "ui_button", 186 "z": "5c322bcd.0d7e24", 187 "name": "", 188 "group": "34ec3061.6e984", 189 "order": 1, 190 "width": 0, 191 "height": 0, 192 "passthru": false, 193 "label": "RPM", 194 "tooltip": "", 195 "color": "", 196 "bgcolor": "", 197 "icon": "", 198 "payload": "\\"5\\"", 199 "payloadType": "json", 200 "topic": "spojka", 201 "x": 90, 202 "y": 620, 203 "wires": [ 204 [ 205 "c2fcb0e4.9df3c", 206 "91e819d.952aee8" 207 ] 208 ] 209 }, 210 { 211 "id": "93e16f5a.1cf5c", 212 "type": "ui_button", 213 "z": "5c322bcd.0d7e24", 214 "name": "", 215 "group": "3fc295fe.9f49ca", 216 "order": 1, 217 "width": 0, 218 "height": 0, 219 "passthru": false, 220 "label": "Velocity", 221 "tooltip": "", 222 "color": "", 223 "bgcolor": "", 224 "icon": "", 225 "payload": "\\"6\\"", 226 "payloadType": "json", 227 "topic": "spojka", 228 "x": 100, 229 "y": 660, 230 "wires": [ 231 [ 232 "c2fcb0e4.9df3c" 233 ] 234 ] 235 }, 236 { 237 "id": "f14580c0.81f91", 238 "type": "ui_button", 239 "z": "5c322bcd.0d7e24", 240 "name": "", 241 "group": "3621392d.b91016", 242 "order": 1, 243 "width": 0, 244 "height": 0, 245 "passthru": false, 246 "label": "VIN", 247 "tooltip": "", 248 "color": "", 249 "bgcolor": "", 250 "icon": "", 251 "payload": "\\"7\\"", 252 "payloadType": "json", 253 "topic": "spojka", 254 "x": 90, 255 "y": 700, 256 "wires": [ 257 [ 258 "c2fcb0e4.9df3c" 259 ] 260 ] 261 }, 262 { 263 "id": "82d427c1.5f1e38", 264 "type": "function", 265 "z": "5c322bcd.0d7e24", 266 "name": "", 267 "func": "switch (msg.topic){\ 268 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotam/fmt/json\\":\ 269 return {payload:msg.payload.TeplotaMotora};\ 270 break;\ 271 \ 272 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotao/fmt/json\\":\ 273 return {payload:msg.payload.TeplotaOleja};\ 274 break;\ 275 \ 276 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/rychlost/fmt/json\\":\ 277 return {payload:msg.payload.Rychlost};\ 278 break;\ 279 \ 280 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/otacky/fmt/json\\":\ 281 return {payload:msg.payload.Otacky};\ 282 break;\ 283 \ 284 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/benzin/fmt/json\\":\ 285 return {payload:msg.payload.Benzin};\ 286 break;\ 287 \ 288 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotav/fmt/json\\":\ 289 return {payload:msg.payload.TeplotaVzduchu};\ 290 break;\ 291 \ 292 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dtcs/fmt/json\\":\ 293 return {payload:msg.payload.DTCs};\ 294 break;\ 295 \ 296 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/vycisti/fmt/json\\":\ 297 return {payload:msg.payload.Vycisti};\ 298 break; \ 299}", 300 "outputs": 1, 301 "noerr": 0, 302 "x": 250, 303 "y": 80, 304 "wires": [ 305 [ 306 "5bd2c651.2adea8" 307 ] 308 ] 309 }, 310 { 311 "id": "5bd2c651.2adea8", 312 "type": "debug", 313 "z": "5c322bcd.0d7e24", 314 "name": "", 315 "active": false, 316 "tosidebar": true, 317 "console": false, 318 "tostatus": false, 319 "complete": "false", 320 "x": 490, 321 "y": 80, 322 "wires": [] 323 }, 324 { 325 "id": "43f37536.a7fcec", 326 "type": "function", 327 "z": "5c322bcd.0d7e24", 328 "name": "", 329 "func": "switch (msg.topic){\ 330 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotam/fmt/json\\":\ 331 return {payload:msg.payload.TeplotaMotora};\ 332}\ 333\ 334\ 335\ 336\ 337\ 338", 339 "outputs": 1, 340 "noerr": 0, 341 "x": 250, 342 "y": 120, 343 "wires": [ 344 [ 345 "fe99fbd4.9109b8", 346 "f2ad5cb4.ababd" 347 ] 348 ] 349 }, 350 { 351 "id": "1435a819.13f948", 352 "type": "function", 353 "z": "5c322bcd.0d7e24", 354 "name": "", 355 "func": "switch (msg.topic){\ 356 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/napatie/fmt/json\\":\ 357 return {payload:msg.payload.Napatie};\ 358}", 359 "outputs": 1, 360 "noerr": 0, 361 "x": 250, 362 "y": 160, 363 "wires": [ 364 [ 365 "e7e764ae.4ca5e8" 366 ] 367 ] 368 }, 369 { 370 "id": "6388de69.38c86", 371 "type": "function", 372 "z": "5c322bcd.0d7e24", 373 "name": "", 374 "func": "switch (msg.topic){\ 375 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/zatazm/fmt/json\\":\ 376 return {payload:msg.payload.ZatazMotora};\ 377}", 378 "outputs": 1, 379 "noerr": 0, 380 "x": 250, 381 "y": 200, 382 "wires": [ 383 [ 384 "7eadc7ad.7cf6e8" 385 ] 386 ] 387 }, 388 { 389 "id": "7b79441a.0c9a0c", 390 "type": "function", 391 "z": "5c322bcd.0d7e24", 392 "name": "", 393 "func": "switch (msg.topic){\ 394 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotasania/fmt/json\\":\ 395 return {payload:msg.payload.TeplotaSania};\ 396}", 397 "outputs": 1, 398 "noerr": 0, 399 "x": 250, 400 "y": 240, 401 "wires": [ 402 [ 403 "45872dba.55fcd4" 404 ] 405 ] 406 }, 407 { 408 "id": "34e21a58.f23676", 409 "type": "function", 410 "z": "5c322bcd.0d7e24", 411 "name": "", 412 "func": "switch (msg.topic){\ 413 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/otacky/fmt/json\\":\ 414 return {payload:msg.payload.Otacky};\ 415}", 416 "outputs": 1, 417 "noerr": 0, 418 "x": 250, 419 "y": 280, 420 "wires": [ 421 [ 422 "2a0f2623.21943a" 423 ] 424 ] 425 }, 426 { 427 "id": "ffca5f60.a2836", 428 "type": "function", 429 "z": "5c322bcd.0d7e24", 430 "name": "", 431 "func": "switch (msg.topic){\ 432 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/VIN/fmt/json\\":\ 433 return {payload:msg.payload.VIN};\ 434}", 435 "outputs": 1, 436 "noerr": 0, 437 "x": 250, 438 "y": 360, 439 "wires": [ 440 [ 441 "f5ad1b10.a28e28" 442 ] 443 ] 444 }, 445 { 446 "id": "4f372508.eed40c", 447 "type": "function", 448 "z": "5c322bcd.0d7e24", 449 "name": "", 450 "func": "switch (msg.topic){\ 451 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/rychlost/fmt/json\\":\ 452 return {payload:msg.payload.Rychlost};\ 453}", 454 "outputs": 1, 455 "noerr": 0, 456 "x": 250, 457 "y": 320, 458 "wires": [ 459 [ 460 "57ee1e71.74562" 461 ] 462 ] 463 }, 464 { 465 "id": "e7e764ae.4ca5e8", 466 "type": "ui_gauge", 467 "z": "5c322bcd.0d7e24", 468 "name": "napatieS", 469 "group": "b3c559b3.3e97d8", 470 "order": 2, 471 "width": "6", 472 "height": "4", 473 "gtype": "wave", 474 "title": "", 475 "label": "V", 476 "format": "{{value}}", 477 "min": "0", 478 "max": "15", 479 "colors": [ 480 "#00b500", 481 "#e6e600", 482 "#ca3838" 483 ], 484 "seg1": "", 485 "seg2": "", 486 "x": 480, 487 "y": 160, 488 "wires": [] 489 }, 490 { 491 "id": "7eadc7ad.7cf6e8", 492 "type": "ui_gauge", 493 "z": "5c322bcd.0d7e24", 494 "name": "", 495 "group": "f7606a4e.234618", 496 "order": 2, 497 "width": 0, 498 "height": 0, 499 "gtype": "gage", 500 "title": "", 501 "label": "%", 502 "format": "{{value}}", 503 "min": "0", 504 "max": "100", 505 "colors": [ 506 "#fee849", 507 "#e39a02", 508 "#d21515" 509 ], 510 "seg1": "", 511 "seg2": "", 512 "x": 470, 513 "y": 200, 514 "wires": [] 515 }, 516 { 517 "id": "45872dba.55fcd4", 518 "type": "ui_gauge", 519 "z": "5c322bcd.0d7e24", 520 "name": "", 521 "group": "f943ae3.4d5b75", 522 "order": 2, 523 "width": 0, 524 "height": 0, 525 "gtype": "gage", 526 "title": "", 527 "label": "° C", 528 "format": "{{value}}", 529 "min": "-40", 530 "max": "40", 531 "colors": [ 532 "#00ff00", 533 "#ffff00", 534 "#e60000" 535 ], 536 "seg1": "", 537 "seg2": "", 538 "x": 470, 539 "y": 240, 540 "wires": [] 541 }, 542 { 543 "id": "2a0f2623.21943a", 544 "type": "ui_gauge", 545 "z": "5c322bcd.0d7e24", 546 "name": "", 547 "group": "34ec3061.6e984", 548 "order": 2, 549 "width": 0, 550 "height": 0, 551 "gtype": "gage", 552 "title": "", 553 "label": "RPM", 554 "format": "{{value}}", 555 "min": 0, 556 "max": "8000", 557 "colors": [ 558 "#ffffff", 559 "#00e611", 560 "#000000" 561 ], 562 "seg1": "", 563 "seg2": "", 564 "x": 470, 565 "y": 280, 566 "wires": [] 567 }, 568 { 569 "id": "57ee1e71.74562", 570 "type": "ui_gauge", 571 "z": "5c322bcd.0d7e24", 572 "name": "", 573 "group": "3fc295fe.9f49ca", 574 "order": 2, 575 "width": 0, 576 "height": 0, 577 "gtype": "gage", 578 "title": "", 579 "label": "kmh", 580 "format": "{{value}}", 581 "min": "0", 582 "max": "250", 583 "colors": [ 584 "#0000c6", 585 "#caceff", 586 "#ec1e00" 587 ], 588 "seg1": "", 589 "seg2": "", 590 "x": 470, 591 "y": 320, 592 "wires": [] 593 }, 594 { 595 "id": "f5ad1b10.a28e28", 596 "type": "ui_text", 597 "z": "5c322bcd.0d7e24", 598 "group": "3621392d.b91016", 599 "order": 2, 600 "width": 6, 601 "height": 4, 602 "name": "", 603 "label": "", 604 "format": "{{msg.payload}}", 605 "layout": "col-center", 606 "x": 470, 607 "y": 360, 608 "wires": [] 609 }, 610 { 611 "id": "7ed3d7b9.a233a8", 612 "type": "function", 613 "z": "5c322bcd.0d7e24", 614 "name": "", 615 "func": " return {payload:\\"\\"};", 616 "outputs": 1, 617 "noerr": 0, 618 "x": 310, 619 "y": 420, 620 "wires": [ 621 [ 622 "e7e764ae.4ca5e8", 623 "7eadc7ad.7cf6e8", 624 "45872dba.55fcd4", 625 "2a0f2623.21943a", 626 "57ee1e71.74562", 627 "f5ad1b10.a28e28", 628 "f2ad5cb4.ababd" 629 ] 630 ] 631 }, 632 { 633 "id": "f2ad5cb4.ababd", 634 "type": "ui_gauge", 635 "z": "5c322bcd.0d7e24", 636 "name": "motorS", 637 "group": "b15ee046.8c935", 638 "order": 2, 639 "width": 0, 640 "height": 0, 641 "gtype": "gage", 642 "title": "", 643 "label": "° C", 644 "format": "{{value}}", 645 "min": 0, 646 "max": "90", 647 "colors": [ 648 "#00b500", 649 "#e6e600", 650 "#ca3838" 651 ], 652 "seg1": "", 653 "seg2": "", 654 "x": 480, 655 "y": 120, 656 "wires": [] 657 }, 658 { 659 "id": "fde36889.95bd38", 660 "type": "ui_button", 661 "z": "5c322bcd.0d7e24", 662 "name": "", 663 "group": "7b6ef1b8.16383", 664 "order": 1, 665 "width": "6", 666 "height": "1", 667 "passthru": false, 668 "label": "Read all", 669 "tooltip": "", 670 "color": "", 671 "bgcolor": "", 672 "icon": "", 673 "payload": "\\"9\\"", 674 "payloadType": "json", 675 "topic": "spojka", 676 "x": 100, 677 "y": 740, 678 "wires": [ 679 [ 680 "c2fcb0e4.9df3c" 681 ] 682 ] 683 }, 684 { 685 "id": "907051c2.7f0d6", 686 "type": "ui_button", 687 "z": "5c322bcd.0d7e24", 688 "name": "", 689 "group": "6f469820.86dbc8", 690 "order": 1, 691 "width": 0, 692 "height": 0, 693 "passthru": false, 694 "label": "Engine temp", 695 "tooltip": "", 696 "color": "", 697 "bgcolor": "", 698 "icon": "", 699 "payload": "\\"13\\"", 700 "payloadType": "json", 701 "topic": "spojka", 702 "x": 650, 703 "y": 460, 704 "wires": [ 705 [ 706 "c2fcb0e4.9df3c", 707 "6d5bcc4c.efd854" 708 ] 709 ] 710 }, 711 { 712 "id": "92f1767a.688ed8", 713 "type": "ui_button", 714 "z": "5c322bcd.0d7e24", 715 "name": "", 716 "group": "c5be57a5.510478", 717 "order": 1, 718 "width": 0, 719 "height": 0, 720 "passthru": false, 721 "label": "Battery voltage", 722 "tooltip": "", 723 "color": "", 724 "bgcolor": "", 725 "icon": "", 726 "payload": "\\"14\\"", 727 "payloadType": "json", 728 "topic": "spojka", 729 "x": 660, 730 "y": 500, 731 "wires": [ 732 [ 733 "c2fcb0e4.9df3c" 734 ] 735 ] 736 }, 737 { 738 "id": "885fc116.356fd", 739 "type": "ui_button", 740 "z": "5c322bcd.0d7e24", 741 "name": "", 742 "group": "5030d833.9eefd8", 743 "order": 1, 744 "width": "0", 745 "height": "0", 746 "passthru": false, 747 "label": "Velocity", 748 "tooltip": "", 749 "color": "", 750 "bgcolor": "", 751 "icon": "", 752 "payload": "\\"15\\"", 753 "payloadType": "json", 754 "topic": "spojka", 755 "x": 640, 756 "y": 540, 757 "wires": [ 758 [ 759 "c2fcb0e4.9df3c" 760 ] 761 ] 762 }, 763 { 764 "id": "d51c239f.9016e", 765 "type": "ui_button", 766 "z": "5c322bcd.0d7e24", 767 "name": "", 768 "group": "be34be57.b6c16", 769 "order": 1, 770 "width": 0, 771 "height": 0, 772 "passthru": false, 773 "label": "RPM", 774 "tooltip": "", 775 "color": "", 776 "bgcolor": "", 777 "icon": "", 778 "payload": "\\"16\\"", 779 "payloadType": "json", 780 "topic": "spojka", 781 "x": 610, 782 "y": 700, 783 "wires": [ 784 [ 785 "c2fcb0e4.9df3c" 786 ] 787 ] 788 }, 789 { 790 "id": "82b1f1c0.61c95", 791 "type": "ui_button", 792 "z": "5c322bcd.0d7e24", 793 "name": "", 794 "group": "9e83fd0.ce74c", 795 "order": 1, 796 "width": 0, 797 "height": 0, 798 "passthru": false, 799 "label": "Engine load", 800 "tooltip": "", 801 "color": "", 802 "bgcolor": "", 803 "icon": "", 804 "payload": "\\"17\\"", 805 "payloadType": "json", 806 "topic": "spojka", 807 "x": 630, 808 "y": 740, 809 "wires": [ 810 [ 811 "c2fcb0e4.9df3c" 812 ] 813 ] 814 }, 815 { 816 "id": "fc2fd3d3.92929", 817 "type": "ui_button", 818 "z": "5c322bcd.0d7e24", 819 "name": "", 820 "group": "2c1d9538.5680ea", 821 "order": 1, 822 "width": 0, 823 "height": 0, 824 "passthru": false, 825 "label": "Intake air temp", 826 "tooltip": "", 827 "color": "", 828 "bgcolor": "", 829 "icon": "", 830 "payload": "\\"18\\"", 831 "payloadType": "json", 832 "topic": "spojka", 833 "x": 640, 834 "y": 780, 835 "wires": [ 836 [ 837 "c2fcb0e4.9df3c" 838 ] 839 ] 840 }, 841 { 842 "id": "5e6ca779.597a68", 843 "type": "ui_button", 844 "z": "5c322bcd.0d7e24", 845 "name": "", 846 "group": "a006a90c.461b58", 847 "order": 0, 848 "width": "6", 849 "height": "5", 850 "passthru": false, 851 "label": "RESTART", 852 "tooltip": "", 853 "color": "", 854 "bgcolor": "", 855 "icon": "", 856 "payload": "\\"12\\"", 857 "payloadType": "json", 858 "topic": "spojka", 859 "x": 650, 860 "y": 420, 861 "wires": [ 862 [ 863 "c2fcb0e4.9df3c", 864 "89ddbf44.c92b3" 865 ] 866 ] 867 }, 868 { 869 "id": "e26b8480.6ed6a8", 870 "type": "ui_gauge", 871 "z": "5c322bcd.0d7e24", 872 "name": "", 873 "group": "6f469820.86dbc8", 874 "order": 2, 875 "width": 0, 876 "height": 0, 877 "gtype": "gage", 878 "title": "", 879 "label": "° C", 880 "format": "{{value}}", 881 "min": 0, 882 "max": "90", 883 "colors": [ 884 "#00b500", 885 "#e6e600", 886 "#ca3838" 887 ], 888 "seg1": "", 889 "seg2": "", 890 "x": 890, 891 "y": 80, 892 "wires": [] 893 }, 894 { 895 "id": "25282f33.397db", 896 "type": "ui_gauge", 897 "z": "5c322bcd.0d7e24", 898 "name": "", 899 "group": "c5be57a5.510478", 900 "order": 2, 901 "width": "6", 902 "height": "4", 903 "gtype": "wave", 904 "title": "", 905 "label": "V", 906 "format": "{{value}}", 907 "min": 0, 908 "max": "15", 909 "colors": [ 910 "#00b500", 911 "#e6e600", 912 "#ca3838" 913 ], 914 "seg1": "", 915 "seg2": "", 916 "x": 890, 917 "y": 120, 918 "wires": [] 919 }, 920 { 921 "id": "9b7438b8.d46d08", 922 "type": "ui_gauge", 923 "z": "5c322bcd.0d7e24", 924 "name": "zatazmD", 925 "group": "9e83fd0.ce74c", 926 "order": 2, 927 "width": 0, 928 "height": 0, 929 "gtype": "gage", 930 "title": "", 931 "label": "%", 932 "format": "{{value}}", 933 "min": 0, 934 "max": "100", 935 "colors": [ 936 "#00b500", 937 "#e6e600", 938 "#ca3838" 939 ], 940 "seg1": "", 941 "seg2": "", 942 "x": 900, 943 "y": 160, 944 "wires": [] 945 }, 946 { 947 "id": "416cd75.90f5128", 948 "type": "ui_gauge", 949 "z": "5c322bcd.0d7e24", 950 "name": "", 951 "group": "2c1d9538.5680ea", 952 "order": 2, 953 "width": 0, 954 "height": 0, 955 "gtype": "gage", 956 "title": "", 957 "label": "° C", 958 "format": "{{value}}", 959 "min": "-40", 960 "max": "40", 961 "colors": [ 962 "#00b500", 963 "#e6e600", 964 "#ca3838" 965 ], 966 "seg1": "", 967 "seg2": "", 968 "x": 890, 969 "y": 200, 970 "wires": [] 971 }, 972 { 973 "id": "487f89ae.f1e818", 974 "type": "ui_gauge", 975 "z": "5c322bcd.0d7e24", 976 "name": "", 977 "group": "5030d833.9eefd8", 978 "order": 2, 979 "width": 0, 980 "height": 0, 981 "gtype": "gage", 982 "title": "", 983 "label": "kmh", 984 "format": "{{value}}", 985 "min": 0, 986 "max": "250", 987 "colors": [ 988 "#00b500", 989 "#e6e600", 990 "#ca3838" 991 ], 992 "seg1": "", 993 "seg2": "", 994 "x": 890, 995 "y": 280, 996 "wires": [] 997 }, 998 { 999 "id": "3ad69aee.451986", 1000 "type": "ui_gauge", 1001 "z": "5c322bcd.0d7e24", 1002 "name": "otackyD", 1003 "group": "be34be57.b6c16", 1004 "order": 2, 1005 "width": 0, 1006 "height": 0, 1007 "gtype": "gage", 1008 "title": "", 1009 "label": "RPM", 1010 "format": "{{value}}", 1011 "min": 0, 1012 "max": "7000", 1013 "colors": [ 1014 "#00b500", 1015 "#e6e600", 1016 "#ca3838" 1017 ], 1018 "seg1": "", 1019 "seg2": "", 1020 "x": 900, 1021 "y": 240, 1022 "wires": [] 1023 }, 1024 { 1025 "id": "1d98f4df.46248b", 1026 "type": "function", 1027 "z": "5c322bcd.0d7e24", 1028 "name": "dteplotam", 1029 "func": "switch (msg.topic){\ 1030 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dteplotam/fmt/json\\":\ 1031 return {payload:msg.payload.TeplotaMotora};\ 1032}", 1033 "outputs": 1, 1034 "noerr": 0, 1035 "x": 680, 1036 "y": 80, 1037 "wires": [ 1038 [ 1039 "e26b8480.6ed6a8", 1040 "bb009985.60d978" 1041 ] 1042 ] 1043 }, 1044 { 1045 "id": "a0a16110.3d97d", 1046 "type": "function", 1047 "z": "5c322bcd.0d7e24", 1048 "name": "dnapatie", 1049 "func": "switch (msg.topic){\ 1050 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dnapatie/fmt/json\\":\ 1051 return {payload:msg.payload.Napatie};\ 1052}", 1053 "outputs": 1, 1054 "noerr": 0, 1055 "x": 680, 1056 "y": 120, 1057 "wires": [ 1058 [ 1059 "25282f33.397db", 1060 "110734fb.37ff5b" 1061 ] 1062 ] 1063 }, 1064 { 1065 "id": "9cbffc43.6fae4", 1066 "type": "function", 1067 "z": "5c322bcd.0d7e24", 1068 "name": "dzatazm", 1069 "func": "switch (msg.topic){\ 1070 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dzatazm/fmt/json\\":\ 1071 return {payload:msg.payload.ZatazMotora};\ 1072}", 1073 "outputs": 1, 1074 "noerr": 0, 1075 "x": 680, 1076 "y": 160, 1077 "wires": [ 1078 [ 1079 "9b7438b8.d46d08" 1080 ] 1081 ] 1082 }, 1083 { 1084 "id": "804e7a.3d19e188", 1085 "type": "function", 1086 "z": "5c322bcd.0d7e24", 1087 "name": "dteplotasania", 1088 "func": "switch (msg.topic){\ 1089 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dteplotasania/fmt/json\\":\ 1090 return {payload:msg.payload.TeplotaSania};\ 1091}", 1092 "outputs": 1, 1093 "noerr": 0, 1094 "x": 690, 1095 "y": 200, 1096 "wires": [ 1097 [ 1098 "416cd75.90f5128" 1099 ] 1100 ] 1101 }, 1102 { 1103 "id": "c95b86aa.ff9988", 1104 "type": "function", 1105 "z": "5c322bcd.0d7e24", 1106 "name": "dotacky", 1107 "func": "switch (msg.topic){\ 1108 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dotacky/fmt/json\\":\ 1109 return {payload:msg.payload.Otacky};\ 1110}", 1111 "outputs": 1, 1112 "noerr": 0, 1113 "x": 680, 1114 "y": 240, 1115 "wires": [ 1116 [ 1117 "3ad69aee.451986", 1118 "3206e8b5.b2df78" 1119 ] 1120 ] 1121 }, 1122 { 1123 "id": "e2afa857.055908", 1124 "type": "function", 1125 "z": "5c322bcd.0d7e24", 1126 "name": "drychlost", 1127 "func": "switch (msg.topic){\ 1128 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/drychlost/fmt/json\\":\ 1129 return {payload:msg.payload.Rychlost};\ 1130}", 1131 "outputs": 1, 1132 "noerr": 0, 1133 "x": 680, 1134 "y": 280, 1135 "wires": [ 1136 [ 1137 "487f89ae.f1e818", 1138 "79739b5d.19d3a4" 1139 ] 1140 ] 1141 }, 1142 { 1143 "id": "89ddbf44.c92b3", 1144 "type": "function", 1145 "z": "5c322bcd.0d7e24", 1146 "name": "", 1147 "func": " return {payload:\\"\\"};", 1148 "outputs": 1, 1149 "noerr": 0, 1150 "x": 670, 1151 "y": 340, 1152 "wires": [ 1153 [ 1154 "e26b8480.6ed6a8", 1155 "25282f33.397db", 1156 "9b7438b8.d46d08", 1157 "416cd75.90f5128", 1158 "3ad69aee.451986", 1159 "487f89ae.f1e818" 1160 ] 1161 ] 1162 }, 1163 { 1164 "id": "f050f736.555a78", 1165 "type": "debug", 1166 "z": "5c322bcd.0d7e24", 1167 "name": "", 1168 "active": true, 1169 "tosidebar": true, 1170 "console": false, 1171 "tostatus": false, 1172 "complete": "false", 1173 "x": 260, 1174 "y": 20, 1175 "wires": [] 1176 }, 1177 { 1178 "id": "bb009985.60d978", 1179 "type": "ibmiot out", 1180 "z": "5c322bcd.0d7e24", 1181 "authentication": "boundService", 1182 "apiKey": "", 1183 "outputType": "cmd", 1184 "deviceId": "ios_i", 1185 "deviceType": "ios_t", 1186 "eventCommandType": "teplota", 1187 "format": "json", 1188 "data": "{}", 1189 "qos": 0, 1190 "name": "IBM IoT", 1191 "service": "registered", 1192 "x": 1140, 1193 "y": 80, 1194 "wires": [] 1195 }, 1196 { 1197 "id": "110734fb.37ff5b", 1198 "type": "ibmiot out", 1199 "z": "5c322bcd.0d7e24", 1200 "authentication": "boundService", 1201 "apiKey": "", 1202 "outputType": "cmd", 1203 "deviceId": "ios_i", 1204 "deviceType": "ios_t", 1205 "eventCommandType": "napatie", 1206 "format": "json", 1207 "data": "{}", 1208 "qos": 0, 1209 "name": "IBM IoT", 1210 "service": "registered", 1211 "x": 1140, 1212 "y": 120, 1213 "wires": [] 1214 }, 1215 { 1216 "id": "79739b5d.19d3a4", 1217 "type": "ibmiot out", 1218 "z": "5c322bcd.0d7e24", 1219 "authentication": "boundService", 1220 "apiKey": "", 1221 "outputType": "cmd", 1222 "deviceId": "ios_i", 1223 "deviceType": "ios_t", 1224 "eventCommandType": "rychlost", 1225 "format": "json", 1226 "data": "{}", 1227 "qos": 0, 1228 "name": "IBM IoT", 1229 "service": "registered", 1230 "x": 1140, 1231 "y": 280, 1232 "wires": [] 1233 }, 1234 { 1235 "id": "3206e8b5.b2df78", 1236 "type": "ibmiot out", 1237 "z": "5c322bcd.0d7e24", 1238 "authentication": "boundService", 1239 "apiKey": "", 1240 "outputType": "cmd", 1241 "deviceId": "ios_i", 1242 "deviceType": "ios_t", 1243 "eventCommandType": "otacky", 1244 "format": "json", 1245 "data": "{}", 1246 "qos": 0, 1247 "name": "IBM IoT", 1248 "service": "registered", 1249 "x": 1140, 1250 "y": 240, 1251 "wires": [] 1252 }, 1253 { 1254 "id": "6d5bcc4c.efd854", 1255 "type": "debug", 1256 "z": "5c322bcd.0d7e24", 1257 "name": "", 1258 "active": false, 1259 "tosidebar": true, 1260 "console": false, 1261 "tostatus": false, 1262 "complete": "payload", 1263 "targetType": "msg", 1264 "x": 870, 1265 "y": 480, 1266 "wires": [] 1267 }, 1268 { 1269 "id": "26a88bb.6c9d574", 1270 "type": "ibmiot in", 1271 "z": "5c322bcd.0d7e24", 1272 "authentication": "boundService", 1273 "apiKey": "", 1274 "inputType": "evt", 1275 "logicalInterface": "", 1276 "ruleId": "", 1277 "deviceId": "ios_i", 1278 "applicationId": "", 1279 "deviceType": "ios_t", 1280 "eventType": "+", 1281 "commandType": "spojka", 1282 "format": "json", 1283 "name": "IBM IoT", 1284 "service": "registered", 1285 "allDevices": "", 1286 "allApplications": "", 1287 "allDeviceTypes": "", 1288 "allLogicalInterfaces": "", 1289 "allEvents": true, 1290 "allCommands": "", 1291 "allFormats": true, 1292 "qos": 0, 1293 "x": 830, 1294 "y": 360, 1295 "wires": [ 1296 [ 1297 "63392018.ad6dc" 1298 ] 1299 ] 1300 }, 1301 { 1302 "id": "63392018.ad6dc", 1303 "type": "function", 1304 "z": "5c322bcd.0d7e24", 1305 "name": "", 1306 "func": "switch (msg.topic){\ 1307 case \\"iot-2/type/ios_t/id/ios_i/evt/ahoj/fmt/json\\":\ 1308 return {payload:msg.payload.RJpay};\ 1309}", 1310 "outputs": 1, 1311 "noerr": 0, 1312 "x": 870, 1313 "y": 420, 1314 "wires": [ 1315 [ 1316 "6d5bcc4c.efd854", 1317 "c2fcb0e4.9df3c" 1318 ] 1319 ] 1320 }, 1321 { 1322 "id": "4652684e.bd8e48", 1323 "type": "inject", 1324 "z": "5c322bcd.0d7e24", 1325 "name": "", 1326 "topic": "spojka", 1327 "payload": "\\"20\\"", 1328 "payloadType": "json", 1329 "repeat": "", 1330 "crontab": "", 1331 "once": false, 1332 "onceDelay": 0.1, 1333 "x": 420, 1334 "y": 800, 1335 "wires": [ 1336 [ 1337 "c2fcb0e4.9df3c" 1338 ] 1339 ] 1340 }, 1341 { 1342 "id": "875485b.33b0078", 1343 "type": "inject", 1344 "z": "5c322bcd.0d7e24", 1345 "name": "", 1346 "topic": "spojka", 1347 "payload": "\\"21\\"", 1348 "payloadType": "json", 1349 "repeat": "", 1350 "crontab": "", 1351 "once": false, 1352 "onceDelay": 0.1, 1353 "x": 420, 1354 "y": 760, 1355 "wires": [ 1356 [ 1357 "c2fcb0e4.9df3c" 1358 ] 1359 ] 1360 }, 1361 { 1362 "id": "87c28d94.43529", 1363 "type": "ibmiot out", 1364 "z": "5c322bcd.0d7e24", 1365 "authentication": "boundService", 1366 "apiKey": "", 1367 "outputType": "cmd", 1368 "deviceId": "ios_i", 1369 "deviceType": "ios_t", 1370 "eventCommandType": "suradnicemotor", 1371 "format": "json", 1372 "data": "{}", 1373 "qos": 0, 1374 "name": "IBM IoT", 1375 "service": "registered", 1376 "x": 1320, 1377 "y": 180, 1378 "wires": [] 1379 }, 1380 { 1381 "id": "2887474f.3903a8", 1382 "type": "function", 1383 "z": "5c322bcd.0d7e24", 1384 "name": "suradnicemotor", 1385 "func": "switch (msg.topic){\ 1386 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/suradnicemotor/fmt/json\\":\ 1387 return {payload:msg.payload};\ 1388}", 1389 "outputs": 1, 1390 "noerr": 0, 1391 "x": 1120, 1392 "y": 180, 1393 "wires": [ 1394 [ 1395 "3c596726.fd9b38", 1396 "87c28d94.43529" 1397 ] 1398 ] 1399 }, 1400 { 1401 "id": "3c596726.fd9b38", 1402 "type": "debug", 1403 "z": "5c322bcd.0d7e24", 1404 "name": "", 1405 "active": true, 1406 "tosidebar": true, 1407 "console": false, 1408 "tostatus": false, 1409 "complete": "false", 1410 "x": 1210, 1411 "y": 520, 1412 "wires": [] 1413 }, 1414 { 1415 "id": "fe99fbd4.9109b8", 1416 "type": "debug", 1417 "z": "5c322bcd.0d7e24", 1418 "name": "", 1419 "active": true, 1420 "tosidebar": true, 1421 "console": false, 1422 "tostatus": false, 1423 "complete": "false", 1424 "x": 660, 1425 "y": 40, 1426 "wires": [] 1427 }, 1428 { 1429 "id": "c334c204.254a9", 1430 "type": "function", 1431 "z": "5c322bcd.0d7e24", 1432 "name": "suradnicenap", 1433 "func": "switch (msg.topic){\ 1434 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/suradnicenap/fmt/json\\":\ 1435 return {payload:msg.payload};\ 1436}", 1437 "outputs": 1, 1438 "noerr": 0, 1439 "x": 1100, 1440 "y": 20, 1441 "wires": [ 1442 [ 1443 "9b089d4d.b06c5" 1444 ] 1445 ] 1446 }, 1447 { 1448 "id": "9b089d4d.b06c5", 1449 "type": "ibmiot out", 1450 "z": "5c322bcd.0d7e24", 1451 "authentication": "boundService", 1452 "apiKey": "", 1453 "outputType": "cmd", 1454 "deviceId": "ios_i", 1455 "deviceType": "ios_t", 1456 "eventCommandType": "suradnicenap", 1457 "format": "json", 1458 "data": "{}", 1459 "qos": 0, 1460 "name": "IBM IoT", 1461 "service": "registered", 1462 "x": 1320, 1463 "y": 80, 1464 "wires": [] 1465 }, 1466 { 1467 "id": "15ac389c.0aeb97", 1468 "type": "ibmiot out", 1469 "z": "5c322bcd.0d7e24", 1470 "authentication": "boundService", 1471 "apiKey": "", 1472 "outputType": "cmd", 1473 "deviceId": "ios_i", 1474 "deviceType": "ios_t", 1475 "eventCommandType": "surarychl", 1476 "format": "json", 1477 "data": "{}", 1478 "qos": 0, 1479 "name": "IBM IoT", 1480 "service": "registered", 1481 "x": 1320, 1482 "y": 340, 1483 "wires": [] 1484 }, 1485 { 1486 "id": "a11eb45f.d38ef8", 1487 "type": "function", 1488 "z": "5c322bcd.0d7e24", 1489 "name": "surarychl", 1490 "func": "switch (msg.topic){\ 1491 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/surarychl/fmt/json\\":\ 1492 return {payload:msg.payload};\ 1493}", 1494 "outputs": 1, 1495 "noerr": 0, 1496 "x": 1120, 1497 "y": 340, 1498 "wires": [ 1499 [ 1500 "15ac389c.0aeb97" 1501 ] 1502 ] 1503 }, 1504 { 1505 "id": "9d5ef054.3aeed", 1506 "type": "function", 1507 "z": "5c322bcd.0d7e24", 1508 "name": "suraotac", 1509 "func": "switch (msg.topic){\ 1510 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/suraotac/fmt/json\\":\ 1511 return {payload:msg.payload};\ 1512}", 1513 "outputs": 1, 1514 "noerr": 0, 1515 "x": 1120, 1516 "y": 400, 1517 "wires": [ 1518 [ 1519 "5a0f36cd.44ca48" 1520 ] 1521 ] 1522 }, 1523 { 1524 "id": "5a0f36cd.44ca48", 1525 "type": "ibmiot out", 1526 "z": "5c322bcd.0d7e24", 1527 "authentication": "boundService", 1528 "apiKey": "", 1529 "outputType": "cmd", 1530 "deviceId": "ios_i", 1531 "deviceType": "ios_t", 1532 "eventCommandType": "suraotac", 1533 "format": "json", 1534 "data": "{}", 1535 "qos": 0, 1536 "name": "IBM IoT", 1537 "service": "registered", 1538 "x": 1320, 1539 "y": 400, 1540 "wires": [] 1541 }, 1542 { 1543 "id": "91e819d.952aee8", 1544 "type": "debug", 1545 "z": "5c322bcd.0d7e24", 1546 "name": "", 1547 "active": true, 1548 "tosidebar": true, 1549 "console": false, 1550 "tostatus": false, 1551 "complete": "payload", 1552 "targetType": "msg", 1553 "x": 200, 1554 "y": 820, 1555 "wires": [] 1556 }, 1557 { 1558 "id": "4bf77032.81e66", 1559 "type": "ui_button", 1560 "z": "5c322bcd.0d7e24", 1561 "name": "", 1562 "group": "7b6ef1b8.16383", 1563 "order": 2, 1564 "width": "6", 1565 "height": "4", 1566 "passthru": false, 1567 "label": "RESTART", 1568 "tooltip": "", 1569 "color": "", 1570 "bgcolor": "", 1571 "icon": "", 1572 "payload": "\\"8\\"", 1573 "payloadType": "json", 1574 "topic": "spojka", 1575 "x": 110, 1576 "y": 420, 1577 "wires": [ 1578 [ 1579 "7ed3d7b9.a233a8", 1580 "c2fcb0e4.9df3c" 1581 ] 1582 ] 1583 }, 1584 { 1585 "id": "67f5864a.d0b778", 1586 "type": "inject", 1587 "z": "5c322bcd.0d7e24", 1588 "name": "", 1589 "topic": "spojka", 1590 "payload": "\\"19\\"", 1591 "payloadType": "json", 1592 "repeat": "", 1593 "crontab": "", 1594 "once": false, 1595 "onceDelay": 0.1, 1596 "x": 660, 1597 "y": 840, 1598 "wires": [ 1599 [ 1600 "c2fcb0e4.9df3c" 1601 ] 1602 ] 1603 }, 1604 { 1605 "id": "b15ee046.8c935", 1606 "type": "ui_group", 1607 "z": "", 1608 "name": "1", 1609 "tab": "92efbb56.641408", 1610 "order": 1, 1611 "disp": false, 1612 "width": "6", 1613 "collapse": false 1614 }, 1615 { 1616 "id": "f7606a4e.234618", 1617 "type": "ui_group", 1618 "z": "", 1619 "name": "3", 1620 "tab": "92efbb56.641408", 1621 "order": 5, 1622 "disp": false, 1623 "width": "6", 1624 "collapse": false 1625 }, 1626 { 1627 "id": "f943ae3.4d5b75", 1628 "type": "ui_group", 1629 "z": "", 1630 "name": "4", 1631 "tab": "92efbb56.641408", 1632 "order": 6, 1633 "disp": false, 1634 "width": "6", 1635 "collapse": false 1636 }, 1637 { 1638 "id": "b3c559b3.3e97d8", 1639 "type": "ui_group", 1640 "z": "", 1641 "name": "2", 1642 "tab": "92efbb56.641408", 1643 "order": 2, 1644 "disp": false, 1645 "width": "6", 1646 "collapse": false 1647 }, 1648 { 1649 "id": "34ec3061.6e984", 1650 "type": "ui_group", 1651 "z": "", 1652 "name": "5", 1653 "tab": "92efbb56.641408", 1654 "order": 4, 1655 "disp": false, 1656 "width": "6", 1657 "collapse": false 1658 }, 1659 { 1660 "id": "3fc295fe.9f49ca", 1661 "type": "ui_group", 1662 "z": "", 1663 "name": "6", 1664 "tab": "92efbb56.641408", 1665 "order": 3, 1666 "disp": false, 1667 "width": "6", 1668 "collapse": false 1669 }, 1670 { 1671 "id": "3621392d.b91016", 1672 "type": "ui_group", 1673 "z": "", 1674 "name": "7", 1675 "tab": "92efbb56.641408", 1676 "order": 7, 1677 "disp": false, 1678 "width": "6", 1679 "collapse": false 1680 }, 1681 { 1682 "id": "7b6ef1b8.16383", 1683 "type": "ui_group", 1684 "z": "", 1685 "name": "8", 1686 "tab": "92efbb56.641408", 1687 "order": 8, 1688 "disp": false, 1689 "width": "6", 1690 "collapse": false 1691 }, 1692 { 1693 "id": "6f469820.86dbc8", 1694 "type": "ui_group", 1695 "z": "", 1696 "name": "Group 1", 1697 "tab": "95159b00.fda818", 1698 "order": 1, 1699 "disp": false, 1700 "width": "6", 1701 "collapse": false 1702 }, 1703 { 1704 "id": "c5be57a5.510478", 1705 "type": "ui_group", 1706 "z": "", 1707 "name": "Group 2", 1708 "tab": "95159b00.fda818", 1709 "order": 2, 1710 "disp": false, 1711 "width": "6", 1712 "collapse": false 1713 }, 1714 { 1715 "id": "5030d833.9eefd8", 1716 "type": "ui_group", 1717 "z": "", 1718 "name": "Group 3", 1719 "tab": "95159b00.fda818", 1720 "order": 3, 1721 "disp": false, 1722 "width": "6", 1723 "collapse": false 1724 }, 1725 { 1726 "id": "be34be57.b6c16", 1727 "type": "ui_group", 1728 "z": "", 1729 "name": "Group 4", 1730 "tab": "95159b00.fda818", 1731 "order": 4, 1732 "disp": false, 1733 "width": "6", 1734 "collapse": false 1735 }, 1736 { 1737 "id": "9e83fd0.ce74c", 1738 "type": "ui_group", 1739 "z": "", 1740 "name": "Group 5", 1741 "tab": "95159b00.fda818", 1742 "order": 5, 1743 "disp": false, 1744 "width": "6", 1745 "collapse": false 1746 }, 1747 { 1748 "id": "2c1d9538.5680ea", 1749 "type": "ui_group", 1750 "z": "", 1751 "name": "Group 6", 1752 "tab": "95159b00.fda818", 1753 "order": 6, 1754 "disp": false, 1755 "width": "6", 1756 "collapse": false 1757 }, 1758 { 1759 "id": "a006a90c.461b58", 1760 "type": "ui_group", 1761 "z": "", 1762 "name": "Group 7", 1763 "tab": "95159b00.fda818", 1764 "order": 7, 1765 "disp": false, 1766 "width": "6", 1767 "collapse": false 1768 }, 1769 { 1770 "id": "92efbb56.641408", 1771 "type": "ui_tab", 1772 "z": "", 1773 "name": "STATICKE TESTY", 1774 "icon": "dashboard", 1775 "order": 1, 1776 "disabled": false, 1777 "hidden": false 1778 }, 1779 { 1780 "id": "95159b00.fda818", 1781 "type": "ui_tab", 1782 "z": "", 1783 "name": "DYNAMICKE TESTY", 1784 "icon": "dashboard", 1785 "order": 2, 1786 "disabled": false, 1787 "hidden": false 1788 } 1789]
MapView - Map with annotation mark Swift code
swift
For iOS application
1// 2// MapView.swift 3// RingViewRPM 4// 5// Created by Kardan on 01/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10import MapKit 11 12 13struct MapView: UIViewRepresentable { 14 var predtym:Double 15 var nazov:String="sevas" 16 var dlzka = 34.011286 17 var sirka = -116.166868 18 @State var prava:Bool=true 19 20 func makeUIView(context: Context) -> MKMapView { 21 MKMapView(frame: .zero) 22 } 23 24 func updateUIView(_ uiView: MKMapView, context: Context) { 25 26 27 let coordinate = CLLocationCoordinate2D( 28 latitude: dlzka, longitude: sirka) 29 let sponka=MKPointAnnotation() 30 sponka.coordinate=coordinate 31 sponka.title=nazov 32 let span = MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01) 33 let region = MKCoordinateRegion(center: coordinate, span: span) 34 uiView.setRegion(region, animated: true) 35 let annotations = uiView.annotations 36 uiView.removeAnnotations(annotations) 37 uiView.addAnnotation(sponka) 38 39 40} 41 42 43 44} 45 46
Node-RED flow
json
1[ 2 { 3 "id": "5c322bcd.0d7e24", 4 "type": "tab", 5 "label": "Flow 1", 6 "disabled": false, 7 "info": "" 8 }, 9 { 10 "id": "fe020458.d37fb8", 11 "type": "ibmiot in", 12 "z": "5c322bcd.0d7e24", 13 "authentication": "boundService", 14 "apiKey": "", 15 "inputType": "evt", 16 "logicalInterface": "", 17 "ruleId": "", 18 "deviceId": "IDkontroler", 19 "applicationId": "", 20 "deviceType": "Mikrokontroler", 21 "eventType": "+", 22 "commandType": "", 23 "format": "json", 24 "name": "IBM IoT", 25 "service": "registered", 26 "allDevices": "", 27 "allApplications": "", 28 "allDeviceTypes": false, 29 "allLogicalInterfaces": "", 30 "allEvents": true, 31 "allCommands": "", 32 "allFormats": false, 33 "qos": 0, 34 "x": 70, 35 "y": 80, 36 "wires": [ 37 [ 38 "82d427c1.5f1e38", 39 "43f37536.a7fcec", 40 "1435a819.13f948", 41 "6388de69.38c86", 42 "7b79441a.0c9a0c", 43 "34e21a58.f23676", 44 "4f372508.eed40c", 45 "ffca5f60.a2836", 46 "1d98f4df.46248b", 47 "a0a16110.3d97d", 48 "9cbffc43.6fae4", 49 "804e7a.3d19e188", 50 "c95b86aa.ff9988", 51 "e2afa857.055908", 52 "f050f736.555a78", 53 "2887474f.3903a8", 54 "c334c204.254a9", 55 "a11eb45f.d38ef8", 56 "9d5ef054.3aeed" 57 ] 58 ] 59 }, 60 { 61 "id": "c2fcb0e4.9df3c", 62 "type": "ibmiot out", 63 "z": "5c322bcd.0d7e24", 64 "authentication": "boundService", 65 "apiKey": "", 66 "outputType": "cmd", 67 "deviceId": "IDkontroler", 68 "deviceType": "Mikrokontroler", 69 "eventCommandType": "spojka", 70 "format": "json", 71 "data": "{}", 72 "qos": 0, 73 "name": "IBM IoT", 74 "service": "registered", 75 "x": 840, 76 "y": 620, 77 "wires": [] 78 }, 79 { 80 "id": "4f20b8e8.6d0368", 81 "type": "ui_button", 82 "z": "5c322bcd.0d7e24", 83 "name": "", 84 "group": "b15ee046.8c935", 85 "order": 1, 86 "width": 0, 87 "height": 0, 88 "passthru": false, 89 "label": "Engine temp", 90 "tooltip": "", 91 "color": "", 92 "bgcolor": "", 93 "icon": "", 94 "payload": "\\"1\\"", 95 "payloadType": "json", 96 "topic": "spojka", 97 "x": 110, 98 "y": 460, 99 "wires": [ 100 [ 101 "c2fcb0e4.9df3c" 102 ] 103 ] 104 }, 105 { 106 "id": "aec1cc46.8c43a", 107 "type": "ui_button", 108 "z": "5c322bcd.0d7e24", 109 "name": "", 110 "group": "f7606a4e.234618", 111 "order": 1, 112 "width": 0, 113 "height": 0, 114 "passthru": false, 115 "label": "Engine load", 116 "tooltip": "", 117 "color": "", 118 "bgcolor": "", 119 "icon": "", 120 "payload": "\\"3\\"", 121 "payloadType": "json", 122 "topic": "spojka", 123 "x": 110, 124 "y": 540, 125 "wires": [ 126 [ 127 "c2fcb0e4.9df3c" 128 ] 129 ] 130 }, 131 { 132 "id": "180233f4.ae6cdc", 133 "type": "ui_button", 134 "z": "5c322bcd.0d7e24", 135 "name": "", 136 "group": "f943ae3.4d5b75", 137 "order": 1, 138 "width": 0, 139 "height": 0, 140 "passthru": false, 141 "label": "Intake air temp", 142 "tooltip": "", 143 "color": "", 144 "bgcolor": "", 145 "icon": "", 146 "payload": "\\"4\\"", 147 "payloadType": "json", 148 "topic": "spojka", 149 "x": 120, 150 "y": 580, 151 "wires": [ 152 [ 153 "c2fcb0e4.9df3c" 154 ] 155 ] 156 }, 157 { 158 "id": "3da42317.916b5c", 159 "type": "ui_button", 160 "z": "5c322bcd.0d7e24", 161 "name": "", 162 "group": "b3c559b3.3e97d8", 163 "order": 1, 164 "width": 0, 165 "height": 0, 166 "passthru": false, 167 "label": "Battery voltage", 168 "tooltip": "", 169 "color": "", 170 "bgcolor": "", 171 "icon": "", 172 "payload": "\\"2\\"", 173 "payloadType": "json", 174 "topic": "spojka", 175 "x": 120, 176 "y": 500, 177 "wires": [ 178 [ 179 "c2fcb0e4.9df3c" 180 ] 181 ] 182 }, 183 { 184 "id": "29d384f.73d7a7c", 185 "type": "ui_button", 186 "z": "5c322bcd.0d7e24", 187 "name": "", 188 "group": "34ec3061.6e984", 189 "order": 1, 190 "width": 0, 191 "height": 0, 192 "passthru": false, 193 "label": "RPM", 194 "tooltip": "", 195 "color": "", 196 "bgcolor": "", 197 "icon": "", 198 "payload": "\\"5\\"", 199 "payloadType": "json", 200 "topic": "spojka", 201 "x": 90, 202 "y": 620, 203 "wires": [ 204 [ 205 "c2fcb0e4.9df3c", 206 "91e819d.952aee8" 207 ] 208 ] 209 }, 210 { 211 "id": "93e16f5a.1cf5c", 212 "type": "ui_button", 213 "z": "5c322bcd.0d7e24", 214 "name": "", 215 "group": "3fc295fe.9f49ca", 216 "order": 1, 217 "width": 0, 218 "height": 0, 219 "passthru": false, 220 "label": "Velocity", 221 "tooltip": "", 222 "color": "", 223 "bgcolor": "", 224 "icon": "", 225 "payload": "\\"6\\"", 226 "payloadType": "json", 227 "topic": "spojka", 228 "x": 100, 229 "y": 660, 230 "wires": [ 231 [ 232 "c2fcb0e4.9df3c" 233 ] 234 ] 235 }, 236 { 237 "id": "f14580c0.81f91", 238 "type": "ui_button", 239 "z": "5c322bcd.0d7e24", 240 "name": "", 241 "group": "3621392d.b91016", 242 "order": 1, 243 "width": 0, 244 "height": 0, 245 "passthru": false, 246 "label": "VIN", 247 "tooltip": "", 248 "color": "", 249 "bgcolor": "", 250 "icon": "", 251 "payload": "\\"7\\"", 252 "payloadType": "json", 253 "topic": "spojka", 254 "x": 90, 255 "y": 700, 256 "wires": [ 257 [ 258 "c2fcb0e4.9df3c" 259 ] 260 ] 261 }, 262 { 263 "id": "82d427c1.5f1e38", 264 "type": "function", 265 "z": "5c322bcd.0d7e24", 266 "name": "", 267 "func": "switch (msg.topic){\ 268 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotam/fmt/json\\":\ 269 return {payload:msg.payload.TeplotaMotora};\ 270 break;\ 271 \ 272 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotao/fmt/json\\":\ 273 return {payload:msg.payload.TeplotaOleja};\ 274 break;\ 275 \ 276 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/rychlost/fmt/json\\":\ 277 return {payload:msg.payload.Rychlost};\ 278 break;\ 279 \ 280 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/otacky/fmt/json\\":\ 281 return {payload:msg.payload.Otacky};\ 282 break;\ 283 \ 284 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/benzin/fmt/json\\":\ 285 return {payload:msg.payload.Benzin};\ 286 break;\ 287 \ 288 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotav/fmt/json\\":\ 289 return {payload:msg.payload.TeplotaVzduchu};\ 290 break;\ 291 \ 292 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dtcs/fmt/json\\":\ 293 return {payload:msg.payload.DTCs};\ 294 break;\ 295 \ 296 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/vycisti/fmt/json\\":\ 297 return {payload:msg.payload.Vycisti};\ 298 break; \ 299}", 300 "outputs": 1, 301 "noerr": 0, 302 "x": 250, 303 "y": 80, 304 "wires": [ 305 [ 306 "5bd2c651.2adea8" 307 ] 308 ] 309 }, 310 { 311 "id": "5bd2c651.2adea8", 312 "type": "debug", 313 "z": "5c322bcd.0d7e24", 314 "name": "", 315 "active": false, 316 "tosidebar": true, 317 "console": false, 318 "tostatus": false, 319 "complete": "false", 320 "x": 490, 321 "y": 80, 322 "wires": [] 323 }, 324 { 325 "id": "43f37536.a7fcec", 326 "type": "function", 327 "z": "5c322bcd.0d7e24", 328 "name": "", 329 "func": "switch (msg.topic){\ 330 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotam/fmt/json\\":\ 331 return {payload:msg.payload.TeplotaMotora};\ 332}\ 333\ 334\ 335\ 336\ 337\ 338", 339 "outputs": 1, 340 "noerr": 0, 341 "x": 250, 342 "y": 120, 343 "wires": [ 344 [ 345 "fe99fbd4.9109b8", 346 "f2ad5cb4.ababd" 347 ] 348 ] 349 }, 350 { 351 "id": "1435a819.13f948", 352 "type": "function", 353 "z": "5c322bcd.0d7e24", 354 "name": "", 355 "func": "switch (msg.topic){\ 356 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/napatie/fmt/json\\":\ 357 return {payload:msg.payload.Napatie};\ 358}", 359 "outputs": 1, 360 "noerr": 0, 361 "x": 250, 362 "y": 160, 363 "wires": [ 364 [ 365 "e7e764ae.4ca5e8" 366 ] 367 ] 368 }, 369 { 370 "id": "6388de69.38c86", 371 "type": "function", 372 "z": "5c322bcd.0d7e24", 373 "name": "", 374 "func": "switch (msg.topic){\ 375 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/zatazm/fmt/json\\":\ 376 return {payload:msg.payload.ZatazMotora};\ 377}", 378 "outputs": 1, 379 "noerr": 0, 380 "x": 250, 381 "y": 200, 382 "wires": [ 383 [ 384 "7eadc7ad.7cf6e8" 385 ] 386 ] 387 }, 388 { 389 "id": "7b79441a.0c9a0c", 390 "type": "function", 391 "z": "5c322bcd.0d7e24", 392 "name": "", 393 "func": "switch (msg.topic){\ 394 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/teplotasania/fmt/json\\":\ 395 return {payload:msg.payload.TeplotaSania};\ 396}", 397 "outputs": 1, 398 "noerr": 0, 399 "x": 250, 400 "y": 240, 401 "wires": [ 402 [ 403 "45872dba.55fcd4" 404 ] 405 ] 406 }, 407 { 408 "id": "34e21a58.f23676", 409 "type": "function", 410 "z": "5c322bcd.0d7e24", 411 "name": "", 412 "func": "switch (msg.topic){\ 413 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/otacky/fmt/json\\":\ 414 return {payload:msg.payload.Otacky};\ 415}", 416 "outputs": 1, 417 "noerr": 0, 418 "x": 250, 419 "y": 280, 420 "wires": [ 421 [ 422 "2a0f2623.21943a" 423 ] 424 ] 425 }, 426 { 427 "id": "ffca5f60.a2836", 428 "type": "function", 429 "z": "5c322bcd.0d7e24", 430 "name": "", 431 "func": "switch (msg.topic){\ 432 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/VIN/fmt/json\\":\ 433 return {payload:msg.payload.VIN};\ 434}", 435 "outputs": 1, 436 "noerr": 0, 437 "x": 250, 438 "y": 360, 439 "wires": [ 440 [ 441 "f5ad1b10.a28e28" 442 ] 443 ] 444 }, 445 { 446 "id": "4f372508.eed40c", 447 "type": "function", 448 "z": "5c322bcd.0d7e24", 449 "name": "", 450 "func": "switch (msg.topic){\ 451 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/rychlost/fmt/json\\":\ 452 return {payload:msg.payload.Rychlost};\ 453}", 454 "outputs": 1, 455 "noerr": 0, 456 "x": 250, 457 "y": 320, 458 "wires": [ 459 [ 460 "57ee1e71.74562" 461 ] 462 ] 463 }, 464 { 465 "id": "e7e764ae.4ca5e8", 466 "type": "ui_gauge", 467 "z": "5c322bcd.0d7e24", 468 "name": "napatieS", 469 "group": "b3c559b3.3e97d8", 470 "order": 2, 471 "width": "6", 472 "height": "4", 473 "gtype": "wave", 474 "title": "", 475 "label": "V", 476 "format": "{{value}}", 477 "min": "0", 478 "max": "15", 479 "colors": [ 480 "#00b500", 481 "#e6e600", 482 "#ca3838" 483 ], 484 "seg1": "", 485 "seg2": "", 486 "x": 480, 487 "y": 160, 488 "wires": [] 489 }, 490 { 491 "id": "7eadc7ad.7cf6e8", 492 "type": "ui_gauge", 493 "z": "5c322bcd.0d7e24", 494 "name": "", 495 "group": "f7606a4e.234618", 496 "order": 2, 497 "width": 0, 498 "height": 0, 499 "gtype": "gage", 500 "title": "", 501 "label": "%", 502 "format": "{{value}}", 503 "min": "0", 504 "max": "100", 505 "colors": [ 506 "#fee849", 507 "#e39a02", 508 "#d21515" 509 ], 510 "seg1": "", 511 "seg2": "", 512 "x": 470, 513 "y": 200, 514 "wires": [] 515 }, 516 { 517 "id": "45872dba.55fcd4", 518 "type": "ui_gauge", 519 "z": "5c322bcd.0d7e24", 520 "name": "", 521 "group": "f943ae3.4d5b75", 522 "order": 2, 523 "width": 0, 524 "height": 0, 525 "gtype": "gage", 526 "title": "", 527 "label": "° C", 528 "format": "{{value}}", 529 "min": "-40", 530 "max": "40", 531 "colors": [ 532 "#00ff00", 533 "#ffff00", 534 "#e60000" 535 ], 536 "seg1": "", 537 "seg2": "", 538 "x": 470, 539 "y": 240, 540 "wires": [] 541 }, 542 { 543 "id": "2a0f2623.21943a", 544 "type": "ui_gauge", 545 "z": "5c322bcd.0d7e24", 546 "name": "", 547 "group": "34ec3061.6e984", 548 "order": 2, 549 "width": 0, 550 "height": 0, 551 "gtype": "gage", 552 "title": "", 553 "label": "RPM", 554 "format": "{{value}}", 555 "min": 0, 556 "max": "8000", 557 "colors": [ 558 "#ffffff", 559 "#00e611", 560 "#000000" 561 ], 562 "seg1": "", 563 "seg2": "", 564 "x": 470, 565 "y": 280, 566 "wires": [] 567 }, 568 { 569 "id": "57ee1e71.74562", 570 "type": "ui_gauge", 571 "z": "5c322bcd.0d7e24", 572 "name": "", 573 "group": "3fc295fe.9f49ca", 574 "order": 2, 575 "width": 0, 576 "height": 0, 577 "gtype": "gage", 578 "title": "", 579 "label": "kmh", 580 "format": "{{value}}", 581 "min": "0", 582 "max": "250", 583 "colors": [ 584 "#0000c6", 585 "#caceff", 586 "#ec1e00" 587 ], 588 "seg1": "", 589 "seg2": "", 590 "x": 470, 591 "y": 320, 592 "wires": [] 593 }, 594 { 595 "id": "f5ad1b10.a28e28", 596 "type": "ui_text", 597 "z": "5c322bcd.0d7e24", 598 "group": "3621392d.b91016", 599 "order": 2, 600 "width": 6, 601 "height": 4, 602 "name": "", 603 "label": "", 604 "format": "{{msg.payload}}", 605 "layout": "col-center", 606 "x": 470, 607 "y": 360, 608 "wires": [] 609 }, 610 { 611 "id": "7ed3d7b9.a233a8", 612 "type": "function", 613 "z": "5c322bcd.0d7e24", 614 "name": "", 615 "func": " return {payload:\\"\\"};", 616 "outputs": 1, 617 "noerr": 0, 618 "x": 310, 619 "y": 420, 620 "wires": [ 621 [ 622 "e7e764ae.4ca5e8", 623 "7eadc7ad.7cf6e8", 624 "45872dba.55fcd4", 625 "2a0f2623.21943a", 626 "57ee1e71.74562", 627 "f5ad1b10.a28e28", 628 "f2ad5cb4.ababd" 629 ] 630 ] 631 }, 632 { 633 "id": "f2ad5cb4.ababd", 634 "type": "ui_gauge", 635 "z": "5c322bcd.0d7e24", 636 "name": "motorS", 637 "group": "b15ee046.8c935", 638 "order": 2, 639 "width": 0, 640 "height": 0, 641 "gtype": "gage", 642 "title": "", 643 "label": "° C", 644 "format": "{{value}}", 645 "min": 0, 646 "max": "90", 647 "colors": [ 648 "#00b500", 649 "#e6e600", 650 "#ca3838" 651 ], 652 "seg1": "", 653 "seg2": "", 654 "x": 480, 655 "y": 120, 656 "wires": [] 657 }, 658 { 659 "id": "fde36889.95bd38", 660 "type": "ui_button", 661 "z": "5c322bcd.0d7e24", 662 "name": "", 663 "group": "7b6ef1b8.16383", 664 "order": 1, 665 "width": "6", 666 "height": "1", 667 "passthru": false, 668 "label": "Read all", 669 "tooltip": "", 670 "color": "", 671 "bgcolor": "", 672 "icon": "", 673 "payload": "\\"9\\"", 674 "payloadType": "json", 675 "topic": "spojka", 676 "x": 100, 677 "y": 740, 678 "wires": [ 679 [ 680 "c2fcb0e4.9df3c" 681 ] 682 ] 683 }, 684 { 685 "id": "907051c2.7f0d6", 686 "type": "ui_button", 687 "z": "5c322bcd.0d7e24", 688 "name": "", 689 "group": "6f469820.86dbc8", 690 "order": 1, 691 "width": 0, 692 "height": 0, 693 "passthru": false, 694 "label": "Engine temp", 695 "tooltip": "", 696 "color": "", 697 "bgcolor": "", 698 "icon": "", 699 "payload": "\\"13\\"", 700 "payloadType": "json", 701 "topic": "spojka", 702 "x": 650, 703 "y": 460, 704 "wires": [ 705 [ 706 "c2fcb0e4.9df3c", 707 "6d5bcc4c.efd854" 708 ] 709 ] 710 }, 711 { 712 "id": "92f1767a.688ed8", 713 "type": "ui_button", 714 "z": "5c322bcd.0d7e24", 715 "name": "", 716 "group": "c5be57a5.510478", 717 "order": 1, 718 "width": 0, 719 "height": 0, 720 "passthru": false, 721 "label": "Battery voltage", 722 "tooltip": "", 723 "color": "", 724 "bgcolor": "", 725 "icon": "", 726 "payload": "\\"14\\"", 727 "payloadType": "json", 728 "topic": "spojka", 729 "x": 660, 730 "y": 500, 731 "wires": [ 732 [ 733 "c2fcb0e4.9df3c" 734 ] 735 ] 736 }, 737 { 738 "id": "885fc116.356fd", 739 "type": "ui_button", 740 "z": "5c322bcd.0d7e24", 741 "name": "", 742 "group": "5030d833.9eefd8", 743 "order": 1, 744 "width": "0", 745 "height": "0", 746 "passthru": false, 747 "label": "Velocity", 748 "tooltip": "", 749 "color": "", 750 "bgcolor": "", 751 "icon": "", 752 "payload": "\\"15\\"", 753 "payloadType": "json", 754 "topic": "spojka", 755 "x": 640, 756 "y": 540, 757 "wires": [ 758 [ 759 "c2fcb0e4.9df3c" 760 ] 761 ] 762 }, 763 { 764 "id": "d51c239f.9016e", 765 "type": "ui_button", 766 "z": "5c322bcd.0d7e24", 767 "name": "", 768 "group": "be34be57.b6c16", 769 "order": 1, 770 "width": 0, 771 "height": 0, 772 "passthru": false, 773 "label": "RPM", 774 "tooltip": "", 775 "color": "", 776 "bgcolor": "", 777 "icon": "", 778 "payload": "\\"16\\"", 779 "payloadType": "json", 780 "topic": "spojka", 781 "x": 610, 782 "y": 700, 783 "wires": [ 784 [ 785 "c2fcb0e4.9df3c" 786 ] 787 ] 788 }, 789 { 790 "id": "82b1f1c0.61c95", 791 "type": "ui_button", 792 "z": "5c322bcd.0d7e24", 793 "name": "", 794 "group": "9e83fd0.ce74c", 795 "order": 1, 796 "width": 0, 797 "height": 0, 798 "passthru": false, 799 "label": "Engine load", 800 "tooltip": "", 801 "color": "", 802 "bgcolor": "", 803 "icon": "", 804 "payload": "\\"17\\"", 805 "payloadType": "json", 806 "topic": "spojka", 807 "x": 630, 808 "y": 740, 809 "wires": [ 810 [ 811 "c2fcb0e4.9df3c" 812 ] 813 ] 814 }, 815 { 816 "id": "fc2fd3d3.92929", 817 "type": "ui_button", 818 "z": "5c322bcd.0d7e24", 819 "name": "", 820 "group": "2c1d9538.5680ea", 821 "order": 1, 822 "width": 0, 823 "height": 0, 824 "passthru": false, 825 "label": "Intake air temp", 826 "tooltip": "", 827 "color": "", 828 "bgcolor": "", 829 "icon": "", 830 "payload": "\\"18\\"", 831 "payloadType": "json", 832 "topic": "spojka", 833 "x": 640, 834 "y": 780, 835 "wires": [ 836 [ 837 "c2fcb0e4.9df3c" 838 ] 839 ] 840 }, 841 { 842 "id": "5e6ca779.597a68", 843 "type": "ui_button", 844 "z": "5c322bcd.0d7e24", 845 "name": "", 846 "group": "a006a90c.461b58", 847 "order": 0, 848 "width": "6", 849 "height": "5", 850 "passthru": false, 851 "label": "RESTART", 852 "tooltip": "", 853 "color": "", 854 "bgcolor": "", 855 "icon": "", 856 "payload": "\\"12\\"", 857 "payloadType": "json", 858 "topic": "spojka", 859 "x": 650, 860 "y": 420, 861 "wires": [ 862 [ 863 "c2fcb0e4.9df3c", 864 "89ddbf44.c92b3" 865 ] 866 ] 867 }, 868 { 869 "id": "e26b8480.6ed6a8", 870 "type": "ui_gauge", 871 "z": "5c322bcd.0d7e24", 872 "name": "", 873 "group": "6f469820.86dbc8", 874 "order": 2, 875 "width": 0, 876 "height": 0, 877 "gtype": "gage", 878 "title": "", 879 "label": "° C", 880 "format": "{{value}}", 881 "min": 0, 882 "max": "90", 883 "colors": [ 884 "#00b500", 885 "#e6e600", 886 "#ca3838" 887 ], 888 "seg1": "", 889 "seg2": "", 890 "x": 890, 891 "y": 80, 892 "wires": [] 893 }, 894 { 895 "id": "25282f33.397db", 896 "type": "ui_gauge", 897 "z": "5c322bcd.0d7e24", 898 "name": "", 899 "group": "c5be57a5.510478", 900 "order": 2, 901 "width": "6", 902 "height": "4", 903 "gtype": "wave", 904 "title": "", 905 "label": "V", 906 "format": "{{value}}", 907 "min": 0, 908 "max": "15", 909 "colors": [ 910 "#00b500", 911 "#e6e600", 912 "#ca3838" 913 ], 914 "seg1": "", 915 "seg2": "", 916 "x": 890, 917 "y": 120, 918 "wires": [] 919 }, 920 { 921 "id": "9b7438b8.d46d08", 922 "type": "ui_gauge", 923 "z": "5c322bcd.0d7e24", 924 "name": "zatazmD", 925 "group": "9e83fd0.ce74c", 926 "order": 2, 927 "width": 0, 928 "height": 0, 929 "gtype": "gage", 930 "title": "", 931 "label": "%", 932 "format": "{{value}}", 933 "min": 0, 934 "max": "100", 935 "colors": [ 936 "#00b500", 937 "#e6e600", 938 "#ca3838" 939 ], 940 "seg1": "", 941 "seg2": "", 942 "x": 900, 943 "y": 160, 944 "wires": [] 945 }, 946 { 947 "id": "416cd75.90f5128", 948 "type": "ui_gauge", 949 "z": "5c322bcd.0d7e24", 950 "name": "", 951 "group": "2c1d9538.5680ea", 952 "order": 2, 953 "width": 0, 954 "height": 0, 955 "gtype": "gage", 956 "title": "", 957 "label": "° C", 958 "format": "{{value}}", 959 "min": "-40", 960 "max": "40", 961 "colors": [ 962 "#00b500", 963 "#e6e600", 964 "#ca3838" 965 ], 966 "seg1": "", 967 "seg2": "", 968 "x": 890, 969 "y": 200, 970 "wires": [] 971 }, 972 { 973 "id": "487f89ae.f1e818", 974 "type": "ui_gauge", 975 "z": "5c322bcd.0d7e24", 976 "name": "", 977 "group": "5030d833.9eefd8", 978 "order": 2, 979 "width": 0, 980 "height": 0, 981 "gtype": "gage", 982 "title": "", 983 "label": "kmh", 984 "format": "{{value}}", 985 "min": 0, 986 "max": "250", 987 "colors": [ 988 "#00b500", 989 "#e6e600", 990 "#ca3838" 991 ], 992 "seg1": "", 993 "seg2": "", 994 "x": 890, 995 "y": 280, 996 "wires": [] 997 }, 998 { 999 "id": "3ad69aee.451986", 1000 "type": "ui_gauge", 1001 "z": "5c322bcd.0d7e24", 1002 "name": "otackyD", 1003 "group": "be34be57.b6c16", 1004 "order": 2, 1005 "width": 0, 1006 "height": 0, 1007 "gtype": "gage", 1008 "title": "", 1009 "label": "RPM", 1010 "format": "{{value}}", 1011 "min": 0, 1012 "max": "7000", 1013 "colors": [ 1014 "#00b500", 1015 "#e6e600", 1016 "#ca3838" 1017 ], 1018 "seg1": "", 1019 "seg2": "", 1020 "x": 900, 1021 "y": 240, 1022 "wires": [] 1023 }, 1024 { 1025 "id": "1d98f4df.46248b", 1026 "type": "function", 1027 "z": "5c322bcd.0d7e24", 1028 "name": "dteplotam", 1029 "func": "switch (msg.topic){\ 1030 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dteplotam/fmt/json\\":\ 1031 return {payload:msg.payload.TeplotaMotora};\ 1032}", 1033 "outputs": 1, 1034 "noerr": 0, 1035 "x": 680, 1036 "y": 80, 1037 "wires": [ 1038 [ 1039 "e26b8480.6ed6a8", 1040 "bb009985.60d978" 1041 ] 1042 ] 1043 }, 1044 { 1045 "id": "a0a16110.3d97d", 1046 "type": "function", 1047 "z": "5c322bcd.0d7e24", 1048 "name": "dnapatie", 1049 "func": "switch (msg.topic){\ 1050 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dnapatie/fmt/json\\":\ 1051 return {payload:msg.payload.Napatie};\ 1052}", 1053 "outputs": 1, 1054 "noerr": 0, 1055 "x": 680, 1056 "y": 120, 1057 "wires": [ 1058 [ 1059 "25282f33.397db", 1060 "110734fb.37ff5b" 1061 ] 1062 ] 1063 }, 1064 { 1065 "id": "9cbffc43.6fae4", 1066 "type": "function", 1067 "z": "5c322bcd.0d7e24", 1068 "name": "dzatazm", 1069 "func": "switch (msg.topic){\ 1070 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dzatazm/fmt/json\\":\ 1071 return {payload:msg.payload.ZatazMotora};\ 1072}", 1073 "outputs": 1, 1074 "noerr": 0, 1075 "x": 680, 1076 "y": 160, 1077 "wires": [ 1078 [ 1079 "9b7438b8.d46d08" 1080 ] 1081 ] 1082 }, 1083 { 1084 "id": "804e7a.3d19e188", 1085 "type": "function", 1086 "z": "5c322bcd.0d7e24", 1087 "name": "dteplotasania", 1088 "func": "switch (msg.topic){\ 1089 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dteplotasania/fmt/json\\":\ 1090 return {payload:msg.payload.TeplotaSania};\ 1091}", 1092 "outputs": 1, 1093 "noerr": 0, 1094 "x": 690, 1095 "y": 200, 1096 "wires": [ 1097 [ 1098 "416cd75.90f5128" 1099 ] 1100 ] 1101 }, 1102 { 1103 "id": "c95b86aa.ff9988", 1104 "type": "function", 1105 "z": "5c322bcd.0d7e24", 1106 "name": "dotacky", 1107 "func": "switch (msg.topic){\ 1108 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/dotacky/fmt/json\\":\ 1109 return {payload:msg.payload.Otacky};\ 1110}", 1111 "outputs": 1, 1112 "noerr": 0, 1113 "x": 680, 1114 "y": 240, 1115 "wires": [ 1116 [ 1117 "3ad69aee.451986", 1118 "3206e8b5.b2df78" 1119 ] 1120 ] 1121 }, 1122 { 1123 "id": "e2afa857.055908", 1124 "type": "function", 1125 "z": "5c322bcd.0d7e24", 1126 "name": "drychlost", 1127 "func": "switch (msg.topic){\ 1128 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/drychlost/fmt/json\\":\ 1129 return {payload:msg.payload.Rychlost};\ 1130}", 1131 "outputs": 1, 1132 "noerr": 0, 1133 "x": 680, 1134 "y": 280, 1135 "wires": [ 1136 [ 1137 "487f89ae.f1e818", 1138 "79739b5d.19d3a4" 1139 ] 1140 ] 1141 }, 1142 { 1143 "id": "89ddbf44.c92b3", 1144 "type": "function", 1145 "z": "5c322bcd.0d7e24", 1146 "name": "", 1147 "func": " return {payload:\\"\\"};", 1148 "outputs": 1, 1149 "noerr": 0, 1150 "x": 670, 1151 "y": 340, 1152 "wires": [ 1153 [ 1154 "e26b8480.6ed6a8", 1155 "25282f33.397db", 1156 "9b7438b8.d46d08", 1157 "416cd75.90f5128", 1158 "3ad69aee.451986", 1159 "487f89ae.f1e818" 1160 ] 1161 ] 1162 }, 1163 { 1164 "id": "f050f736.555a78", 1165 "type": "debug", 1166 "z": "5c322bcd.0d7e24", 1167 "name": "", 1168 "active": true, 1169 "tosidebar": true, 1170 "console": false, 1171 "tostatus": false, 1172 "complete": "false", 1173 "x": 260, 1174 "y": 20, 1175 "wires": [] 1176 }, 1177 { 1178 "id": "bb009985.60d978", 1179 "type": "ibmiot out", 1180 "z": "5c322bcd.0d7e24", 1181 "authentication": "boundService", 1182 "apiKey": "", 1183 "outputType": "cmd", 1184 "deviceId": "ios_i", 1185 "deviceType": "ios_t", 1186 "eventCommandType": "teplota", 1187 "format": "json", 1188 "data": "{}", 1189 "qos": 0, 1190 "name": "IBM IoT", 1191 "service": "registered", 1192 "x": 1140, 1193 "y": 80, 1194 "wires": [] 1195 }, 1196 { 1197 "id": "110734fb.37ff5b", 1198 "type": "ibmiot out", 1199 "z": "5c322bcd.0d7e24", 1200 "authentication": "boundService", 1201 "apiKey": "", 1202 "outputType": "cmd", 1203 "deviceId": "ios_i", 1204 "deviceType": "ios_t", 1205 "eventCommandType": "napatie", 1206 "format": "json", 1207 "data": "{}", 1208 "qos": 0, 1209 "name": "IBM IoT", 1210 "service": "registered", 1211 "x": 1140, 1212 "y": 120, 1213 "wires": [] 1214 }, 1215 { 1216 "id": "79739b5d.19d3a4", 1217 "type": "ibmiot out", 1218 "z": "5c322bcd.0d7e24", 1219 "authentication": "boundService", 1220 "apiKey": "", 1221 "outputType": "cmd", 1222 "deviceId": "ios_i", 1223 "deviceType": "ios_t", 1224 "eventCommandType": "rychlost", 1225 "format": "json", 1226 "data": "{}", 1227 "qos": 0, 1228 "name": "IBM IoT", 1229 "service": "registered", 1230 "x": 1140, 1231 "y": 280, 1232 "wires": [] 1233 }, 1234 { 1235 "id": "3206e8b5.b2df78", 1236 "type": "ibmiot out", 1237 "z": "5c322bcd.0d7e24", 1238 "authentication": "boundService", 1239 "apiKey": "", 1240 "outputType": "cmd", 1241 "deviceId": "ios_i", 1242 "deviceType": "ios_t", 1243 "eventCommandType": "otacky", 1244 "format": "json", 1245 "data": "{}", 1246 "qos": 0, 1247 "name": "IBM IoT", 1248 "service": "registered", 1249 "x": 1140, 1250 "y": 240, 1251 "wires": [] 1252 }, 1253 { 1254 "id": "6d5bcc4c.efd854", 1255 "type": "debug", 1256 "z": "5c322bcd.0d7e24", 1257 "name": "", 1258 "active": false, 1259 "tosidebar": true, 1260 "console": false, 1261 "tostatus": false, 1262 "complete": "payload", 1263 "targetType": "msg", 1264 "x": 870, 1265 "y": 480, 1266 "wires": [] 1267 }, 1268 { 1269 "id": "26a88bb.6c9d574", 1270 "type": "ibmiot in", 1271 "z": "5c322bcd.0d7e24", 1272 "authentication": "boundService", 1273 "apiKey": "", 1274 "inputType": "evt", 1275 "logicalInterface": "", 1276 "ruleId": "", 1277 "deviceId": "ios_i", 1278 "applicationId": "", 1279 "deviceType": "ios_t", 1280 "eventType": "+", 1281 "commandType": "spojka", 1282 "format": "json", 1283 "name": "IBM IoT", 1284 "service": "registered", 1285 "allDevices": "", 1286 "allApplications": "", 1287 "allDeviceTypes": "", 1288 "allLogicalInterfaces": "", 1289 "allEvents": true, 1290 "allCommands": "", 1291 "allFormats": true, 1292 "qos": 0, 1293 "x": 830, 1294 "y": 360, 1295 "wires": [ 1296 [ 1297 "63392018.ad6dc" 1298 ] 1299 ] 1300 }, 1301 { 1302 "id": "63392018.ad6dc", 1303 "type": "function", 1304 "z": "5c322bcd.0d7e24", 1305 "name": "", 1306 "func": "switch (msg.topic){\ 1307 case \\"iot-2/type/ios_t/id/ios_i/evt/ahoj/fmt/json\\":\ 1308 return {payload:msg.payload.RJpay};\ 1309}", 1310 "outputs": 1, 1311 "noerr": 0, 1312 "x": 870, 1313 "y": 420, 1314 "wires": [ 1315 [ 1316 "6d5bcc4c.efd854", 1317 "c2fcb0e4.9df3c" 1318 ] 1319 ] 1320 }, 1321 { 1322 "id": "4652684e.bd8e48", 1323 "type": "inject", 1324 "z": "5c322bcd.0d7e24", 1325 "name": "", 1326 "topic": "spojka", 1327 "payload": "\\"20\\"", 1328 "payloadType": "json", 1329 "repeat": "", 1330 "crontab": "", 1331 "once": false, 1332 "onceDelay": 0.1, 1333 "x": 420, 1334 "y": 800, 1335 "wires": [ 1336 [ 1337 "c2fcb0e4.9df3c" 1338 ] 1339 ] 1340 }, 1341 { 1342 "id": "875485b.33b0078", 1343 "type": "inject", 1344 "z": "5c322bcd.0d7e24", 1345 "name": "", 1346 "topic": "spojka", 1347 "payload": "\\"21\\"", 1348 "payloadType": "json", 1349 "repeat": "", 1350 "crontab": "", 1351 "once": false, 1352 "onceDelay": 0.1, 1353 "x": 420, 1354 "y": 760, 1355 "wires": [ 1356 [ 1357 "c2fcb0e4.9df3c" 1358 ] 1359 ] 1360 }, 1361 { 1362 "id": "87c28d94.43529", 1363 "type": "ibmiot out", 1364 "z": "5c322bcd.0d7e24", 1365 "authentication": "boundService", 1366 "apiKey": "", 1367 "outputType": "cmd", 1368 "deviceId": "ios_i", 1369 "deviceType": "ios_t", 1370 "eventCommandType": "suradnicemotor", 1371 "format": "json", 1372 "data": "{}", 1373 "qos": 0, 1374 "name": "IBM IoT", 1375 "service": "registered", 1376 "x": 1320, 1377 "y": 180, 1378 "wires": [] 1379 }, 1380 { 1381 "id": "2887474f.3903a8", 1382 "type": "function", 1383 "z": "5c322bcd.0d7e24", 1384 "name": "suradnicemotor", 1385 "func": "switch (msg.topic){\ 1386 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/suradnicemotor/fmt/json\\":\ 1387 return {payload:msg.payload};\ 1388}", 1389 "outputs": 1, 1390 "noerr": 0, 1391 "x": 1120, 1392 "y": 180, 1393 "wires": [ 1394 [ 1395 "3c596726.fd9b38", 1396 "87c28d94.43529" 1397 ] 1398 ] 1399 }, 1400 { 1401 "id": "3c596726.fd9b38", 1402 "type": "debug", 1403 "z": "5c322bcd.0d7e24", 1404 "name": "", 1405 "active": true, 1406 "tosidebar": true, 1407 "console": false, 1408 "tostatus": false, 1409 "complete": "false", 1410 "x": 1210, 1411 "y": 520, 1412 "wires": [] 1413 }, 1414 { 1415 "id": "fe99fbd4.9109b8", 1416 "type": "debug", 1417 "z": "5c322bcd.0d7e24", 1418 "name": "", 1419 "active": true, 1420 "tosidebar": true, 1421 "console": false, 1422 "tostatus": false, 1423 "complete": "false", 1424 "x": 660, 1425 "y": 40, 1426 "wires": [] 1427 }, 1428 { 1429 "id": "c334c204.254a9", 1430 "type": "function", 1431 "z": "5c322bcd.0d7e24", 1432 "name": "suradnicenap", 1433 "func": "switch (msg.topic){\ 1434 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/suradnicenap/fmt/json\\":\ 1435 return {payload:msg.payload};\ 1436}", 1437 "outputs": 1, 1438 "noerr": 0, 1439 "x": 1100, 1440 "y": 20, 1441 "wires": [ 1442 [ 1443 "9b089d4d.b06c5" 1444 ] 1445 ] 1446 }, 1447 { 1448 "id": "9b089d4d.b06c5", 1449 "type": "ibmiot out", 1450 "z": "5c322bcd.0d7e24", 1451 "authentication": "boundService", 1452 "apiKey": "", 1453 "outputType": "cmd", 1454 "deviceId": "ios_i", 1455 "deviceType": "ios_t", 1456 "eventCommandType": "suradnicenap", 1457 "format": "json", 1458 "data": "{}", 1459 "qos": 0, 1460 "name": "IBM IoT", 1461 "service": "registered", 1462 "x": 1320, 1463 "y": 80, 1464 "wires": [] 1465 }, 1466 { 1467 "id": "15ac389c.0aeb97", 1468 "type": "ibmiot out", 1469 "z": "5c322bcd.0d7e24", 1470 "authentication": "boundService", 1471 "apiKey": "", 1472 "outputType": "cmd", 1473 "deviceId": "ios_i", 1474 "deviceType": "ios_t", 1475 "eventCommandType": "surarychl", 1476 "format": "json", 1477 "data": "{}", 1478 "qos": 0, 1479 "name": "IBM IoT", 1480 "service": "registered", 1481 "x": 1320, 1482 "y": 340, 1483 "wires": [] 1484 }, 1485 { 1486 "id": "a11eb45f.d38ef8", 1487 "type": "function", 1488 "z": "5c322bcd.0d7e24", 1489 "name": "surarychl", 1490 "func": "switch (msg.topic){\ 1491 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/surarychl/fmt/json\\":\ 1492 return {payload:msg.payload};\ 1493}", 1494 "outputs": 1, 1495 "noerr": 0, 1496 "x": 1120, 1497 "y": 340, 1498 "wires": [ 1499 [ 1500 "15ac389c.0aeb97" 1501 ] 1502 ] 1503 }, 1504 { 1505 "id": "9d5ef054.3aeed", 1506 "type": "function", 1507 "z": "5c322bcd.0d7e24", 1508 "name": "suraotac", 1509 "func": "switch (msg.topic){\ 1510 case \\"iot-2/type/Mikrokontroler/id/IDkontroler/evt/suraotac/fmt/json\\":\ 1511 return {payload:msg.payload};\ 1512}", 1513 "outputs": 1, 1514 "noerr": 0, 1515 "x": 1120, 1516 "y": 400, 1517 "wires": [ 1518 [ 1519 "5a0f36cd.44ca48" 1520 ] 1521 ] 1522 }, 1523 { 1524 "id": "5a0f36cd.44ca48", 1525 "type": "ibmiot out", 1526 "z": "5c322bcd.0d7e24", 1527 "authentication": "boundService", 1528 "apiKey": "", 1529 "outputType": "cmd", 1530 "deviceId": "ios_i", 1531 "deviceType": "ios_t", 1532 "eventCommandType": "suraotac", 1533 "format": "json", 1534 "data": "{}", 1535 "qos": 0, 1536 "name": "IBM IoT", 1537 "service": "registered", 1538 "x": 1320, 1539 "y": 400, 1540 "wires": [] 1541 }, 1542 { 1543 "id": "91e819d.952aee8", 1544 "type": "debug", 1545 "z": "5c322bcd.0d7e24", 1546 "name": "", 1547 "active": true, 1548 "tosidebar": true, 1549 "console": false, 1550 "tostatus": false, 1551 "complete": "payload", 1552 "targetType": "msg", 1553 "x": 200, 1554 "y": 820, 1555 "wires": [] 1556 }, 1557 { 1558 "id": "4bf77032.81e66", 1559 "type": "ui_button", 1560 "z": "5c322bcd.0d7e24", 1561 "name": "", 1562 "group": "7b6ef1b8.16383", 1563 "order": 2, 1564 "width": "6", 1565 "height": "4", 1566 "passthru": false, 1567 "label": "RESTART", 1568 "tooltip": "", 1569 "color": "", 1570 "bgcolor": "", 1571 "icon": "", 1572 "payload": "\\"8\\"", 1573 "payloadType": "json", 1574 "topic": "spojka", 1575 "x": 110, 1576 "y": 420, 1577 "wires": [ 1578 [ 1579 "7ed3d7b9.a233a8", 1580 "c2fcb0e4.9df3c" 1581 ] 1582 ] 1583 }, 1584 { 1585 "id": "67f5864a.d0b778", 1586 "type": "inject", 1587 "z": "5c322bcd.0d7e24", 1588 "name": "", 1589 "topic": "spojka", 1590 "payload": "\\"19\\"", 1591 "payloadType": "json", 1592 "repeat": "", 1593 "crontab": "", 1594 "once": false, 1595 "onceDelay": 0.1, 1596 "x": 660, 1597 "y": 840, 1598 "wires": [ 1599 [ 1600 "c2fcb0e4.9df3c" 1601 ] 1602 ] 1603 }, 1604 { 1605 "id": "b15ee046.8c935", 1606 "type": "ui_group", 1607 "z": "", 1608 "name": "1", 1609 "tab": "92efbb56.641408", 1610 "order": 1, 1611 "disp": false, 1612 "width": "6", 1613 "collapse": false 1614 }, 1615 { 1616 "id": "f7606a4e.234618", 1617 "type": "ui_group", 1618 "z": "", 1619 "name": "3", 1620 "tab": "92efbb56.641408", 1621 "order": 5, 1622 "disp": false, 1623 "width": "6", 1624 "collapse": false 1625 }, 1626 { 1627 "id": "f943ae3.4d5b75", 1628 "type": "ui_group", 1629 "z": "", 1630 "name": "4", 1631 "tab": "92efbb56.641408", 1632 "order": 6, 1633 "disp": false, 1634 "width": "6", 1635 "collapse": false 1636 }, 1637 { 1638 "id": "b3c559b3.3e97d8", 1639 "type": "ui_group", 1640 "z": "", 1641 "name": "2", 1642 "tab": "92efbb56.641408", 1643 "order": 2, 1644 "disp": false, 1645 "width": "6", 1646 "collapse": false 1647 }, 1648 { 1649 "id": "34ec3061.6e984", 1650 "type": "ui_group", 1651 "z": "", 1652 "name": "5", 1653 "tab": "92efbb56.641408", 1654 "order": 4, 1655 "disp": false, 1656 "width": "6", 1657 "collapse": false 1658 }, 1659 { 1660 "id": "3fc295fe.9f49ca", 1661 "type": "ui_group", 1662 "z": "", 1663 "name": "6", 1664 "tab": "92efbb56.641408", 1665 "order": 3, 1666 "disp": false, 1667 "width": "6", 1668 "collapse": false 1669 }, 1670 { 1671 "id": "3621392d.b91016", 1672 "type": "ui_group", 1673 "z": "", 1674 "name": "7", 1675 "tab": "92efbb56.641408", 1676 "order": 7, 1677 "disp": false, 1678 "width": "6", 1679 "collapse": false 1680 }, 1681 { 1682 "id": "7b6ef1b8.16383", 1683 "type": "ui_group", 1684 "z": "", 1685 "name": "8", 1686 "tab": "92efbb56.641408", 1687 "order": 8, 1688 "disp": false, 1689 "width": "6", 1690 "collapse": false 1691 }, 1692 { 1693 "id": "6f469820.86dbc8", 1694 "type": "ui_group", 1695 "z": "", 1696 "name": "Group 1", 1697 "tab": "95159b00.fda818", 1698 "order": 1, 1699 "disp": false, 1700 "width": "6", 1701 "collapse": false 1702 }, 1703 { 1704 "id": "c5be57a5.510478", 1705 "type": "ui_group", 1706 "z": "", 1707 "name": "Group 2", 1708 "tab": "95159b00.fda818", 1709 "order": 2, 1710 "disp": false, 1711 "width": "6", 1712 "collapse": false 1713 }, 1714 { 1715 "id": "5030d833.9eefd8", 1716 "type": "ui_group", 1717 "z": "", 1718 "name": "Group 3", 1719 "tab": "95159b00.fda818", 1720 "order": 3, 1721 "disp": false, 1722 "width": "6", 1723 "collapse": false 1724 }, 1725 { 1726 "id": "be34be57.b6c16", 1727 "type": "ui_group", 1728 "z": "", 1729 "name": "Group 4", 1730 "tab": "95159b00.fda818", 1731 "order": 4, 1732 "disp": false, 1733 "width": "6", 1734 "collapse": false 1735 }, 1736 { 1737 "id": "9e83fd0.ce74c", 1738 "type": "ui_group", 1739 "z": "", 1740 "name": "Group 5", 1741 "tab": "95159b00.fda818", 1742 "order": 5, 1743 "disp": false, 1744 "width": "6", 1745 "collapse": false 1746 }, 1747 { 1748 "id": "2c1d9538.5680ea", 1749 "type": "ui_group", 1750 "z": "", 1751 "name": "Group 6", 1752 "tab": "95159b00.fda818", 1753 "order": 6, 1754 "disp": false, 1755 "width": "6", 1756 "collapse": false 1757 }, 1758 { 1759 "id": "a006a90c.461b58", 1760 "type": "ui_group", 1761 "z": "", 1762 "name": "Group 7", 1763 "tab": "95159b00.fda818", 1764 "order": 7, 1765 "disp": false, 1766 "width": "6", 1767 "collapse": false 1768 }, 1769 { 1770 "id": "92efbb56.641408", 1771 "type": "ui_tab", 1772 "z": "", 1773 "name": "STATICKE TESTY", 1774 "icon": "dashboard", 1775 "order": 1, 1776 "disabled": false, 1777 "hidden": false 1778 }, 1779 { 1780 "id": "95159b00.fda818", 1781 "type": "ui_tab", 1782 "z": "", 1783 "name": "DYNAMICKE TESTY", 1784 "icon": "dashboard", 1785 "order": 2, 1786 "disabled": false, 1787 "hidden": false 1788 } 1789]
Main .ino file
arduino
1#include <WiFi101.h> 2#include <WiFiSSLClient.h> //ak by sme bezali cez SSL (8883) 3#include <MQTTClient.h> 4#include <wiring_private.h> 5#include <TinyGPS++.h> 6#include "premenne.h" 7 8 9 10/*****************************************/ 11/* Serial2 */ 12/*****************************************/ 13 14#define PIN_SERIAL2_RX (1ul) 15#define PIN_SERIAL2_TX (0ul) 16#define PAD_SERIAL2_TX (UART_TX_PAD_0) 17#define PAD_SERIAL2_RX (SERCOM_RX_PAD_1) 18 19Uart Serial2(&sercom3, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX); 20 21void SERCOM3_Handler() 22{ 23 Serial2.IrqHandler(); 24} 25 26 27 28/*****************************************/ 29/* WiFi */ 30/*****************************************/ 31 32char *ssid = "WIFI_AP"; 33char *pass = "AP_PWD_37"; 34 35WiFiClient net; // Vytvorime WiFi klienta, ktory sa vie pripojit k specifickej adrese a portu 36 37 38/*****************************************/ 39/* MQTT */ 40/*****************************************/ 41 42#define ORG "orgid" 43#define DEVICE_TYPE "devid" 44#define DEVICE_ID "devid2" 45#define TOKEN "devtoken" 46 47int status = WL_IDLE_STATUS; // priradenie pre WiFi.status() docasny stav 48 49char *client_id = "d:" ORG ":" DEVICE_TYPE ":" DEVICE_ID; 50char *user_id = "use-token-auth"; 51char *pwd = TOKEN; 52char *ibm_hostname = ORG ".messaging.internetofthings.ibmcloud.com"; 53 54/*****************************************/ 55/* OSTATNE PREMENNE */ 56/*****************************************/ 57unsigned long cas = 0; 58TinyGPSPlus gps; 59int awq=0; 60 61 62 63/*****************************************/ 64/* FUNKCIA PRE PRIPOJENIE */ 65/*****************************************/ 66 67void connect_mqtt() { 68 // Pokial nieje priopojene k wifi AP, bude vypisovat WIFI_CHYBA 69 while (WiFi.status() != WL_CONNECTED) { 70 Serial.print(" WIFI_CHYBA "); 71 delay(1000); 72 } 73 74 // Pokial nieje pripojene k MQTT brokeru, bude vypisovat BROKER_CHYBA 75 76 while (!client.connect(client_id, user_id, pwd)) { // v zatvorke uvedene samotne pripojenie k vytvorenemu zariadeniu v IBM CLOUDE 77 Serial.print(" BROKER_CHYBA "); 78 delay(1000); 79 } 80 81 // Vypise pripojene, pri uspesnom pripojeni k AP a brokeru 82 Serial.println("\ 83Pripojene!"); 84 85 // ODBER TOPICU 86 client.subscribe("iot-2/cmd/spojka/fmt/json"); 87} 88 89 90/*****************************************/ 91/* FUNKCIA NA SUBSCRIBE */ 92/*****************************************/ 93 94void messageReceived(String &topic, String &payload) { 95 int prevedene=payload.toInt(); 96 97 switch (prevedene) { 98 case 1: 99 statepmot=pTeplotum(); 100 client.publish("iot-2/evt/teplotam/fmt/json", statepmot); 101 break; 102 case 2: 103 stanapat=pNapatie(); 104 client.publish("iot-2/evt/napatie/fmt/json", stanapat); 105 break; 106 case 3: 107 stazta=pZatazm(); 108 client.publish("iot-2/evt/zatazm/fmt/json", stazta); 109 break; 110 case 4: 111 stateplosan=pTeplotasania(); 112 client.publish("iot-2/evt/teplotasania/fmt/json", stateplosan); 113 break; 114 case 5: 115 staotac=pOtacky(); 116 client.publish("iot-2/evt/otacky/fmt/json", staotac); 117 break; 118 case 6: 119 starychl=pRychlost(); 120 client.publish("iot-2/evt/rychlost/fmt/json", starychl); 121 break; 122 case 7: 123 staVIN=pVIN(); 124 client.publish("iot-2/evt/VIN/fmt/json", staVIN); 125 break; 126 case 8: 127 Serial.println("Restart"); 128 break; 129 case 9: 130 statepmot=pTeplotum(); 131 client.publish("iot-2/evt/teplotam/fmt/json", statepmot); 132 delay(2000); 133 stanapat=pNapatie(); 134 client.publish("iot-2/evt/napatie/fmt/json", stanapat); 135 delay(2000); 136 stazta=pZatazm(); 137 client.publish("iot-2/evt/zatazm/fmt/json", stazta); 138 delay(2000); 139 stateplosan=pTeplotasania(); 140 client.publish("iot-2/evt/teplotasania/fmt/json", stateplosan); 141 delay(2000); 142 staotac=pOtacky(); 143 client.publish("iot-2/evt/otacky/fmt/json", staotac); 144 delay(2000); 145 starychl=pRychlost(); 146 client.publish("iot-2/evt/rychlost/fmt/json", starychl); 147 delay(2000); 148 staVIN=pVIN(); 149 client.publish("iot-2/evt/VIN/fmt/json", staVIN); 150 delay(2000); 151 break; 152 case 10: 153 awq=1; 154 break; 155 case 11: 156 awq=2; 157 break; 158 case 12: 159 awq=3; 160 break; 161 case 13: 162 awq=4; 163 break; 164 case 14: 165 awq=5; 166 break; 167 case 15: 168 awq=6; 169 break; 170 case 16: 171 awq=7; 172 break; 173 case 17: 174 awq=8; 175 break; 176 case 18: 177 awq=9; 178 break; 179 case 19: 180 awq=10; 181 break; 182 case 20: 183 awq=11; 184 break; 185 case 21: 186 awq=12; 187 break; 188 case 22: 189 awq=13; 190 break; 191 case 23: 192 awq=14; 193 break; 194 } 195 196} 197 198 199/*****************************************/ 200/* ARDUINO SETUP */ 201/*****************************************/ 202 203void setup() { 204 Serial.begin(9600); 205 delay(1000); 206 Serial1.begin(38400); //SPUSTENIE RX TX PRE ELM327 207 Serial1.println("atl1\ "); // ABY SLI ODPOVEDE NA NEW LINE 208 delay(1000); 209 Serial1.println("0105"); 210 delay(1000); 211 pinPeripheral(1, PIO_SERCOM); 212 pinPeripheral(0, PIO_SERCOM); 213 Serial2.begin(9600); 214 215/*****************************************/ 216/* Pripojenie k WiFi */ 217/*****************************************/ 218 //Pokial nieje pripojeny k wifi, vypise nazov siete siete ku ktorej sa pripaja: 219 while (status != WL_CONNECTED) { 220 Serial.println("\ 221Pripajam sa k wifi s nazvom: "); 222 Serial.println(ssid); 223 224 //WiFi.begin sluzi na pripojenie k sieti, pricom do premennej status priradi stav pripojenia (zmena pre zamzdzenie opakovania podmienky) 225 status = WiFi.begin(ssid, pass); 226 227 //Pockaj 10 sekund na pripojenie: 228 if (status != WL_CONNECTED) { 229 delay(10000); 230 } 231 } 232 233/*****************************************/ 234/* Pripojenie k MQTT brokeru */ 235/*****************************************/ 236 //Pripojenie Arduina do IBM Cloudu pomocou kniznice MQTTClient.h 237 client.begin(ibm_hostname, 1883, net); 238 connect_mqtt(); 239 client.onMessage(messageReceived); 240} 241 242 243/*****************************************/ 244/* ARDUINO LOOP */ 245/*****************************************/ 246void loop() { 247 248 client.loop(); // Spustenie MQTT publish/subscribe v slucke - jednoducho spracuva odosielane/prijate spravy 249 delay(10); 250 251 // Znova overenie ci sme pripojeny k AP a IBM Cloudu: 252 253 if(!client.connected()) { 254 255 connect_mqtt(); 256 } 257 258 259 260 while (Serial2.available() > 0){ 261 gps.encode(Serial2.read()); 262 if (gps.location.isUpdated()){ 263 for(millis(); (millis() - cas) > 5000;){ 264 cas = millis(); 265 latitude=(gps.location.lat()); 266 longitude=(gps.location.lng()); 267 } 268 } 269} 270 271if(awq==1){ 272 client.publish("iot-2/evt/VIN/fmt/json", String(longitude, 6)); 273 delay(1000); 274 } 275 else if(awq==2){ 276 client.publish("iot-2/evt/VIN/fmt/json", String(latitude, 6)); 277 delay(1000); 278 } 279 else if(awq==3){ 280 awq=0; 281 } 282 else if(awq==4){ 283 statepmot=pTeplotum(); 284 client.publish("iot-2/evt/dteplotam/fmt/json", statepmot); 285 delay(2000); 286 } 287 else if(awq==5){ 288 stanapat=pNapatie(); 289 client.publish("iot-2/evt/dnapatie/fmt/json", stanapat); 290 delay(2000); 291 } 292 else if(awq==6){ 293 starychl=pRychlost(); 294 client.publish("iot-2/evt/drychlost/fmt/json", starychl); 295 delay(2000); 296 } 297 else if(awq==7){ 298 staotac=pOtacky(); 299 client.publish("iot-2/evt/dotacky/fmt/json", staotac); 300 delay(2000); 301 } 302 else if(awq==8){ 303 stazta=pZatazm(); 304 client.publish("iot-2/evt/dzatazm/fmt/json", stazta); 305 delay(2000); 306 } 307 else if(awq==9){ 308 stateplosan=pTeplotasania(); 309 client.publish("iot-2/evt/dteplotasania/fmt/json", stateplosan); 310 delay(2000); 311 } 312 else if(awq==10){ 313 client.publish("iot-2/evt/suradnice/fmt/json", pGPS()); 314 delay(2000); 315 } 316 else if(awq==11){ 317 inba=GPSmotora(); 318 client.publish("iot-2/evt/suradnicemotor/fmt/json", inba); 319 delay(2000); 320 } 321 else if(awq==12){ 322 inbc=pGPSnapatie(); 323 client.publish("iot-2/evt/suradnicenap/fmt/json", inbc); 324 delay(2000); 325 } 326 else if(awq==13){ 327 inbd=pGPSRychl(); 328 client.publish("iot-2/evt/surarychl/fmt/json", inbd); 329 delay(2000); 330 } 331 else if(awq==14){ 332 inbf=pGPSotacky(); 333 client.publish("iot-2/evt/suraotac/fmt/json", inbf); 334 delay(2000); 335 } 336 337 338 339}
Temperature Gauge - Swift code
swift
For iOS application
1// 2// Teplota.swift 3// RingViewRPM 4// 5// Created by Kardan on 19/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10 11struct Teplota: View { 12 @State var rozhodni=0 13 var hodnotka:CGFloat = 0 14 var body: some View { 15 ZStack{ 16 Text("Teplota motora") 17 .font(.largeTitle) 18 .fontWeight(.semibold) 19 .foregroundColor(Color.yellow) 20 .multilineTextAlignment(.center) 21 .padding(.top,200) 22 Circle() 23 .trim(from: 0.0, to: 0.5) 24 .stroke(Color.blue, style: StrokeStyle(lineWidth: 12.0, dash: [8])) 25 .frame(width: 400, height: 300) 26 .rotationEffect(Angle(degrees: -180)) 27 28 Circle() 29 .trim(from: 0.0, to: hodnotka/200) 30 .stroke(Color.blue, lineWidth: 12.0) 31 .frame(width: 400, height: 300) 32 .rotationEffect(Angle(degrees: -180)) 33 .animation(.easeOut(duration: 0.5)) 34 Text("\\(Int(hodnotka)) °") 35 .font(.largeTitle) 36 .fontWeight(.semibold) 37 .multilineTextAlignment(.center) 38 .padding() 39 .transition(.opacity) 40 41 42 } 43 .padding(.top) 44 } 45} 46
RPM gauge - Swift code
swift
For iOS application
1// 2// Otacky.swift 3// RingViewRPM 4// 5// Created by Kardan on 19/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10 11struct Otacky: View { 12 var otacocky:CGFloat = 0 13 var body: some View { 14 ZStack{ 15 Text("Otacky") 16 .font(.largeTitle) 17 .fontWeight(.semibold) 18 .foregroundColor(Color.yellow) 19 .multilineTextAlignment(.center) 20 .padding(.top,200) 21 Circle() 22 .trim(from: 0.0, to: 0.5) 23 .stroke(Color.blue, style: StrokeStyle(lineWidth: 12.0, dash: [8])) 24 .frame(width: 400, height: 300) 25 .rotationEffect(Angle(degrees: -180)) 26 27 Circle() 28 .trim(from: 0.0, to: otacocky/16000) 29 .stroke(Color.blue, lineWidth: 12.0) 30 .frame(width: 400, height: 300) 31 .rotationEffect(Angle(degrees: -180)) 32 .animation(.easeOut(duration: 0.5)) 33 Text("\\(Int(otacocky)) RPM") 34 .font(.largeTitle) 35 .fontWeight(.semibold) 36 .multilineTextAlignment(.center) 37 .padding() 38 .transition(.opacity) 39 40 41 } 42 .padding(.top) 43 } 44 } 45
Velocity gauge - Swift code
swift
For iOS application
1// 2// Rychlost.swift 3// RingViewRPM 4// 5// Created by Kardan on 19/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10 11struct Rychlost: View { 12 var rychlostka:CGFloat = 0 13 var body: some View { 14 ZStack{ 15 Text("Rychlost") 16 .font(.largeTitle) 17 .fontWeight(.semibold) 18 .foregroundColor(Color.yellow) 19 .multilineTextAlignment(.center) 20 .padding(.top,200) 21 Circle() 22 .trim(from: 0.0, to: 0.5) 23 .stroke(Color.blue, style: StrokeStyle(lineWidth: 12.0, dash: [8])) 24 .frame(width: 400, height: 300) 25 .rotationEffect(Angle(degrees: -180)) 26 27 Circle() 28 .trim(from: 0.0, to: rychlostka/500) 29 .stroke(Color.blue, lineWidth: 12.0) 30 .frame(width: 400, height: 300) 31 .rotationEffect(Angle(degrees: -180)) 32 .animation(.easeOut(duration: 0.5)) 33 Text("\\(Int(rychlostka)) km/h") 34 .font(.largeTitle) 35 .fontWeight(.semibold) 36 .multilineTextAlignment(.center) 37 .padding() 38 .transition(.opacity) 39 40 41 } 42 .padding(.top) 43 } 44 } 45
Header file premenne.h
arduino
1MQTTClient client(1024); // Vytvorime MQTT klienta - 256 bytov urcuje velkost buffera (defaultne je 128 bytov) 2float latitude=40.5; 3float longitude=18.5; 4 5String statepmot; 6String engine_temp; //1 7String suengine_temp; 8int vengine_temp; 9 10String stanapat; 11String napatie; //2 12String snapatie; 13int vnapatie; 14 15String stazta; 16String zatazm; //4 17String szatazm; 18int vzatazm; 19 20String stateplosan; 21String teplotasania; //5 22String steplotasania; 23int vteplotasania; 24 25String staotac; 26String otackyA; //6 27String sotackyA; 28int votackyA; 29String otackyB; //6 30String sotackyB; 31int votackyB; 32 33String starychl; 34String rychlost; //7 35String srychlost; 36int vrychlost; 37 38String staVIN; 39 40String inba; 41String inbc; 42String inbd; 43String inbf; 44 45////////////////PREMENNE PRE VIN CISLO 46String vincislo; 47String podvincislo; 48String vinpole[33]; 49String vinpole2[33]; 50String ziskanevin; 51int vina=0; 52 53 54 55////////////////////FUNKCIE 56 57String pTeplotum(){ 58 Serial1.println("0105"); 59 engine_temp = Serial1.readString(); 60 suengine_temp=engine_temp.substring(12,14); 61 vengine_temp = (strtol(suengine_temp.c_str(),NULL,16))-40; 62 63 64 String pengine_temp = "{\\"TeplotaMotora\\":"; 65 pengine_temp += vengine_temp; 66 pengine_temp += "}"; 67 return pengine_temp; 68} 69 70 71String pNapatie(){ 72 Serial1.println("atrv"); 73 napatie = Serial1.readString(); 74 snapatie=napatie.substring(6,15); 75 vnapatie=snapatie.toInt(); 76 Serial.println("PRVY RIADOK"); 77 Serial.println(napatie); 78 Serial.println("DRUHY RIADOK"); 79 Serial.println(vnapatie); 80 81 String p_napatie = "{\\"Napatie\\":"; 82 p_napatie += vnapatie; 83 p_napatie += "}"; 84 return p_napatie; 85} 86 87String pZatazm(){ 88 Serial1.println("0104"); 89 zatazm = Serial1.readString(); 90 szatazm=zatazm.substring(12,14); 91 vzatazm = (strtol(szatazm.c_str(),NULL,16))/2.55; 92 Serial.println(vzatazm); 93 94 String p_zataz = "{\\"ZatazMotora\\":"; 95 p_zataz += vzatazm; 96 p_zataz += "}"; 97 return p_zataz; 98} 99 100String pTeplotasania(){ 101 Serial1.println("010F"); 102 teplotasania = Serial1.readString(); 103 steplotasania=teplotasania.substring(12,14); 104 vteplotasania = (strtol(steplotasania.c_str(),NULL,16))-40; 105 Serial.println(vteplotasania); 106 107 String p_tesania = "{\\"TeplotaSania\\":"; 108 p_tesania += vteplotasania; 109 p_tesania += "}"; 110 return p_tesania; 111} 112 113//////////********* 114String pOtacky(){ 115 Serial1.println("010C"); 116 otackyA = Serial1.readString(); 117 sotackyA=otackyA.substring(12,14); 118 sotackyB=otackyA.substring(15,17); 119 votackyA = ((256*(strtol(sotackyA.c_str(),NULL,16)))+(strtol(sotackyB.c_str(),NULL,16)))/4; 120 Serial.println(votackyA); 121 122 123 String p_otacky = "{\\"Otacky\\":"; 124 p_otacky += votackyA; 125 p_otacky += "}"; 126 return p_otacky; 127} 128 129 130String pRychlost(){ 131 Serial1.println("010D"); 132 rychlost = Serial1.readString(); 133 srychlost=rychlost.substring(12,14); 134 vrychlost = (strtol(srychlost.c_str(),NULL,16)); 135 Serial.println(vrychlost); 136 137 String pcar_speed = "{\\"Rychlost\\":"; 138 pcar_speed += vrychlost; 139 pcar_speed += "}"; 140 return pcar_speed; 141} 142 143 144 145String pGPSRychl(){ 146 Serial1.println("010D"); 147 rychlost = Serial1.readString(); 148 srychlost=rychlost.substring(12,14); 149 vrychlost = (strtol(srychlost.c_str(),NULL,16)); 150 Serial.println(vrychlost); 151 152 String pcar_speed = "{\\"Longituda\\":"; 153 pcar_speed += String(longitude, 6); 154 pcar_speed += ",\\"Latituda\\":"; 155 pcar_speed += String(latitude, 6); 156 pcar_speed += ",\\"Rychlost\\":"; 157 pcar_speed += vrychlost; 158 pcar_speed += "}"; 159 return pcar_speed; 160} 161 162String pGPS(){ 163 String navka = "{\\"Longituda\\":"; 164 navka += String(longitude, 6); 165 navka += ",\\"Latituda\\":"; 166 navka += String(latitude, 6); 167 navka += "}"; 168 return navka; 169} 170 171String GPSmotora(){ 172 Serial1.println("0105"); 173 engine_temp = Serial1.readString(); 174 suengine_temp=engine_temp.substring(12,14); 175 vengine_temp = (strtol(suengine_temp.c_str(),NULL,16))-40; 176 177 String pengine_temp = "{\\"Longituda\\":"; 178 pengine_temp += String(longitude, 6); 179 pengine_temp += ",\\"Latituda\\":"; 180 pengine_temp += String(latitude, 6); 181 pengine_temp += ",\\"Teplota\\":"; 182 pengine_temp += vengine_temp; 183 pengine_temp += "}"; 184 return pengine_temp; 185} 186 187 188String pGPSnapatie(){ 189 Serial1.println("atrv"); 190 napatie = Serial1.readString(); 191 snapatie=napatie.substring(6,15); 192 vnapatie=snapatie.toInt(); 193 194 String p_napatie = "{\\"Longituda\\":"; 195 p_napatie += String(longitude, 6); 196 p_napatie += ",\\"Latituda\\":"; 197 p_napatie += String(latitude, 6); 198 p_napatie += ",\\"Napatie\\":"; 199 p_napatie += vnapatie; 200 p_napatie += "}"; 201 return p_napatie; 202} 203 204 205 206String pGPSotacky(){ 207 Serial1.println("010C"); 208 otackyA = Serial1.readString(); 209 sotackyA=otackyA.substring(12,14); 210 sotackyB=otackyA.substring(15,17); 211 votackyA = ((256*(strtol(sotackyA.c_str(),NULL,16)))+(strtol(sotackyB.c_str(),NULL,16)))/4; 212 Serial.println(votackyA); 213 214 String p_otacky = "{\\"Longituda\\":"; 215 p_otacky += String(longitude, 6); 216 p_otacky += ",\\"Latituda\\":"; 217 p_otacky += String(latitude, 6); 218 p_otacky += ",\\"Otacky\\":"; 219 p_otacky += votackyA; 220 p_otacky += "}"; 221 return p_otacky; 222} 223 224String pVIN(){ 225 Serial1.println("0902"); 226 vincislo = Serial1.readString(); 227 vincislo.replace("\ 228",""); 229 vincislo.replace(" ",""); 230 vincislo.replace(":",""); 231 podvincislo=vincislo.substring(15,21)+vincislo.substring(22,36)+vincislo.substring(37,51); 232 for (int i=0; i<33; i++){ 233 if (i%2 == 0){ 234 vinpole[i]="0x"+(podvincislo.substring(i,i+2)); 235 vinpole2[i]=(char)(strtol((vinpole[i]).c_str(),NULL,16)); 236 } 237 } 238 while (vina<33){ 239 ziskanevin+=vinpole2[vina]; 240 vina+=2; 241 } 242 243 String pVIN = "{\\"VIN\\":\\""; 244 pVIN += ziskanevin; 245 pVIN += "\\"}"; 246 return pVIN; 247} 248
Main .ino file
arduino
1#include <WiFi101.h> 2#include <WiFiSSLClient.h> //ak by sme bezali cez SSL (8883) 3#include <MQTTClient.h> 4#include <wiring_private.h> 5#include <TinyGPS++.h> 6#include "premenne.h" 7 8 9 10/*****************************************/ 11/* Serial2 */ 12/*****************************************/ 13 14#define PIN_SERIAL2_RX (1ul) 15#define PIN_SERIAL2_TX (0ul) 16#define PAD_SERIAL2_TX (UART_TX_PAD_0) 17#define PAD_SERIAL2_RX (SERCOM_RX_PAD_1) 18 19Uart Serial2(&sercom3, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX); 20 21void SERCOM3_Handler() 22{ 23 Serial2.IrqHandler(); 24} 25 26 27 28/*****************************************/ 29/* WiFi */ 30/*****************************************/ 31 32char *ssid = "WIFI_AP"; 33char *pass = "AP_PWD_37"; 34 35WiFiClient net; // Vytvorime WiFi klienta, ktory sa vie pripojit k specifickej adrese a portu 36 37 38/*****************************************/ 39/* MQTT */ 40/*****************************************/ 41 42#define ORG "orgid" 43#define DEVICE_TYPE "devid" 44#define DEVICE_ID "devid2" 45#define TOKEN "devtoken" 46 47int status = WL_IDLE_STATUS; // priradenie pre WiFi.status() docasny stav 48 49char *client_id = "d:" ORG ":" DEVICE_TYPE ":" DEVICE_ID; 50char *user_id = "use-token-auth"; 51char *pwd = TOKEN; 52char *ibm_hostname = ORG ".messaging.internetofthings.ibmcloud.com"; 53 54/*****************************************/ 55/* OSTATNE PREMENNE */ 56/*****************************************/ 57unsigned long cas = 0; 58TinyGPSPlus gps; 59int awq=0; 60 61 62 63/*****************************************/ 64/* FUNKCIA PRE PRIPOJENIE */ 65/*****************************************/ 66 67void connect_mqtt() { 68 // Pokial nieje priopojene k wifi AP, bude vypisovat WIFI_CHYBA 69 while (WiFi.status() != WL_CONNECTED) { 70 Serial.print(" WIFI_CHYBA "); 71 delay(1000); 72 } 73 74 // Pokial nieje pripojene k MQTT brokeru, bude vypisovat BROKER_CHYBA 75 76 while (!client.connect(client_id, user_id, pwd)) { // v zatvorke uvedene samotne pripojenie k vytvorenemu zariadeniu v IBM CLOUDE 77 Serial.print(" BROKER_CHYBA "); 78 delay(1000); 79 } 80 81 // Vypise pripojene, pri uspesnom pripojeni k AP a brokeru 82 Serial.println("\ 83Pripojene!"); 84 85 // ODBER TOPICU 86 client.subscribe("iot-2/cmd/spojka/fmt/json"); 87} 88 89 90/*****************************************/ 91/* FUNKCIA NA SUBSCRIBE */ 92/*****************************************/ 93 94void messageReceived(String &topic, String &payload) { 95 int prevedene=payload.toInt(); 96 97 switch (prevedene) { 98 case 1: 99 statepmot=pTeplotum(); 100 client.publish("iot-2/evt/teplotam/fmt/json", statepmot); 101 break; 102 case 2: 103 stanapat=pNapatie(); 104 client.publish("iot-2/evt/napatie/fmt/json", stanapat); 105 break; 106 case 3: 107 stazta=pZatazm(); 108 client.publish("iot-2/evt/zatazm/fmt/json", stazta); 109 break; 110 case 4: 111 stateplosan=pTeplotasania(); 112 client.publish("iot-2/evt/teplotasania/fmt/json", stateplosan); 113 break; 114 case 5: 115 staotac=pOtacky(); 116 client.publish("iot-2/evt/otacky/fmt/json", staotac); 117 break; 118 case 6: 119 starychl=pRychlost(); 120 client.publish("iot-2/evt/rychlost/fmt/json", starychl); 121 break; 122 case 7: 123 staVIN=pVIN(); 124 client.publish("iot-2/evt/VIN/fmt/json", staVIN); 125 break; 126 case 8: 127 Serial.println("Restart"); 128 break; 129 case 9: 130 statepmot=pTeplotum(); 131 client.publish("iot-2/evt/teplotam/fmt/json", statepmot); 132 delay(2000); 133 stanapat=pNapatie(); 134 client.publish("iot-2/evt/napatie/fmt/json", stanapat); 135 delay(2000); 136 stazta=pZatazm(); 137 client.publish("iot-2/evt/zatazm/fmt/json", stazta); 138 delay(2000); 139 stateplosan=pTeplotasania(); 140 client.publish("iot-2/evt/teplotasania/fmt/json", stateplosan); 141 delay(2000); 142 staotac=pOtacky(); 143 client.publish("iot-2/evt/otacky/fmt/json", staotac); 144 delay(2000); 145 starychl=pRychlost(); 146 client.publish("iot-2/evt/rychlost/fmt/json", starychl); 147 delay(2000); 148 staVIN=pVIN(); 149 client.publish("iot-2/evt/VIN/fmt/json", staVIN); 150 delay(2000); 151 break; 152 case 10: 153 awq=1; 154 break; 155 case 11: 156 awq=2; 157 break; 158 case 12: 159 awq=3; 160 break; 161 case 13: 162 awq=4; 163 break; 164 case 14: 165 awq=5; 166 break; 167 case 15: 168 awq=6; 169 break; 170 case 16: 171 awq=7; 172 break; 173 case 17: 174 awq=8; 175 break; 176 case 18: 177 awq=9; 178 break; 179 case 19: 180 awq=10; 181 break; 182 case 20: 183 awq=11; 184 break; 185 case 21: 186 awq=12; 187 break; 188 case 22: 189 awq=13; 190 break; 191 case 23: 192 awq=14; 193 break; 194 } 195 196} 197 198 199/*****************************************/ 200/* ARDUINO SETUP */ 201/*****************************************/ 202 203void setup() { 204 Serial.begin(9600); 205 delay(1000); 206 Serial1.begin(38400); //SPUSTENIE RX TX PRE ELM327 207 Serial1.println("atl1\ "); // ABY SLI ODPOVEDE NA NEW LINE 208 delay(1000); 209 Serial1.println("0105"); 210 delay(1000); 211 pinPeripheral(1, PIO_SERCOM); 212 pinPeripheral(0, PIO_SERCOM); 213 Serial2.begin(9600); 214 215/*****************************************/ 216/* Pripojenie k WiFi */ 217/*****************************************/ 218 //Pokial nieje pripojeny k wifi, vypise nazov siete siete ku ktorej sa pripaja: 219 while (status != WL_CONNECTED) { 220 Serial.println("\ 221Pripajam sa k wifi s nazvom: "); 222 Serial.println(ssid); 223 224 //WiFi.begin sluzi na pripojenie k sieti, pricom do premennej status priradi stav pripojenia (zmena pre zamzdzenie opakovania podmienky) 225 status = WiFi.begin(ssid, pass); 226 227 //Pockaj 10 sekund na pripojenie: 228 if (status != WL_CONNECTED) { 229 delay(10000); 230 } 231 } 232 233/*****************************************/ 234/* Pripojenie k MQTT brokeru */ 235/*****************************************/ 236 //Pripojenie Arduina do IBM Cloudu pomocou kniznice MQTTClient.h 237 client.begin(ibm_hostname, 1883, net); 238 connect_mqtt(); 239 client.onMessage(messageReceived); 240} 241 242 243/*****************************************/ 244/* ARDUINO LOOP */ 245/*****************************************/ 246void loop() { 247 248 client.loop(); // Spustenie MQTT publish/subscribe v slucke - jednoducho spracuva odosielane/prijate spravy 249 delay(10); 250 251 // Znova overenie ci sme pripojeny k AP a IBM Cloudu: 252 253 if(!client.connected()) { 254 255 connect_mqtt(); 256 } 257 258 259 260 while (Serial2.available() > 0){ 261 gps.encode(Serial2.read()); 262 if (gps.location.isUpdated()){ 263 for(millis(); (millis() - cas) > 5000;){ 264 cas = millis(); 265 latitude=(gps.location.lat()); 266 longitude=(gps.location.lng()); 267 } 268 } 269} 270 271if(awq==1){ 272 client.publish("iot-2/evt/VIN/fmt/json", String(longitude, 6)); 273 delay(1000); 274 } 275 else if(awq==2){ 276 client.publish("iot-2/evt/VIN/fmt/json", String(latitude, 6)); 277 delay(1000); 278 } 279 else if(awq==3){ 280 awq=0; 281 } 282 else if(awq==4){ 283 statepmot=pTeplotum(); 284 client.publish("iot-2/evt/dteplotam/fmt/json", statepmot); 285 delay(2000); 286 } 287 else if(awq==5){ 288 stanapat=pNapatie(); 289 client.publish("iot-2/evt/dnapatie/fmt/json", stanapat); 290 delay(2000); 291 } 292 else if(awq==6){ 293 starychl=pRychlost(); 294 client.publish("iot-2/evt/drychlost/fmt/json", starychl); 295 delay(2000); 296 } 297 else if(awq==7){ 298 staotac=pOtacky(); 299 client.publish("iot-2/evt/dotacky/fmt/json", staotac); 300 delay(2000); 301 } 302 else if(awq==8){ 303 stazta=pZatazm(); 304 client.publish("iot-2/evt/dzatazm/fmt/json", stazta); 305 delay(2000); 306 } 307 else if(awq==9){ 308 stateplosan=pTeplotasania(); 309 client.publish("iot-2/evt/dteplotasania/fmt/json", stateplosan); 310 delay(2000); 311 } 312 else if(awq==10){ 313 client.publish("iot-2/evt/suradnice/fmt/json", pGPS()); 314 delay(2000); 315 } 316 else if(awq==11){ 317 inba=GPSmotora(); 318 client.publish("iot-2/evt/suradnicemotor/fmt/json", inba); 319 delay(2000); 320 } 321 else if(awq==12){ 322 inbc=pGPSnapatie(); 323 client.publish("iot-2/evt/suradnicenap/fmt/json", inbc); 324 delay(2000); 325 } 326 else if(awq==13){ 327 inbd=pGPSRychl(); 328 client.publish("iot-2/evt/surarychl/fmt/json", inbd); 329 delay(2000); 330 } 331 else if(awq==14){ 332 inbf=pGPSotacky(); 333 client.publish("iot-2/evt/suraotac/fmt/json", inbf); 334 delay(2000); 335 } 336 337 338 339}
Battery voltage gauge - Swift code
swift
For iOS application
1// 2// Napatie.swift 3// RingViewRPM 4// 5// Created by Kardan 6 on 19/04/2020. 7// Copyright © 2020 Kardan. All rights reserved. 8// 9 10import 11 SwiftUI 12 13struct Napatie: View { 14 var napaticko:CGFloat = 0 15 var 16 body: some View { 17 ZStack{ 18 Text("Napatie baterie") 19 20 .font(.largeTitle) 21 .fontWeight(.semibold) 22 23 .foregroundColor(Color.yellow) 24 .multilineTextAlignment(.center) 25 26 .padding(.top,200) 27 Circle() 28 .trim(from: 29 0.0, to: 0.5) 30 .stroke(Color.blue, style: StrokeStyle(lineWidth: 31 12.0, dash: [8])) 32 .frame(width: 400, height: 300) 33 .rotationEffect(Angle(degrees: 34 -180)) 35 36 Circle() 37 .trim(from: 0.0, 38 to: napaticko/30) 39 .stroke(Color.blue, lineWidth: 12.0) 40 .frame(width: 41 400, height: 300) 42 .rotationEffect(Angle(degrees: -180)) 43 .animation(.easeOut(duration: 44 0.5)) 45 Text("\\(Int(napaticko)) V") 46 .font(.largeTitle) 47 48 .fontWeight(.semibold) 49 .multilineTextAlignment(.center) 50 51 .padding() 52 .transition(.opacity) 53 54 55 56 } 57 .padding(.top) 58 } 59} 60
ContentView - main Swift code
swift
For iOS application
1// 2// ContentView.swift 3// RingViewRPM 4// 5// Created by Kardan on 01/04/2020. 6// Copyright © 2020 Kardan. All rights reserved. 7// 8 9import SwiftUI 10import CocoaMQTT 11 12 13public struct DarkView<Content> : View where Content : View { 14 var darkContent: Content 15 var on: Bool 16 public init(_ on: Bool, @ViewBuilder content: () -> Content) { 17 self.darkContent = content() 18 self.on = on 19 } 20 21 public var body: some View { 22 ZStack { 23 if on { 24 Spacer() 25 .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) 26 .background(Color.black) 27 .edgesIgnoringSafeArea(.all) 28 darkContent.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity).background(Color.black).colorScheme(.dark) 29 } else { 30 darkContent 31 } 32 } 33 } 34} 35 36extension View { 37 public func darkModeFix(_ on: Bool = true) -> DarkView<Self> { 38 DarkView(on) { 39 self 40 } 41 } 42} 43 44struct ContentView: View { 45 46 47 48 49 let mqttClient = CocoaMQTT(clientID:"d:ORGID:ios_t:ios_i",host:"ORGID.messaging.internetofthings.ibmcloud.com",port: 1883) 50 var hodnota10:String="{\\"properta\\":10}" 51 var hodnota8:String="{\\"properta\\":8}" 52 var hodnota7:String="{\\"properta\\":7}" 53 54 55 56 @State var starahodnota:Double=5.55 57 @State var nazvik="Vozidlo" 58 @State var counter="" 59 @State var nrdlzka:Double = 40.9{ 60 didSet{ 61 starahodnota=oldValue 62 } 63 } 64 @State var nrsirka:Double = 15.5890 65 @State var cgCislo:CGFloat = 0 66 @State var cNapatie:CGFloat = 0 67 @State var cRychlost:CGFloat = 0 68 @State var cOtacky:CGFloat = 0 69 @State var cZataz:CGFloat = 0 70 @State var cSanie:CGFloat = 0 71 var body: some View { 72 73 ZStack { 74 VStack { 75 HStack { 76 Button(action: { 77 self.mqttClient.username="use-token-auth" 78 self.mqttClient.password="ios_token" 79 self.mqttClient.connect() 80 self.counter="Pripojene" 81 }) { 82 Image(systemName: "person.circle") 83 .font(Font.system(.largeTitle).bold()) 84 } 85 .padding() 86 Spacer() 87 Button(action: { 88 self.mqttClient.publish("iot-2/evt/ahoj/fmt/json", withString: "{\\"RJpay\\":\\"20\\"}") 89 self.mqttClient.subscribe("iot-2/cmd/suradnicemotor/fmt/json") 90 self.mqttClient.didReceiveMessage = { mqtt, message, id in 91 print("Message received in topic \\(message.topic) with payload \\(message.string!)") 92 if (message.topic=="iot-2/cmd/suradnicemotor/fmt/json"){ 93 let dorucene:String=message.string! 94 let sevas=dorucene.data(using: .utf8)! 95 let dekodovac = JSONDecoder() 96 let osobka = try! dekodovac.decode(Hodnota.self, from: sevas) 97 let prevteplota=String(osobka.Teplota) 98 self.nrdlzka=osobka.Latituda 99 self.nrsirka=osobka.Longituda 100 self.cgCislo = CGFloat((prevteplota as NSString).doubleValue) 101 } 102 } 103 }) { 104 Image(systemName: "thermometer") 105 .font(Font.system(.largeTitle).bold()) 106 } 107 .padding() 108 Spacer() 109 Button(action: { 110 self.mqttClient.publish("iot-2/evt/ahoj/fmt/json", withString: "{\\"RJpay\\":\\"21\\"}") 111 self.mqttClient.subscribe("iot-2/cmd/suradnicenap/fmt/json") 112 self.mqttClient.didReceiveMessage = { mqtt, message, id in 113 print("Message received in topic \\(message.topic) with payload \\(message.string!)") 114 if (message.topic=="iot-2/cmd/suradnicenap/fmt/json"){ 115 let dorucene:String=message.string! 116 let sevas=dorucene.data(using: .utf8)! 117 let dekodovac = JSONDecoder() 118 let osobka = try! dekodovac.decode(Hodnota3.self, from: sevas) 119 let prevteplota=String(osobka.Napatie) 120 self.nrdlzka=osobka.Latituda 121 self.nrsirka=osobka.Longituda 122 self.cNapatie = CGFloat((prevteplota as NSString).doubleValue) 123 } 124 } 125 }) { 126 Image(systemName: "battery.100") 127 .font(Font.system(.largeTitle).bold()) 128 } 129 .padding() 130 131 Spacer() 132 Button(action: { 133 self.mqttClient.publish("iot-2/evt/ahoj/fmt/json", withString: "{\\"RJpay\\":\\"22\\"}") 134 self.mqttClient.subscribe("iot-2/cmd/surarychl/fmt/json") 135 self.mqttClient.didReceiveMessage = { mqtt, message, id in 136 print("Message received in topic \\(message.topic) with payload \\(message.string!)") 137 if (message.topic=="iot-2/cmd/surarychl/fmt/json"){ 138 let dorucene:String=message.string! 139 let sevas=dorucene.data(using: .utf8)! 140 let dekodovac = JSONDecoder() 141 let osobka = try! dekodovac.decode(Hodnota1.self, from: sevas) 142 let prevteplota=String(osobka.Rychlost) 143 self.nrdlzka=osobka.Latituda 144 self.nrsirka=osobka.Longituda 145 self.cRychlost = CGFloat((prevteplota as NSString).doubleValue) 146 } 147 } 148 149 }) { 150 Image(systemName: "speedometer") 151 .font(Font.system(.largeTitle).bold()) 152 } 153 .padding() 154 155 Spacer() 156 Button(action: { 157 self.mqttClient.publish("iot-2/evt/ahoj/fmt/json", withString: "{\\"RJpay\\":\\"23\\"}") 158 self.mqttClient.subscribe("iot-2/cmd/suraotac/fmt/json") 159 self.mqttClient.didReceiveMessage = { mqtt, message, id in 160 print("Message received in topic \\(message.topic) with payload \\(message.string!)") 161 if (message.topic=="iot-2/cmd/suraotac/fmt/json"){ 162 let dorucene:String=message.string! 163 let sevas=dorucene.data(using: .utf8)! 164 let dekodovac = JSONDecoder() 165 let osobka = try! dekodovac.decode(Hodnota2.self, from: sevas) 166 let prevteplota=String(osobka.Otacky) 167 self.nrdlzka=osobka.Latituda 168 self.nrsirka=osobka.Longituda 169 self.cOtacky = CGFloat((prevteplota as NSString).doubleValue) 170 } 171 } 172 }) { 173 Image(systemName: "arrow.2.circlepath.circle") 174 .font(Font.system(.largeTitle).bold()) 175 } 176 .padding() 177 } 178 Spacer() 179 } 180 VStack { 181 MapView(predtym: starahodnota, nazov: nazvik, dlzka: nrdlzka, sirka: nrsirka) 182 .cornerRadius(25) 183 .frame(height:300) 184 .padding(.top,50) 185 .padding() 186 187 188 Spacer() 189 190 ZStack{ 191 192 //Teplota(hodnotka: cgCislo) 193 ScrollView(.horizontal, showsIndicators: false){ 194 HStack(spacing:5){ 195 Teplota(hodnotka: cgCislo) 196 Napatie(napaticko: cNapatie) 197 Rychlost(rychlostka: cRychlost) 198 Otacky(otacocky: cOtacky) 199 Zataz(zatazka: cZataz) 200 Sanie(sanicko: cSanie) 201 } 202 } 203 204 } 205 } 206 207 } 208 } 209} 210 211struct ContentView_Previews: PreviewProvider { 212 static var previews: some View { 213 ContentView() 214 .darkModeFix() 215 //.environment(\\.colorScheme, .dark) 216 217 } 218} 219 220struct Hodnota: Decodable{ 221 var Longituda:Double 222 var Latituda:Double 223 var Teplota:Int 224} 225 226struct Hodnota1: Decodable{ 227 var Longituda:Double 228 var Latituda:Double 229 var Rychlost:Int 230} 231 232struct Hodnota2: Decodable{ 233 var Longituda:Double 234 var Latituda:Double 235 var Otacky:Int 236} 237 238struct Hodnota3: Decodable{ 239 var Longituda:Double 240 var Latituda:Double 241 var Napatie:Int 242} 243 244
Downloadable files
ELM327 + NEO-6M connection to Arduino MRK1000
Wiring diagram
ELM327 + NEO-6M connection to Arduino MRK1000
ELM327 + NEO-6M connection to Arduino MRK1000
Wiring diagram
ELM327 + NEO-6M connection to Arduino MRK1000
Comments
Only logged in users can leave comments
jassak
0 Followers
•0 Projects
Table of contents
Intro
7
0