Difference between revisions of "MM Defender IOT Controller"

From PalOMoney
Jump to navigation Jump to search
Line 25: Line 25:
 
== MQTT Messages ==
 
== MQTT Messages ==
  
The software currently sends a line of information about once per second. Here are a few messages separated by several minutes each:
+
The software currently sends a line of information about once per second. Here are some messages separated by several minutes each:
 
 
temp = 921 / 1013 => 188440 => 27.1 C (0.2) at 1:8 F=1 I=0 G=0
 
temp = 852 / 1013 => 99613 => 40.6 C (0.5) at 3:89 F=1 I=1 G=1
 
temp = 778 / 1013 => 62318 => 51.3 C (0.5) at 4:3 F=1 I=0 G=1
 
temp = 366 / 1013 => 10648 => 101.3 C (0.2) at 5:263 F=1 I=0 G=1
 
temp = 145 / 1012 => 3148 => 144.3 C (1.8) at 5:1351 F=1 I=0 G=1
 
temp = 283 / 1015 => 7277 => 113.2 C (-1) at 5:2260 F=1 I=0 G=1
 
  
 
The first two numbers are the adc output with the thermistor in the circuit and out.  
 
The first two numbers are the adc output with the thermistor in the circuit and out.  
 
This ratio permits calculation of the thermistor resistance.
 
This ratio permits calculation of the thermistor resistance.
A complex formula calculates the temperature in Celsius followed by the (temperature change)
+
The temperature in Celsius from a complex formula, followed by the (temperature change).
The next numbers show the state # (1-7) : seconds in that state.
+
The next numbers show the state # (1-7) : then approximate seconds in that state.
The last three show the Fan, Igniter, and Gas outputs.
+
The last five show the Fan, Igniter, and Gas outputs followed by the switch position and last error code.
(Not shown is the Switch position, and the most recent error code.)
+
 
 +
temp = 471 / 1015 = 16298 = 88.6 C (-0.3) at 1:3 F=1 I=0 G=0 S=1 E=0
 +
temp = 861 / 1018 = 103230 = 39.8 C (-0.2) at 1:394 F=1 I=0 G=0 S=1 E=0 
 +
temp = 859 / 1015 = 103650 = 39.7 C (-0.1) at 2:3 F=1 I=1 G=0 S=1 E=0
 +
temp = 861 / 1015 = 105241 = 39.4 C (0.4) at 3:2 F=1 I=1 G=1 S=1 E=0
 +
temp = 861 / 1015 = 105241 = 39.4 C (0.4) at 3:40 F=1 I=1 G=1 S=1 E=0
 +
temp = 835 / 1018 = 85889 = 44.1 C (0.2) at 3:90 F=1 I=1 G=1 S=1 E=0
 +
temp = 792 / 1015 = 66853 = 50.2 C (0.3) at 3:118 F=1 I=1 G=1 S=1 E=0
 +
temp = 787 / 1015 = 64974 = 50.3 C (0.1) at 4:0 F=1 I=1 G=1 S=1 E=0
 +
temp = 330 / 1017 = 9042 = 106 C (0.2) at 5:352 F=1 I=0 G=1 S=1 E=0
 +
temp = 291 / 1016 = 7555 = 112 C (0.2) at 5:889 F=1 I=0 G=1 S=1 E=0
 +
temp = 242 / 1016 = 5885 = 120.7 C (0.2) at 5:959 F=1 I=0 G=1 S=1 E=0
 +
temp = 196 / 1016 = 4499 = 130.5 C (0.2) at 5:1019 F=1 I=0 G=1 S=1 E=0
 +
temp = 159 / 1014 = 3501 = 140.1 C (1.9) at 5:1258 F=1 I=0 G=1 S=1 E=0
 +
temp = 128 / 1014 = 2719 = 150.3 C (2.4) at 5:1554 F=1 I=0 G=1 S=1 E=0
 +
temp = 127 / 1015 = 2692 = 150.7 C (0.4) at 5:1561 F=1 I=0 G=1 S=1 E=0
 +
temp = 127 / 1014 = 2695 = 150.7 C (-0.4) at 5:1703 F=1 I=0 G=1 S=1 E=0
 +
temp = 159 / 1014 = 3501 = 140.1 C (1) at 5:1741 F=1 I=0 G=1 S=1 E=0
 +
temp = 198 / 1016 = 4556 = 130 C (-0.3) at 5:1776 F=1 I=0 G=1 S=1 E=0
 +
temp = 242 / 1015 = 5893 = 120.6 C (0.9) at 5:1838 F=1 I=0 G=1 S=1 E=0
 +
temp = 303 / 1016 = 7999 = 110 C (-0.2) at 5:2232 F=1 I=0 G=1 S=1 E=0
 +
temp = 320 / 1016 = 8654 = 107.4 C (-0.7) at 5:8987 F=1 I=0 G=1 S=1 E=0
 +
temp = 321 / 1016 = 8694 = 107.3 C (-0.6) at 5:11433 F=1 I=0 G=1 S=1 E=0
  
 
= Discussion =  
 
= Discussion =  
  
The software needs revision. It fails to re-connect to the server if the connection is lost. It does not respond to commands. You cannot set the wifi SSID and password without attaching a USB cable. It lacks its own web page. It is primitive in its control of the combustion process. Like the previous controller, there is sometimes a pop that sounds like a small explosion when the gas finally starts combustion. I would like to eliminate that, perhaps by increasing the gas levels gradually until a rapid temperature rise.  
+
* The trap was stopped to replace the revision 0 software with rev 1. It was still hot (88.6 C) when restarted. The current algorithm requires the trap to initially cool down (state 1) to an initial temperature well below the starting combustion temperature so that we can tell whether the gas is burning or not.
 +
* At 394 seconds into state 1, the temperature has dropped to "cool enough," and the controller moves to state 2 - igniter, which is activated, and the fan power (and air flow) reduced.
 +
* After 15 seconds, state 3 - gas on, is entered. The fan is returned to full power, and the gas is turned on.
 +
* At 3:90, a significant temperature rise is noted.
 +
* At 3:118, the temperature exceeds 50 C, which means it is getting hot, and the trap enters the state 4 - warming, then right away to state 5 - steady (although it is by no means steady, but it is likely to work). The switch light changes from blinking to solid.
 +
* At 5:352, typical operating temperature (about 110 C) is reached. You would think that would be that, but no.
 +
 
 +
Temperature Rise and Return
 +
 
 +
* At 5:889, the trap temperature starts to climb. Ot reaches peak at 5:1554, stays there until 5:1703, then starts to decline
 +
* at 5:2242, the trap temperature begins to stabilize at 110 C, slowly dropping to about 107 C over a period of time.
 +
 
 +
I have no explanation for the the observed temperature rise and return. I suppose the catalyst is heating up and ... what? If anyone can think of an explanation, please let us know.
 +
 
 +
 
 +
= Software Revisions =
 +
 
 +
This software is the first revision.
 +
* The igniter is on without the gas in state 2 to allow the igniter to get hot enough before the gas arrives. I am hoping to avoid the 'pop' explosion observed in the original unit.
 +
** Issue: Like the previous controller, there is sometimes a pop that sounds like a small explosion when the gas finally starts combustion. I would like to eliminate that, perhaps by increasing the gas levels gradually until a rapid temperature rise.
 +
* The software re-connects to the mqtt broker server if the connection is lost.
 +
* It now responds to commands to change the state, for experimenting.
 +
 
 +
= Planned Updates =
 +
 
 +
* Add a means to set the WiFi SSID and password without attaching a USB cable. This requires the system to operate in access point mode.
 +
* Add a means to specify the MQTT broker server, and topic.
 +
* Add a web page.
 +
* Improve the control of the combustion process. 
  
 
And so on, and so on. The trap needs to keep running to catch those too numerous mosquitos. When the catch dies down, I can update the software.  
 
And so on, and so on. The trap needs to keep running to catch those too numerous mosquitos. When the catch dies down, I can update the software.  

Revision as of 13:10, 14 June 2018

Introduction

I stupidly blew up the Mosquito Magnet Defender PIC controller, see MM Defender Controller. The only alternative was a new controller. I looked at Arduino boards, which have a robust environment community. However, I just discovered the Espressif Systems ESP8266 WIFI chip, which has very limited computing capacity, but WIFI connectivity! I purchased a couple of very cheap development boards, and programmed a new controller using the data below, and wired it into the board in place of the PIC controller. Today it is working, catching hundreds of hungry mosquitos in its first day of operation. Plus, I can check it and the combustion chamber temperature from my PC or phone. What more could I ask?

