Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:55 02 Aug 2025 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 : Humid Command

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 05:28am 09 Jul 2018
Copy link to clipboard 
Print this post

Trying to teach my Grandson about the mites and I feel like a real goose.
We have a DHT22 connected with the following code
' Temperatue and Humidity
Dim as float temp, humidity
humid 18, temp, humidity
print temp, humidity

CSub HUMID integer, float, float
0000002B 27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008
27BD0008 27BDFFE0 AFBF001C 00002021 3C059D00 24A50040 27A60010 0411FFF1
00000000 8FA30010 3C029D00 8C4200BC 3C049D00 24840414 0040F809 00832021
8FBF001C 03E00008 27BD0020 00041080 000419C0 00621823 00642021 000418C0
3C029D00 8C420000 3C047735 34849400 8C420000 0082001B 004001F4 00002012
0064001B 008001F4 03E00008 00001012
27BDFFB8 AFBF0044 AFBE0040 AFB7003C AFB60038 AFB50034 AFB40030 AFB3002C
AFB20028 AFB10024 AFB00020 00808821 00A0A821 3C029D00 8C420000 8C430000
3C020098 34429680 0062102B 10400003 00C0B021 0411FFC7 00000000 3C109D00
8E02001C 8E240000 0040F809 24050006 8E020010 8E240000 24050009 0040F809
00003021 8E02001C 8E240000 0040F809 2405000E 8E02001C 8E240000 0040F809
24050005 8E020004 0040F809 240403E8 8E02001C 8E240000 0040F809 24050006
8E020080 240403E8 0040F809 00002821 AEC20000 AEA20000 0411FFB8 24040190
00409821 0000A021 40944800 00008021 10000005 3C129D00 40104800 0270102B
1440008E 8FBF0044 8E420020 0040F809 8E240000 1440FFF8 00000000 10000007
3C129D00 40104800 0270102B 50400004 8E420020 10000081 8FBF0044 8E420020
0040F809 8E240000 1040FFF6 00000000 10000007 3C129D00 40104800 0270102B
50400004 8E420020 10000074 8FBF0044 8E420020 0040F809 8E240000 1440FFF6
00001021 00001821 AFA20010 AFA30014 0000B821 10000005 3C129D00 40104800
0270102B 14400065 8FBF0044 8E420020 0040F809 8E240000 1040FFF8 00000000
40944800 10000006 8E420020 40104800 0270102B 14400059 8FBF0044 8E420020
0040F809 8E240000 1440FFF8 8FA30010 000317C2 8FA50014 0005F040 005EF025
00031040 AFA20018 0411FF6C 24040032 0050102B 8FA30018 00431025 AFA20010
26F70001 24050028 16E5FFE0 AFBE0014 001E1600 8FA50010 00052202 00442025
001E1200 00058E02 00518825 7CA33C00 308200FF 00621821 322200FF 00621821
93A50014 30A200FF 00621021 8FA30010 00431026 304200FF 1440002F 001EA603
3C109D00 8E130064 8E020080 30847FFF 0040F809 00002821 00409021 8E020080
2404000A 0040F809 00002821 02402021 0260F809 00402821 00408021 AEA20000
3C020080 8FA50010 00451024 5040000C 3C109D00 3C029D00 8C520058 8C420080
2404FFFF 0040F809 2405FFFF 02002021 0240F809 00402821 AEA20000 3C109D00
8E120064 8E020080 02202021 0040F809 02802821 00408821 8E020080 2404000A
0040F809 00002821 02202021 0240F809 00402821 AEC20000 8FBF0044 8FBE0040
8FB7003C 8FB60038 8FB50034 8FB40030 8FB3002C 8FB20028 8FB10024 8FB00020
03E00008 27BD0048 20555043 65657073 6F742064 6F6C206F 000A0D77
End CSub


When run I get this error
  Quote  run
[2] Dim As float temp, humidity
Error: Variable name
>

Sometimes I get
  Quote  CPU exception #7 at address 0x9D03DE78
Processor restarted

What is wrong.
Paul.Edited by palcal 2018-07-10
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:09am 09 Jul 2018
Copy link to clipboard 
Print this post

The PIN has to be an INTEGER.
I use:
  Quote   DIM AS INTEGER DHT22pin = 26
DIM AS FLOAT TEMP, HUMIDITY

SUB readhumidity
HUMID DHT22pin, TEMP, HUMIDITY ' dump stale reading
PAUSE 2000 ' time for the sensor to complete next read
HUMID DHT22pin, TEMP, HUMIDITY ' this reading is only 2 seconds old
IF temp = 1000 THEN
HUMID DHT22pin, TEMP, HUMIDITY
ENDIF
END SUB


If you have DEFAULT INTEGER set, your code 'should' work as is but I prefer to set each one as required.

Jim


VK7JH
MMedit
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 06:21am 09 Jul 2018
Copy link to clipboard 
Print this post

Thank Jim, a while since I have used this. I was showing my Grandson from the manual and it is not mentioned there.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 06:34am 09 Jul 2018
Copy link to clipboard 
Print this post

OK did that but now getting error
  Quote  2] Dim As integer DHT22pin=18
Error: Variable name

I think I will re flash the chip and start again.
It can't be this hard, and just when I'm showing my Grandson how smart I am.

Edit...I now see the "DIM AS INTEGER DHT22pin = 26"
is mentioned in the CSUBEdited by palcal 2018-07-10
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 07:51am 09 Jul 2018
Copy link to clipboard 
Print this post

Got to the bottom of the problem, something stupid as usual. I am using an E-28 I bought from Grogster but the version of the firmware it was using did not support the HUMID C sub. Upgraded to a later version and all is OK.

Got that wrong as well, not Grogster's fault, I showed my Grandson how to flash the chip and I used the wrong version.Edited by palcal 2018-07-10
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 11:36am 09 Jul 2018
Copy link to clipboard 
Print this post

Glad that it was fixed.

Just a point of clarification. The CSub starts with:
CSub HUMID integer, float, float
0000002B 27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008
27BD0008 27BDFFE0 AFBF001C 00002021 3C059D00 24A50040 27A60010 0411FFF1
...

The first argument is declared as an INTEGER. This means that MMBasic will convert a float (if supplied) to an integer - so you don't have to worry what type of argument it is (float or integer) MMBasic knows that an integer is required and will make it so.

This does not apply to the next two arguments. Because the CSub needs to pass back the results to a float these variables must to be declared as floats.
Geoff Graham - http://geoffg.net
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025