Hello, the earth sensor has an digital and an analog output pin. All examples are focused on analog reading.
Can someone provide an example for digital reading?
Posts made by herb
-
earth sensor module - looking for an example for digital reading
-
RE: How to get an IMU MPU6886 work at M5Paper?
I switched over to this library https://github.com/tanakamasayuki/I2C_MPU6886
There is no modification of the EPD Library necessary. Now it works with there example code.
-
How to get an IMU MPU6886 work at M5Paper?
I tried to get an M5 Stack MPU6886 to work on my M5Paper Unit. But without success.
What did I do?
Connected the IMU MPU6886 to Port A.
modified the example Code from M5 to the following
#include <M5EPD.h> #include "time.h" #ifdef __cplusplus extern "C" { #include "IMU_6886.h" } #endif IMU_6886 imu6886; float accX = 0; float accY = 0; float accZ = 0; float gyroX = 0; float gyroY = 0; float gyroZ = 0; char string_buff[40]; float temp = 0; void setup() { // put your setup code here, to run once: M5.begin(); imu6886.Init(25, 32); } void loop() { // put your main code here, to run repeatedly: imu6886.getGyroData(&gyroX,&gyroY,&gyroZ); Serial.print("gyroX: "); Serial.println(gyroX); imu6886.getAccelData(&accX,&accY,&accZ); Serial.print("accX: "); Serial.println(accX); imu6886.getTempData(&temp); Serial.print("Temp: "); Serial.println(temp); delay(1000); }
At the first line I changed M5EPD.h instead of M5Stack.h and changed I2C Port to 25/32
The same within IMU_6886.cpp .
Comparing M5EPD.h to M5Stack.h, the M5EPD has no I2C Class Reference to CommUtil .
So I added these two lines into M5EPD.h together with an #include "utility/CommUtil.h" at the beginning of the code.Button BtnR = Button(M5EPD_KEY_RIGHT_PIN, true, 10); // I2C CommUtil I2C = CommUtil(); M5EPD_Driver EPD = M5EPD_Driver();
CommUtil.h and CommUtil.cpp I copied from M5Stack/src/utility to the corresponding path of M5EPD.
Within CommUtil.cpp I changed the include also to ../M5EPD.h".After doing these steps the Compiling process ends without any errors and I can upload the sketch to the unit.
Looking at the serial monitor it does not display any valid values. Only 25 Temperature but it's not changing and the other values are zero.
Doeas anyone have an example code for IMU6886 running together with M5 Paper or can give me some hints to get the example code for m5Stack working on M5Paper?
Regards Herb
-
RE: Problem with M5.shutdown and deep sleep - M5.shutdown example does not run anymore
Hello Felix, I found the reason why the program has always stopped after "// until this point all is ok" . :-)
It was the "sleep" before and afterSerial.println("Boot number: " + String(bootCount));
It should only be a delay for better debugging and watching on the serial monitor.
Changing it to delay() all works fine including the shutdown and reboot. Hooray.BTW.
Your mentioned preferences.begin was already in the code at the beginning. The preferences.end() I placed at the end.
Thanks for this advice.The serial.println's were only for debugging to find the reason why the program stops before the shutdown.
Because the shutdown statement was never reached, it didn't matter if it was plugged into the usb or not.Now I'm happy. Regards Herb
-
RE: Problem with M5.shutdown and deep sleep - M5.shutdown example does not run anymore
Thank you Felix,
long-pressing the button on the back in battery mode doesn't change anything.I'm really frustrated with this device. The whole behavior is no longer understandable - not only with the shutdown function.
After switching back to my real application, an adtl. problem occurs that I can't explain.
This is a snippet of my code:
... M5.RTC.getTime(&RTCtime); M5.RTC.getDate(&RTCDate); sprintf(timeStrbuff,"%02d.%02d.%d --- %02d:%02d", RTCDate.day,RTCDate.mon,RTCDate.year, RTCtime.hour,RTCtime.min); status_oben.drawString(timeStrbuff, 150, 17); Serial.print("Zeit/Datum im RTC: "); Serial.println (timeStrbuff); uint32_t vol = M5.getBatteryVoltage(); float vol_f = vol / 1000.0f; status_oben.drawFloat(vol_f,2,630,17); status_unten.drawNumber(bootCount,630,17); status_oben.pushCanvas(130,27,UPDATE_MODE_GC16); status_unten.drawString("Ich gehe gleich schlafen", 150, 17); status_unten.pushCanvas(130,457,UPDATE_MODE_GC16); // until this point all is ok sleep(1000); Serial.println("Boot number: " + String(bootCount)); sleep(10000); if (bootCount > 1) { status_unten.drawString("Ich gehe schlafen", 150, 17); status_unten.pushCanvas(130,457,UPDATE_MODE_GC16); preferences.putUInt("Boot",1); Serial.println("Ich gehe schlafen"); delay(5000); M5.shutdown(30); } } void loop() { status_unten.drawString("In der Schleife", 150, 17); status_unten.pushCanvas(130,457,UPDATE_MODE_GC16); if (M5.BtnP.wasPressed()) { delay(1000); M5.shutdown(60); // shut donw now and wake up after 60 seconds } M5.update(); delay(100); }
Within the very first run with bootCount=0 it should go until the loop, so I can initiate the first shutdown manually after disconnecting from usb.
bootCount is stored as a preference, so it would not be deleted after the next reboot and will incremented at the beginning of every restart.After this initial restart the program should never reach the loop, because the condition should be met.
But since the shutdown() doesn't work bootCount was incremented every time. I can see on the display that the bootCount keeps increasing.
So I realized that the code within the if condition was never processed.Because I did not understand why, I went backwards within my code and placed some debugging lines in it.
The string "Ich gehe gleich schlafen" is still being written to the display. If the device is still connected to the PC the next line after the sleep should also be executed.
But that doesn't happen. I really can't understand why...BTW: the brownout message also occurs when the device has been charged for several hours.
Thanks
Herb -
RE: Problem with M5.shutdown and deep sleep - M5.shutdown example does not run anymore
Hello Felix,
thanks for your support.I tried your hints, but unfortunately without success. Due to the lack of documentation, it's not clear to me how long I have to press the button on the back.
Whether I press briefly or long, nothing changes in the behavior. The device will not reboot.
The text on the display is only updated when I connect it to the USB again, i.e. the program restarts again.In the serial monitor I can observe sometimes the following:
Brownout detector was triggered
M5EPD initializing...OKTaking your other hint into account, I replaced the loop part of the program as follows to disable GPIO_hold
void loop()
{
if(M5.BtnP.wasPressed()){
canvas.drawString("I'm going to sleep.zzzZZZ~", 45, 550);
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
gpio_hold_dis((gpio_num_t)M5EPD_MAIN_PWR_PIN);
delay(1000);
M5.shutdown(5);
}
M5.update();
delay(100);
}That doesn't change the behavior either. No programatic wakeup is possible :-(
Only if I connect the device back to usb it will restart again.Is it possible to reset the whole ESP device with all of its components and registers incl. RTC to factory defaults?
Thank you for any advice.
Herb
-
Problem with M5.shutdown and deep sleep - M5.shutdown example does not run anymore
Hi all,
after I received the m5Paper a few days ago, I was very disappointed with its power consumption. With a small test program that should simply display the actual time updated every minute, the battery was low after a few hours using only EPD.Sleep(). I found several posts describing the power and battery management of the M5Paper as very poor from design. While searching this forum i came across the two ways how to save power consumption.- M5.shutdown which only works if the M5Paper is not connected to USB Power Supply
- esp_deep_sleep_start() with esp_sleep_enable_timer_wakeup and gpio_hold_en((gpio_num_t)M5EPD_MAIN_PWR_PIN) before.
Because I wanted to compare these two ways in there ability to save power better I first tested the M5.shutdown example from m5-docs.
#include <M5EPD.h>
M5EPD_Canvas canvas(&M5.EPD);
void setup()
{
M5.begin();
M5.EPD.SetRotation(90);
M5.TP.SetRotation(90);
M5.EPD.Clear(true);
M5.RTC.begin();
canvas.createCanvas(540, 960);
canvas.setTextSize(3);
canvas.drawString("Press PWR Btn for sleep!", 45, 350);
canvas.drawString("after 5 sec wakeup!", 70, 450);
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
}void loop()
{
if(M5.BtnP.wasPressed()){
canvas.drawString("I'm going to sleep.zzzZZZ~", 45, 550);
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
delay(1000);
M5.shutdown(5);
}
M5.update();
delay(100);
}After that was successful, i did several tests with the esp_deep_sleep_start() function.
Since these did not lead to the goal, I wanted to expand the M5.shutdown example more to my requirements.
Now I had to realize that this simple example no longer runs on my M5Paper.
After pressing the button, the message "I'm going to slepp.zzzZZZ" appears in the display, but nothing happens.
It makes no difference whether the M5paper is connected to the USB or not.Is it possible that the previous tests with gpio_hold_en((gpio_num_t)M5EPD_MAIN_PWR_PIN) set something permanently,
which is now interfering with the execution of m5.shutdown and its waking up?Any hints for solving this problem?
Thx