Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 14:36 26 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Air Quality Sensors and Systems for MM?

     Page 3 of 4    
Author Message
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 10:35pm 09 Mar 2020
Copy link to clipboard 
Print this post

Hi Phil (et al),
My CCS811 arrived last week too but I couldn't play with it until yesterday.
It worked straight out of the box - Geoff certainly is a Wizard! (such nice colours too)
It is not yet 1/2 way through burning in.
I have it in the same box as a SDS011. My plan is to isolate the two by poking a say 4mm thick gasket all around the CCS811 so that it only sees the outside air (otherwise it would also see dirty air from within the enclosure - including that sucked in by the SDS).

(I too am seeing higher temperatures - my guess is that it is contributed to by the LCD and the other electronics in the box. I see this in my 6 other DS18B20s (with 1.8" LCDs). I reckon it is as much as 4+ degC with the 2.8" touch and about 2.5 for the 1.8"s).
I now have all my DS18B20s poke outside the box but they are still compromised.
One "test" I did was with a 1.8" LCD in a thermally stable room (bathroom with tiles and terrazzo all around). After I turned it on the temperature rose by 2.5 deg over 15-20 minutes then stabilised - I now can adjust the temperature readings at each station by sending an adjustment via HC-12.)

Keep us posted.

Cheers, Andrew
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 379
Posted: 12:38am 10 Mar 2020
Copy link to clipboard 
Print this post

  Quote  A truck load of shipping pallets arrived & were cut to fire sized billets & stacked against the fence.


I don't want to be a killjoy here but.....be careful about burning wood that has been pressure-treated with preservative. In particular, a greenish preservative is often used to prevent munch by borer etc, namely copper arsenite, which will give you a nicely dispersed smoke containing serious amounts of arsenic. Not good for you at all.  
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 01:32am 10 Mar 2020
Copy link to clipboard 
Print this post

Hi Zeitfest,
Quite right about older treated pine but I think/hope that the newer stuff is less toxic (for that reason eg gets used in playgrounds etc)?
But better not to burn any of it as softwood is no good any way (more smoke less heat etc and it clogs the flue).
(I think it is Phil's neighbour that plans to burn it so it does get tricky.)

Cheers, Andrew
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 01:34am 10 Mar 2020
Copy link to clipboard 
Print this post

  Phil23 said  A truck load of shipping pallets arrived & were cut to fire sized billets & stacked against the fence.

  zeitfest said  I don't want to be a killjoy here but.....be careful about burning wood that has been pressure-treated with preservative.....
Not good for you at all.  




Not me that's planning on using the treated timber from the pallets.
I am assuming that's what the neighbour is cutting them up for.

Ours is a hundred year old weatherboard house that leaks some of the neighbouring smoke into certain rooms under particular conditions.


Phil.
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 09:32am 10 Mar 2020
Copy link to clipboard 
Print this post

  zeitfest said  
I don't want to be a killjoy here but.....be careful about burning wood that has been pressure-treated with preservative. In particular, a greenish preservative is often used to prevent munch by borer etc, namely copper arsenite, which will give you a nicely dispersed smoke containing serious amounts of arsenic. Not good for you at all.  


ironic considering the thread  

perhaps a test is in order?
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 08:10pm 10 Mar 2020
Copy link to clipboard 
Print this post

Stumbled across another sensor of interest just a while ago.

Caught my eye as the name Sensirion is familiar to Davis Weather station users.

Big thing that jumps out of the spec sheet is the life expectancy.

>8 years with 24/7 operation.

The 5 pin interface can be either UART or I²C with the Sel pin pulled low.

RS's price is $84.00 (or a bit over $56 if you get a tray of 56).

Might be an interesting on to play with down the track.

24/7 would be a bonus in the fire smoke monitoring situation mentioned above.
I can just see myself smelling smoke & knowing I'm only getting 5 min readings as per Jim's previous suggestion.

Re the lifespan of the SDS011, it gets a bit of a mention here.

My SDS011 should turn up today, so will get the first taste of the readings.

Phil.
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 08:33pm 10 Mar 2020
Copy link to clipboard 
Print this post

Out of interest, this is Geoff's monitor after it spent the night in the bedroom again.

The 12 hour mark corresponds to about 7:15pm & I called it quits a bit after 9:00.
Was up about 2 hours before the graph ends.




Was up around the 1:00am mark & noticed an 1800ish reading & wonder if that's what disturbed me.

Can't quite figure yet why the value rises so dramatically overnight.
It's a 4x7m room with 3.2m ceiling.

Renovated with new wall linings, paint & carpet about 10 years ago.
All furnishings outdate that time frame.


Cheers

Phil.
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 04:15am 16 Mar 2020
Copy link to clipboard 
Print this post

My SDS011 arrived today,

So far have just run the Windows software that Andrew mentioned.

Has anyone progressed further with their code?

Was thinking of puting mine out in the inverter cabinet, where I already have an MM reading my energy meters.

So would need to have it on Com2 & then incorporate the two sets of code.

Maybe then way it up every 5 minutes @ times like 9:54:30 etc & take the readings @ 9:55:00 etc.

Was thinking for testing an active LED would be helpful. Probably the simplest place to jump that would be across the fan pins.

Other think I'd like to add is a HC-12 so my MM+ can poll it for data & log it.

That would require a 3rd Com port, which could be done with the two CFunctions. but I don't think this could be interupt driven, which is what my polling from the "Coms Master" MM+ relies on.
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 05:03am 16 Mar 2020
Copy link to clipboard 
Print this post

Phil,
Here is my "code" (FWIW). I'm happy to explain if you need it.
(and I'd really appreciate feedback, "why did you do that?" included)
- this is just for the SDS011 (I have a separate program based on Geoff G's for the VOC (same hardware)). I'll get round to combining with the two sensors in due course).
- the guts of it is Tassie Jim's work I just massaged it for my HC-12 network
- my network has a GPS up a pole with the weather station sensors - this sends sentences via HC-12s
- the Time and Date are updated every 2 hours (with a $AGD_T" sentence) or when any site sends a "$AGFST" sentence
- it uses two serial comms ports
- you'll need to change the TEXT fonts (the two Geoff G ones are from his VOC Monitor in Silicon Chip or on his website).

OK?

Andrew
(Edit - I've left the typos/formatting errors in my code for your amusement)


 'AirQual.BAS
 
 'Based on "AirQual By Jim.BAS" (= TassieJim from The Back Shed)
 
 ' SDS011 dust sensor
 ' serial 9600 8 N 1 5V TTL
 '
 ' device = &HFFFF for all connected devices.
 'Fonts #2, #3, #6 (=GeoffG's #8), #7 (=GeoffG's #7) & #8 loaded into Library
 
 Dim String Prog(3) = ("AirQual", "v13","    ", "Stn ID=")
 Dim String  StationID = "7"
 Prog(3) = Prog(3) + StationID
 
'zzz_to_do:
 
 'Close down properly so it restarts better
'V13:
 'Uses a 320x240 LCD - is upside down which means HC-12 aerial points down
 
 
'V12:
 'Incorporates HC-12 and code from AmbiMon to send FST and receive and process time.
 'Sends AGPPM message (zzz need to correct all AmbiMon devices)
 'Saves Geoff G's fonts 7 and 8 to LIBRARY as 7 and 6
 
'v11:
 'Supersedes v9 - Stick with Jim's from now on
 
 'AG Changes:
 ' changed "l" to "L" (3 off in Function CS)
 
 Dim String  arg$(20)   'The upto 21 arguments in the NMEA-like sentence 'zzz can reduce
 DIM FLOAT PM25, PM10, PM25Min, PM25Max, PM10Min, PM10Max
 DIM INTEGER x, readAvailable, sleepTime
 DIM k$, r$, reportMode$, state$, ID$
 dim String OldTime
 
 OPEN "COM2:9600,256" AS #3              'Incoming SDS data
 OPEN "COM1:9600, 1024, HC12In, 4" as #1 'Data in/out HC-12
 
 Cls
 
 Date$ = "01-01-2000"  'Enter a dummy date to check it has been updated properly
 Send_FST  'Tells the network that it is starting up and sends inital values
 '         'Gets date and time in return. $AGD_T sentences update these every 2 hours.
 
 Print Prog1$;" ";Prog2$
 Print "Station ID is "; StationID
 
 for I = 0 to 3
   Text MM.Hres/2, MM.Vres/2 - 40 + 22*I), Prog(I) , CM, 1,2, RGB(Green)
 next I
 pause 3000 'This is to show the ID and allow FST to return date and time (2000 is adequate)
 
 For I = 1 to 10 'Should already have the Date and Time this just makes sure
   if Date$ = "01-01-2000" then
     Send_FST
     text mm.hres/2,mm.Vres/2 + 60, "PL.WAIT "+STR$(I),CM,1,2,RGB(CYAN)
     Pause 1000
   else
     exit For
   endif
 next I
 
 Cls
 
 UpdateTime  'Updates the time on LCD and every minute thereafter
 'Every 2 hours the AmbiMon base station sends a Time$/Date$ update
 
 x = sendCMD(8,1,0,&HFFFF) ' Duty cycle continuous to get the initial reading
 PAUSE 1000
 x = sendCMD(2,0,0,&HFFFF) ' check report mode
 x = sendCMD(6,0,0,&HFFFF) ' check state
 x = sendCMD(8,1,5,&HFFFF) ' duty cycle 30 secs on every 5 minutes
 
 OldTime$ = Mid$(Time$, 1, 5)
 
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM_Start_Main_Loop:
 DO
   If OldTime <> Mid$(Time$, 1, 5) then
     OldTime = Mid$(Time$, 1, 5)
     UpdateTime
   End If
   
   IF LOC(#3) > 0 THEN
     k$ = INPUT$(1,#3)
     r$ = r$ + k$
     IF ASC(k$) = 171 THEN doRead ' end of data flag rec
   ENDIF
   
   IF readAvailable THEN doDisplay
   
   If SleepTime > 0 and timer =>(SleepTime)*1000 then  'Just as it is due to awake check, and confirm that it is then awake
     Checkstate
     Timer = 0
   end if
   
 LOOP
 
'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm_End_Main_Loop:
ENd
 
Sub CheckState
 x = sendCMD(6,0,0,&HFFFF) ' check state
End Sub 'Checkstate
 
Sub UpdateTime  'Show the time each minute
 Text mm.Hres -1, 0, Mid$(Time$, 1, 5), RT, 6,1, RGB(Yellow)
End Sub 'UpdateTime
 
SUB doDisplay
 'zzz can redo to only draw stuff that has changed
 PRINT TIME$;", PM2.5="; STR$(PM25,4,1);", PM10="; STR$(PM10,4,1);", Mode= "; reportMode$;", State= "; state$;
 IF SleepTime = 0 THEN
   PRINT ", Duty= continuous"
 ELSE
   PRINT ", Duty= "; (sleepTime + 30)/60;" mins"
 ENDIF
 
 if State$ = "Sleep" then
   text 0, 0, State$, LT,6,1,  RGB(170,170,170)
 else
   text 0, 0, State$, LT,6,1,  RGB(Green)    
 Endif
 Text 0, 70, "PM2.5", LB, 6,1, RGB(170,170,170)
 Text 0, 180, "PM 10", LB, 6,1,RGB(170,170,170)
 
 text mm.Hres, 90, STR$(PM25,3,1), RB,7,1, RGB(Green)
 circle mm.Hres-50, 70, 5,,, RGB(Green),RGB(Green)
 text mm.Hres/2+20, 130, STR$(PM25Min,3,1), RB,6,1, RGB(Cyan)
 text mm.Hres, 130, STR$(PM25Max,3,1), RB,6,1, RGB(Red)
 
 text mm.Hres, 200, STR$(PM10,3,1), RB,7,1, RGB(Green)
 circle mm.Hres-50, 180, 5,,, RGB(Green),RGB(Green)
 text mm.Hres/2+20, mm.Vres, STR$(PM10Min,3,1), RB,6,1, RGB(Cyan)
 text mm.Hres, mm.Vres, STR$(PM10Max,3,1), RB,6,1, RGB(Red)
 readAvailable = 0
END SUB
 
SUB doRead
 LOCAL INTEGER replyMode
 IF MID$(r$,2,1)= CHR$(&hC0) THEN replyMode = 1
 IF MID$(r$,2,1)= CHR$(&hC5) THEN replyMode = ASC(MID$(r$,3,1))
 SELECT CASE replyMode
   CASE 1 ' data
     PM25 = (ASC(MID$(r$,3,1)) + ASC(MID$(r$,4,1))*256)/10
     PM10 = (ASC(MID$(r$,5,1)) + ASC(MID$(r$,6,1))*256)/10
     
     Out$ = "$AGPPM"+","+Str$(PM25)+","+Str$(PM10)+"," + StationID
     Out$ = CRC$(Out$)
     Print #1,Out$
     print
     Print Out$, Tab(40);"Sent at ", Time$
     
     if PM25Min = 0 then PM25Min = PM25
     If PM25 > PM25Max then PM25Max = PM25
     If PM25 < PM25Min then PM25Min = PM25
     if PM10Min = 0 then PM10Min = PM10
     If PM10 > PM10Max then PM10Max = PM10
     If PM10 < PM10Min then PM10Min = PM10
     '          'The CO will report "Awake"
     Checkstate 'Immediately after a "CO" this should report "Sleep"
     Timer = 0
   CASE 2 ' data reporting mode
     IF ASC(MID$(r$,5,1)) = 1 THEN
       reportMode$ = "query "
     ELSE
       reportMode$ = "active"
     ENDIF
   CASE 5 ' new ID 'zzz not used???
     ID$ = HEX$(MID$(r$,8,1),2)+HEX$(MID$(r$,9,1),2)
   CASE 6 ' sleep mode
     IF ASC(MID$(r$,5,1)) = 1 THEN
       state$ = "Awake "
     ELSE
       state$ = "Sleep"
     ENDIF
   CASE 8 ' duty cycle
     SleepTime = ASC(MID$(r$,5,1))*60 - 30 'For a 5 min duty cycle SleepTime = 270 seconds (= 5*60 - 30)
     IF SleepTime < 0 THEN sleepTime = 0
 END SELECT
 r$ = ""
 readAvailable = 1
END SUB
 
Sub HC12In  'COM port directs to here if there are any incoming sentences 'zzz delete unused ones
 Local Integer II
Again4:
 HCIn$ = ""
 Line Input #1, HCIn$
 If LEN(HCIn$) = 0 then GoTo Again4
 If CheckCRC(HCIn$) Then 'CRC Check is OK
   If Mid$(HCIn$, 1, 6) = "$AGD_T" Then
     For II = 1 to 2
       arg$(II) = Field$(HCIn$, II+1)
     Next II
     Print "Old Date:", Tab(11), Date$;
     Date$ = arg$(1)
     Print Tab(22), "New Date: ", Tab(32), Date$
     Print "Old Time:", Tab(11), Time$;
     Time$ = arg$(2)
     Print Tab(22), "New Time: ", Tab(32), Time$
     Exit Sub
   End If
 Else
   Print "CRC Fail:", HCIn$, "  ", Chksum
   HCIn$ = ""
 End If
End Sub 'HC12In
 
Sub Send_FST
 'Out$ = "$AGFST"+","+Str$(temp)+","+Str$(humidity)+","+Str$(Voltage,0,2)+","+StationID
 'zzzTemp = TEMPR(TemprPin)
 Temp = 0.0  'zzz
 'Ex WS RemoteOut$ = "$AGFST"+","+Str$(temp)+","+Str$(humidity)+","+Str$(Raining)+","+StationID
 Out$ = "$AGFST"+","+Str$(Temp)+",0,0," + StationID
 Out$ = CRC$(Out$)
 Print #1,Out$
 print
 Print Out$, Tab(40);"Sent at ", Time$
End Sub 'Send_FST
 
Function Field$(s As String, n As Integer)
 Const delim1 = ","                 ' set this to the field delimiter
 Const delim2 = "*"                 ' set this to the second field delimiter
 Local Integer i, StartIdx = 1, EndIdx
 
 ' get the start of the field in StartIdx
 For i = 2 To n
   StartIdx = Instr(StartIdx, s, delim1) + 1
   If StartIdx = 1 Then StartIdx = Instr(StartIdx, s, delim2) + 1
   If StartIdx = 1 Or StartIdx > Len(s) Then Exit Function
 Next i
 
 ' get the end of the field in EndIdx and extract the field
 EndIdx = Instr(StartIdx, s, delim1)
 If EndIdx = 0 Then EndIdx = Instr(StartIdx, s, delim2)
 If EndIdx = 0 Then EndIdx = 255
 Field$ = Mid$(s, StartIdx, EndIdx - StartIdx)
End Function  'Field
 
FUNCTION CRC$(Txt$ AS String) 'Returns the Txt$ passed to it with "*hh" added, where hh is the NMEA Hex checksum
 'Local String Txt$
 Local Integer n
 Chksum = 0
 FOR n = 2 TO LEN(Txt$)  'n=2 makes it skip the leading $
   Chksum=Chksum XOR ASC(MID$(Txt$,n,1))
 NEXT n
 CRC$=Txt$+"*"+HEX$(Chksum,2)
END FUNCTION
 
FUNCTION CheckCRC(Txt$ AS String) 'Txt is the full NMEA sentence ie "$ . . .*hh"
 'Function returns Chksum and CheckCRC = 1 if Calculated CRC = received CRC
 Local Integer n
 Chksum = 0
 CheckCRC = 0  'zzz Not strictly necessary
 FOR n = 2 TO LEN(Txt$)-3  'n=2 makes it skip the leading $ and -3 stops before the *
   Chksum=Chksum XOR ASC(MID$(Txt$,n,1)) 'The standard NMEA checksum calculation
 NEXT n
 IF RIGHT$(Txt$,3) = "*"+HEX$(Chksum,2) THEN ' Crc match
   CheckCRC = 1
 Else
   CheckCRC = 0
 ENDIF
END FUNCTION  'CheckCRC
 
FUNCTION sendCMD( c AS INTEGER, d AS INTEGER, e AS INTEGER, device AS INTEGER) AS INTEGER
 LOCAL s$
 s$ = CHR$(&hAA)+CHR$(&hB4)+CHR$(c)+CHR$(d)+CHR$(e)+STRING$(10,0)+CHR$(device\256)+CHR$(device AND 255)
 s$ = s$ + cs$(s$,17)+CHR$(&hAB)
 PRINT #3,s$;
END FUNCTION
 
FUNCTION cs$(s$,L AS INTEGER)' L should be 7 for reply or 17 for command
 LOCAL n, k
 FOR n = 3 TO L
   k = k + ASC(MID$(s$,n,1))
 NEXT n
 cs$ = CHR$(k AND 255)
END FUNCTION
Edited 2020-03-16 15:08 by Andrew_G
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 05:16am 16 Mar 2020
Copy link to clipboard 
Print this post

Phil,
I'm also interested in an LED to show when it is "asleep" or "awake". I couldn't get one working off the power to the fan - please let me know if you do.

I partially got around this by testing its status ( "state$" above) just before/after it was meant to be asleep or awake and then reporting that on the LCD.

Andrew
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 08:09am 16 Mar 2020
Copy link to clipboard 
Print this post

Hi Andrew,

Just reposting your code for the sake of readability.
Also, can you post a pic of you display for the hell of it.

Pic is worth a thousand words; & beats deciphering code.


Cheers.

  Quote   'AirQual.BAS
 
 
'Based on "AirQual By Jim.BAS" (= TassieJim from The Back Shed)
 
 
' SDS011 dust sensor
 ' serial 9600 8 N 1 5V TTL
 '
 ' device = &HFFFF for all connected devices.
 'Fonts #2, #3, #6 (=GeoffG's #8), #7 (=GeoffG's #7) & #8 loaded into Library
 
 
Dim String Prog(3) = ("AirQual", "v13","    ", "Stn ID=")
 
Dim String  StationID = "7"
 Prog(
3) = Prog(3) + StationID
 
'zzz_to_do:
 
 
'Close down properly so it restarts better
'V13:
 'Uses a 320x240 LCD - is upside down which means HC-12 aerial points down
 
 
'V12:
 'Incorporates HC-12 and code from AmbiMon to send FST and receive and process time.
 'Sends AGPPM message (zzz need to correct all AmbiMon devices)
 'Saves Geoff G's fonts 7 and 8 to LIBRARY as 7 and 6
 
'v11:
 'Supersedes v9 - Stick with Jim's from now on
 
 
'AG Changes:
 ' changed "l" to "L" (3 off in Function CS)
 
 
Dim String  arg$(20)   'The upto 21 arguments in the NMEA-like sentence 'zzz can reduce
 DIM FLOAT PM25, PM10, PM25Min, PM25Max, PM10Min, PM10Max
 
DIM INTEGER x, readAvailable, sleepTime
 
DIM k$, r$, reportMode$, state$, ID$
 
dim String OldTime
 
 
OPEN "COM2:9600,256" AS #3              'Incoming SDS data
 OPEN "COM1:9600, 1024, HC12In, 4" as #1 'Data in/out HC-12
 
 
Cls
 
 
Date$ = "01-01-2000"  'Enter a dummy date to check it has been updated properly
 Send_FST  'Tells the network that it is starting up and sends inital values
 '         'Gets date and time in return. $AGD_T sentences update these every 2 hours.
 
 
Print Prog1$;" ";Prog2$
 
Print "Station ID is "; StationID
 
 
for I = 0 to 3
   
Text MM.Hres/2, MM.Vres/2 - 40 + 22*I), Prog(I) , CM, 1,2, RGB(Green)
 
next I
 
pause 3000 'This is to show the ID and allow FST to return date and time (2000 is adequate)
 
 
For I = 1 to 10 'Should already have the Date and Time this just makes sure
   if Date$ = "01-01-2000" then
     Send_FST
     
text mm.hres/2,mm.Vres/2 + 60, "PL.WAIT "+STR$(I),CM,1,2,RGB(CYAN)
     
Pause 1000
   
else
     
exit For
   
endif
 
next I
 
 
Cls
 
 UpdateTime  
'Updates the time on LCD and every minute thereafter
 'Every 2 hours the AmbiMon base station sends a Time$/Date$ update
 
 x = sendCMD(
8,1,0,&HFFFF) ' Duty cycle continuous to get the initial reading
 PAUSE 1000
 x = sendCMD(
2,0,0,&HFFFF) ' check report mode
 x = sendCMD(6,0,0,&HFFFF) ' check state
 x = sendCMD(8,1,5,&HFFFF) ' duty cycle 30 secs on every 5 minutes
 
 OldTime$ =
Mid$(Time$, 1, 5)
 
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM_Start_Main_Loop:
 DO
   
If OldTime <> Mid$(Time$, 1, 5) then
     OldTime =
Mid$(Time$, 1, 5)
     UpdateTime
   
End If
   
   
IF LOC(#3) > 0 THEN
     k$ =
INPUT$(1,#3)
     r$ = r$ + k$
     
IF ASC(k$) = 171 THEN doRead ' end of data flag rec
   ENDIF
   
   
IF readAvailable THEN doDisplay
   
   
If SleepTime > 0 and timer =>(SleepTime)*1000 then  'Just as it is due to awake check, and confirm that it is then awake
     Checkstate
     
Timer = 0
   
end if
   
 
LOOP
 
'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm_End_Main_Loop:
ENd
 
Sub CheckState
 x = sendCMD(
6,0,0,&HFFFF) ' check state
End Sub 'Checkstate
 
Sub UpdateTime  'Show the time each minute
 Text mm.Hres -1, 0, Mid$(Time$, 1, 5), RT, 6,1, RGB(Yellow)
End Sub 'UpdateTime
 
SUB doDisplay
 
'zzz can redo to only draw stuff that has changed
 PRINT TIME$;", PM2.5="; STR$(PM25,4,1);", PM10="; STR$(PM10,4,1);", Mode= "; reportMode$;", State= "; state$;
 
IF SleepTime = 0 THEN
   
PRINT ", Duty= continuous"
 
ELSE
   
PRINT ", Duty= "; (sleepTime + 30)/60;" mins"
 
ENDIF
 
 
if State$ = "Sleep" then
   
text 0, 0, State$, LT,6,1,  RGB(170,170,170)
 
else
   
text 0, 0, State$, LT,6,1,  RGB(Green)    
 
Endif
 
Text 0, 70, "PM2.5", LB, 6,1, RGB(170,170,170)
 
Text 0, 180, "PM 10", LB, 6,1,RGB(170,170,170)
 
 
text mm.Hres, 90, STR$(PM25,3,1), RB,7,1, RGB(Green)
 
circle mm.Hres-50, 70, 5,,, RGB(Green),RGB(Green)
 
text mm.Hres/2+20, 130, STR$(PM25Min,3,1), RB,6,1, RGB(Cyan)
 
text mm.Hres, 130, STR$(PM25Max,3,1), RB,6,1, RGB(Red)
 
 
text mm.Hres, 200, STR$(PM10,3,1), RB,7,1, RGB(Green)
 
circle mm.Hres-50, 180, 5,,, RGB(Green),RGB(Green)
 
text mm.Hres/2+20, mm.Vres, STR$(PM10Min,3,1), RB,6,1, RGB(Cyan)
 
text mm.Hres, mm.Vres, STR$(PM10Max,3,1), RB,6,1, RGB(Red)
 readAvailable =
0
END SUB
 
SUB doRead
 
LOCAL INTEGER replyMode
 
IF MID$(r$,2,1)= CHR$(&hC0) THEN replyMode = 1
 
IF MID$(r$,2,1)= CHR$(&hC5) THEN replyMode = ASC(MID$(r$,3,1))
 
SELECT CASE replyMode
   
CASE 1 ' data
     PM25 = (ASC(MID$(r$,3,1)) + ASC(MID$(r$,4,1))*256)/10
     PM10 = (
ASC(MID$(r$,5,1)) + ASC(MID$(r$,6,1))*256)/10
     
     Out$ =
"$AGPPM"+","+Str$(PM25)+","+Str$(PM10)+"," + StationID
     Out$ = CRC$(Out$)
     
Print #1,Out$
     
print
     
Print Out$, Tab(40);"Sent at ", Time$
     
     
if PM25Min = 0 then PM25Min = PM25
     
If PM25 > PM25Max then PM25Max = PM25
     
If PM25 < PM25Min then PM25Min = PM25
     
if PM10Min = 0 then PM10Min = PM10
     
If PM10 > PM10Max then PM10Max = PM10
     
If PM10 < PM10Min then PM10Min = PM10
     
'          'The CO will report "Awake"
     Checkstate 'Immediately after a "CO" this should report "Sleep"
     Timer = 0
   
CASE 2 ' data reporting mode
     IF ASC(MID$(r$,5,1)) = 1 THEN
       reportMode$ =
"query "
     
ELSE
       reportMode$ =
"active"
     
ENDIF
   
CASE 5 ' new ID 'zzz not used???
     ID$ = HEX$(MID$(r$,8,1),2)+HEX$(MID$(r$,9,1),2)
   
CASE 6 ' sleep mode
     IF ASC(MID$(r$,5,1)) = 1 THEN
       state$ =
"Awake "
     
ELSE
       state$ =
"Sleep"
     
ENDIF
   
CASE 8 ' duty cycle
     SleepTime = ASC(MID$(r$,5,1))*60 - 30 'For a 5 min duty cycle SleepTime = 270 seconds (= 5*60 - 30)
     IF SleepTime < 0 THEN sleepTime = 0
 
END SELECT
 r$ =
""
 readAvailable =
1
END SUB
 
Sub HC12In  'COM port directs to here if there are any incoming sentences 'zzz delete unused ones
 Local Integer II
Again4:
 HCIn$ =
""
 
Line Input #1, HCIn$
 
If LEN(HCIn$) = 0 then GoTo Again4
 
If CheckCRC(HCIn$) Then 'CRC Check is OK
   If Mid$(HCIn$, 1, 6) = "$AGD_T" Then
     
For II = 1 to 2
       arg$(II) = Field$(HCIn$, II+
1)
     
Next II
     
Print "Old Date:", Tab(11), Date$;
     
Date$ = arg$(1)
     
Print Tab(22), "New Date: ", Tab(32), Date$
     
Print "Old Time:", Tab(11), Time$;
     
Time$ = arg$(2)
     
Print Tab(22), "New Time: ", Tab(32), Time$
     
Exit Sub
   
End If
 
Else
   
Print "CRC Fail:", HCIn$, "  ", Chksum
   HCIn$ =
""
 
End If
End Sub 'HC12In
 
Sub Send_FST
 
'Out$ = "$AGFST"+","+Str$(temp)+","+Str$(humidity)+","+Str$(Voltage,0,2)+","+StationID
 'zzzTemp = TEMPR(TemprPin)
 Temp = 0.0  'zzz
 'Ex WS RemoteOut$ = "$AGFST"+","+Str$(temp)+","+Str$(humidity)+","+Str$(Raining)+","+StationID
 Out$ = "$AGFST"+","+Str$(Temp)+",0,0," + StationID
 Out$ = CRC$(Out$)
 
Print #1,Out$
 
print
 
Print Out$, Tab(40);"Sent at ", Time$
End Sub 'Send_FST
 
Function Field$(s As String, n As Integer)
 
Const delim1 = ","                 ' set this to the field delimiter
 Const delim2 = "*"                 ' set this to the second field delimiter
 Local Integer i, StartIdx = 1, EndIdx
 
 
' get the start of the field in StartIdx
 For i = 2 To n
   StartIdx =
Instr(StartIdx, s, delim1) + 1
   
If StartIdx = 1 Then StartIdx = Instr(StartIdx, s, delim2) + 1
   
If StartIdx = 1 Or StartIdx > Len(s) Then Exit Function
 
Next i
 
 
' get the end of the field in EndIdx and extract the field
 EndIdx = Instr(StartIdx, s, delim1)
 
If EndIdx = 0 Then EndIdx = Instr(StartIdx, s, delim2)
 
If EndIdx = 0 Then EndIdx = 255
 Field$ =
Mid$(s, StartIdx, EndIdx - StartIdx)
End Function  'Field
 
FUNCTION CRC$(Txt$ AS String) 'Returns the Txt$ passed to it with "*hh" added, where hh is the NMEA Hex checksum
 'Local String Txt$
 Local Integer n
 Chksum =
0
 
FOR n = 2 TO LEN(Txt$)  'n=2 makes it skip the leading $
   Chksum=Chksum XOR ASC(MID$(Txt$,n,1))
 
NEXT n
 CRC$=Txt$+
"*"+HEX$(Chksum,2)
END FUNCTION
 
FUNCTION CheckCRC(Txt$ AS String) 'Txt is the full NMEA sentence ie "$ . . .*hh"
 'Function returns Chksum and CheckCRC = 1 if Calculated CRC = received CRC
 Local Integer n
 Chksum =
0
 CheckCRC =
0  'zzz Not strictly necessary
 FOR n = 2 TO LEN(Txt$)-3  'n=2 makes it skip the leading $ and -3 stops before the *
   Chksum=Chksum XOR ASC(MID$(Txt$,n,1)) 'The standard NMEA checksum calculation
 NEXT n
 
IF RIGHT$(Txt$,3) = "*"+HEX$(Chksum,2) THEN ' Crc match
   CheckCRC = 1
 
Else
   CheckCRC =
0
 
ENDIF
END FUNCTION  'CheckCRC
 
FUNCTION sendCMD( c AS INTEGER, d AS INTEGER, e AS INTEGER, device AS INTEGER) AS INTEGER
 
LOCAL s$
 s$ =
CHR$(&hAA)+CHR$(&hB4)+CHR$(c)+CHR$(d)+CHR$(e)+STRING$(10,0)+CHR$(device\256)+CHR$(device AND 255)
 s$ = s$ + cs$(s$,
17)+CHR$(&hAB)
 
PRINT #3,s$;
END FUNCTION
 
FUNCTION cs$(s$,L AS INTEGER)' L should be 7 for reply or 17 for command
 LOCAL n, k
 
FOR n = 3 TO L
   k = k +
ASC(MID$(s$,n,1))
 
NEXT n
 cs$ =
CHR$(k AND 255)
END FUNCTION
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 11:33pm 16 Mar 2020
Copy link to clipboard 
Print this post

Hi Phil,
Thanks for tidying up my "code" - I guess that is what the "Code" button is for??
(Jim's MMEdit formats things to look better so the typos are less apparent.)

Here are two pictures:








The display shows current P2.5 and P10 values, in larger font, and the minimum and maximum values to date (Cyan and Red). The grey word "Sleep" changes to a green "Awake" when the sensor is working.
The top left time is from my HC-12 network as described above.
There is no graph (yet) but I graph all my HC-12 inputs on my PC.

The other pic shows you can just fit both sensors, an HC-12 and a LCD BackPack in the box. There is a bend in the tube feeding the SDS011 (and its covered in black heat shrink) to reduce the light getting to the sensor. I've enlarged the 4 holes at the back of the box to exhaust air from the SDS fan. I have yet to isolate the VOC sensor from the air inside the box.

OK?  Andrew
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 522
Posted: 06:30am 17 Mar 2020
Copy link to clipboard 
Print this post

If a good detection system can be done low cost it could be used to turn on
electrostatic based air purifier in rooms not being occupied. One that is low
current and very high voltage would pull the particles out of the air.
This would even help slow down air born viruses from spreading.

 Here is an updated page
Air Ionizers  


Just today's rambling thoughts.
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 08:34am 17 Mar 2020
Copy link to clipboard 
Print this post

  Quazee137 said   Here is an updated page
Air Ionizers  


Just today's rambling thoughts.


Interesting,

I have an Ozone Generator on my Spa.

Built it from components from Ali, with output potentially 10x above the overpriced commercial offerings for the task.

It runs at a low level, but does a superb job.

Phil.
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 08:41am 17 Mar 2020
Copy link to clipboard 
Print this post

Andrew,

Good to see the pics & particularly the assurance that I'm not the only one that still uses strip board.

I'm sure I could learn to do my own PCB's, but work has me sitting behind screens enough in a day, let alone learning another PC based task.


Still trying to get my head around the graphs module here, but will get back to it.

Phil.
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 11:02am 18 Mar 2020
Copy link to clipboard 
Print this post

Has anyone seen these?
Enviroment Sensor



and

Pm1, PM2.5, PM10 Particulate Sensor


They work really well, Python code is Here

With a Pi Zero+ I'm sure MM could do a great job displaying, storing and uploading the results

Enviro + Air Quality features
BME280 temperature, pressure, humidity sensor (datasheet)
LTR-559 light and proximity sensor (datasheet)
MICS6814 analog gas sensor (datasheet)
ADS1015 analog to digital converter (ADC) (datasheet)
MEMS microphone (datasheet)
0.96" colour LCD (160x80)
Connector for particulate matter (PM) sensor (available separately)
Pimoroni breakout-compatible pin header
pHAT-format board
Fully-assembled
Compatible with all 40-pin header Raspberry Pi models
Pinout
Python library
Dimensions: 65x30x8.5mm
PM1.0, PM2.5 and PM10.0 concentration in both standard & enviromental units
Particulate matter per 0.1L air, categorized into 0.3um, 0.5um, 1.0um, 2.5um, 5.0um and 10um size bins

I'm sure the right person could convery the Python code to Basic to use with Pi-Cromite?
Edited 2020-03-18 21:04 by lew247
 
BrianP
Senior Member

Joined: 30/03/2017
Location: Australia
Posts: 292
Posted: 03:02am 19 Mar 2020
Copy link to clipboard 
Print this post

  Phil23 said  Andrew,

Good to see the pics & particularly the assurance that I'm not the only one that still uses strip board.

I'm sure I could learn to do my own PCB's, but work has me sitting behind screens enough in a day, let alone learning another PC based task.


Still trying to get my head around the graphs module here, but will get back to it.

Phil.

Strip board ist gut!!!
B
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 04:24am 19 Mar 2020
Copy link to clipboard 
Print this post

Phil,
For such a simple circuit - yes!

I'm hanging out for a 3D printer that can do simple PCB-like boards. Now that would be good

Andrew
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 05:51am 02 Apr 2020
Copy link to clipboard 
Print this post

Hi All,

Received the Sensirion SPS30 I ordered a week or so back.





First stumbling block was that it's interface connector is a ZHR-5.
1.5mm pin spacing....

Received the plugs & pins from RS today & managed to get it connected to a USB port via the CH340 USB-Serial adaptor that came with my SDS011.

Sensirion's Evaluation software was quite happy to connect to the device & read it regardless of me not having their USB device.

Won't do too much with it of the SDS011 just yet as I'd like to get my head around Geoff's graphing code first so I can add more traces.



 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 07:49am 02 Apr 2020
Copy link to clipboard 
Print this post

  BrianP said  
  Phil23 said  Andrew,

Good to see the pics & particularly the assurance that I'm not the only one that still uses strip board.

Strip board ist gut!!!
B


I never really like strip board, only used it for basic stuff. I preferred paperboard with the land around each hole or eurocard style ones laid out for ICs. Then backwire from a net list.

These days, I don't do either (for single sided stuff), I etch a single PCB. Circuit ends up in Eagle anyway, lay-up a board - which I find quite therapeutic. Then save out the track, pads & vias image of the board as a PNG, covert to SVG with Inkscape and cut it onto a bit of black-painted board and etch. The export, convert, cut, etch takes less than an hour and I have a guaranteed working hookup - barring mistakes. I did two yesterday alone. I lay the board up as two-sided, avoiding the top as much as possible and then use that to top-links where I get stuck. Can't do really fine stuff though as my laser etcher is a only cheapie, but it can just about do down to tracks of 32 thou. Prefer 50 thou as a standard which give a very robust board.
 
     Page 3 of 4    
Print this page
© JAQ Software 2024