E707 Basic NodeMCU-V2 Shield Library  1.0
basic-nodemcuv2-shield.h
Go to the documentation of this file.
1 
14 #ifndef BASIC_NODEMCU_V2_DEV_SHIELD
15 #define BASIC_NODEMCU_V2_DEV_SHIELD
16 
17 #include <Arduino.h>
18 
19 // This library should only be included if using a NodeMCU V2 (as it's for
20 // keyword definitions and examples. We can't directly check if the board
21 // is specifically a V2, but we can do the next best thing and check if it's
22 // a NodeMCU at all.
23 #if !defined(ARDUINO_ESP8266_NODEMCU)
24 #error Only the NodeMCU V2 board is supported for this program
25 #endif
26 
27 // Define the 7-segment pins
29 #define SHIELD_SEGA 15
31 #define SHIELD_SEGB 13
33 #define SHIELD_SEGC 12
35 #define SHIELD_SEGD 4
37 #define SHIELD_SEGE 0
39 #define SHIELD_SEGG 2
41 #define SHIELD_SEGF 14
42 // Define the RGB LED's pins
44 #define SHIELD_LEDR SHIELD_SEGA
46 #define SHIELD_LEDG SHIELD_SEGD
48 #define SHIELD_LEDB SHIELD_SEGG
49 // Define the button's pins
51 #define SHIELD_BT1 16
53 #define SHIELD_BT2 5
55 #define SHIELD_BT3 10
56 
60 void shieldSetPinout(void);
61 
81 void shieldDisplayDigit(int digit);
82 
89  public:
94  float getTemperatureC(void);
99  float getTemperatureF(void);
100  protected:
106  int offset;
113 };
114 
120 class LM35: public _TempSensor{
121  public:
122  LM35(){
123  offset = 0;
124  divide_by = 10;
125  }
126 };
127 
133 class LM36: public _TempSensor{
134  public:
135  LM36(){
136  offset = 500;
137  divide_by = 10;
138  }
139 };
140 
141 #endif
void shieldSetPinout(void)
Set the pin mode (INPUT or OUTPUT) for all relavent pins for the shield's periferals.
Definition: basic-nodemcuv2-shield.cpp:30
void shieldDisplayDigit(int digit)
Set a digit (between 0 and 9) on the 7 segment display of the shield.
Definition: basic-nodemcuv2-shield.cpp:46
The LM35 temp-sensor class.
Definition: basic-nodemcuv2-shield.h:120
LM35()
Definition: basic-nodemcuv2-shield.h:122
The LM36 temp-sensor class.
Definition: basic-nodemcuv2-shield.h:133
LM36()
Definition: basic-nodemcuv2-shield.h:135
Base class for any temperature sensor.
Definition: basic-nodemcuv2-shield.h:88
float getTemperatureC(void)
Function to read the temperature of a temp-sensor and return it in Celcius.
Definition: basic-nodemcuv2-shield.cpp:66
int offset
The voltage offset in mV from the temperature sensor.
Definition: basic-nodemcuv2-shield.h:106
int divide_by
The voltage division in mV from the temperature sensor.
Definition: basic-nodemcuv2-shield.h:112
float getTemperatureF(void)
Function to read the temperature of a temp-sensor and return it in Fahrenheit.
Definition: basic-nodemcuv2-shield.cpp:76