Example program to create IoT devices for a local network, which connect to a local server.

Dependencies:   WebSocketClient WiflyInterface mbed messages

This code is used in the second part of my Internet of Things (IoT) blog post available here. The code is fairly simple, but its real value is in its reliability. I have worked hard to try to make the wireless connection as reliable, and as fast, as possible. There are a few lines of code that must be modified before it will work correctly, and those are described in the following Wiki pages.

It is designed to work with a Python WebSocket Server running on a PC, the source code of which is available here.

Once operating with the server, each microcontroller, or IoT device, will broadcast a counter and its internal temperature to your WebSocket Server.

Committer:
defrost
Date:
Thu Nov 24 16:54:56 2016 +0000
Revision:
8:5afd599875e4
Parent:
6:424e225d2a91
- Updated messages.h to its own library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
defrost 6:424e225d2a91 1 /**
defrost 6:424e225d2a91 2 * @author Damien Frost
defrost 6:424e225d2a91 3 *
defrost 6:424e225d2a91 4 * @section LICENSE
defrost 6:424e225d2a91 5 *
defrost 6:424e225d2a91 6 * Copyright (c) 2016 Damien Frost
defrost 6:424e225d2a91 7 *
defrost 6:424e225d2a91 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
defrost 6:424e225d2a91 9 * of this software and associated documentation files (the "Software"), to deal
defrost 6:424e225d2a91 10 * in the Software without restriction, including without limitation the rights
defrost 6:424e225d2a91 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
defrost 6:424e225d2a91 12 * copies of the Software, and to permit persons to whom the Software is
defrost 6:424e225d2a91 13 * furnished to do so, subject to the following conditions:
defrost 6:424e225d2a91 14 *
defrost 6:424e225d2a91 15 * The above copyright notice and this permission notice shall be included in
defrost 6:424e225d2a91 16 * all copies or substantial portions of the Software.
defrost 6:424e225d2a91 17 *
defrost 6:424e225d2a91 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
defrost 6:424e225d2a91 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
defrost 6:424e225d2a91 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
defrost 6:424e225d2a91 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
defrost 6:424e225d2a91 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
defrost 6:424e225d2a91 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
defrost 6:424e225d2a91 24 * THE SOFTWARE.
defrost 6:424e225d2a91 25 *
defrost 6:424e225d2a91 26 * @file "ADC.h"
defrost 6:424e225d2a91 27 *
defrost 6:424e225d2a91 28 * @section DESCRIPTION
defrost 6:424e225d2a91 29 * Configuration of the ADC for the IoT example.
defrost 6:424e225d2a91 30 *
defrost 6:424e225d2a91 31 */
defrost 1:4403f2ed1c1f 32
defrost 1:4403f2ed1c1f 33 #ifndef IQ_ADC_H
defrost 1:4403f2ed1c1f 34 #define IQ_ADC_H
defrost 1:4403f2ed1c1f 35
defrost 1:4403f2ed1c1f 36 // Properties of the internal temperature sensor:
defrost 1:4403f2ed1c1f 37 #define IT_VMIN 1.7f
defrost 1:4403f2ed1c1f 38 #define IT_VMAX 3.3f
defrost 1:4403f2ed1c1f 39 #define IT_AVG_SLOPE 0.0025f
defrost 1:4403f2ed1c1f 40 #define IT_V25 0.76f
defrost 1:4403f2ed1c1f 41
defrost 1:4403f2ed1c1f 42 #define ADC_MAX 4095.0f
defrost 1:4403f2ed1c1f 43
defrost 2:7abdaa5a9209 44 #define STARTADCCONVERSION ADC1->CR2 |= ADC_CR2_SWSTART // This command starts the ADC Conversion.
defrost 2:7abdaa5a9209 45 #define ADCCONVERSIONCOMPLETE ((ADC1->SR & ADC_SR_EOC) > 0) // This command returns true when the ADC conversion is complete.
defrost 1:4403f2ed1c1f 46
defrost 1:4403f2ed1c1f 47 void ConfigureADC(void);
defrost 1:4403f2ed1c1f 48
defrost 1:4403f2ed1c1f 49
defrost 1:4403f2ed1c1f 50 #endif /* IQ_ADC_H */