diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs index 7b45063..5d98259 100644 --- a/.settings/org.eclipse.cdt.core.prefs +++ b/.settings/org.eclipse.cdt.core.prefs @@ -187,10 +187,10 @@ environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.DTS environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.DTS/value=3600 environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.LOCAL/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.LOCAL/operation=replace -environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.LOCAL/value=1503312196 +environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.LOCAL/value=1503395543 environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.UTC/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.UTC/operation=replace -environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.UTC/value=1503304996 +environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.UTC/value=1503388343 environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.ZONE/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.ZONE/operation=replace environment/project/io.sloeber.core.toolChain.release.936970421/A.EXTRA.TIME.ZONE/value=3600 @@ -469,10 +469,10 @@ environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARD_NAM environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.BOARD_NAME/value=NodeMCU 1.0 (ESP-12E Module) environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.COM_PORT/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.COM_PORT/operation=replace -environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.COM_PORT/value=/dev/ttyUSB0 +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.COM_PORT/value=/dev/ttyUSB2 environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ECLIPSE_LOCATION/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ECLIPSE_LOCATION/operation=replace -environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ECLIPSE_LOCATION/value=${eclipse_home}/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.ECLIPSE_LOCATION/value=${eclipse_home}///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.C.COMPILE/delimiter=\: environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.C.COMPILE/operation=replace environment/project/io.sloeber.core.toolChain.release.936970421/JANTJE.EXTRA.C.COMPILE/value= diff --git a/ConfigGenerator/configuration_c.tmpl b/ConfigGenerator/configuration_c.tmpl index 33b4040..eb5f172 100644 --- a/ConfigGenerator/configuration_c.tmpl +++ b/ConfigGenerator/configuration_c.tmpl @@ -14,6 +14,8 @@ tConfigBlock configBlock; const uint32_t MAGIC = 0xC0DE0001; extern ESP8266WebServer webServer; +bool configSaved = false; + void configServeIndex() { bool configValid = (configBlock.magic == MAGIC); @@ -36,7 +38,14 @@ void configServeIndex() { " ESP8266 Thermometer Configuration Page" " " " " - "

ESP8266 Configuration Page

" + "

ESP8266 Configuration Page

"; + + if (configSaved) { + configSaved = false; + buffer += "

Configuration saved

"; + } + + buffer += "
" " " #for $configItem in $configItems @@ -88,8 +97,6 @@ void configServeGetConfiguration() { #for $configItem in $configItems #if $configItem.label != "_" arg = webServer.arg("$configItem.key"); - Serial.print("$configItem.key"); - Serial.println(arg); #if $configItem.type == "C" strcpy(configBlock.$configItem.key, arg.c_str()); #else if $configItem.type == "I" @@ -103,19 +110,15 @@ void configServeGetConfiguration() { showConfiguration(); EEPROM.begin(512); - for (uint16_t i = 0; i < sizeof(configBlock); i++) { - char c = *(((char*)(&configBlock))+i); - Serial.print("write to eeprom: "); - Serial.print(i); - Serial.print(" "); - Serial.println(c); - EEPROM.write(EEPROM_ADDR + i, c); - } + EEPROM.put(EEPROM_ADDR, configBlock); EEPROM.commit(); Serial.println("EEPROM saved"); - - webServer.send(200, "text/html", "configuration saved"); + + configSaved = true; + webServer.sendHeader("Location", String("/"), true); + webServer.send(302, "text/plain", ""); + //webServer.send(200, "text/html", "configuration saved"); } void showConfiguration() { diff --git a/EspThermometer2.cpp b/EspThermometer2.cpp index c7d0fed..61bc323 100644 --- a/EspThermometer2.cpp +++ b/EspThermometer2.cpp @@ -17,17 +17,8 @@ ADC_MODE(ADC_VCC); - - - - - bool configMode = false; - - - - uint32_t startTime = 0; @@ -43,16 +34,7 @@ void setup() { EEPROM.begin(512); - for (uint16_t i = 0; i < sizeof(configBlock); i++) { - char x = EEPROM.read(EEPROM_ADDR + i); - Serial.print("read from eeprom: "); - Serial.print(i); - Serial.print(" "); - Serial.print((uint8_t)x); - Serial.print(" "); - Serial.println(x); - *(((char*)(&configBlock))+i) = x; - } + EEPROM.get(EEPROM_ADDR, configBlock); Serial.print("Magic: "); @@ -64,7 +46,7 @@ void setup() { #ifdef DEBUG Serial.println("Configuration mode"); #endif - digitalWrite(LED_PIN, HIGH); + digitalWrite(LED_PIN, LOW); setupConfiguration(); } else { #ifdef DEBUG @@ -74,7 +56,7 @@ void setup() { showConfiguration(); #endif - digitalWrite(LED_PIN, LOW); + digitalWrite(LED_PIN, HIGH); setupProduction(); } diff --git a/Hardware/Hardware-cache.lib b/Hardware/Hardware-cache.lib new file mode 100644 index 0000000..adf625f --- /dev/null +++ b/Hardware/Hardware-cache.lib @@ -0,0 +1,108 @@ +EESchema-LIBRARY Version 2.3 +#encoding utf-8 +# +# +3V3 +# +DEF +3V3 #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -150 50 H I C CNN +F1 "+3V3" 0 140 50 H V C CNN +F2 "" 0 0 50 H V C CNN +F3 "" 0 0 50 H V C CNN +ALIAS +3.3V +DRAW +P 2 0 1 0 -30 50 0 100 N +P 2 0 1 0 0 0 0 100 N +P 2 0 1 0 0 100 30 50 N +X +3V3 1 0 0 0 U 50 50 1 1 W N +ENDDRAW +ENDDEF +# +# ESP-12E +# +DEF ESP-12E U 0 40 Y Y 1 F N +F0 "U" 0 -100 50 H V C CNN +F1 "ESP-12E" 0 100 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + ESP-12E + ESP-12E_SMD +$ENDFPLIST +DRAW +S -600 -600 600 600 1 0 0 N +X REST 1 -900 300 300 R 50 50 1 1 I +X ADC 2 -900 200 300 R 50 50 1 1 P +X CH_PD 3 -900 100 300 R 50 50 1 1 I +X GPIO16 4 -900 0 300 R 50 50 1 1 B +X GPIO14 5 -900 -100 300 R 50 50 1 1 B +X GPIO12 6 -900 -200 300 R 50 50 1 1 B +X GPIO13 7 -900 -300 300 R 50 50 1 1 B +X VCC 8 -900 -400 300 R 50 50 1 1 W +X GND 9 900 -400 300 L 50 50 1 1 W +X GPIO15 10 900 -300 300 L 50 50 1 1 B +X GPIO10 20 50 -900 300 U 50 50 1 1 B +X GPIO2 11 900 -200 300 L 50 50 1 1 B +X MOSI 21 150 -900 300 U 50 50 1 1 B +X GPIO0 12 900 -100 300 L 50 50 1 1 B +X SCLK 22 250 -900 300 U 50 50 1 1 B +X GPIO4 13 900 0 300 L 50 50 1 1 B +X GPIO5 14 900 100 300 L 50 50 1 1 B +X RXD 15 900 200 300 L 50 50 1 1 I +X TXD 16 900 300 300 L 50 50 1 1 O +X CS0 17 -250 -900 300 U 50 50 1 1 B +X MISO 18 -150 -900 300 U 50 50 1 1 B +X GPIO9 19 -50 -900 300 U 50 50 1 1 B +ENDDRAW +ENDDEF +# +# GND +# +DEF GND #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -250 50 H I C CNN +F1 "GND" 0 -150 50 H V C CNN +F2 "" 0 0 50 H V C CNN +F3 "" 0 0 50 H V C CNN +DRAW +P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N +X GND 1 0 0 0 D 50 50 1 1 W N +ENDDRAW +ENDDEF +# +# MAX31820 +# +DEF MAX31820 U 0 40 Y Y 1 F N +F0 "U" -150 250 50 H V C CNN +F1 "MAX31820" 0 -250 50 H V C CNN +F2 "" -150 250 50 H I C CNN +F3 "" -150 250 50 H I C CNN +ALIAS DS1822 DS18B20 DS18S20 DS1821C +$FPLIST + TO-92_* +$ENDFPLIST +DRAW +S -200 200 200 -200 0 1 0 N +X GND 1 -300 -100 100 R 50 50 1 1 W +X DQ 2 -300 0 100 R 50 50 1 1 B +X VDD 3 -300 100 100 R 50 50 1 1 W +ENDDRAW +ENDDEF +# +# R +# +DEF R R 0 0 N Y 1 F N +F0 "R" 80 0 50 V V C CNN +F1 "R" 0 0 50 V V C CNN +F2 "" -70 0 50 V V C CNN +F3 "" 0 0 50 H V C CNN +$FPLIST + R_* + Resistor_* +$ENDFPLIST +DRAW +S -40 -100 40 100 0 1 10 N +X ~ 1 0 150 50 D 50 50 1 1 P +X ~ 2 0 -150 50 U 50 50 1 1 P +ENDDRAW +ENDDEF +# +#End Library diff --git a/Hardware/Hardware.bak b/Hardware/Hardware.bak new file mode 100644 index 0000000..8b829fb --- /dev/null +++ b/Hardware/Hardware.bak @@ -0,0 +1 @@ +EESchema Schematic File Version 2 diff --git a/Hardware/Hardware.kicad_pcb b/Hardware/Hardware.kicad_pcb new file mode 100644 index 0000000..02c8ecb --- /dev/null +++ b/Hardware/Hardware.kicad_pcb @@ -0,0 +1 @@ +(kicad_pcb (version 4) (host kicad "dummy file") ) diff --git a/Hardware/Hardware.pro b/Hardware/Hardware.pro new file mode 100644 index 0000000..420a9f7 --- /dev/null +++ b/Hardware/Hardware.pro @@ -0,0 +1,156 @@ +update=Mon 21 Aug 2017 02:34:52 PM CEST +version=1 +last_client=kicad +[pcbnew] +version=1 +LastNetListRead= +UseCmpFile=1 +PadDrill=0.600000000000 +PadDrillOvalY=0.600000000000 +PadSizeH=1.500000000000 +PadSizeV=1.500000000000 +PcbTextSizeV=1.500000000000 +PcbTextSizeH=1.500000000000 +PcbTextThickness=0.300000000000 +ModuleTextSizeV=1.000000000000 +ModuleTextSizeH=1.000000000000 +ModuleTextSizeThickness=0.150000000000 +SolderMaskClearance=0.000000000000 +SolderMaskMinWidth=0.000000000000 +DrawSegmentWidth=0.200000000000 +BoardOutlineThickness=0.100000000000 +ModuleOutlineThickness=0.150000000000 +[cvpcb] +version=1 +NetIExt=net +[general] +version=1 +[eeschema] +version=1 +LibDir=/home/wn/kicad/libraries +[eeschema/libraries] +LibName1=power +LibName2=device +LibName3=transistors +LibName4=conn +LibName5=linear +LibName6=regul +LibName7=74xx +LibName8=cmos4000 +LibName9=adc-dac +LibName10=memory +LibName11=xilinx +LibName12=microcontrollers +LibName13=dsp +LibName14=microchip +LibName15=analog_switches +LibName16=motorola +LibName17=texas +LibName18=intel +LibName19=audio +LibName20=interface +LibName21=digital-audio +LibName22=philips +LibName23=display +LibName24=cypress +LibName25=siliconi +LibName26=opto +LibName27=atmel +LibName28=contrib +LibName29=valves +LibName30=/home/wn/kicad/libraries/kicad-ESP8266/ESP8266 +LibName31=kicad-library/library/74xgxx +LibName32=kicad-library/library/74xx +LibName33=kicad-library/library/ac-dc +LibName34=kicad-library/library/actel +LibName35=kicad-library/library/adc-dac +LibName36=kicad-library/library/allegro +LibName37=kicad-library/library/Altera +LibName38=kicad-library/library/analog_devices +LibName39=kicad-library/library/analog_switches +LibName40=kicad-library/library/atmel +LibName41=kicad-library/library/audio +LibName42=kicad-library/library/battery_management +LibName43=kicad-library/library/bbd +LibName44=kicad-library/library/bosch +LibName45=kicad-library/library/brooktre +LibName46=kicad-library/library/cmos4000 +LibName47=kicad-library/library/cmos_ieee +LibName48=kicad-library/library/conn +LibName49=kicad-library/library/contrib +LibName50=kicad-library/library/cypress +LibName51=kicad-library/library/dc-dc +LibName52=kicad-library/library/device +LibName53=kicad-library/library/digital-audio +LibName54=kicad-library/library/diode +LibName55=kicad-library/library/display +LibName56=kicad-library/library/dsp +LibName57=kicad-library/library/elec-unifil +LibName58=kicad-library/library/ESD_Protection +LibName59=kicad-library/library/ftdi +LibName60=kicad-library/library/gennum +LibName61=kicad-library/library/graphic_symbols +LibName62=kicad-library/library/hc11 +LibName63=kicad-library/library/infineon +LibName64=kicad-library/library/intel +LibName65=kicad-library/library/interface +LibName66=kicad-library/library/intersil +LibName67=kicad-library/library/ir +LibName68=kicad-library/library/Lattice +LibName69=kicad-library/library/leds +LibName70=kicad-library/library/LEM +LibName71=kicad-library/library/linear +LibName72=kicad-library/library/logic_programmable +LibName73=kicad-library/library/maxim +LibName74=kicad-library/library/mechanical +LibName75=kicad-library/library/memory +LibName76=kicad-library/library/microchip +LibName77=kicad-library/library/microchip_dspic33dsc +LibName78=kicad-library/library/microchip_pic10mcu +LibName79=kicad-library/library/microchip_pic12mcu +LibName80=kicad-library/library/microchip_pic16mcu +LibName81=kicad-library/library/microchip_pic18mcu +LibName82=kicad-library/library/microchip_pic24mcu +LibName83=kicad-library/library/microchip_pic32mcu +LibName84=kicad-library/library/microcontrollers +LibName85=kicad-library/library/modules +LibName86=kicad-library/library/motor_drivers +LibName87=kicad-library/library/motorola +LibName88=kicad-library/library/motors +LibName89=kicad-library/library/msp430 +LibName90=kicad-library/library/nordicsemi +LibName91=kicad-library/library/nxp +LibName92=kicad-library/library/nxp_armmcu +LibName93=kicad-library/library/onsemi +LibName94=kicad-library/library/opto +LibName95=kicad-library/library/Oscillators +LibName96=kicad-library/library/philips +LibName97=kicad-library/library/power +LibName98=kicad-library/library/powerint +LibName99=kicad-library/library/Power_Management +LibName100=kicad-library/library/pspice +LibName101=kicad-library/library/references +LibName102=kicad-library/library/regul +LibName103=kicad-library/library/relays +LibName104=kicad-library/library/rfcom +LibName105=kicad-library/library/RFSolutions +LibName106=kicad-library/library/sensors +LibName107=kicad-library/library/silabs +LibName108=kicad-library/library/siliconi +LibName109=kicad-library/library/stm8 +LibName110=kicad-library/library/stm32 +LibName111=kicad-library/library/supertex +LibName112=kicad-library/library/switches +LibName113=kicad-library/library/texas +LibName114=kicad-library/library/transf +LibName115=kicad-library/library/transistors +LibName116=kicad-library/library/triac_thyristor +LibName117=kicad-library/library/ttl_ieee +LibName118=kicad-library/library/valves +LibName119=kicad-library/library/video +LibName120=kicad-library/library/wiznet +LibName121=kicad-library/library/Worldsemi +LibName122=kicad-library/library/Xicor +LibName123=kicad-library/library/xilinx +LibName124=kicad-library/library/zetex +LibName125=kicad-library/library/Zilog diff --git a/Hardware/Hardware.sch b/Hardware/Hardware.sch new file mode 100644 index 0000000..b903a26 --- /dev/null +++ b/Hardware/Hardware.sch @@ -0,0 +1,241 @@ +EESchema Schematic File Version 2 +LIBS:power +LIBS:device +LIBS:transistors +LIBS:conn +LIBS:linear +LIBS:regul +LIBS:74xx +LIBS:cmos4000 +LIBS:adc-dac +LIBS:memory +LIBS:xilinx +LIBS:microcontrollers +LIBS:dsp +LIBS:microchip +LIBS:analog_switches +LIBS:motorola +LIBS:texas +LIBS:intel +LIBS:audio +LIBS:interface +LIBS:digital-audio +LIBS:philips +LIBS:display +LIBS:cypress +LIBS:siliconi +LIBS:opto +LIBS:atmel +LIBS:contrib +LIBS:valves +LIBS:ESP8266 +LIBS:74xgxx +LIBS:ac-dc +LIBS:actel +LIBS:allegro +LIBS:Altera +LIBS:analog_devices +LIBS:battery_management +LIBS:bbd +LIBS:bosch +LIBS:brooktre +LIBS:cmos_ieee +LIBS:dc-dc +LIBS:diode +LIBS:elec-unifil +LIBS:ESD_Protection +LIBS:ftdi +LIBS:gennum +LIBS:graphic_symbols +LIBS:hc11 +LIBS:infineon +LIBS:intersil +LIBS:ir +LIBS:Lattice +LIBS:leds +LIBS:LEM +LIBS:logic_programmable +LIBS:maxim +LIBS:mechanical +LIBS:microchip_dspic33dsc +LIBS:microchip_pic10mcu +LIBS:microchip_pic12mcu +LIBS:microchip_pic16mcu +LIBS:microchip_pic18mcu +LIBS:microchip_pic24mcu +LIBS:microchip_pic32mcu +LIBS:modules +LIBS:motor_drivers +LIBS:motors +LIBS:msp430 +LIBS:nordicsemi +LIBS:nxp +LIBS:nxp_armmcu +LIBS:onsemi +LIBS:Oscillators +LIBS:powerint +LIBS:Power_Management +LIBS:pspice +LIBS:references +LIBS:relays +LIBS:rfcom +LIBS:RFSolutions +LIBS:sensors +LIBS:silabs +LIBS:stm8 +LIBS:stm32 +LIBS:supertex +LIBS:switches +LIBS:transf +LIBS:triac_thyristor +LIBS:ttl_ieee +LIBS:video +LIBS:wiznet +LIBS:Worldsemi +LIBS:Xicor +LIBS:zetex +LIBS:Zilog +EELAYER 25 0 +EELAYER END +$Descr A4 11693 8268 +encoding utf-8 +Sheet 1 1 +Title "ESP Thermometer 2" +Date "2017-08-21" +Rev "1" +Comp "hottis.de" +Comment1 "Wolfgang Hottgenroth" +Comment2 "" +Comment3 "" +Comment4 "" +$EndDescr +$Comp +L ESP-12E U? +U 1 1 599AD18B +P 5900 3700 +F 0 "U?" H 5900 3600 50 0000 C CNN +F 1 "ESP-12E" H 5900 3800 50 0000 C CNN +F 2 "" H 5900 3700 50 0001 C CNN +F 3 "" H 5900 3700 50 0001 C CNN + 1 5900 3700 + 1 0 0 -1 +$EndComp +$Comp +L DS18B20 U? +U 1 1 599AD38A +P 7900 3900 +F 0 "U?" H 7750 4150 50 0000 C CNN +F 1 "DS18B20" H 7900 3650 50 0000 C CNN +F 2 "" H 7750 4150 50 0001 C CNN +F 3 "" H 7750 4150 50 0001 C CNN + 1 7900 3900 + 1 0 0 -1 +$EndComp +$Comp +L R R? +U 1 1 599AD3E3 +P 7400 3650 +F 0 "R?" V 7480 3650 50 0000 C CNN +F 1 "R" V 7400 3650 50 0000 C CNN +F 2 "" V 7330 3650 50 0000 C CNN +F 3 "" H 7400 3650 50 0000 C CNN + 1 7400 3650 + 1 0 0 -1 +$EndComp +$Comp +L R R? +U 1 1 599AD440 +P 6550 2300 +F 0 "R?" V 6630 2300 50 0000 C CNN +F 1 "R" V 6550 2300 50 0000 C CNN +F 2 "" V 6480 2300 50 0000 C CNN +F 3 "" H 6550 2300 50 0000 C CNN + 1 6550 2300 + 1 0 0 -1 +$EndComp +$Comp +L R R? +U 1 1 599AD487 +P 4850 3150 +F 0 "R?" V 4930 3150 50 0000 C CNN +F 1 "R" V 4850 3150 50 0000 C CNN +F 2 "" V 4780 3150 50 0000 C CNN +F 3 "" H 4850 3150 50 0000 C CNN + 1 4850 3150 + 1 0 0 -1 +$EndComp +$Comp +L +3.3V #PWR? +U 1 1 599AD888 +P 4500 2700 +F 0 "#PWR?" H 4500 2550 50 0001 C CNN +F 1 "+3.3V" H 4500 2840 50 0000 C CNN +F 2 "" H 4500 2700 50 0000 C CNN +F 3 "" H 4500 2700 50 0000 C CNN + 1 4500 2700 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR? +U 1 1 599AD9A6 +P 6900 4350 +F 0 "#PWR?" H 6900 4100 50 0001 C CNN +F 1 "GND" H 6900 4200 50 0000 C CNN +F 2 "" H 6900 4350 50 0000 C CNN +F 3 "" H 6900 4350 50 0000 C CNN + 1 6900 4350 + 1 0 0 -1 +$EndComp +Wire Wire Line + 4850 3700 5000 3700 +Wire Wire Line + 4850 3300 4850 3700 +Wire Wire Line + 4850 3400 5000 3400 +Wire Wire Line + 6800 4000 7600 4000 +Wire Wire Line + 6900 4000 6900 4350 +Wire Wire Line + 6900 4100 6800 4100 +Wire Wire Line + 4500 4100 5000 4100 +Wire Wire Line + 4500 2700 4500 4100 +Wire Wire Line + 5000 3600 4500 3600 +Connection ~ 4500 3600 +Connection ~ 4850 3400 +Wire Wire Line + 4850 3000 4850 2900 +Wire Wire Line + 4850 2900 4500 2900 +Connection ~ 4500 2900 +Connection ~ 6900 4100 +Connection ~ 6900 4000 +$Comp +L +3.3V #PWR? +U 1 1 599ADB76 +P 7500 3250 +F 0 "#PWR?" H 7500 3100 50 0001 C CNN +F 1 "+3.3V" H 7500 3390 50 0000 C CNN +F 2 "" H 7500 3250 50 0000 C CNN +F 3 "" H 7500 3250 50 0000 C CNN + 1 7500 3250 + 1 0 0 -1 +$EndComp +Wire Wire Line + 7600 3800 7500 3800 +Wire Wire Line + 7500 3800 7500 3250 +Wire Wire Line + 6800 3900 7600 3900 +Wire Wire Line + 7400 3900 7400 3800 +Wire Wire Line + 7400 3500 7400 3400 +Wire Wire Line + 7400 3400 7500 3400 +Connection ~ 7500 3400 +Connection ~ 7400 3900 +$EndSCHEMATC diff --git a/configuration.cpp b/configuration.cpp index 0b02697..fde01fd 100644 --- a/configuration.cpp +++ b/configuration.cpp @@ -12,6 +12,8 @@ tConfigBlock configBlock; const uint32_t MAGIC = 0xC0DE0001; extern ESP8266WebServer webServer; +bool configSaved = false; + void configServeIndex() { bool configValid = (configBlock.magic == MAGIC); @@ -34,7 +36,14 @@ void configServeIndex() { " ESP8266 Thermometer Configuration Page" " " " " - "

