Skip to content
This repository was archived by the owner on Feb 25, 2024. It is now read-only.

Freezes once in a while #3

Open
augisbud opened this issue Aug 25, 2018 · 100 comments
Open

Freezes once in a while #3

augisbud opened this issue Aug 25, 2018 · 100 comments
Labels
bug Something isn't working

Comments

@augisbud
Copy link
Owner

The Arduino freezes once in awhile it only seems to be happening with my hard driving so right now I think it's trying to open the menu because there is no speed check for that but that doesn't always seem to be the case. Anyone else experienced something similar?

@augisbud
Copy link
Owner Author

I'm starting to think that the issue is with the library, gonna change it to the Adafruit library and maybe create a separate github for testing purposes 😕

@augisbud
Copy link
Owner Author

augisbud commented Sep 5, 2018

Try out this
This is the beta branch, it might contain bugs, but worth checking out, it uses a U8G2 library so download it before.

@tibzejoker
Copy link

Hi !
I'm running your sketch on my m365, and it crashes every 30s.
I have another arduino on the same 5V source next to the batteries that i'll remove soon.
I've started to think that the arduino pro mini must crash when it's running on like 4V.
So maybe the solution is to put a big capacitor on the power line to avoid this ?
I'll try it soon, but if you do it first, fell free to let us know ;)

@augisbud
Copy link
Owner Author

Well I have discovered that it seems like the bus overflows, because everytime i spin the tire in the air from 5km/h to 30km/h(custom firmware), the speedo freezes and sometimes catches back on

@tibzejoker
Copy link

Oh, ok..
So maybe the solution may be to add an interruption timer that starts before every serial.read ?
Then you can flush the serial port if it freezes by doing something like that if i remember :
void flushSerial(){
while(Serial.available () > 0){
Serial.read();
}
}

@tibzejoker
Copy link

Or, maybe the best solution is to use
Serial.onReceive(stockInATabFunction);
that triggers on every serial event ?
then in the dataFSM(), you can just check if there is something waiting in the tab

@augisbud
Copy link
Owner Author

Hmmm, It freezes because it receives too much data so a millis() delay could help it

@augisbud
Copy link
Owner Author

But a delay is not a solution, so having something like you mentioned could work better

@augisbud
Copy link
Owner Author

augisbud commented Oct 7, 2018

brake and throttle value filter seems to help for someone on youtube, any ideas ?

oh and it makes sense, because it's spamming the same values and it overflows

@voodou59
Copy link

voodou59 commented Oct 7, 2018

Hi, thanks for sharing that project. Did you tried with pro mini 3.3v ?

@tibzejoker
Copy link

I have no idea, but can you give us the link to that video please ?
i've also seen that some days, instead of freezing, it could work just nicely.. Btw, how have you found out that it is an overflow error ?
Thanks !

@augisbud
Copy link
Owner Author

It's kinda an overflow, even the xiaomi mi app freezes if you put the scooter in the air and press the throttle fully

@augisbud
Copy link
Owner Author

Hi, thanks for sharing that project. Did you tried with pro mini 3.3v ?

You will destroy it, the rail is 5v, a capacitor or some kind of regulator.

@voodou59
Copy link

Not really. It is supposed to accept voltage up to 12VDC.

@augisbud
Copy link
Owner Author

Uhmm, heat? the uno is good for 12 volts too, but it's actually made for 5v

@voodou59
Copy link

I agree that 12v requires a heatsink but the electric scooter regulator range is 0 to 5.5-6v max

@jordicli
Copy link

For me it's freezing in every trip :(

@lukaszlukasz0
Copy link
Contributor

For me it happend one time, i drive with this software over a week (60km).
Maybe it depends of arduino, ther are so many manufactors?

@augisbud
Copy link
Owner Author

more like on the scooter I guess

@tibzejoker
Copy link

Mine freezes every 1km approximatively..
I dont really know why because when i put the scooter in the air and press the throttle fully nothing more than the "normal" 1km freeze occurs..
I'm trying to add a second "watchdog arduino" to see if i can fix it that way

@tibzejoker
Copy link

tibzejoker commented Oct 11, 2018

of course i have deleted the bootup part to skip the animation ^^.
I'll tell you if it can kind of fix it

@augisbud
Copy link
Owner Author

Check if the percentage drops after sometime, because sometimes only the speedo freezes

@tibzejoker
Copy link

no it doesnt unfortunately.. everything stops even the percentage.. (infinite power i gess ?? 👍 )

@augisbud
Copy link
Owner Author

hmm, for me only the speedometer crashes

@lukaszlukasz0
Copy link
Contributor

and for me :-)

