A simple WIP that logs data from a Grove sensor, and can send and receive information over USB and SMS.
Dependencies: DHT DS_1337 SDFileSystem USBDevice mbed
readme.md@0:2df78a4443cd, 2016-04-10 (annotated)
- Committer:
- Joseph Radford
- Date:
- Sun Apr 10 15:47:33 2016 +1000
- Revision:
- 0:2df78a4443cd
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Joseph Radford |
0:2df78a4443cd | 1 | This project is written for the Arch GPRS V2. |
Joseph Radford |
0:2df78a4443cd | 2 | |
Joseph Radford |
0:2df78a4443cd | 3 | It aims to provide a convenient method of alerting a user of humidity. However, the grove DHT22 |
Joseph Radford |
0:2df78a4443cd | 4 | sensor could easily be replaced with another Grove sensor with small changes to the code. |
Joseph Radford |
0:2df78a4443cd | 5 | |
Joseph Radford |
0:2df78a4443cd | 6 | Directories: |
Joseph Radford |
0:2df78a4443cd | 7 | * DHT |
Joseph Radford |
0:2df78a4443cd | 8 | - for accessing the grove |
Joseph Radford |
0:2df78a4443cd | 9 | * DS_1337 |
Joseph Radford |
0:2df78a4443cd | 10 | - interface to the real time clock (which is a separate chip, i.e. not part of the micro) |
Joseph Radford |
0:2df78a4443cd | 11 | * mbed |
Joseph Radford |
0:2df78a4443cd | 12 | - all mbed libraries |
Joseph Radford |
0:2df78a4443cd | 13 | * SDFileSystem |
Joseph Radford |
0:2df78a4443cd | 14 | - for accessing the SD card. You need to be careful to import the right one (link to my blog) |
Joseph Radford |
0:2df78a4443cd | 15 | * USBDevice |
Joseph Radford |
0:2df78a4443cd | 16 | - interface to serial comms over USB (talk to it from a PC) |
Joseph Radford |
0:2df78a4443cd | 17 | * Handlers |
Joseph Radford |
0:2df78a4443cd | 18 | - this is where almost all of my code lives |
Joseph Radford |
0:2df78a4443cd | 19 | |
Joseph Radford |
0:2df78a4443cd | 20 | Handlers |
Joseph Radford |
0:2df78a4443cd | 21 | The handlers have the same structure (although they do not inherit from a common base class, but they should). They have a run function, which is a state machine called from the main while loop in main.cpp. This will run continuous routines such as polling and checking if a request has been raised. |
Joseph Radford |
0:2df78a4443cd | 22 | |
Joseph Radford |
0:2df78a4443cd | 23 | A request might be raised through a common request interface that passes an enum. However this might have to be more specific. Either way, the request is then handled in the state machine. |
Joseph Radford |
0:2df78a4443cd | 24 | |
Joseph Radford |
0:2df78a4443cd | 25 | GroveDht22 |
Joseph Radford |
0:2df78a4443cd | 26 | * Takes a measurement from the DHT22 hardware at a set interval |
Joseph Radford |
0:2df78a4443cd | 27 | * On success, sends to measurement handler |
Joseph Radford |
0:2df78a4443cd | 28 | |
Joseph Radford |
0:2df78a4443cd | 29 | SdHandler |
Joseph Radford |
0:2df78a4443cd | 30 | * Initialises and polls the SD card, checks for errors, etc |
Joseph Radford |
0:2df78a4443cd | 31 | * Receives requests for writing a system message to the log, or writing a measurement to CSV |
Joseph Radford |
0:2df78a4443cd | 32 | |
Joseph Radford |
0:2df78a4443cd | 33 | UsbComms |
Joseph Radford |
0:2df78a4443cd | 34 | * Checks to see if there is a connection to a PC |
Joseph Radford |
0:2df78a4443cd | 35 | * Receives requests to send messages to PC |
Joseph Radford |
0:2df78a4443cd | 36 | * Diverts incoming messages from PC to appropriate handlers |
Joseph Radford |
0:2df78a4443cd | 37 | |
Joseph Radford |
0:2df78a4443cd | 38 | MeasurementHandler |
Joseph Radford |
0:2df78a4443cd | 39 | * GroveDht22 sends a measurement to this and it decides what to do with it |
Joseph Radford |
0:2df78a4443cd | 40 | * Stores values for schedules, thresholds, last measurements |
Joseph Radford |
0:2df78a4443cd | 41 | * Decides if a new measurement should be sent over SMS, SD |
Joseph Radford |
0:2df78a4443cd | 42 | * Receives a request for last measurement, state, etc, from either UsbComms or SmsHandler |
Joseph Radford |
0:2df78a4443cd | 43 | |
Joseph Radford |
0:2df78a4443cd | 44 | GprsHandler (WIP) |
Joseph Radford |
0:2df78a4443cd | 45 | * Checks to see if there are any incoming messages, directs them appropriately |
Joseph Radford |
0:2df78a4443cd | 46 | * Gets requests from other handlers to send an SMS |
Joseph Radford |
0:2df78a4443cd | 47 | |
Joseph Radford |
0:2df78a4443cd | 48 | |
Joseph Radford |
0:2df78a4443cd | 49 | |
Joseph Radford |
0:2df78a4443cd | 50 | |
Joseph Radford |
0:2df78a4443cd | 51 | To do: |
Joseph Radford |
0:2df78a4443cd | 52 | * Complete basic GprsHandler |
Joseph Radford |
0:2df78a4443cd | 53 | * Set a threshold for humidity (hardcoded to start with) and send messages at this threshold |
Joseph Radford |
0:2df78a4443cd | 54 | * Avoid sending more than x messages per y time (so don't get bombarded with messages) |
Joseph Radford |
0:2df78a4443cd | 55 | * Send messages to a list of numbers, not just one |
Joseph Radford |
0:2df78a4443cd | 56 | * Send messages on a schedule, e.g. send current humidity and temp once a day, so user knows it's OK |
Joseph Radford |
0:2df78a4443cd | 57 | * Make the above three points configurable over USB (threshold, time off, list of numbers, schedule) |
Joseph Radford |
0:2df78a4443cd | 58 | * Respond to certain messages, over SMS, to configure and make status known. |
Joseph Radford |
0:2df78a4443cd | 59 | * Make a base class for handlers to inherit from, so that interface stays consistent |