Skip to content

Commit d148349

Browse files
committed
add module example comment
1 parent 4f2ef76 commit d148349

File tree

102 files changed

+233
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+233
-154
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
DHT12.cpp - Library for DHT12 sensor.
3+
v0.0.1 Beta
4+
Created by Bobadas, July 30,2016.
5+
Released into the public domain.
6+
*/
7+
#include "Arduino.h"
8+
#include "Wire.h"
9+
#include "DHT12.h"
10+
11+
DHT12::DHT12(byte scale,byte id)
12+
{
13+
if (id==0 || id>126) _id=0x5c;
14+
else _id=id;
15+
if (scale==0 || scale>3) _scale=CELSIUS;
16+
else _scale=scale;
17+
}
18+
19+
byte DHT12::read()
20+
{
21+
Wire.beginTransmission(_id);
22+
Wire.write(0);
23+
if (Wire.endTransmission()!=0) return 1;
24+
Wire.requestFrom(_id, 5);
25+
for (int i=0;i<5;i++) {
26+
datos[i]=Wire.read();
27+
};
28+
delay(50);
29+
if (Wire.available()!=0) return 2;
30+
if (datos[4]!=(datos[0]+datos[1]+datos[2]+datos[3])) return 3;
31+
return 0;
32+
}
33+
34+
float DHT12::readTemperature(byte scale)
35+
{
36+
float resultado=0;
37+
byte error=read();
38+
if (error!=0) return (float)error/100;
39+
if (scale==0) scale=_scale;
40+
switch(scale) {
41+
case CELSIUS:
42+
resultado=(datos[2]+(float)datos[3]/10);
43+
break;
44+
case FAHRENHEIT:
45+
resultado=((datos[2]+(float)datos[3]/10)*1.8+32);
46+
break;
47+
case KELVIN:
48+
resultado=(datos[2]+(float)datos[3]/10)+273.15;
49+
break;
50+
};
51+
return resultado;
52+
}
53+
54+
float DHT12::readHumidity()
55+
{
56+
float resultado;
57+
byte error=read();
58+
if (error!=0) return (float)error/100;
59+
resultado=(datos[0]+(float)datos[1]/10);
60+
return resultado;
61+
}
62+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
DHT12.h - Library for DHT12 sensor.
3+
v0.0.1 Beta
4+
Created by Bobadas, July 30,2016.
5+
Released into the public domain.
6+
*/
7+
#ifndef DHT12_h
8+
#define DHT12_h
9+
#include "Arduino.h"
10+
#include "Wire.h"
11+
12+
#define CELSIUS 1
13+
#define KELVIN 2
14+
#define FAHRENHEIT 3
15+
16+
class DHT12
17+
{
18+
public:
19+
DHT12(byte scale=0,byte id=0);
20+
float readTemperature(byte scale=0);
21+
float readHumidity();
22+
private:
23+
byte read();
24+
byte datos[5];
25+
byte _id;
26+
byte _scale;
27+
};
28+
29+
#endif
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*************************************************************
2+
Download latest Blynk library here:
3+
https://github.com/blynkkk/blynk-library/releases/latest
4+
Blynk is a platform with iOS and Android apps to control
5+
Arduino, Raspberry Pi and the likes over the Internet.
6+
You can easily build graphic interfaces for all your
7+
projects by simply dragging and dropping widgets.
8+
Downloads, docs, tutorials: http://www.blynk.cc
9+
Sketch generator: http://examples.blynk.cc
10+
Blynk community: http://community.blynk.cc
11+
Follow us: http://www.fb.com/blynkapp
12+
http://twitter.com/blynk_app
13+
Blynk library is licensed under MIT license
14+
This example code is in public domain.
15+
*************************************************************
16+
This example shows how value can be pushed from Arduino to
17+
the Blynk App.
18+
NOTE:
19+
BlynkTimer provides SimpleTimer functionality:
20+
http://playground.arduino.cc/Code/SimpleTimer
21+
App project setup:
22+
Value Display widget attached to Virtual Pin V5
23+
*************************************************************/
24+
25+
#include <M5Stack.h>
26+
#include <WiFi.h>
27+
#include <WiFiClient.h>
28+
#include <BlynkSimpleEsp32.h>
29+
#include "DHT12.h"
30+
#include <Wire.h> //The DHT12 uses I2C comunication.
31+
DHT12 dht12; //Preset scale CELSIUS and ID 0x5c.
32+
33+
// You should get Auth Token in the Blynk App.
34+
// Go to the Project Settings (nut icon).
35+
char auth[] = "auth";
36+
char ssid[] = "SSID";
37+
char pass[] = "PASSWD";
38+
39+
BlynkTimer timer;
40+
41+
// This function sends Arduino's up time every second to Virtual Pin (5).
42+
// In the app, Widget's reading frequency should be set to PUSH. This means
43+
// that you define how often to send data to Blynk App.
44+
void myTimerEvent() {
45+
// You can send any value at any time.
46+
// Please don't send more that 10 values per second.
47+
// Blynk.virtualWrite(V9, millis() / 1000)
48+
float tmp = dht12.readTemperature();
49+
float hum = dht12.readHumidity();
50+
Serial.printf("Temperatura: %2.2f*C Humedad: %0.2f%%\r\n", tmp, hum);
51+
52+
Blynk.virtualWrite(V0, tmp);
53+
Blynk.virtualWrite(V1, hum);
54+
M5.Lcd.setCursor(0, 0);
55+
M5.Lcd.setTextColor(WHITE, BLACK);
56+
M5.Lcd.setTextSize(3);
57+
M5.Lcd.printf("Temperatura:%2.1f \r\nHumedad: %2.0f%%", tmp, hum);
58+
}
59+
60+
void setup() {
61+
// Debug console
62+
M5.begin();
63+
Wire.begin();
64+
65+
//Blynk start
66+
Blynk.begin(auth, ssid, pass, "blynk.m5stack.com");
67+
68+
// Setup a function to be called every second
69+
timer.setInterval(2000L, myTimerEvent);
70+
M5.Lcd.setBrightness(10);
71+
}
72+
73+
void loop() {
74+
75+
Blynk.run();
76+
timer.run(); // Initiates BlynkTimer
77+
}
78+

