PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266

Dependencies:   mbed

Committer:
skrawool
Date:
Mon Dec 05 16:39:27 2016 +0000
Revision:
0:3954a906acc2
PIR grove sensor that sends the sensed data to thingspeak through the wifi module ESP 8266

Who changed what in which revision?

UserRevisionLine numberNew contents of line
skrawool 0:3954a906acc2 1 /* mbed Microcontroller Library
skrawool 0:3954a906acc2 2 * Copyright (c) 2006-2013 ARM Limited
skrawool 0:3954a906acc2 3 *
skrawool 0:3954a906acc2 4 * Licensed under the Apache License, Version 2.0 (the "License");
skrawool 0:3954a906acc2 5 * you may not use this file except in compliance with the License.
skrawool 0:3954a906acc2 6 * You may obtain a copy of the License at
skrawool 0:3954a906acc2 7 *
skrawool 0:3954a906acc2 8 * http://www.apache.org/licenses/LICENSE-2.0
skrawool 0:3954a906acc2 9 *
skrawool 0:3954a906acc2 10 * Unless required by applicable law or agreed to in writing, software
skrawool 0:3954a906acc2 11 * distributed under the License is distributed on an "AS IS" BASIS,
skrawool 0:3954a906acc2 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
skrawool 0:3954a906acc2 13 * See the License for the specific language governing permissions and
skrawool 0:3954a906acc2 14 * limitations under the License.
skrawool 0:3954a906acc2 15 */
skrawool 0:3954a906acc2 16 #ifndef MBED_RAW_SERIAL_H
skrawool 0:3954a906acc2 17 #define MBED_RAW_SERIAL_H
skrawool 0:3954a906acc2 18
skrawool 0:3954a906acc2 19 #include "platform/platform.h"
skrawool 0:3954a906acc2 20
skrawool 0:3954a906acc2 21 #if DEVICE_SERIAL
skrawool 0:3954a906acc2 22
skrawool 0:3954a906acc2 23 #include "drivers/SerialBase.h"
skrawool 0:3954a906acc2 24 #include "hal/serial_api.h"
skrawool 0:3954a906acc2 25
skrawool 0:3954a906acc2 26 namespace mbed {
skrawool 0:3954a906acc2 27 /** \addtogroup drivers */
skrawool 0:3954a906acc2 28 /** @{*/
skrawool 0:3954a906acc2 29
skrawool 0:3954a906acc2 30 /** A serial port (UART) for communication with other serial devices
skrawool 0:3954a906acc2 31 * This is a variation of the Serial class that doesn't use streams,
skrawool 0:3954a906acc2 32 * thus making it safe to use in interrupt handlers with the RTOS.
skrawool 0:3954a906acc2 33 *
skrawool 0:3954a906acc2 34 * Can be used for Full Duplex communication, or Simplex by specifying
skrawool 0:3954a906acc2 35 * one pin as NC (Not Connected)
skrawool 0:3954a906acc2 36 *
skrawool 0:3954a906acc2 37 * @Note Synchronization level: Not protected
skrawool 0:3954a906acc2 38 *
skrawool 0:3954a906acc2 39 * Example:
skrawool 0:3954a906acc2 40 * @code
skrawool 0:3954a906acc2 41 * // Send a char to the PC
skrawool 0:3954a906acc2 42 *
skrawool 0:3954a906acc2 43 * #include "mbed.h"
skrawool 0:3954a906acc2 44 *
skrawool 0:3954a906acc2 45 * RawSerial pc(USBTX, USBRX);
skrawool 0:3954a906acc2 46 *
skrawool 0:3954a906acc2 47 * int main() {
skrawool 0:3954a906acc2 48 * pc.putc('A');
skrawool 0:3954a906acc2 49 * }
skrawool 0:3954a906acc2 50 * @endcode
skrawool 0:3954a906acc2 51 */
skrawool 0:3954a906acc2 52 class RawSerial: public SerialBase {
skrawool 0:3954a906acc2 53
skrawool 0:3954a906acc2 54 public:
skrawool 0:3954a906acc2 55 /** Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud.
skrawool 0:3954a906acc2 56 *
skrawool 0:3954a906acc2 57 * @param tx Transmit pin
skrawool 0:3954a906acc2 58 * @param rx Receive pin
skrawool 0:3954a906acc2 59 * @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
skrawool 0:3954a906acc2 60 *
skrawool 0:3954a906acc2 61 * @note
skrawool 0:3954a906acc2 62 * Either tx or rx may be specified as NC if unused
skrawool 0:3954a906acc2 63 */
skrawool 0:3954a906acc2 64 RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
skrawool 0:3954a906acc2 65
skrawool 0:3954a906acc2 66 /** Write a char to the serial port
skrawool 0:3954a906acc2 67 *
skrawool 0:3954a906acc2 68 * @param c The char to write
skrawool 0:3954a906acc2 69 *
skrawool 0:3954a906acc2 70 * @returns The written char or -1 if an error occured
skrawool 0:3954a906acc2 71 */
skrawool 0:3954a906acc2 72 int putc(int c);
skrawool 0:3954a906acc2 73
skrawool 0:3954a906acc2 74 /** Read a char from the serial port
skrawool 0:3954a906acc2 75 *
skrawool 0:3954a906acc2 76 * @returns The char read from the serial port
skrawool 0:3954a906acc2 77 */
skrawool 0:3954a906acc2 78 int getc();
skrawool 0:3954a906acc2 79
skrawool 0:3954a906acc2 80 /** Write a string to the serial port
skrawool 0:3954a906acc2 81 *
skrawool 0:3954a906acc2 82 * @param str The string to write
skrawool 0:3954a906acc2 83 *
skrawool 0:3954a906acc2 84 * @returns 0 if the write succeeds, EOF for error
skrawool 0:3954a906acc2 85 */
skrawool 0:3954a906acc2 86 int puts(const char *str);
skrawool 0:3954a906acc2 87
skrawool 0:3954a906acc2 88 int printf(const char *format, ...);
skrawool 0:3954a906acc2 89
skrawool 0:3954a906acc2 90 protected:
skrawool 0:3954a906acc2 91
skrawool 0:3954a906acc2 92 /** Acquire exclusive access to this serial port
skrawool 0:3954a906acc2 93 */
skrawool 0:3954a906acc2 94 virtual void lock(void);
skrawool 0:3954a906acc2 95
skrawool 0:3954a906acc2 96 /** Release exclusive access to this serial port
skrawool 0:3954a906acc2 97 */
skrawool 0:3954a906acc2 98 virtual void unlock(void);
skrawool 0:3954a906acc2 99 };
skrawool 0:3954a906acc2 100
skrawool 0:3954a906acc2 101 } // namespace mbed
skrawool 0:3954a906acc2 102
skrawool 0:3954a906acc2 103 #endif
skrawool 0:3954a906acc2 104
skrawool 0:3954a906acc2 105 #endif
skrawool 0:3954a906acc2 106
skrawool 0:3954a906acc2 107 /** @}*/