LOL - I've not been on this forum for years, and today received notification of your post... How you doing ?
Like I said I've not been active on here for some years, and no longer program in PBP so I'm rusty when it comes to the workings ![Smilie](images/smilies/smile.gif)
Comments taken form that library file file suggest
Code:
'-- To REMOVE SENSORS perform the following: --
'-- 1. Change the "AM2302_MAX_SENSORS" constant to the correct number. --
'-- 2. Comment out the appropriate "AM2302_Sensor_x" Alias lines. --
'-- 3. In the "AM2302_Read" subroutine in the library file, --
'-- edit the "select case AM2302_Sensor_Num" block, comment out the --
'-- "Case x" portion for the sensor number you want to remove. --
'-- 4. Comment out the entire "AM_Readx" subroutine at the end --
'-- of this library file for the sensor you want to remove. --
and this needs editing
Code:
'****************************************************************************
'*** EDIT THIS SELECT CASE BLOCK TO ADD/REMOVE SENSORS (see instructions) ***
'****************************************************************************
select case AM2302_Sensor_Num
case 1 'Sensor #1
gosub Read_AM1
case 2 'Sensor #2
gosub Read_AM2
case 3 'Sensor #2
gosub Read_AM3
case 4 'Sensor #2
gosub Read_AM4
end select
Looking at the code for the version of thermostat that I used as a test platform when Tabsoft was developing the library the main program has this line in the set up area of the code (using include "AM2302_LIB_v024.bas" )
Code:
;----[AM2302 ]------------------------------------------------------------------
AM2302_MAX_SENSORS con 4 ' Number of Sensors Used
I then used a word array for the temp and humidity values
Code:
AM2302_H var word[4] ' AM2302 sensors - Humidity values
AM2302H1 var AM2302_H[0]
AM2302H2 var AM2302_H[1]
AM2302H3 var AM2302_H[2]
AM2302H4 var AM2302_H[3]
AM2302_T Var Word[4] ' AM2302 sensors - temperatures
AM2303T1 Var AM2302_T[0]
AM2303T2 Var AM2302_T[1]
AM2303T3 Var AM2302_T[2]
AM2303T4 Var AM2302_T[3]
I guess if using just the one sensor this could be a straight word variable
I then have a link to a subroutine
Code:
for cn=1 to 4
Pid_channel=cn-1
AM2302_Sensor_Num = cn
gosub read_dht
And the subroutine it links to is
Code:
read_dht:
gosub AM2302_Read
AM2302_H[Pid_channel]= AM2302_Hum
AM2302_T[Pid_channel]= AM2302_Temp
if AM2302_Temp/10=0 then return
serout2 portB.0, 84, [$1B,"[H"]
serout2 portB.0, 84,[$1b, "[", dec cn+1, "B"]
serout2 portB.0, 84, [$1B,"[11C"]
serout2 portB.0, 84, [dec AM2302_Temp/10,".",dec AM2302_Temp//10]
serout2 portB.0, 84, [$1B,"[H"]
serout2 portB.0, 84,[$1b, "[", dec cn+1, "B"]
serout2 portB.0, 84, [$1B,"[17C"]
serout2 portB.0, 84, [dec AM2302_Hum/10,"%"]
Return
Ignore all the serial out commands, I was using a serial to GLCD adapter at the time. The gosub called in the above subroutine is in the library file.
Hopefully that dissection of my old program helps ? I sold my old EasyPic5 board at the beginning of September this year, and uninstalled PBP years ago, so have no means to test, but the code ran for a few years in the controller before I move to the dark side and ported the code to an Arduino Mega to take advantage of colour TFT screens.
Bookmarks