All scooter hang up, and stop driving, all led are off, and the display was on and suspended showed the speed.

@tibzejoker
Copy link

hey guys i've figured out that when the port crashes, the arduino is still alive and working !
https://photos.app.goo.gl/jfD18F17mBE4PSTo9
On this video you can see that the screen is frozen and the arduino is still working (i've made the led on port 13 blink for debug)

@lukaszlukasz0
Copy link
Contributor

I see something like this sometimes (long time ago), when i drive with phone on bluetooth, my speed on mihome app freezes.
I am not sure if this is not a coincidence, but often helped by tapping on a platform or passing through bumps or holes on the way 😃

@tibzejoker
Copy link

I've finally fixed it with my second watchdog arduino.
Actually, when the arduino freezes due to a serial overflow, the 13th pin starts to blink pretty fast, and you cant reset it via the reset pin. You have to physically turn it off and on.
That's why i'm now doing that.
I'll release my fix tomorrow i think, it only costs the price of a second arduino nano.
scheme

@tibzejoker
Copy link

It's not the best solution but at least.. it works ^^
https://github.com/tibzejoker/m365_dashboard

@carlosmellado
Copy link

Hi all,
I’m waiting for a new oled screen to test it out since I broke mine :p but...
There is a command for serial that checks for an overflow, and another for flush the serial, so... what if you put this piece of code at the very begging of the loop() function?

if(XIAOMI_PORT.overflow()) {
XIAOMI_PORT.flush();
}

Sorry if there are errors but I’m writing from the phone.
Will be working also to find a software based solution! :)

@afonsos
Copy link

afonsos commented May 20, 2019

This freezes only display or also scooter?
Lately randomly Im experiencing both freezing and I have to reboot scooter.

@duts33
Copy link

duts33 commented Jun 3, 2019

Hi. It freezes only in Big spidometer mode. Maybe you want to delete or fix it? And also can you add remaining mileage?

@dimitrisdaniil
Copy link

How can i test it before soldering the cables to the scooter? Should it report bus data is missing?
I am asking because i tried to power it and the screen remains black... Any help would be appreciated

@dimitrisdaniil
Copy link

Is this project abandoned?

@afonsos
Copy link

afonsos commented Sep 7, 2019

it should power up showing bus error,maybe you have a bad connection somewhere or bad oled

@dimitrisdaniil
Copy link

I fixed it. I removed the lines refering to spi screen libraries

@dimitrisdaniil
Copy link

Does it still hangs without the external watchdog?

@carlosmellado
Copy link

I fixed it. I removed the lines refering to spi screen libraries

Did you fixed? or not?
If you did it, can you make a pull request or explain what did you changed on the code please?

Thanks!

@dimitrisdaniil
Copy link

Sorry for the delayed precense but i am abroad and i have limited time.
I have fixed the black screen issue that some peaple including me are facing (i believe it was related to the i2c vs spi libraries selection-at least in my case-since it is working now)
replace these lines from original "defines.h" in order to use it with i2c screen
(sorry i am a noob- it is the original code corrected where the compiler gave me an error and now the screen works fine.)

#include "WatchDog.h"

//#define DISPLAY_I2C

//#define US_Version

//ifdef DISPLAY_I2C
#include "SSD1306AsciiWire.h"

#include "fonts/m365.h"
#if Language == RU
#include "fonts/System5x7ru.h"
#else
#include "fonts/System5x7mod.h"
#endif
#include "fonts/stdNumb.h"
#include "fonts/bigNumb.h"

#include <EEPROM.h>

#include "language.h"
#include "messages.h"

MessagesClass Message;

const uint16_t LONG_PRESS = 2000;
uint8_t warnBatteryPercent = 5;

bool autoBig = true;
uint8_t bigMode = 0;
bool bigWarn = true;

bool Settings = false;
bool ShowBattInfo = false;
bool M365Settings = false;

uint8_t menuPos = 0;
uint8_t sMenuPos = 0;

bool cfgCruise = false;
bool cfgTailight = false;
uint8_t cfgKERS = 0;

volatile uint8_t oldBrakeVal = -1;
volatile uint8_t oldThrottleVal = -1;
volatile bool btnPressed = false;
bool bAlarm = false;

uint32_t timer = 0;

//ifdef DISPLAY_I2C
SSD1306AsciiWire display;

bool WheelSize = true; //whell 8,5"

uint8_t WDTcounts = 0;
void(* resetFunc) (void) = 0;

(i have made minor corrections so that my screen would work but the code is the original and not mine :)))

@dimitrisdaniil
Copy link

Has anybody found a solution for the freezing, without second arduino as watchdog?