ESP8266 Configuration Page

" + "

ESP8266 Configuration Page

"; + + if (configSaved) { + configSaved = false; + buffer += "

Configuration saved

"; + } + + buffer += " " "
" " " @@ -192,40 +201,22 @@ void configServeGetConfiguration() { String arg; arg = webServer.arg("wifiSsid"); - Serial.print("wifiSsid"); - Serial.println(arg); strcpy(configBlock.wifiSsid, arg.c_str()); arg = webServer.arg("wifiKey"); - Serial.print("wifiKey"); - Serial.println(arg); strcpy(configBlock.wifiKey, arg.c_str()); arg = webServer.arg("mqttBroker"); - Serial.print("mqttBroker"); - Serial.println(arg); strcpy(configBlock.mqttBroker, arg.c_str()); arg = webServer.arg("mqttUser"); - Serial.print("mqttUser"); - Serial.println(arg); strcpy(configBlock.mqttUser, arg.c_str()); arg = webServer.arg("mqttPass"); - Serial.print("mqttPass"); - Serial.println(arg); strcpy(configBlock.mqttPass, arg.c_str()); arg = webServer.arg("mqttClientId"); - Serial.print("mqttClientId"); - Serial.println(arg); strcpy(configBlock.mqttClientId, arg.c_str()); arg = webServer.arg("mqttTopic"); - Serial.print("mqttTopic"); - Serial.println(arg); strcpy(configBlock.mqttTopic, arg.c_str()); arg = webServer.arg("mqttPort"); - Serial.print("mqttPort"); - Serial.println(arg); configBlock.mqttPort = atoi(arg.c_str()); arg = webServer.arg("measurePeriod"); - Serial.print("measurePeriod"); - Serial.println(arg); configBlock.measurePeriod = atoi(arg.c_str()); configBlock.magic = MAGIC; @@ -233,19 +224,15 @@ void configServeGetConfiguration() { showConfiguration(); EEPROM.begin(512); - for (uint16_t i = 0; i < sizeof(configBlock); i++) { - char c = *(((char*)(&configBlock))+i); - Serial.print("write to eeprom: "); - Serial.print(i); - Serial.print(" "); - Serial.println(c); - EEPROM.write(EEPROM_ADDR + i, c); - } + EEPROM.put(EEPROM_ADDR, configBlock); EEPROM.commit(); Serial.println("EEPROM saved"); - - webServer.send(200, "text/html", "configuration saved"); + + configSaved = true; + webServer.sendHeader("Location", String("/"), true); + webServer.send(302, "text/plain", ""); + //webServer.send(200, "text/html", "configuration saved"); } void showConfiguration() {