examples/Fire/M5StackFire_MPU9250/M5StackFire_MPU9250.ino

Lines changed: 0 additions & 117 deletions
This file was deleted.

examples/Modules/AC-SOCKET/AC-SOCKET.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*
2+
Description:Click button B to turn on the power. Click button A to turn off the power.
3+
*/
14
#include <Arduino.h>
25
#include <M5Stack.h>
36
#include "protocol.h"

examples/Modules/BALA/BALA.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// only for mpu6886 !!!!!
2-
// first init need press BtnC and reboot to calibrate
1+
/*
2+
Description: This code only for mpu6886! first init need press BtnC and reboot to calibrate !
3+
*/
34

45
#include <M5Stack.h>
56

examples/Modules/BaseX/BaseX.ino

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
/*
2-
* @Author: Sorzn
3-
* @Date: 2019-12-12 14:33:57
4-
* @LastEditTime: 2019-12-13 16:18:07
5-
* @Description: M5Stack project
6-
* @FilePath: /M5Stack/examples/Modules/BaseX/BaseX.ino
7-
*/
2+
Description: Provide three LEGO motor drive modes。Press button B to switch the mode, button A and C control parameter value increase and decrease
3+
*/
84

95
#include <M5Stack.h>
106
#include "BaseX.h"

examples/Modules/COMMU/factory_test/COMMU_Test_A/COMMU_Test_A.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
please add MCP_CAN_LIB to your library first........
3-
MCP_CAN_LIB file in M5stack lib examples -> modules -> COMMU -> MCP_CAN_lib.rar
2+
Description: Press button A for CAN communication test, press button B for RS485 communication test.
3+
Please install library before compiling:
4+
MCP_CAN_LIB: file in M5stack lib examples -> modules -> COMMU -> MCP_CAN_lib.rar(unzip the lib zip file to the Arduino Lib path)
45
*/
56

67
#include <M5Stack.h>

examples/Modules/DHT12/DHT12.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*
2+
Description: Use DHT12 Sensor to read temperature, humidity and display the data on the screen.
3+
*/
14
#include <M5Stack.h>
25
#include "DHT12.h"
36
#include <Wire.h> //The DHT12 uses I2C comunication.

examples/Modules/GPS/FullExample/FullExample.ino renamed to examples/Modules/GPS_NEO_M8N/FullExample/FullExample.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
please add TinyGPSPlus to your library first........
3-
TinyGPSPlus file in M5stack lib examples -> modules -> GPS -> TinyGPSPlus-1.0.2.zip
2+
Description: Use GPS Module to get the coordinate data and time of the current location.
3+
Please install library before compiling:
4+
TinyGPSPlus: file in M5stack lib examples -> modules -> GPS -> TinyGPSPlus-1.0.2.zip (unzip the lib zip file to the Arduino Lib path)
45
*/
56

67
#include <M5Stack.h>

0 commit comments

Comments
 (0)