Actually, I could ask quite a lot more. Here is the first revision schematic.

Schematic

MMDefender NodeMCU Schem 1r0.png

The $4 NodeMCU ESP-12E wireless development board provides greatly improved troubleshooting. Temperature is measured using the 12 bit ADC input buffered by a 220k/100k divider to give a 3.2v full scale input. R6 (20k) drops 3.3 volts so that an open thermistor TH201 yields about full scale. ThermLo connects to U301 D5 open drain that is switched on and off to add and remove TH201, yielding a voltage ratio to calculate its resistance then temperature.

The software implements an MQTT client that publishes its status 'topic' to an MQTT broker for viewing on a PC or phone app. It can also receive commands. A simple web page can also be implemented. WiFi configuration is done with the unit in access point mode so you can enter a WiFi SSID and password.

NodeMCU ESP-12E

71DMo7akIQL. SL1200 .jpg

The development board has 2 rows of 15 pins on 100 mil centers to fit standard 100 mil sockets. I used a 15 pin socket for the right side, and a dual and single socket for the left side. Flexible stranded 6" color coded wires are soldered to the used pins. The foil from the +5v rail was cut. The new rail is labeled +5C, which is powered by the +3.3v from the NodeMCU board. The lower voltage seems to work (power the LED, Q1 gas driver, and the two FETs for the fan and igniter) most of the time (but see below). The foil from C4 was also cut. The wires are soldered onto components or vias where possible - the largish wires can easily rip up a thin foil trace on the controller. The wires should be glued down or potted to the PCB for greater stability (later).

The controller drives 4 outputs: switch LED, Gas, Fan, and Igniter. It has a digital input to read the switch position. The analog input measures the voltage across the thermistor TH201 when the ThermLo signal is low. When ThermLo goes open drain, it measures the +3.3v power supply voltage divided by the 20k resistor and the adc input. This ratio measurement technique is intended to compensate for variations in the +3.3v rail plus other temperature variations.

The software is of the primitive "Hello, World" quality, lacking robust error recovery and the like. Still, it was capable of starting the running the trap. Currently, it connects to an open public MQTT broker server test.mosquitto.org and publishes internal temperature and state info whenever the temperature changes (sometimes once per second) to the /test/MMD/esp###### topic. You can look at that using an MQTT client and tell if the trap is running or not. The broker server and topic is expected to change soon.

MQTT Messages

The software currently sends a line of information about once per second. Here are some messages separated by several minutes each:

The first two numbers are the adc output with the thermistor in the circuit and out. This ratio permits calculation of the thermistor resistance. The temperature in Celsius from a complex formula, followed by the (temperature change). The next numbers show the state # (1-7) : then approximate seconds in that state. The last five show the Fan, Igniter, and Gas outputs followed by the switch position and last error code.

temp = 471 / 1015 = 16298 = 88.6 C (-0.3) at 1:3 F=1 I=0 G=0 S=1 E=0
temp = 861 / 1018 = 103230 = 39.8 C (-0.2) at 1:394 F=1 I=0 G=0 S=1 E=0  
temp = 859 / 1015 = 103650 = 39.7 C (-0.1) at 2:3 F=1 I=1 G=0 S=1 E=0
temp = 861 / 1015 = 105241 = 39.4 C (0.4) at 3:2 F=1 I=1 G=1 S=1 E=0
temp = 861 / 1015 = 105241 = 39.4 C (0.4) at 3:40 F=1 I=1 G=1 S=1 E=0
temp = 835 / 1018 = 85889 = 44.1 C (0.2) at 3:90 F=1 I=1 G=1 S=1 E=0
temp = 792 / 1015 = 66853 = 50.2 C (0.3) at 3:118 F=1 I=1 G=1 S=1 E=0
temp = 787 / 1015 = 64974 = 50.3 C (0.1) at 4:0 F=1 I=1 G=1 S=1 E=0
temp = 330 / 1017 = 9042 = 106 C (0.2) at 5:352 F=1 I=0 G=1 S=1 E=0
temp = 291 / 1016 = 7555 = 112 C (0.2) at 5:889 F=1 I=0 G=1 S=1 E=0
temp = 242 / 1016 = 5885 = 120.7 C (0.2) at 5:959 F=1 I=0 G=1 S=1 E=0
temp = 196 / 1016 = 4499 = 130.5 C (0.2) at 5:1019 F=1 I=0 G=1 S=1 E=0
temp = 159 / 1014 = 3501 = 140.1 C (1.9) at 5:1258 F=1 I=0 G=1 S=1 E=0
temp = 128 / 1014 = 2719 = 150.3 C (2.4) at 5:1554 F=1 I=0 G=1 S=1 E=0
temp = 127 / 1015 = 2692 = 150.7 C (0.4) at 5:1561 F=1 I=0 G=1 S=1 E=0
temp = 127 / 1014 = 2695 = 150.7 C (-0.4) at 5:1703 F=1 I=0 G=1 S=1 E=0
temp = 159 / 1014 = 3501 = 140.1 C (1) at 5:1741 F=1 I=0 G=1 S=1 E=0
temp = 198 / 1016 = 4556 = 130 C (-0.3) at 5:1776 F=1 I=0 G=1 S=1 E=0
temp = 242 / 1015 = 5893 = 120.6 C (0.9) at 5:1838 F=1 I=0 G=1 S=1 E=0
temp = 303 / 1016 = 7999 = 110 C (-0.2) at 5:2232 F=1 I=0 G=1 S=1 E=0
temp = 320 / 1016 = 8654 = 107.4 C (-0.7) at 5:8987 F=1 I=0 G=1 S=1 E=0
temp = 321 / 1016 = 8694 = 107.3 C (-0.6) at 5:11433 F=1 I=0 G=1 S=1 E=0

