Greenhouse Data logger...

cactusface

Senior Member
Hi Folks,
Not been here for a little time? For years even in the good old Z80 days, I've had ideas for a data logger. But now the Picaxe seems to make it all seem so easy?? One problem it seems would be how do I get this data into the PC? I note that on the AXE110 there are 2 download sockets, and one must be for uploading, but just how do I get it into a database or spreadsheet?? (PC or MAC). To make memory easy I thought of using say a 24C256 for each of the 4 sets of data, to get the addressing right do I tie A0 high on the 2nd chip, A1 on the 3rd and A0 & A1 on the 4th?

I have heard about page read/write limits, but if I am writing one byte at a time, I think this is not a problem and the memory will just fill up to it's limit.... (not likely to happen)

I may build it around the shield.

Any help and ideas very welcome.

Regards
Mel.
 

nick12ab

Senior Member
One problem it seems would be how do I get this data into the PC?
Using the serial connection. The CSV format (separating data with commas and CR,LFs) is a good one to use as it is very simple for the PICAXE to do and it can be imported into Excel. The PICAXE can convert the numbers to ASCII and insert commas itself and you receive the data using the terminal or the PICAXE can just send raw data and you write a program to convert it.

I note that on the AXE110 there are 2 download sockets, and one must be for uploading
That is correct. The second socket is for the Datalink utility in Programming Editor which you access by pressing [F9].

To make memory easy I thought of using say a 24C256 for each of the 4 sets of data, to get the addressing right do I tie A0 high on the 2nd chip, A1 on the 3rd and A0 & A1 on the 4th?
Yes.
 

SAborn

Senior Member
What sort of data do you wish to log, Light, Moisture, Temp???

Is it you want to store the data and download it to the PC or do you want the PC to be active and record the data 24/7.
 

cactusface

Senior Member
Hi SAborn,
Thanks for your reply! Yes I will be logging inside & outside temp, light, humidity. If I get really good may even add wind speed, etc. The data will be stored in the on-board memory, not sure if I will try a radio link to a PIcaxe receiver? indoors, but the data will be uploaded to the PC say every day. I think I'm OK with the connections, not so sure just how I get the software (Picaxe & PC) to do that.

Any ideas welcome.
Regards
Mel.
 

MFB

Senior Member
Download a copy of the free StampPlot Pro plotting and storage application, and take a look at the example programmes for sending CSV formatted data serial to the PC. These are written for the Basic Stamp but can easily be converted to PICAXE version of Basic. Its also worth searching this forum for StampPlot example code.
 

SAborn

Senior Member
not sure if I will try a radio link to a PIcaxe receiver? indoors, but the data will be uploaded to the PC say every day
If you want to do a reliable wireless link to the PC i highly recommend you use these Dorji modules.

http://www.dorji.com/docs/data/DRF4432D20I.pdf

The serial module will connect direct to the picaxe programming socket and work with "sertxd" and "serrxd" making it a very easy serial link.

The TTL module can be fitted directly onto one of the Dorji USB adapter boards and made into a small usb dongle that will plug direct into the pc (no picaxe needed on the PC end), both modules are compatable with each other and form a strong simple wireless link.

These particular Dorji modules are so well suited for use with Picaxe, compared to other modules in the range/market these are just a perfect match for picaxe use.
 

westaust55

Moderator
While the AXE110 has a second programming socket for the purpose of downloading the stored data with hand shaking (eg sending a "G" from PC to initiate PICAXE sending data)
it is possible to set up a datalogger and use the primary programming socket for data transfer as well.
The attached 08M code is a demo I wrote a few years ago before then writing code for a more extensive 18X based weather station with a separate EEPROM chip for data storage.
Not saying it is optimal, but does demostrate use of the normal prograqmming socket in conjunction with the Programming Editor's Datalink software accessed with [F9].
Code:
; =========================================================================
;   File....... MiniWeather
;   Purpose.... PICAXE 08M based weather station to measure the temp, humidity and light level and then
;               store data for later transfer to a PC via the Prog Editor Datalink function for viewing in Excel
;               After a recording mission, once the data has been transferred to the PC,
;               MUST turn power Off and back On for a new "mission" 
;
;   Author..... Westaust55
;   Written.... 2-05-2009
;   
;  =======================================================================
;The formula for RH% is: RH(%) = (Offset-Soh) * Sens /(2^12)    2^12 = 4096
;
;
#PICAXE 08M
;
; IO DEFINITIONS
;
SYMBOL temp     = 4                 ; using a DS18B20 temperature sensor (available from MicroZed)
SYMBOL humid   = 3                 ; using a HOPERF HH10D Humidity Sensor (available from MicroZed)
SYMBOL ldres     = 2                 ; Using a Jaycar supplied LDR Cat No RD3485
;                                                    Dark resistance: 0.5M ohm min.
;                                                    Light resistance: 2.8K ohm min 8.4K ohm max.
SYMBOL ULoad   = pin1                ; switch - low to record and when memory full a high to initiate transfer to PC
SYMBOL spare    = 0                ; pin 0 = output only - used for SERTDX  suggest do not use elsewhere
;
; VARIABLE DEFINITIONS 
; 
SYMBOL light       = b0               ; holds the current light level as measured by the LDR
SYMBOL degC      = b1               ; holds the current temperature as measured by the temp sensor
SYMBOL axefactr  = b2               ; a scaled factor to prevent overflow in the maths to calculate humidity 
SYMBOL addr       = b3
SYMBOL Soh	= w2	       ; w2 = b5:b4	 =  the frequency from the humidity sensor 	
SYMBOL diff	= w3	       ; w3 = b7:b6  = intermediate value used in humidity calculations
SYMBOL RH	= w4	       ; w4 = b9:b8  = the relative humidity value

