Skip to content

Commit 15fde31

Browse files
committed
clarified wiring scheme conventions, added voltage measurements for ESP8266
1 parent 946e0bf commit 15fde31

File tree

4 files changed

+137
-1
lines changed

4 files changed

+137
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright © 2017 Simon Rupf
3+
*
4+
* This file is part of MonSens.
5+
*
6+
* MonSens is free software: you can redistribute it and/or modify it under the
7+
* terms of the GNU Lesser General Public License as published by the Free
8+
* Software Foundation, either version 3 of the License, or (at your option)
9+
* any later version.
10+
*
11+
* MonSens is distributed in the hope that it will be useful, but WITHOUT ANY
12+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14+
* more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with MonSens. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
/**
21+
* @file
22+
* @author Simon Rupf <[email protected]>
23+
* @brief MonSens implementation of the ESP8266 internal voltage sensor.
24+
*
25+
* The ESP8266 can measure its internal voltage (around 2.7 - 3.1 V) when the
26+
* analog pin A0 is left unconnected.
27+
*/
28+
29+
#include <MonSens_ESP8266_Vcc.h>
30+
31+
/**
32+
* After it is registered in the communicator, the sensor gets initialized.
33+
*/
34+
void MonSens_ESP8266_Vcc::init() {
35+
}
36+
37+
/**
38+
* Take a sensor reading, to be returned by the communicator.
39+
*/
40+
bool MonSens_ESP8266_Vcc::measure(const char* input) {
41+
if (strstr(input, "V") != NULL) {
42+
reading = (float) ESP.getVcc() / 1000.0;
43+
return true;
44+
}
45+
return false;
46+
}
47+
48+
/**
49+
* If no sensor supports the input value, usage instructions are collected.
50+
*/
51+
const __FlashStringHelper* MonSens_ESP8266_Vcc::usage() {
52+
return F("V - voltage at the ESP8266 chip");
53+
}
54+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright © 2017 Simon Rupf
3+
*
4+
* This file is part of MonSens.
5+
*
6+
* MonSens is free software: you can redistribute it and/or modify it under the
7+
* terms of the GNU Lesser General Public License as published by the Free
8+
* Software Foundation, either version 3 of the License, or (at your option)
9+
* any later version.
10+
*
11+
* MonSens is distributed in the hope that it will be useful, but WITHOUT ANY
12+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14+
* more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with MonSens. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
/**
21+
* @file
22+
* @author Simon Rupf <[email protected]>
23+
* @brief MonSens implementation of the ESP8266 internal voltage sensor.
24+
*
25+
* The ESP8266 can measure its internal voltage (around 2.7 - 3.1 V) when the
26+
* analog pin A0 is left unconnected.
27+
*/
28+
29+
#ifndef MONSENS_ESP8266_VCC_H
30+
#define MONSENS_ESP8266_VCC_H
31+
32+
#include <MonSens.h>
33+
34+
/* as of Arduino IDE 1.6.8, the below sequence doesn't work:
35+
ADC_MODE(ADC_VCC);
36+
*/
37+
38+
/**
39+
* MonSens implementation for a Photoresistor
40+
*/
41+
class MonSens_ESP8266_Vcc: public IMonSens_Sensor {
42+
public:
43+
/**
44+
* After it is registered in the communicator, the sensor gets initialized.
45+
*/
46+
void init();
47+
48+
/**
49+
* Take a sensor reading, to be returned by the communicator.
50+
*/
51+
bool measure(const char* input);
52+
53+
/**
54+
* If no sensor supports the input value, usage instructions are collected.
55+
*/
56+
const __FlashStringHelper* usage();
57+
};
58+
59+
#endif
60+

sensors/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,25 @@ easier to use one of the many breakout boards available online. These will
88
package the sensor with all the required components (usually in SMD formats) and
99
leads out clearly labelled pins to solder it onto the MCU with a few short wires
1010
or to stick it to a breadboard for testing.
11+
12+
Illustrations
13+
-------------
14+
15+
Included with the supported sensors description are Fritzing project files that
16+
show working examples for wiring these to the various MCUs. You may extend these
17+
with your own modifications.
18+
19+
As a convention the following wire colors are used throughout these sketches:
20+
21+
- power:
22+
- red: 3.3 V (ESP8266) / 5 V (DigiSpark)
23+
- black: ground
24+
- SPI bus:
25+
- orange: serial clock (SCLK or SCK)
26+
- yellow: master input, slave output (MISO or SDO on the sensor side)
27+
- green: master output, slave input (MOSI or SDI on the sensor side)
28+
- blue: chip select (CS or SS for slave select)
29+
- I²C bus:
30+
- brown: signal clock (SCL)
31+
- white: signal data (SDA)
32+

wireless/ESP8266/initialize-sketchbooks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ done
4444
# MonSens libraries, excluding DigiSpark (those only works when the Arduino IDE
4545
# is set to that board)
4646
cp -r "$SELF_PATH/../../libraries/MonSens" "$LIBRARY_PATH/"
47-
rm "$LIBRARY_PATH/DigiSpark.*"
47+
rm "$LIBRARY_PATH/MonSens/MonSens_DigiSpark"*
4848

4949
# MonSens sketches
5050
for SKETCH in monsens-esp8266-example

0 commit comments

Comments
 (0)