Discussion

  • The trap was stopped to replace the revision 0 software with rev 1. It was still hot (88.6 C) when restarted. The current algorithm requires the trap to initially cool down (state 1) to an initial temperature well below the starting combustion temperature so that we can tell whether the gas is burning or not.
  • At 394 seconds into state 1, the temperature has dropped to "cool enough," and the controller moves to state 2 - igniter, which is activated, and the fan power (and air flow) reduced.
  • After 15 seconds, state 3 - gas on, is entered. The fan is returned to full power, and the gas is turned on.
  • At 3:90, a significant temperature rise is noted.
  • At 3:118, the temperature exceeds 50 C, which means it is getting hot, and the trap enters the state 4 - warming, then right away to state 5 - steady (although it is by no means steady, but it is likely to work). The switch light changes from blinking to solid.
  • At 5:352, typical operating temperature (about 110 C) is reached. You would think that would be that, but no.

Temperature Rise and Return

  • At 5:889, the trap temperature starts to climb. Ot reaches peak at 5:1554, stays there until 5:1703, then starts to decline
  • at 5:2242, the trap temperature begins to stabilize at 110 C, slowly dropping to about 107 C over a period of time.

I have no explanation for the the observed temperature rise and return. I suppose the catalyst is heating up and ... what? If anyone can think of an explanation, please let us know.


Software Revisions

This software is the first revision.

  • The igniter is on without the gas in state 2 to allow the igniter to get hot enough before the gas arrives. I am hoping to avoid the 'pop' explosion observed in the original unit.
    • Issue: Like the previous controller, there is sometimes a pop that sounds like a small explosion when the gas finally starts combustion. I would like to eliminate that, perhaps by increasing the gas levels gradually until a rapid temperature rise.
  • The software re-connects to the mqtt broker server if the connection is lost.
  • It now responds to commands to change the state, for experimenting.

Planned Updates

  • Add a means to set the WiFi SSID and password without attaching a USB cable. This requires the system to operate in access point mode.
  • Add a means to specify the MQTT broker server, and topic.
  • Add a web page.
  • Improve the control of the combustion process.

And so on, and so on. The trap needs to keep running to catch those too numerous mosquitos. When the catch dies down, I can update the software.

June 13, 2018

Last night, the trap would start then die as the internal temperature reached 130 C. It did this 3 times. The steady state was about 100-110 C, but initially the temperature climbs to about 150 C before it settles down. But the combustion stopped at 130 degrees, and it cooled all the way down to where the gas turned off and the fast blinking fault state entered. My guess is that the NodeMCU was getting too hot. I moved the board as far away from the combustion chamber as I could, and that worked. The whole system is marginal regarding heat and environmental conditions. We will see what happens during a thunderstorm. Again, my guess is that Q1 is losing drive and opening up, shutting off the gas at this temperature. I will have to instrument this to see what is happening. But now it is working, and the mosquitos are coming far and wide. Just keep going!

Happy Trapping!