MQ4 gas sensor story...

J

Jan Panteltje

Guest
Testing the MQ4 gas sensor

So I bought a MQ4 gas sensor module:
https://www.tinytronics.nl/shop/en/sensors/air/gas/mq-4-gas-sensor-module

Had it on for 24 hours on the lab supply, in that period output on analog out dropped slowly to a very low value (takes hours).

Tested it in the kitchen, powered from a LM317 programmed for 5 V, thing uses about 170 mA,
meter on the analog output,
gas tap open, and low and behold the analog output went up considerable in a minute or so.
And went back to normal with no gas.
Put it on a piece of cloth drenched in some alcohol and that make the analog output rise too,
so thing is sensitive to alcohol too, may give false alarm in kitchen?

Anyways, whatever, I once a long time ago (2016). designed a wind sensor with a Microchip PIC 18F14K22 chip, it uses power over Ethernet,
and basically has 4 analog input channels, so borrowed one and connected it to the MQ4 module analog output via a resistor divider
(ADCc runs on 3.3V, the MQ4 on 5V
You can download the PIC asm, hexfile, and ciccuit here:
http://www.panteltje.nl/panteltje/pic/wind_pic_thermal_udp/wind_thermal-0.1.tgz

This wind_thermal is a nice way to get analog values into your computers via POE.
It sends UDP packets continuously to an IP address on the LAN that you can specify.
This is where the software comes in., to process it!

So I have one Raspberry Pi (a very old one) that runs as server for many things, much data in the house goes to that,
and can then be accessed from a website or via ssh etc, or by other computers on the LAN, that ls is what happens here now.

So for listening for UDP packets, looking at the received analog level from the MQ4 sensor, setting an alarm limit, I wrote the following code
The wind_thermal unit sends to IP address 192.168./178.73 (the raspi server) port 1078.
This is the C source code, it uses the \'netcat\' utility to receive and send data, netcat is one of the greatest network utilities I know about.


/* for internet */
#define _BSD_SOURCE /* this is needed to avoid compile error messages in internet routines */

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <wchar.h> // for open_wmemstream()
/* end for internet */


#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <stdlib.h>
#include <sys/file.h>
#include <errno.h>
#include \"getopt.h\"
#include <math.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
#include <stddef.h>
#include <pwd.h>
#include <math.h>
#include <pthread.h>
#include <stdint.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/time.h>


#include <stdio.h>
#include <stdlib.h>

int verbose;
int gas_alarm_level;

#define TEMP_SIZE 65535


void print_usage()
{
fprintf(stderr,\\
\"\\nPanteltje gas_pic level detector\\n\\
Usage:\\ngas_pic -h -l int -v\\n\\
\\n\\
-h help (this help).\\n\\
-l alarm_level, range 0 to 1000 default %d\\n\\
-v verbose, prints functions and arguments.\\n\"
, gas_alarm_level);

fprintf(stderr,\\
\"Examples, \\n\\
gas_pic -l 30\\n\\n\");

} /* end function print_usage */



int main(int argc, char **argv)
{
int a, b, c;
FILE *pptr;
int gas_adc_level;
char temp[TEMP_SIZE];
char out_string[TEMP_SIZE];

/* proces any command line arguments */
while(1)
{
a = getopt(argc, argv, \"hl:v\");
if(a == -1) break;

switch(a)
{
case \'h\': // help
print_usage();
exit(1);
break;

case \'l\': // gas alarm level
gas_alarm_level = atoi(optarg);
break;

case \'v\': // verbose
verbose = 1;
break;

default:
print_usage();

exit(1);
break;
} /* end switch a */

} /* end while command line argumants */


gas_adc_level = 0;
a = 0;
while(1)
{
sprintf(temp, \"netcat -u -l -p 1078\");
if(verbose)
{
fprintf(stderr, \"temp=%s\\n\", temp);
}

pptr = popen(temp, \"r\");
while(1)
{
c = fgetc(pptr);

if(verbose)
{
fprintf(stderr, \"%c\", c);
}

out_string[a] = c;
a++;

if(c == 10)
{
pclose(pptr);

a = 0;

if(verbose)
{
fprintf(stderr, \"out_string=%s\\n\", out_string);
}

// F23 R753 B747 L751a
sscanf(out_string ,\"F%d\", &gas_adc_level);

// if(verbose)
{
fprintf(stderr, \"gas_adc_level=%d\\n\", gas_adc_level);
}

if(gas_adc_level >= gas_alarm_level)
{
fprintf(stderr, \"gas alarm!!! gas_adc_level=%d gas_alarm_level=%d \\n\", gas_adc_level, gas_alarm_level);
sprintf(temp, \"echo \\\"alarm gas %d %d\\\" | netcat -q 1 -u 192.168.178.95 1078\", gas_adc_level, gas_alarm_level);
}
else
{
fprintf(stderr, \"gas_adc_level=%d gas_alarm_level=%d \\n\", gas_adc_level, gas_alarm_level);
sprintf(temp, \"echo \\\"gas %d %d\\\" | netcat -q 1 -u 192.168.178.95 1078\", gas_adc_level, gas_alarm_level);
}

if(verbose)

{
fprintf(stderr, \"executing %s\\n\", temp);
}

system(temp);

break;
} /* end if c == 10) */

} /* end while getc */

usleep(10000000);
} /* end while */

exit(1);
} /* end function main */


You can compile that code with
gcc -o gas_pic_udp gas_pic_udp.c


And then run it, with ADC alarm level (gas level) set to 100, like this:
gas_pic_udp -l 100 -v
-v for verbose shows you what is happening if run in a terminal

It now forwards the data to an other Raspberry on the LAN, 192.168.78.95 port 1078, alos in UDP packets
That is the main security computer, it record security cameras, audio, air traffic, ship traffic, temperature, humidity, CO level, many more things and now also gas level!
It has an about 4TB hard disc connected to it.. Also plays background music over a speaker if enabled (is always enabled, and here comes the fun

In the next code, on that rapi ..95 I run the following program to listen for the messages from that rapsi ..73.

#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <stdlib.h>
#include <sys/file.h>
#include <errno.h>
#include \"getopt.h\"
#include <math.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
#include <stddef.h>
#include <pwd.h>
#include <math.h>
#include <pthread.h>
#include <stdint.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/time.h>


int verbose;
int gas_alarm_level;

#define TEMP_SIZE 65535

pthread_t timer_thread;
pthread_attr_t *attributes;

int timer_running_flag;
int stop_timer_flag;

struct timeval timeout;
time_t now;
time_t ptime = 0;
struct tm *utc_time;
time_t old_ptime = 0;
int elapsed_seconds;



void *timer_routine()
{
time_t now;

if(verbose)
{
fprintf(stderr, \"timer_routine(): arg none\\n\");
}

timer_running_flag = 1;

while(1)
{
if(stop_timer_flag)
{
break;
}

usleep(1000000);
elapsed_seconds++;

if(verbose)
{
fprintf(stderr, \"elapsed_seconds=%d\\n\", elapsed_seconds);
}

if(elapsed_seconds > 30)
{
fprintf(stderr, \"ALARM no signal from gas sensor\\n\");
system(\"amixer sset PCM 100% 1>/dev/zero 2>/dev/zero\");

system(\"mpg123 /root/alarm_geen_signaal_van_gas_detector.mp3 1>/dev/zero 2>/dev/zero\");

usleep(3000000);

system(\"mpg123 /root/alarm_no_signal_from_gas_sensor.mp3 1>/dev/zeroo 2>/dev/zero\");

/* forc alarm voice repeat after 10 seconds */
elapsed_seconds = 20;
} /* end if elapsed_seconds > 30 */

} /* end while */

timer_running_flag = 0;

now = time(0);
fprintf(stderr, \"timer_routine(): exit at %s\\n\", ctime(&now) );

//pthread_exit(0);

return 0;
} /* end function timer_routine */



int start_timer_thread()
{
pthread_create(&timer_thread, 0, &timer_routine, 0);

if(verbose)
{
fprintf(stderr, \"start_timer_thread(): timer_thread_started\\n\");
}

return 1;
} /* end function start_timer_thread */



int main(int argc, char **argv)
{
int a, b, c;
FILE *pptr;
int gas_adc_level;
char temp[TEMP_SIZE];
char rx_string[TEMP_SIZE];
char * ptr;

/* proces any command line arguments */
while(1)
{
a = getopt(argc, argv, \"hl:v\");
if(a == -1) break;

switch(a)
{
case \'h\': // help
print_usage();
exit(1);
break;

case \'v\': // verbose
verbose = 1;
break;

default:
print_usage();

exit(1);
break;
} /* end switch a */

} /* end while command line argumants */

elapsed_seconds = 0;
start_timer_thread();

gas_adc_level = 0;
a = 0;

sprintf(temp, \"netcat -k -u -l -p 1078\");
if(verbose)
{
fprintf(stderr, \"executing=%s\\n\", temp);
}

pptr = popen(temp, \"r\");

// alarm gas 24 1

while(1)
{
c = fgetc(pptr);

if(verbose)
{
fprintf(stderr, \"%c\", c);
}

rx_string[a] = c;
a++;

if(c == 10) // !!! no close, keep reading line by line from netcat
{
a = 0;

if(verbose)
{
fprintf(stderr, \"rx_string=%s\\n\", rx_string);
}

// alarm gas 24 1
ptr = strstr(rx_string, \"alarm\");
if(ptr)
{
fprintf(stderr ,\"ALARM GAS\\n\");

system(\"amixer sset PCM 100%\");

system(\"mpg123 /root/gas_alarm_nl.mp3 1>/dev/zero 2>/dev/zero\");
}

/* reset timer */
elapsed_seconds = 0;

} /* end if c == 10) */

} /* end while getc */


exit(1);
} /* end function main */


So, you can compile that with
gcc -o gas_pic_udp_rx -lpthread gas_pic_udp_rx.c

So what does it DO?
It listens to the MQ4 messages it receives on UDP port 1078, and if it detects the word \'alarm\'
it set the audio mixer volume to maximum using amixer, and then plays audio file /root/gas_alarm_nl.mp3
It is a 50 W amp, and a big speaker, you will notice, all runs on UPS so...
But there was a catch, what if it received no messages from the first Raspberry for whatever reason?
So I added a timer thread, and if it times out on messages received it sets volume again to maximum and plays
/root/alarm_no_signal_from_gas_sensor.mp3

Nice female voices, made with this script using google:

gst5_en

#!/bin/bash
read user_reply
wget -O \"$user_reply\".mp3 \"http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$user_reply&tl=en\"
exit 0

you type
gst5_en
Then the text you want spoken foloed by ENTER key
and out comes the mp3 file with that text spoken.

If you wanted Dutch use =nl at the end, =de for German.

So, this code and hardware is released under the GPL licence.


I found an ethernet module as in the wind_thermal thing and a LM2596 switcher chip today in one of the many boxes with electronics here,
so will make a peeseebee and switcher to replace the LM317, plasic box to fit it all in Ifound too too.. PICs I have..
Busy! my new keyboard arrived, so far sound is very good...
https://www.bax-shop.nl/keyboards/fazley-fkb-180-61-toetsen-keyboard-zwart#productreviews
Very cheap, about 120 Euro / dollars.. sound alone is even better than more expensive speakers ...
Different keyboard to hit than this!!!
learning curve...
 
On Tue, 03 Oct 2023 15:07:39 GMT, Jan Panteltje <alien@comet.invalid>
wrote:

Testing the MQ4 gas sensor

So I bought a MQ4 gas sensor module:
https://www.tinytronics.nl/shop/en/sensors/air/gas/mq-4-gas-sensor-module

Had it on for 24 hours on the lab supply, in that period output on analog out dropped slowly to a very low value (takes hours).

Tested it in the kitchen, powered from a LM317 programmed for 5 V, thing uses about 170 mA,
meter on the analog output,
gas tap open, and low and behold the analog output went up considerable in a minute or so.
And went back to normal with no gas.
Put it on a piece of cloth drenched in some alcohol and that make the analog output rise too,
so thing is sensitive to alcohol too, may give false alarm in kitchen?

Anyways, whatever, I once a long time ago (2016). designed a wind sensor with a Microchip PIC 18F14K22 chip, it uses power over Ethernet,

Is the power from a PoE hub isolated? It would be convenient if my
PoE-powered boxes didn\'t need isolated converters to pick off power.
 
On Tuesday, October 3, 2023 at 11:07:49 AM UTC-4, Jan Panteltje wrote:
Testing the MQ4 gas sensor

So I bought a MQ4 gas sensor module:
https://www.tinytronics.nl/shop/en/sensors/air/gas/mq-4-gas-sensor-module

Had it on for 24 hours on the lab supply, in that period output on analog out dropped slowly to a very low value (takes hours).

Tested it in the kitchen, powered from a LM317 programmed for 5 V, thing uses about 170 mA,
meter on the analog output,
gas tap open, and low and behold the analog output went up considerable in a minute or so.
And went back to normal with no gas.
Put it on a piece of cloth drenched in some alcohol and that make the analog output rise too,
so thing is sensitive to alcohol too, may give false alarm in kitchen?

Anyways, whatever, I once a long time ago (2016). designed a wind sensor with a Microchip PIC 18F14K22 chip, it uses power over Ethernet,
and basically has 4 analog input channels, so borrowed one and connected it to the MQ4 module analog output via a resistor divider
(ADCc runs on 3.3V, the MQ4 on 5V
You can download the PIC asm, hexfile, and ciccuit here:
http://www.panteltje.nl/panteltje/pic/wind_pic_thermal_udp/wind_thermal-0..1.tgz

This wind_thermal is a nice way to get analog values into your computers via POE.
It sends UDP packets continuously to an IP address on the LAN that you can specify.
This is where the software comes in., to process it!

So I have one Raspberry Pi (a very old one) that runs as server for many things, much data in the house goes to that,
and can then be accessed from a website or via ssh etc, or by other computers on the LAN, that ls is what happens here now.

So for listening for UDP packets, looking at the received analog level from the MQ4 sensor, setting an alarm limit, I wrote the following code
The wind_thermal unit sends to IP address 192.168./178.73 (the raspi server) port 1078.
This is the C source code, it uses the \'netcat\' utility to receive and send data, netcat is one of the greatest network utilities I know about.


/* for internet */
#define _BSD_SOURCE /* this is needed to avoid compile error messages in internet routines */

#include <sys/types.h
#include <sys/socket.h
#include <netinet/in.h
#include <netdb.h
#include <arpa/inet.h
#include <wchar.h> // for open_wmemstream()
/* end for internet */


#include <stdio.h
#include <string.h
#include <termios.h
#include <stdlib.h
#include <sys/file.h
#include <errno.h
#include \"getopt.h\"
#include <math.h
#include <unistd.h
#include <ctype.h
#include <time.h
#include <stddef.h
#include <pwd.h
#include <math.h
#include <pthread.h
#include <stdint.h
#include <dirent.h
#include <sys/types.h
#include <sys/time.h


#include <stdio.h
#include <stdlib.h

int verbose;
int gas_alarm_level;

#define TEMP_SIZE 65535


void print_usage()
{
fprintf(stderr,\\
\"\\nPanteltje gas_pic level detector\\n\\
Usage:\\ngas_pic -h -l int -v\\n\\
\\n\\
-h help (this help).\\n\\
-l alarm_level, range 0 to 1000 default %d\\n\\
-v verbose, prints functions and arguments.\\n\"
, gas_alarm_level);

fprintf(stderr,\\
\"Examples, \\n\\
gas_pic -l 30\\n\\n\");

} /* end function print_usage */



int main(int argc, char **argv)
{
int a, b, c;
FILE *pptr;
int gas_adc_level;
char temp[TEMP_SIZE];
char out_string[TEMP_SIZE];

/* proces any command line arguments */
while(1)
{
a = getopt(argc, argv, \"hl:v\");
if(a == -1) break;

switch(a)
{
case \'h\': // help
print_usage();
exit(1);
break;

case \'l\': // gas alarm level
gas_alarm_level = atoi(optarg);
break;

case \'v\': // verbose
verbose = 1;
break;

default:
print_usage();

exit(1);
break;
} /* end switch a */

} /* end while command line argumants */


gas_adc_level = 0;
a = 0;
while(1)
{
sprintf(temp, \"netcat -u -l -p 1078\");
if(verbose)
{
fprintf(stderr, \"temp=%s\\n\", temp);
}

pptr = popen(temp, \"r\");
while(1)
{
c = fgetc(pptr);

if(verbose)
{
fprintf(stderr, \"%c\", c);
}

out_string[a] = c;
a++;

if(c == 10)
{
pclose(pptr);

a = 0;

if(verbose)
{
fprintf(stderr, \"out_string=%s\\n\", out_string);
}

// F23 R753 B747 L751a
sscanf(out_string ,\"F%d\", &gas_adc_level);

// if(verbose)
{
fprintf(stderr, \"gas_adc_level=%d\\n\", gas_adc_level);
}

if(gas_adc_level >= gas_alarm_level)
{
fprintf(stderr, \"gas alarm!!! gas_adc_level=%d gas_alarm_level=%d \\n\", gas_adc_level, gas_alarm_level);
sprintf(temp, \"echo \\\"alarm gas %d %d\\\" | netcat -q 1 -u 192.168.178.95 1078\", gas_adc_level, gas_alarm_level);
}
else
{
fprintf(stderr, \"gas_adc_level=%d gas_alarm_level=%d \\n\", gas_adc_level, gas_alarm_level);
sprintf(temp, \"echo \\\"gas %d %d\\\" | netcat -q 1 -u 192.168.178.95 1078\", gas_adc_level, gas_alarm_level);
}

if(verbose)

{
fprintf(stderr, \"executing %s\\n\", temp);
}

system(temp);

break;
} /* end if c == 10) */

} /* end while getc */

usleep(10000000);
} /* end while */

exit(1);
} /* end function main */


You can compile that code with
gcc -o gas_pic_udp gas_pic_udp.c


And then run it, with ADC alarm level (gas level) set to 100, like this:
gas_pic_udp -l 100 -v
-v for verbose shows you what is happening if run in a terminal

It now forwards the data to an other Raspberry on the LAN, 192.168.78.95 port 1078, alos in UDP packets
That is the main security computer, it record security cameras, audio, air traffic, ship traffic, temperature, humidity, CO level, many more things and now also gas level!
It has an about 4TB hard disc connected to it.. Also plays background music over a speaker if enabled (is always enabled, and here comes the fun

In the next code, on that rapi ..95 I run the following program to listen for the messages from that rapsi ..73.

#include <stdio.h
#include <string.h
#include <termios.h
#include <stdlib.h
#include <sys/file.h
#include <errno.h
#include \"getopt.h\"
#include <math.h
#include <unistd.h
#include <ctype.h
#include <time.h
#include <stddef.h
#include <pwd.h
#include <math.h
#include <pthread.h
#include <stdint.h
#include <dirent.h
#include <sys/types.h
#include <sys/time.h


int verbose;
int gas_alarm_level;

#define TEMP_SIZE 65535

pthread_t timer_thread;
pthread_attr_t *attributes;

int timer_running_flag;
int stop_timer_flag;

struct timeval timeout;
time_t now;
time_t ptime = 0;
struct tm *utc_time;
time_t old_ptime = 0;
int elapsed_seconds;



void *timer_routine()
{
time_t now;

if(verbose)
{
fprintf(stderr, \"timer_routine(): arg none\\n\");
}

timer_running_flag = 1;

while(1)
{
if(stop_timer_flag)
{
break;
}

usleep(1000000);
elapsed_seconds++;

if(verbose)
{
fprintf(stderr, \"elapsed_seconds=%d\\n\", elapsed_seconds);
}

if(elapsed_seconds > 30)
{
fprintf(stderr, \"ALARM no signal from gas sensor\\n\");
system(\"amixer sset PCM 100% 1>/dev/zero 2>/dev/zero\");

system(\"mpg123 /root/alarm_geen_signaal_van_gas_detector.mp3 1>/dev/zero 2>/dev/zero\");

usleep(3000000);

system(\"mpg123 /root/alarm_no_signal_from_gas_sensor.mp3 1>/dev/zeroo 2>/dev/zero\");

/* forc alarm voice repeat after 10 seconds */
elapsed_seconds = 20;
} /* end if elapsed_seconds > 30 */

} /* end while */

timer_running_flag = 0;

now = time(0);
fprintf(stderr, \"timer_routine(): exit at %s\\n\", ctime(&now) );

//pthread_exit(0);

return 0;
} /* end function timer_routine */



int start_timer_thread()
{
pthread_create(&timer_thread, 0, &timer_routine, 0);

if(verbose)
{
fprintf(stderr, \"start_timer_thread(): timer_thread_started\\n\");
}

return 1;
} /* end function start_timer_thread */



int main(int argc, char **argv)
{
int a, b, c;
FILE *pptr;
int gas_adc_level;
char temp[TEMP_SIZE];
char rx_string[TEMP_SIZE];
char * ptr;

/* proces any command line arguments */
while(1)
{
a = getopt(argc, argv, \"hl:v\");
if(a == -1) break;

switch(a)
{
case \'h\': // help
print_usage();
exit(1);
break;

case \'v\': // verbose
verbose = 1;
break;

default:
print_usage();

exit(1);
break;
} /* end switch a */

} /* end while command line argumants */

elapsed_seconds = 0;
start_timer_thread();

gas_adc_level = 0;
a = 0;

sprintf(temp, \"netcat -k -u -l -p 1078\");
if(verbose)
{
fprintf(stderr, \"executing=%s\\n\", temp);
}

pptr = popen(temp, \"r\");

// alarm gas 24 1

while(1)
{
c = fgetc(pptr);

if(verbose)
{
fprintf(stderr, \"%c\", c);
}

rx_string[a] = c;
a++;

if(c == 10) // !!! no close, keep reading line by line from netcat
{
a = 0;

if(verbose)
{
fprintf(stderr, \"rx_string=%s\\n\", rx_string);
}

// alarm gas 24 1
ptr = strstr(rx_string, \"alarm\");
if(ptr)
{
fprintf(stderr ,\"ALARM GAS\\n\");

system(\"amixer sset PCM 100%\");

system(\"mpg123 /root/gas_alarm_nl.mp3 1>/dev/zero 2>/dev/zero\");
}

/* reset timer */
elapsed_seconds = 0;

} /* end if c == 10) */

} /* end while getc */


exit(1);
} /* end function main */


So, you can compile that with
gcc -o gas_pic_udp_rx -lpthread gas_pic_udp_rx.c

So what does it DO?
It listens to the MQ4 messages it receives on UDP port 1078, and if it detects the word \'alarm\'
it set the audio mixer volume to maximum using amixer, and then plays audio file /root/gas_alarm_nl.mp3
It is a 50 W amp, and a big speaker, you will notice, all runs on UPS so....
But there was a catch, what if it received no messages from the first Raspberry for whatever reason?
So I added a timer thread, and if it times out on messages received it sets volume again to maximum and plays
/root/alarm_no_signal_from_gas_sensor.mp3

Nice female voices, made with this script using google:

gst5_en

#!/bin/bash
read user_reply
wget -O \"$user_reply\".mp3 \"http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$user_reply&tl=en\"
exit 0

you type
gst5_en
Then the text you want spoken foloed by ENTER key
and out comes the mp3 file with that text spoken.

If you wanted Dutch use =nl at the end, =de for German.

So, this code and hardware is released under the GPL licence.


I found an ethernet module as in the wind_thermal thing and a LM2596 switcher chip today in one of the many boxes with electronics here,
so will make a peeseebee and switcher to replace the LM317, plasic box to fit it all in Ifound too too.. PICs I have..
Busy! my new keyboard arrived, so far sound is very good...
https://www.bax-shop.nl/keyboards/fazley-fkb-180-61-toetsen-keyboard-zwart#productreviews
Very cheap, about 120 Euro / dollars.. sound alone is even better than more expensive speakers ...
Different keyboard to hit than this!!!
learning curve...

The MOS sensors can be permanently damaged by too much gas, they lose sensitivity. The original replacement schedule was to replace them after an activation. Something to look into...
 
On 2023-10-03, John Larkin <jl@997arbor.com> wrote:
Is the power from a PoE hub isolated? It would be convenient if my
PoE-powered boxes didn\'t need isolated converters to pick off power.

No. The powered device needs to be either fully isolated, or it needs an
isolated converter - see IEEE 802.3af (nowaday incorporated into the monster
IEEE 802.3 standard).

cu
Michael
--
Some people have no respect of age unless it is bottled.
 
Jan Panteltje <alien@comet.invalid> Wrote in message:r
> Testing the MQ4 gas sensorSo I bought a MQ4 gas sensor module: https://www.tinytronics.nl/shop/en/sensors/air/gas/mq-4-gas-sensor-moduleHad it on for 24 hours on the lab supply, in that period output on analog out dropped slowly to a very low value (takes hours).Tested it in the kitchen, powered from a LM317 programmed for 5 V, thing uses about 170 mA,meter on the analog output,gas tap open, and low and behold the analog output went up considerable in a minute or so.And went back to normal with no gas.Put it on a piece of cloth drenched in some alcohol and that make the analog output rise too,so thing is sensitive to alcohol too, may give false alarm in kitchen?Anyways, whatever, I once a long time ago (2016). designed a wind sensor with a Microchip PIC 18F14K22 chip, it uses power over Ethernet,and basically has 4 analog input channels, so borrowed one and connected it to the MQ4 module analog output via a resistor divider(ADCc runs on 3.3V, the MQ4 on 5VYou can download the PIC asm, hexfile, and ciccuit here: http://www.panteltje.nl/panteltje/pic/wind_pic_thermal_udp/wind_thermal-0.1.tgzThis wind_thermal is a nice way to get analog values into your computers via POE.It sends
UDP packets continuously to an IP address on the LAN that you can specify.This is where the software comes in., to process it!So I have one Raspberry Pi (a very old one) that runs as server for many things, much data in the house goes to that,and can then be accessed from a website or via ssh etc, or by other computers on the LAN, that ls is what happens here now.So for listening for UDP packets, looking at the received analog level from the MQ4 sensor, setting an alarm limit, I wrote the following codeThe wind_thermal unit sends to IP address 192.168./178.73 (the raspi server) port 1078.This is the C source code, it uses the \'netcat\' utility to receive and send data, netcat is one of the greatest network utilities I know about./* for internet */#define _BSD_SOURCE /* this is needed to avoid compile error messages in internet routines */#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#include <arpa/inet.h>#include <wchar.h> // for open_wmemstream()/* end for internet */#include <stdio.h>#include <string.h>#include <termios.h>#include <stdlib.h>#include <sys/file.h>#include <errno.h>#include \"getopt.h\"#include <math.h>#include <unistd.h>#inclu
de <ctype.h>#include <time.h>#include <stddef.h>#include <pwd.h>#include <math.h>#include <pthread.h>#include <stdint.h>#include <dirent.h>#include <sys/types.h>#include <sys/time.h>#include <stdio.h>#include <stdlib.h>int verbose;int gas_alarm_level;#define TEMP_SIZE 65535void print_usage(){fprintf(stderr,\\\"\\nPanteltje gas_pic level detector\\n\\Usage:\\ngas_pic -h -l int -v\\n\\\\n\\-h help (this help).\\n\\-l alarm_level, range 0 to 1000 default %d\\n\\-v verbose, prints functions and arguments.\\n\", gas_alarm_level);fprintf(stderr,\\\"Examples, \\n\\ gas_pic -l 30\\n\\n\");} /* end function print_usage */ int main(int argc, char **argv){int a, b, c;FILE *pptr;int gas_adc_level;char temp[TEMP_SIZE];char out_string[TEMP_SIZE];/* proces any command line arguments */while(1) { a = getopt(argc, argv, \"hl:v\"); if(a == -1) break; switch(a) { case \'h\': // help print_usage(); exit(1); break; case \'l\': // gas alarm level gas_alarm_level = atoi(optarg); break; case \'v\'
: // verbose verbose = 1; break; default: print_usage(); exit(1); break; } /* end switch a */ } /* end while command line argumants */ gas_adc_level = 0;a = 0;while(1) { sprintf(temp, \"netcat -u -l -p 1078\"); if(verbose) { fprintf(stderr, \"temp=%s\\n\", temp); } pptr = popen(temp, \"r\"); while(1) { c = fgetc(pptr); if(verbose) { fprintf(stderr, \"%c\", c); } out_string[a] = c; a++; if(c == 10) { pclose(pptr); a = 0; if(verbose) { fprintf(stderr, \"out_string=%s\\n\", out_string); } // F23 R753 B747 L751a sscanf(out_string ,
\"F%d\", &gas_adc_level);// if(verbose) { fprintf(stderr, \"gas_adc_level=%d\\n\", gas_adc_level); } if(gas_adc_level >= gas_alarm_level) { fprintf(stderr, \"gas alarm!!! gas_adc_level=%d gas_alarm_level=%d \\n\", gas_adc_level, gas_alarm_level); sprintf(temp, \"echo \\\"alarm gas %d %d\\\" | netcat -q 1 -u 192.168.178.95 1078\", gas_adc_level, gas_alarm_level); } else { fprintf(stderr, \"gas_adc_level=%d gas_alarm_level=%d \\n\", gas_adc_level, gas_alarm_level); sprintf(temp, \"echo \\\"gas %d %d\\\" | netcat -q 1 -u 192.168.178.95 1078\", gas_adc_level, gas_alarm_level); } if(verbose) { fprintf(stderr, \"executing %s\\n\", temp); }
system(temp); break; } /* end if c == 10) */ } /* end while getc */ usleep(10000000); } /* end while */ exit(1);} /* end function main */You can compile that code with gcc -o gas_pic_udp gas_pic_udp.c And then run it, with ADC alarm level (gas level) set to 100, like this: gas_pic_udp -l 100 -v-v for verbose shows you what is happening if run in a terminalIt now forwards the data to an other Raspberry on the LAN, 192.168.78.95 port 1078, alos in UDP packetsThat is the main security computer, it record security cameras, audio, air traffic, ship traffic, temperature, humidity, CO level, many more things and now also gas level!It has an about 4TB hard disc connected to it.. Also plays background music over a speaker if enabled (is always enabled, and here comes the funIn the next code, on that rapi ..95 I run the following program to listen for the messages from that rapsi ..73.#include <stdio.h>#include <string.h>#include <termios.h>#include <stdlib.h>#include <sys/file.h>#include <errno.h>#include \"getopt.h\"#include <math.h>#include <unistd.h>#include <ctype.h>#include <time.h
>#include <stddef.h>#include <pwd.h>#include <math.h>#include <pthread.h>#include <stdint.h>#include <dirent.h>#include <sys/types.h>#include <sys/time.h>int verbose;int gas_alarm_level;#define TEMP_SIZE 65535pthread_t timer_thread;pthread_attr_t *attributes;int timer_running_flag;int stop_timer_flag;struct timeval timeout;time_t now;time_t ptime = 0;struct tm *utc_time;time_t old_ptime = 0;int elapsed_seconds;void *timer_routine(){time_t now;if(verbose) { fprintf(stderr, \"timer_routine(): arg none\\n\"); }timer_running_flag = 1;while(1) { if(stop_timer_flag) { break; } usleep(1000000); elapsed_seconds++; if(verbose) { fprintf(stderr, \"elapsed_seconds=%d\\n\", elapsed_seconds); } if(elapsed_seconds > 30) { fprintf(stderr, \"ALARM no signal from gas sensor\\n\"); system(\"amixer sset PCM 100% 1>/dev/zero 2>/dev/zero\"); system(\"mpg123 /root/alarm_geen_signaal_van_gas_detector.mp3 1>/dev/zero 2>/dev/zero\"); usleep(3000000);
system(\"mpg123 /root/alarm_no_signal_from_gas_sensor.mp3 1>/dev/zeroo 2>/dev/zero\"); /* forc alarm voice repeat after 10 seconds */ elapsed_seconds = 20; } /* end if elapsed_seconds > 30 */ } /* end while */timer_running_flag = 0;now = time(0);fprintf(stderr, \"timer_routine(): exit at %s\\n\", ctime(&now) );//pthread_exit(0); return 0;} /* end function timer_routine */int start_timer_thread(){pthread_create(&timer_thread, 0, &timer_routine, 0);if(verbose) { fprintf(stderr, \"start_timer_thread(): timer_thread_started\\n\"); }return 1;} /* end function start_timer_thread */int main(int argc, char **argv){int a, b, c;FILE *pptr;int gas_adc_level;char temp[TEMP_SIZE];char rx_string[TEMP_SIZE];char * ptr; /* proces any command line arguments */while(1) { a = getopt(argc, argv, \"hl:v\"); if(a == -1) break; switch(a) { case \'h\': // help print_usage(); exit(1); break; case \'v\': // verbose verbose = 1;
break; default: print_usage(); exit(1); break; } /* end switch a */ } /* end while command line argumants */elapsed_seconds = 0;start_timer_thread();gas_adc_level = 0;a = 0;sprintf(temp, \"netcat -k -u -l -p 1078\");if(verbose) { fprintf(stderr, \"executing=%s\\n\", temp); }pptr = popen(temp, \"r\"); // alarm gas 24 1 while(1) { c = fgetc(pptr); if(verbose) { fprintf(stderr, \"%c\", c); } rx_string[a] = c; a++; if(c == 10) // !!! no close, keep reading line by line from netcat { a = 0; if(verbose) { fprintf(stderr, \"rx_string=%s\\n\", rx_string); } // alarm gas 24 1 ptr = strstr(rx_string, \"alarm\"); if(ptr) { fprintf(stderr ,\"ALARM GAS\\n\"); system(\"amixer ss
et PCM 100%\"); system(\"mpg123 /root/gas_alarm_nl.mp3 1>/dev/zero 2>/dev/zero\"); } /* reset timer */ elapsed_seconds = 0; } /* end if c == 10) */ } /* end while getc */ exit(1);} /* end function main */So, you can compile that with gcc -o gas_pic_udp_rx -lpthread gas_pic_udp_rx.cSo what does it DO?It listens to the MQ4 messages it receives on UDP port 1078, and if it detects the word \'alarm\'it set the audio mixer volume to maximum using amixer, and then plays audio file /root/gas_alarm_nl.mp3 It is a 50 W amp, and a big speaker, you will notice, all runs on UPS so...But there was a catch, what if it received no messages from the first Raspberry for whatever reason?So I added a timer thread, and if it times out on messages received it sets volume again to maximum and plays/root/alarm_no_signal_from_gas_sensor.mp3Nice female voices, made with this script using google:gst5_en#!/bin/bashread user_replywget -O \"$user_reply\".mp3 \"http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$user_reply&tl=en\"exit 0you typegst5_enThen the text you want spoken foloed
by ENTER keyand out comes the mp3 file with that text spoken.If you wanted Dutch use =nl at the end, =de for German.So, this code and hardware is released under the GPL licence.I found an ethernet module as in the wind_thermal thing and a LM2596 switcher chip today in one of the many boxes with electronics here,so will make a peeseebee and switcher to replace the LM317, plasic box to fit it all in Ifound too too.. PICs I have..Busy! my new keyboard arrived, so far sound is very good... https://www.bax-shop.nl/keyboards/fazley-fkb-180-61-toetsen-keyboard-zwart#productreviews Very cheap, about 120 Euro / dollars.. sound alone is even better than more expensive speakers ... Different keyboard to hit than this!!! learning curve...

My Father, played with these in the 70\'s.
Bad breath sets them off too.

Cheers
--


----Android NewsGroup Reader----
https://piaohong.s3-us-west-2.amazonaws.com/usenet/index.html
 
On 3 Oct 2023 21:52:58 GMT, Michael Schwingen
<news-1513678000@discworld.dascon.de> wrote:

On 2023-10-03, John Larkin <jl@997arbor.com> wrote:

Is the power from a PoE hub isolated? It would be convenient if my
PoE-powered boxes didn\'t need isolated converters to pick off power.

No. The powered device needs to be either fully isolated, or it needs an
isolated converter - see IEEE 802.3af (nowaday incorporated into the monster
IEEE 802.3 standard).

cu
Michael

I could use something like this on my end

https://www.digikey.com/en/products/detail/silver-telecom-ltd/AG9712-2BR/21187200

with the appropriate magnetics.
 
On a sunny day (Tue, 03 Oct 2023 09:06:35 -0700) it happened John Larkin
<jl@997arbor.com> wrote in <lseohih84pmmug6o63k4vjpqe9h0repr6l@4ax.com>:

On Tue, 03 Oct 2023 15:07:39 GMT, Jan Panteltje <alien@comet.invalid
wrote:

Testing the MQ4 gas sensor

So I bought a MQ4 gas sensor module:
https://www.tinytronics.nl/shop/en/sensors/air/gas/mq-4-gas-sensor-module

Had it on for 24 hours on the lab supply, in that period output on analog out dropped slowly to a very low value (takes
hours).

Tested it in the kitchen, powered from a LM317 programmed for 5 V, thing uses about 170 mA,
meter on the analog output,
gas tap open, and low and behold the analog output went up considerable in a minute or so.
And went back to normal with no gas.
Put it on a piece of cloth drenched in some alcohol and that make the analog output rise too,
so thing is sensitive to alcohol too, may give false alarm in kitchen?

Anyways, whatever, I once a long time ago (2016). designed a wind sensor with a Microchip PIC 18F14K22 chip, it uses power
over Ethernet,

Is the power from a PoE hub isolated? It would be convenient if my
PoE-powered boxes didn\'t need isolated converters to pick off power.

Well the data in and out is isolated by the ethernet trnsformer.
The power lines in the ethternet cable are connected to a down-switcher chip that powers the PIC and MQ4 gas sensor.
But nobody is stopping you from using a transformer stage in the outpot of the switcher so your - whatever it is circuit - floats.
 
On a sunny day (Tue, 3 Oct 2023 11:36:29 -0700 (PDT)) it happened Fred Bloggs
<bloggs.fredbloggs.fred@gmail.com> wrote in
<31b7c523-f400-40f2-97c8-300c5d024710n@googlegroups.com>:

The MOS sensors can be permanently damaged by too much gas, they lose sensitivity.
The original replacement schedule was to replace them after an activation. Something to look into...

OK, I activated one, and it still seems to be working.
I will run some more tests, now has been on all night without making alarms.
Will try activating it a couple of times and see how the analog output changes or returns
to previous value over time...
I have 2, always order 2 so I can compare things and blow things up :)
Indeed the thing works by gas causing a hot spiral to heat up more due to combustion
causing changes in resistance.

A broken or eroded filament could perhaps happen at high gas concentrations.
So we also need a test if the 170 mA heating current is still present.
I will test what happens, what the analog output does, without that current.
If it goes into alarm OK, if not then there is a series resistor that I can hang an ADC input on
to measure current and then monitor it remotely in the same way as the main channel
and make it say: \"Alarm gas sensor heater current zero, replace sensor\"

:)
The possibilities are almost endless.
I really like electronics that talks over beeps.

Thank you for the info!
 
On a sunny day (Tue, 3 Oct 2023 18:57:08 -0400 (EDT)) it happened Martin Rid
<martin_riddle@verison.net> wrote in <ufi685$3pghu$1@dont-email.me>:


My Father, played with these in the 70\'s.
Bad breath sets them off too.

Would you believe I already tried breathing in it?
Nothing happened...
Have not tried farting yet, now there is an idea, should give alarm!
I have seen a movie of somebody farting with a match behind him,
https://en.m.wikipedia.org/wiki/Fart_lighting
 
On Wed, 04 Oct 2023 05:37:47 GMT, Jan Panteltje <alien@comet.invalid>
wrote:

On a sunny day (Tue, 03 Oct 2023 09:06:35 -0700) it happened John Larkin
jl@997arbor.com> wrote in <lseohih84pmmug6o63k4vjpqe9h0repr6l@4ax.com>:

On Tue, 03 Oct 2023 15:07:39 GMT, Jan Panteltje <alien@comet.invalid
wrote:

Testing the MQ4 gas sensor

So I bought a MQ4 gas sensor module:
https://www.tinytronics.nl/shop/en/sensors/air/gas/mq-4-gas-sensor-module

Had it on for 24 hours on the lab supply, in that period output on analog out dropped slowly to a very low value (takes
hours).

Tested it in the kitchen, powered from a LM317 programmed for 5 V, thing uses about 170 mA,
meter on the analog output,
gas tap open, and low and behold the analog output went up considerable in a minute or so.
And went back to normal with no gas.
Put it on a piece of cloth drenched in some alcohol and that make the analog output rise too,
so thing is sensitive to alcohol too, may give false alarm in kitchen?

Anyways, whatever, I once a long time ago (2016). designed a wind sensor with a Microchip PIC 18F14K22 chip, it uses power
over Ethernet,

Is the power from a PoE hub isolated? It would be convenient if my
PoE-powered boxes didn\'t need isolated converters to pick off power.

Well the data in and out is isolated by the ethernet trnsformer.
The power lines in the ethternet cable are connected to a down-switcher chip that powers the PIC and MQ4 gas sensor.
But nobody is stopping you from using a transformer stage in the outpot of the switcher so your - whatever it is circuit - floats.

A little research suggets that the PoE switches and power injectors
are not dependably isolated power sources - they are after all cheap -
so the end-element box has to use an isolated dc/dc
converter/regulator out of the ethernet magnetics. Fortunately, there
are little subasemblies available to do that.

My boxes could dissipate maybe 5 watts or so, and I can get a lot more
than that from the PoE DC on just the tx/rx pairs.
 
On Wed, 04 Oct 2023 05:58:15 GMT, Jan Panteltje <alien@comet.invalid>
wrote:

On a sunny day (Tue, 3 Oct 2023 11:36:29 -0700 (PDT)) it happened Fred Bloggs
bloggs.fredbloggs.fred@gmail.com> wrote in
31b7c523-f400-40f2-97c8-300c5d024710n@googlegroups.com>:

The MOS sensors can be permanently damaged by too much gas, they lose sensitivity.
The original replacement schedule was to replace them after an activation. Something to look into...

OK, I activated one, and it still seems to be working.
I will run some more tests, now has been on all night without making alarms.
Will try activating it a couple of times and see how the analog output changes or returns
to previous value over time...
I have 2, always order 2 so I can compare things and blow things up :)
Indeed the thing works by gas causing a hot spiral to heat up more due to combustion
causing changes in resistance.

A broken or eroded filament could perhaps happen at high gas concentrations.
So we also need a test if the 170 mA heating current is still present.
I will test what happens, what the analog output does, without that current.
If it goes into alarm OK, if not then there is a series resistor that I can hang an ADC input on
to measure current and then monitor it remotely in the same way as the main channel
and make it say: \"Alarm gas sensor heater current zero, replace sensor\"

:)
The possibilities are almost endless.
I really like electronics that talks over beeps.

Thank you for the info!

One type of combustible gas sensor is a thermistor coated with a
catalyst. It self-heats and combustible gasses get oxidized/burned on
the surface and that makes it even hotter,.

Of course, the catalyst could get poisoned or whatever.

I was thinking about a product that was an environment sensor. It
would be a surrogate for a peson being there and telling you how it
feels. Simulate as many senses as possible, including death. It could
include some gas sensors.
 
On a sunny day (Wed, 04 Oct 2023 03:45:55 -0700) it happened John Larkin
<jl@997arbor.com> wrote in <6agqhid6k6ekfj3eiet7rbpklp0muh3chc@4ax.com>:

On Wed, 04 Oct 2023 05:58:15 GMT, Jan Panteltje <alien@comet.invalid
wrote:

On a sunny day (Tue, 3 Oct 2023 11:36:29 -0700 (PDT)) it happened Fred Bloggs
bloggs.fredbloggs.fred@gmail.com> wrote in
31b7c523-f400-40f2-97c8-300c5d024710n@googlegroups.com>:

The MOS sensors can be permanently damaged by too much gas, they lose sensitivity.
The original replacement schedule was to replace them after an activation. Something to look into...

OK, I activated one, and it still seems to be working.
I will run some more tests, now has been on all night without making alarms.
Will try activating it a couple of times and see how the analog output changes or returns
to previous value over time...
I have 2, always order 2 so I can compare things and blow things up :)
Indeed the thing works by gas causing a hot spiral to heat up more due to combustion
causing changes in resistance.

A broken or eroded filament could perhaps happen at high gas concentrations.
So we also need a test if the 170 mA heating current is still present.
I will test what happens, what the analog output does, without that current.
If it goes into alarm OK, if not then there is a series resistor that I can hang an ADC input on
to measure current and then monitor it remotely in the same way as the main channel
and make it say: \"Alarm gas sensor heater current zero, replace sensor\"

:)
The possibilities are almost endless.
I really like electronics that talks over beeps.

Thank you for the info!







One type of combustible gas sensor is a thermistor coated with a
catalyst. It self-heats and combustible gasses get oxidized/burned on
the surface and that makes it even hotter,.

Of course, the catalyst could get poisoned or whatever.

I was thinking about a product that was an environment sensor. It
would be a surrogate for a peson being there and telling you how it
feels. Simulate as many senses as possible, including death. It could
include some gas sensors.

Fun, I followed Fred s suggestion and added one analog channel to measure that sensor current
the heating element is in series with a 5 Ohm resistor to ground, so if the heating element burns,
goes open circuit, then the voltage over that 5 Ohm resistor drops to zero.
I cut the PCB of the MQ4 sensor and added a bridge so I could test that broken heater mode.
Now it will say, execute this, if the sensor is broken:
mpg123 gas_alarm_defective_sensor.mp3

How far can you go having systems report in detail, and how can it be tested?
Now already have to test all possibilities, so for 2 error modes 4, for 3 error modes 8 ...
Testing becomes exponentially longer, just like us humans, you need a shrink!
Having systems do their own fault finding is a very interesting subject, been doing fault finding for a living for many years.


It reminded me of us humans
Little baby cries if something is wrong, it wants something = sensor beeps
Then we teach it language and what things / feelings mean,. hungry, cold, pain, etc sensor speaks.
Then how much do we put into the sensor itself, and how much into the \'higher\' electronics? knee reflex versus brain controlling legs?
There is so much there!
I have always said that \"Descartes \'It think so I am\'\" consciousness is nothing special.
Even a simple sunshade that closes when sun shines using a motor can have a voice added \'To much light, closing\', is conscious of light!
How simple we are !!
The sensor can still have a beeper (knee reflex) but the remote computer will / can take action as well (brain) .
Was just reading this:
https://www.sciencedaily.com/releases/2023/10/231004132400.htm

All that with AI and robots, so much there!
 
On Thu, 05 Oct 2023 05:41:09 GMT, Jan Panteltje <alien@comet.invalid>
wrote:

On a sunny day (Wed, 04 Oct 2023 03:45:55 -0700) it happened John Larkin
jl@997arbor.com> wrote in <6agqhid6k6ekfj3eiet7rbpklp0muh3chc@4ax.com>:

On Wed, 04 Oct 2023 05:58:15 GMT, Jan Panteltje <alien@comet.invalid
wrote:

On a sunny day (Tue, 3 Oct 2023 11:36:29 -0700 (PDT)) it happened Fred Bloggs
bloggs.fredbloggs.fred@gmail.com> wrote in
31b7c523-f400-40f2-97c8-300c5d024710n@googlegroups.com>:

The MOS sensors can be permanently damaged by too much gas, they lose sensitivity.
The original replacement schedule was to replace them after an activation. Something to look into...

OK, I activated one, and it still seems to be working.
I will run some more tests, now has been on all night without making alarms.
Will try activating it a couple of times and see how the analog output changes or returns
to previous value over time...
I have 2, always order 2 so I can compare things and blow things up :)
Indeed the thing works by gas causing a hot spiral to heat up more due to combustion
causing changes in resistance.

A broken or eroded filament could perhaps happen at high gas concentrations.
So we also need a test if the 170 mA heating current is still present.
I will test what happens, what the analog output does, without that current.
If it goes into alarm OK, if not then there is a series resistor that I can hang an ADC input on
to measure current and then monitor it remotely in the same way as the main channel
and make it say: \"Alarm gas sensor heater current zero, replace sensor\"

:)
The possibilities are almost endless.
I really like electronics that talks over beeps.

Thank you for the info!







One type of combustible gas sensor is a thermistor coated with a
catalyst. It self-heats and combustible gasses get oxidized/burned on
the surface and that makes it even hotter,.

Of course, the catalyst could get poisoned or whatever.

I was thinking about a product that was an environment sensor. It
would be a surrogate for a peson being there and telling you how it
feels. Simulate as many senses as possible, including death. It could
include some gas sensors.

Fun, I followed Fred s suggestion and added one analog channel to measure that sensor current
the heating element is in series with a 5 Ohm resistor to ground, so if the heating element burns,
goes open circuit, then the voltage over that 5 Ohm resistor drops to zero.
I cut the PCB of the MQ4 sensor and added a bridge so I could test that broken heater mode.
Now it will say, execute this, if the sensor is broken:
mpg123 gas_alarm_defective_sensor.mp3

How far can you go having systems report in detail, and how can it be tested?
Now already have to test all possibilities, so for 2 error modes 4, for 3 error modes 8 ...
Testing becomes exponentially longer, just like us humans, you need a shrink!
Having systems do their own fault finding is a very interesting subject, been doing fault finding for a living for many years.


It reminded me of us humans
Little baby cries if something is wrong, it wants something = sensor beeps
Then we teach it language and what things / feelings mean,. hungry, cold, pain, etc sensor speaks.
Then how much do we put into the sensor itself, and how much into the \'higher\' electronics? knee reflex versus brain controlling legs?
There is so much there!
I have always said that \"Descartes \'It think so I am\'\" consciousness is nothing special.
Even a simple sunshade that closes when sun shines using a motor can have a voice added \'To much light, closing\', is conscious of light!
How simple we are !!
The sensor can still have a beeper (knee reflex) but the remote computer will / can take action as well (brain) .
Was just reading this:
https://www.sciencedaily.com/releases/2023/10/231004132400.htm

All that with AI and robots, so much there!

I hadn\'t considered, in my environment hazard sensor, including
psychological threats. Maybe I can have the box blush if it\'s
insulted. Or go out on strike.

The problem with gas detectors (O2, CO, CO2, explosives) is sensor
lifetime. I can\'t get a good surface-mount IR absorption spectrometer.
 
On a sunny day (Thu, 05 Oct 2023 07:32:09 -0700) it happened John Larkin
<jl@997arbor.com> wrote in <sshthitdmhdsf06fvj11h9kbs4v1u4sgjg@4ax.com>:

On Thu, 05 Oct 2023 05:41:09 GMT, Jan Panteltje <alien@comet.invalid
wrote:

On a sunny day (Wed, 04 Oct 2023 03:45:55 -0700) it happened John Larkin
jl@997arbor.com> wrote in <6agqhid6k6ekfj3eiet7rbpklp0muh3chc@4ax.com>:

On Wed, 04 Oct 2023 05:58:15 GMT, Jan Panteltje <alien@comet.invalid
wrote:

On a sunny day (Tue, 3 Oct 2023 11:36:29 -0700 (PDT)) it happened Fred Bloggs
bloggs.fredbloggs.fred@gmail.com> wrote in
31b7c523-f400-40f2-97c8-300c5d024710n@googlegroups.com>:

The MOS sensors can be permanently damaged by too much gas, they lose sensitivity.
The original replacement schedule was to replace them after an activation. Something to look into...

OK, I activated one, and it still seems to be working.
I will run some more tests, now has been on all night without making alarms.
Will try activating it a couple of times and see how the analog output changes or returns
to previous value over time...
I have 2, always order 2 so I can compare things and blow things up :)
Indeed the thing works by gas causing a hot spiral to heat up more due to combustion
causing changes in resistance.

A broken or eroded filament could perhaps happen at high gas concentrations.
So we also need a test if the 170 mA heating current is still present.
I will test what happens, what the analog output does, without that current.
If it goes into alarm OK, if not then there is a series resistor that I can hang an ADC input on
to measure current and then monitor it remotely in the same way as the main channel
and make it say: \"Alarm gas sensor heater current zero, replace sensor\"

:)
The possibilities are almost endless.
I really like electronics that talks over beeps.

Thank you for the info!







One type of combustible gas sensor is a thermistor coated with a
catalyst. It self-heats and combustible gasses get oxidized/burned on
the surface and that makes it even hotter,.

Of course, the catalyst could get poisoned or whatever.

I was thinking about a product that was an environment sensor. It
would be a surrogate for a peson being there and telling you how it
feels. Simulate as many senses as possible, including death. It could
include some gas sensors.

Fun, I followed Fred s suggestion and added one analog channel to measure that sensor current
the heating element is in series with a 5 Ohm resistor to ground, so if the heating element burns,
goes open circuit, then the voltage over that 5 Ohm resistor drops to zero.
I cut the PCB of the MQ4 sensor and added a bridge so I could test that broken heater mode.
Now it will say, execute this, if the sensor is broken:
mpg123 gas_alarm_defective_sensor.mp3

How far can you go having systems report in detail, and how can it be tested?
Now already have to test all possibilities, so for 2 error modes 4, for 3 error modes 8 ...
Testing becomes exponentially longer, just like us humans, you need a shrink!
Having systems do their own fault finding is a very interesting subject, been doing fault finding for a living for many years.


It reminded me of us humans
Little baby cries if something is wrong, it wants something = sensor beeps
Then we teach it language and what things / feelings mean,. hungry, cold, pain, etc sensor speaks.
Then how much do we put into the sensor itself, and how much into the \'higher\' electronics? knee reflex versus brain
controlling legs?
There is so much there!
I have always said that \"Descartes \'It think so I am\'\" consciousness is nothing special.
Even a simple sunshade that closes when sun shines using a motor can have a voice added \'To much light, closing\', is conscious
of light!
How simple we are !!
The sensor can still have a beeper (knee reflex) but the remote computer will / can take action as well (brain) .
Was just reading this:
https://www.sciencedaily.com/releases/2023/10/231004132400.htm

All that with AI and robots, so much there!

I hadn\'t considered, in my environment hazard sensor, including
psychological threats. Maybe I can have the box blush if it\'s
insulted. Or go out on strike.

If you curse the box you are working on it will execute
mpg123 \"May_I_remind_you_that_you_designed_this box?.mp3\"

Somebody will read this, or will find it using google, even AI may grab it,
and before you know it is standard in every box
and of course El Tea Spice will speak to you too.

The problem with gas detectors (O2, CO, CO2, explosives) is sensor
lifetime. I can\'t get a good surface-mount IR absorption spectrometer.

Well I do have a IR absorbtion CO2 meter module somehere from ebay.
Has IR light source, some prism, and detector (took it apart once out of curiosity):
https://www.ebay.com/itm/204366070251


>
 
On a sunny day (Thu, 05 Oct 2023 07:32:09 -0700) it happened John Larkin
<jl@997arbor.com> wrote in <sshthitdmhdsf06fvj11h9kbs4v1u4sgjg@4ax.com>:

PS
The problem with gas detectors (O2, CO, CO2, explosives) is sensor
lifetime. I can\'t get a good surface-mount IR absorption spectrometer.

Well I do have a IR absorbtion CO2 meter module somehere from ebay.
Has IR light source, some prism, and detector (took it apart once out of curiosity):
https://www.ebay.com/itm/204366070251


http://panteltje.nl/pub/MH-Z19_CO2_sensor_board_plus_optical_cavity_IMG_6083.JPG
http://panteltje.nl/pub/MH-Z19_CO2_sensor_optical_chamber_IMG_6075.JPG
I think it just looks for absorbtion of that CO2 spectral line?
 
On Fri, 06 Oct 2023 09:34:11 GMT, Jan Panteltje <alien@comet.invalid>
wrote:

On a sunny day (Thu, 05 Oct 2023 07:32:09 -0700) it happened John Larkin
jl@997arbor.com> wrote in <sshthitdmhdsf06fvj11h9kbs4v1u4sgjg@4ax.com>:

PS
The problem with gas detectors (O2, CO, CO2, explosives) is sensor
lifetime. I can\'t get a good surface-mount IR absorption spectrometer.

Well I do have a IR absorbtion CO2 meter module somehere from ebay.
Has IR light source, some prism, and detector (took it apart once out of curiosity):
https://www.ebay.com/itm/204366070251


http://panteltje.nl/pub/MH-Z19_CO2_sensor_board_plus_optical_cavity_IMG_6083.JPG
http://panteltje.nl/pub/MH-Z19_CO2_sensor_optical_chamber_IMG_6075.JPG
I think it just looks for absorbtion of that CO2 spectral line?

That is cool. I guess the IR from the bulb rattles around in the
cavity and passes through a narrowband filter of some sort, into the
detector. The bulb probably runs at low temp so should last forever.

Such a scheme probably wouldn\'t work for CO because PPMs of CO are
lethal. The household-type CO detectors are cheap but only last a few
years, which might be OK.
 

Welcome to EDABoard.com

Sponsor

Back
Top