Ok - I found. You have to use #include "M5_ENV.h"
and include the library M5UNIT-ENV in Arduino.
Posts made by aafortinet
-
RE: ENV III unit on M5Stack CoreInk
-
ENV III unit on M5Stack CoreInk
Hi,
Very n00b question, but how do I use the ENV III sensor on CoreInk? T
From sample code https://docs.m5stack.com/en/unit/envIII, I tried this butUNIT_ENV.h
does not exist on CoreInk#include "M5CoreInk.h" #include "UNIT_ENV.h" SHT3X sht30; QMP6988 qmp6988;
Same
#include "M5_ENV.h"
does not exist either.
Thanks. -
Erasing the EEPROM of a m5CoreInk
Hello,
I have written data in the EEPROM of a M5 CoreInk, usingEEPROM.write()
.
How can I erase the entire area? Of course, I can write the area with zeros, but this is going to be long. Is there something likeEEPROM.clear()
or anything?
Thanks -
RE: Bad Ultrasonic distance measure
@aafortinet after more measures, the ultrasonic sensors seems to work correctly. It's just that (1) the units in my program were wrong, (2) it does not work below 2cm and above 150 and gives erroneous answer then. This range isn't very big, and typically I measured 2m.
-
Bad Ultrasonic distance measure
My ultrasonic sensor reports a bad distance. For example, I measure to the ceiling of the room, and it reports 80 cm where it is above 2 meters.
I have:
- a Ultrasonic range sensor
- a M5 CoreInk. The sensor is connected on GPIO 32 and 33.
This is how I do it. Can you tell me what's wrong or an idea how to debug? thx
#define M5_I2C_ADDR_ULTRASONIC 0x57 Ink_Sprite InkPageSprite(&M5.M5Ink); void setup() { M5.begin(); //Init CoreInk. digitalWrite(LED_EXT_PIN,LOW); if( !M5.M5Ink.isInit()) //Init CoreInk screen. { Serial.printf("[-] M5Ink init failed"); while (1) delay(100); } Wire.begin(32,33); Serial.printf("[+] Wire begin done\n"); M5.M5Ink.clear(); //Clear screen. Serial.printf("[+] Clearing eInk screen\n"); delay(1000); if( InkPageSprite.creatSprite(0,0,200,200,true) != 0 ){ Serial.printf("[-] Ink Sprite create failed"); } } void loop() { static float distance = 0; distance = readDistance(); Serial.printf("Distance=%.1f cm\n",distance); if ((distance < 150) && (distance > 0)) { char buffer[30]; sprintf(buffer,"%.1f cm",distance); InkPageSprite.drawString(15,150,buffer,&AsciiFont24x48); InkPageSprite.pushSprite(); } // Sleep delay(2000); }
-
RE: M5core Ink battery duration
My battery duration seems longer: the program I ran Tuesday is still running "more or less". By "more or less" I mean that sometimes I find the M5 with a black screen, and I have to press the POWER ON button to wake it up. I shouldn't need to do that, so this strange. But at least with the counter displayed on the screen, I know my program ran for 72 hours (indeed more or less 3 days).
Difference with yours:
- I do not connect to a Wifi / Internet (which usually consumes battery quite a lot)
-
RE: M5core Ink battery duration
@eddie2070 ok - got the answer for
shutdown()
: it only works when powered from battery. So, I've created a small test program that just displays an image + counter, then shuts down for 1 hour. I'm going to see how long it lasts... -
RE: M5.shutdown(x) does not last x seconds
@felmue said in M5.shutdown(x) does not last x seconds:
the shutdown functionality only works when M5CoreInk is running from battery.
ah haaaaaaaa! ok! Thanks for the remark! Indeed. And now it works (when from battery).
And if somebody wonders, it might be useful to note in the doc that
shutdown()
actually has the M5 run again thesetup()
code (it makes sense, as it is "shut-down" but worth mentioning because it changes the way to implement things). -
Where is the API ?
Hi,
Where is the micropython API? Namely, where can I find the content of those:from m5stack import * from m5ui import * from uiflow import *
Among other, I would like to find the API which displays text on the eInk screen of a M5 Core Ink...
Thanks.
NB. I did read this which is interesting and gives a few examples, but it's not an API reference + it doesn't explain how to display on CoreInk...
-
RE: Newbie at ALL. Be patient.
Found my error. I had flashed the M5 with a program of my own using Arduino. Using the UI Flow firmware, I get the Micropython REPL no problem with
screen /dev/ttyUSB0 115200
. -
M5.shutdown(x) does not last x seconds
I would like my M5 Core Ink to shutdown (to save battery), then automatically wake up after a given amount of seconds and resume its activity.
For that, I useM5.shutdown(x)
wherex
is the amount of seconds. To my understanding, that's typically whatshutdown
does.It is not working! For example, I specify 60 seconds as argument to
M5.shutdown()
, the program'sloop()
is still called every ~5 seconds!
Strange: the eInk display is not refreshed... (at all).Precisely, my
loop
code- Gets the RTC time
- Displays it (both Serial and eInk)
- Calls
M5.shutdown(60)
The serial monitor shows that
loop
is called every ~6-7 seconds. Strange, the eInk screen is not refreshed and displays only the first RTC time.RTC Time 14:07:35 Shutting down for 60 seconds RTC Time 14:07:41 Shutting down for 60 seconds
Code
#define DELAY_SECONDS 60 void loop() { // Get RTC time RTC_TimeTypeDef rtcTime; M5.rtc.GetTime(&rtcTime); // Display time sprintf(buf, "%02d:%02d:%02d", rtcTime.Hours, rtcTime.Minutes, rtcTime.Seconds); InkPageSprite.drawString(10,50,buf); InkPageSprite.pushSprite(); Serial.printf("RTC Time %02d:%02d:%02d\n", rtcTime.Hours, rtcTime.Minutes, rtcTime.Seconds); // Sleep delay(100); Serial.printf("Shutting down for %d seconds\n", DELAY_SECONDS); M5.shutdown(DELAY_SECONDS); }
I tried
M5.shutdown(60000)
, same result. I also tried supplying a rtcTime toshutdown
, but it didn't change anything either.The creation of the sprite is in
setup
:void setup() { M5.begin(); //Init CoreInk. if( !M5.M5Ink.isInit()) //Init CoreInk screen. { Serial.printf("[-] M5Ink init failed"); while (1) delay(100); } M5.M5Ink.clear(); // Clear screen. Serial.printf("[+] Clearing eInk screen\n"); delay(1000); if( InkPageSprite.creatSprite(0,0,200,200,true) != 0 ){ Serial.printf("[-] Ink Sprite create failed\n"); } // set RTC time RTC_TimeTypeDef rtcTime; rtcTime.Hours = 14; rtcTime.Minutes = 6; rtcTime.Seconds = 0; M5.rtc.SetTime(&rtcTime); Serial.printf("[+] Setup success\n"); }
-
RE: M5core Ink battery duration
@eddie2070 said in M5core Ink battery duration:
With the default 1 minute shutdown
Is the
M5.shutdown()
command working for you? Is it really sleeping for 1 minute? In my case, whatever delay I specify it sleeps for ~5 seconds no more!If you have the same issue, that could explain why you have battery duration issues ;-)
-
RE: M5core Ink battery duration
@eddie2070 interesting. Once you've collected the temperature, what are you doing with it? Just displaying it? or are you sending it via WiFi?
I don't have a temperature sensor, but I'm going to try on my side with a ultrasonic sensor and see how long it works. -
RE: Ultrasonic unit reads erroneous distance
The distances I get are really strange:
- The values are well below or well above the expected ones. For example, for a distance of ~95cm the sensor answers 4.5cm. For a distance of ~110cm, 4.9cm. For ~35cm, 3.7cm etc.
- The values change for the same distance. So different measures of ~200cm gives 13.7cm or 79.6cm the next time...
The command
Wire.begin(32,33)
seems correct as I realize those are the ports for the sensor on the CoreInk.So, what am I doing wrong?
-
RE: Ultrasonic unit reads erroneous distance
I fixed my problem using
Wire.begin(32,33);
The distance now makes sense. I don't know what these values are for, though...
Also, my distance is not precise. I'll investigate and post again if the problem persists.
-
Ultrasonic unit reads erroneous distance
Hello, I have a M5 CoreInk onto which I have plugged a Ultrasonic sensor. I am getting a buggy distance read all the time.
[-] bad distance: 4294967.500000 [-] bad distance: 4294967.500000 [-] bad distance: 4294967.500000
My code is very much taken from this example.
This is how I initialized Wire. I am not sure about this
Wire.begin(21,22)
. It is taken from this code, but this other code uses other values...void setup() { M5.begin(); //Init CoreInk. if( !M5.M5Ink.isInit()) //Init CoreInk screen. { Serial.printf("[-] M5Ink init failed"); while (1) delay(100); } Wire.begin(21,22); Serial.printf("[+] Wire begin done\n"); M5.M5Ink.clear(); //Clear screen. ...
And this is how I read distance. This looks good to me...
#define M5_I2C_ADDR_ULTRASONIC 0x57 float readDistance() { uint32_t data; Wire.beginTransmission(M5_I2C_ADDR_ULTRASONIC); Wire.write(0x01); Wire.endTransmission(); delay(120); Wire.requestFrom(M5_I2C_ADDR_ULTRASONIC,3); data = Wire.read();data <<= 8; data |= Wire.read();data <<= 8; data |= Wire.read(); return float(data) / 1000; // distance in mm }
and then the
loop
- can't see anything wrong either...void loop() { static float newvalue = 0; newvalue = readDistance(); if ((newvalue < 1500) && (newvalue > 0)) { Serial.printf("Distance: ",newvalue); } else { Serial.printf("[-] bad distance: %f\n",newvalue); } delay(100); }
Can you help me spot the error? Or is my sensor faulty? or is something different with CoreInk?
Thanks
-
CoreInk reboot & eInk refresh
Hello,
I have a M5 CoreInk which I have programmed to display a given hard coded image. Works fine. I have 2 surprises though:-
- If I unplug the CoreInk from USB, the image fades out after a few hours. I am surprised: I have already used an eInk screen (completely different, not via M5CoreInk) and the image stayed there for months. Why does it fade off?
-
- When I plug back in my CoreInk on USB, it boots up and shows a black screen with a white line. Why doesn't it resume my program that prints the image?
Thanks!
-
-
RE: Newbie at ALL. Be patient.
@ajb2k3 yes. I program it with Arduino, no problem.
-
RE: Newbie at ALL. Be patient.
@ajb2k3 no, /dev/USBtoUART does not exist on my host. It is /dev/ttyUSB0. Tried thonny, not better than picocom or screen. I think the software is not the issue. Am I meant to have a specific firmware on the device for micropython to work?