@zazzimazzi
Copy link

Hi can you converting this project SSD1306AsciiWire library to adafruitssd1306.h library or u8glib or u8g2lib

@dimitrisdaniil
Copy link

To be honest personally i do not have the knowledge to do it... It requires a lot of reading...and i do not have the time, this reriod...
But why you want to do this? It works pretty well this way

@dimitrisdaniil
Copy link

Is this project abandoned?

@GivvHub
Copy link

GivvHub commented Oct 18, 2019

i thikk: yes. not happy

@alexandrugai
Copy link

anyone tried this project on a d1mini?

@pawelmakowski26
Copy link

Witajcie.
Wyeliminowałem zawieszanie się dodając rezystor 120ohm na linii data pomiędzy płytka m365 a Arduino.
Do tej pory zawieszała się co chwilę , oraz silnik czasami jakby się wyłączał . Dzisiaj rano przejechałem 5 km bez żadnego błędu.

@pawelmakowski26
Copy link

IMG_20200324_061727

Na razie nie zawiesza sie

@duts33
Copy link

duts33 commented Mar 24, 2020

Witajcie.
Wyeliminowałem zawieszanie się dodając rezystor 120ohm na linii data pomiędzy płytka m365 a Arduino.
Do tej pory zawieszała się co chwilę , oraz silnik czasami jakby się wyłączał . Dzisiaj rano przejechałem 5 km bez żadnego błędu.

Have you also had the screen freeze on the speed reading?

@pawelmakowski26
Copy link

pawelmakowski26 commented Mar 24, 2020

today I drove about 15km and the meter worked perfectly. never hung.

@duts33
Copy link

duts33 commented Mar 24, 2020

today I drove about 15km and the meter worked perfectly. never hung.

thanks, I will try this method too.

@pawelmakowski26
Copy link

Wczoraj działało idealnie. Dzisiaj znowu przerywa.

@VVerlog
Copy link

VVerlog commented Jun 9, 2020

Hi together, is there any solution available till now?

@duts33
Copy link

duts33 commented Jun 9, 2020

There is no concrete solution. I replaced the resistors with other values, as advised in similar projects, and the Arduino still freezes. It can run for a few days without freezes, and then still hang.

@VVerlog
Copy link

VVerlog commented Jun 9, 2020

Has anyone a look at the data signal with an oszi? Maybe the signal is not good enough. But I think there is an code bug too, because freezing should not happen if the data could not be read. Maybe something with interrupt. Now I will start to have a look on the code.

@hojnikb
Copy link

hojnikb commented Oct 6, 2020

Any solutions for this till now?

@38293312
Copy link

38293312 commented Apr 2, 2021

I can’t turn on the headlights with this item meter. I wonder if everyone has the same problem?

@Dubstaaa
Copy link

Glad to release the v 0.B version (B means Bruno). A improved software watchdog is in place. Never freezed in some months of heavy use, at high speed and neither on hard braking. Made the necessary corrections to made the code work on pro's version (now can display current speed, or real time current value) cause these models, unlike the classic m365, have another ble protocol. No more crashing when tyre is spinning.
Works fine on almost every 5V Arduino board, even all those who integrate a Serial TTL that could interferes with bus, Half Duplex is now reached by SoftwareSerial().
Tested on Xiaomi Scooter Essential, Xiaomi PRO 2 and Mi Scooter 3. Also works in combination with CamiBLE 075 v 10.
You can find the project on my Github home.

@duts33
Copy link

duts33 commented Nov 15, 2021

Glad to release the v 0.B version (B means Bruno). A improved software watchdog is in place. Never freezed in some months of heavy use, at high speed and neither on hard braking. Made the necessary corrections to made the code work on pro's version (now can display current speed, or real time current value) cause these models, unlike the classic m365, have another ble protocol. No more crashing when tyre is spinning. Works fine on almost every 5V Arduino board, even all those who integrate a Serial TTL that could interferes with bus, Half Duplex is now reached by SoftwareSerial(). Tested on Xiaomi Scooter Essential, Xiaomi PRO 2 and Mi Scooter 3. Also works in combination with CamiBLE 075 v 10. You can find the project on my Github home.

Could you give a link?

@Dubstaaa
Copy link

Im hard working to make it cheaper, easier and more affordable... even more useful than commercial version of “M365 dash”. To achieve a good result I need some more days to refine my project.
Next week two versions will be released :
Ninebot compatible;
Xiaomi compatible;

@Dubstaaa
Copy link

Im glad to share with you my project, fully compatible with multiple scooter versions.
Neat dash, test release by Bruno. Available on https://github.com/Dubstaaa/NeatDash-

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests