You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino
+16Lines changed: 16 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -282,6 +282,10 @@ volatile boolean readtorque=false; //true if torque array has been updated -> r
282
282
unsignedlong bbs_pausestart=0; //start time of power pause for gear change
283
283
#endif
284
284
285
+
#ifdef SUPPORT_THERMISTOR
286
+
float temperature_thermistor=0; //thermistor temperature
287
+
#endif
288
+
285
289
#if (SERIAL_MODE & SERIAL_MODE_MMC) //communicate with mmc-app
286
290
String mmc_command="";
287
291
byte mmc_value=0;
@@ -544,6 +548,10 @@ loadcell.tare(); //set zero scale. remove any load diring star
544
548
loadcell.set_scale(hx711_scale); //apply scaling
545
549
#endif
546
550
551
+
#ifdef SUPPORT_THERMISTOR
552
+
pinMode(thermistor_pin,INPUT);
553
+
#endif
554
+
547
555
#ifdef DEBUG_MEMORY_USAGE
548
556
Serial.print(MY_F("memFree after setup:"));
549
557
Serial.print(memFree());
@@ -975,6 +983,10 @@ if (loadcell.is_ready()) //new conversion result from load cell available
975
983
sensors.requestTemperatures(); // read temperature(s) from DS18x20 sensor. Readouts are in sensors.getTempCByIndex(n)
976
984
#endif
977
985
986
+
#ifdef SUPPORT_THERMISTOR
987
+
temperature_thermistor=1/(thermistor_t0+thermistor_b*log((10240/analogRead(thermistor_pin)-10)/thermistor_r))-273.15; //calculate thermistor temperature from Steinhart-Hart parameters
988
+
#endif
989
+
978
990
battery_percent_fromcapacity = constrain((1-wh/ curr_capacity)*100,0,100); //battery percent calculation from battery capacity. For voltage-based calculation see above
979
991
range=constrain(curr_capacity/wh*km-km,0.0,200.0); //range calculation from battery capacity
0 commit comments