SYMBOL timr       = b10
;	
;
; CONSTANTS
;
SYMBOL COM       = 44              ; ASCII value for a comma
SYMBOL RET        = 13              ; ASCII value for a carriage return
SYMBOL LFEED    = 10              ; ASCII value for a line feed
;				
SYMBOL Offset    = 7762            ; HH10D module 1 calibration constant	
SYMBOL Sens      = 340             ; HH10D module 1 calibration constant 
;
SYMBOL mins       = 1                ; Minutes between each reading
SYMBOL basetime = 58800         ; Basic increment of time set for 1 minute min period
;                                 NOTE: using 58,800 not 60,000 to account for time reading in data each interval
SYMBOL space     = 50              ; max space for data storage typ = space bytes -2 bytes 
;                                                  PICAXE-08M EEPROM memory available =  0 to (255 - number of used bytes)
;                                                  Actual is 56 bytes   54 / 3 = 18 complete (3-byte) slots for data
; 
; =========================================================================
; MAIN PROGRAM
; =========================================================================
;
Init:
; First check if there is data in memory still to download
      READ addr, light                    ; read the first memory location. If zero, then clear for new mission
      IF light > 0 THEN Download    ; if not clear then get ready to download to PC
;
; here waiting for the switch to be changed to low to intiate data recording
     DO
     LOOP UNTIL Uload = 0             ; wait for switch to be moved to the  Record/Logging position

; here to start recording weather data at the defined intervals
Record:
;
; Step 1 = Fetch the current weather data
      READADC ldres, light               ; read the relative light level value

      READTEMP temp, degC           ; read the temperature in Degrees C.

      COUNT humid, 1000, Soh         ; read the frequency (ie cycles in 1 second)
      
      diff = Offset - Soh

      axefactr = diff / 19 + 1               ; a factor to prevent number roll over error (ie >65535)
      RH = 10 * diff / axefactr * Sens  ; intermediate result (multiply by 10 is to enable 0,1 resolution later if required)
      axefactr = 4096 / axefactr         ; a factor to prevent number roll over error
      RH = RH / axefactr / 10            ; final value for RH% - divided by 10 (for now) as not transmitting fractional
;      
; Step 2 = Store the current weather data values for 1 record
     WRITE addr, light                    ; save the light level value
     INC addr      
     WRITE addr, degC                   ;  save the temperature value
     INC addr 
     WRITE addr, RH                      ;  save the humidity value
     INC addr 

     IF addr > space THEN Download  ; branch from data collection when the allocated memory is full

; Step 3 = Wait for time interval to next reading
      FOR timr = 1 to mins             ;   loop for the specified number of basic time periods
        PAUSE basetime                ;   pause for the basic period of time
      NEXT timr
      
      GOTO Record                       ; continue to take weather readings
;
;
; Here when memory is full and ready to download to the PC
Download:
;
; Step 1 = Turn on LED, set up pointers, then wait for signal to transfer
      HIGH 0                                ; turn on the LED to indicate when recording phase is finished
      
      Addr = 0                       ; reset address pointer for data
      Timr = 0                       ; reset timer as record counter
      
      DO
      LOOP UNTIL Uload = 1           ; wait for command (switch) to transfer the data
      LOW 0                               ; Turn off LED
;
;Step 2 = Transmit the titles
      SERTXD("Record", COM, "Light", COM, "Temp.", COM, "Humidity", RET, LFEED)
;
NuLine:

; Step 2 =  retrieve the saved data for 1 record      
      IF addr > space THEN Finished ; branch from data transfer when all data has been sent

      READ addr, light                ; fetch the light level value
      INC addr
      READ addr, degC              ; fetch the temperature value
      INC addr
      READ addr, RH                 ; fetch the humifity value
      INC addr
      INC timr                            ; advance the time interval counter

; Step 3 = Transmit the weather data for 1 record 
      SERTXD (#timr, COM, #light, COM, #degC, COM, #RH, COM, RET, LFEED)
      PAUSE 50                     ; allow a short pause for the  data to be handled at the PC 
      GOTO Nuline

Finished:
; delete the next line to gain 3 exta bytes for data storage but will get a time-out in Datalink
; instead of the proper completion message - but still works okay.
; 
      SERTXD (0)                     ; send a null to indicate to Datalink transfer is complete
      WRITE 0,0                      ; clear first memory location to indicate download was done
;
; 
; =========================================================================
;      THE END
; =========================================================================
 

cactusface

Senior Member
Hi All,
And thanks for the replies, some have been very useful. Like MBF's suggestion regarding the StampPlot program, it's great and will also be a useful analogue debugging tool too. SAborn the radio modules look pretty smart, will give it some thought, as I'm not sure how I will be uploading the data yet. Westy your MiniWeather looks like a base to start from, but like you I don't think an 08M is goingt o have enough I/O for my needs so an 18 or 20M2 may be the answer.
Please keep them coming,
Regards
Mel.
 
B

bob @ rmb electronics

Guest
Hi Mel. We might be from the same era, and even heading in the same direction regarding the greenhouse project. Please check out my website at www.rmbelectronics.co.nz. You might find some useful information there from my experiments over the past 6 months with data logging etc. Cheers. Bob
 

cactusface

Senior Member
Hi Bob,
Thanks for that you have a few good ideas there, sure they will be useful and of help......
Regards
Mel.
 
B

bob @ rmb electronics

Guest
I'll be putting circuits & layouts on the site as soon as I have time. If you or anyone has any questions, spots mistakes, please don't hesitate to email etc.
Cheers

Bob
 
Top